@markus-global/cli 0.11.3-rc.0 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web-ui/assets/{CommentInput-C-niUbUY.js → CommentInput-DN3Cichs.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-DxsnJJRX.js → ContentRenderer-CjHOyYgJ.js} +2 -2
- package/dist/web-ui/assets/{DeliverableShareModal-DV3TiZx0.js → DeliverableShareModal-CBSvxB-X.js} +1 -1
- package/dist/web-ui/assets/{Deliverables-tlLsJnxZ.js → Deliverables-BaAF4-w0.js} +1 -1
- package/dist/web-ui/assets/{Notifications-4KXYRdkr.js → Notifications-CCsdBfdg.js} +1 -1
- package/dist/web-ui/assets/{Search-CPFwZv1U.js → Search-BiBdevAU.js} +1 -1
- package/dist/web-ui/assets/{Settings-DIa-_qre.js → Settings-CawBnWuy.js} +1 -1
- package/dist/web-ui/assets/{Store-JWjwXfTU.js → Store-BWi97VP9.js} +1 -1
- package/dist/web-ui/assets/{Team-COBxn96h.js → Team-CfUDkdc3.js} +4 -4
- package/dist/web-ui/assets/{Work-BScJUqWL.js → Work-DrIXOW-P.js} +1 -1
- package/dist/web-ui/assets/{arc-DPZmpo1U.js → arc-Cg0-C295.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-DlOs02JO.js → architectureDiagram-3BPJPVTR-BctEHNLp.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-C7qsXNUe.js → blockDiagram-GPEHLZMM-hxr2ZwOV.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-Drwp-rtM.js → c4Diagram-AAUBKEIU-CfIRo1GE.js} +1 -1
- package/dist/web-ui/assets/channel-DAQ2Rbxq.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-VgR09Mqk.js → chunk-2J33WTMH-T0bENsqX.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-CuwDpBRL.js → chunk-4BX2VUAB-ChLLkyYx.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-nC7YWJ_i.js → chunk-55IACEB6-BD3ENYp9.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-Dw6mBsRE.js → chunk-727SXJPM-BAes4atE.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-CPhNJbHl.js → chunk-AQP2D5EJ-FymM7gfT.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-AyhQakG8.js → chunk-FMBD7UC4-N5sRT0m9.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-DgYemv8I.js → chunk-ND2GUHAM-BSjS3JyS.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-CLdqxrFB.js → chunk-QZHKN3VN-Dkwitdbr.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BZyCVtJb.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BZyCVtJb.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-DrOgwDIH.js → cose-bilkent-S5V4N54A-BLuYATCK.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-DhoJiA83.js → dagre-BM42HDAG-DGLiqiH2.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-BDILSgqK.js → diagram-2AECGRRQ-Cq_GnNKs.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-CeXywd1i.js → diagram-5GNKFQAL-CHNz-2dA.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-Bi4RlMT0.js → diagram-KO2AKTUF-D8eKa7jh.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-Cw1yxk8b.js → diagram-LMA3HP47-RkDgQcLr.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-Bl857da2.js → diagram-OG6HWLK6-LqxQrIwa.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-CjoUhrMq.js → docx-preview-Be-Qo_ag.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DEiaMhuV.js → erDiagram-TEJ5UH35-BX0zZgYQ.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BgKZhO0h.js → flowDiagram-I6XJVG4X-DKnfIFA4.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-Dkx-EaS8.js → ganttDiagram-6RSMTGT7-DjBURmY-.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DXaQwA0y.js → gitGraphDiagram-PVQCEYII-BvSi7SvS.js} +1 -1
- package/dist/web-ui/assets/{index-C_QhfMcC.js → index-D8vskks7.js} +5 -5
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-Dpx9IOkx.js → infoDiagram-5YYISTIA-CwtIgim2.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-BWqWgitQ.js → ishikawaDiagram-YF4QCWOH-CWhXJfSa.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-BBwIZ4k9.js → journeyDiagram-JHISSGLW-DN9rorlL.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-C_MRWV8R.js → kanban-definition-UN3LZRKU-Burf5FE8.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-BMAh3nnq.js → mermaid.core-Dx4rzlyC.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-B6vJQcat.js → mindmap-definition-RKZ34NQL-DqZ21Siw.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-BxdEttqt.js → pieDiagram-4H26LBE5-C_4ksu-T.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-gsNs2VfP.js → quadrantDiagram-W4KKPZXB-Dl6Rjg1X.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-BSC9KvC2.js → requirementDiagram-4Y6WPE33-CzmWi02d.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-DktAZfe_.js → sankeyDiagram-5OEKKPKP-D8K7e8we.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-BIPt8kGU.js → sequenceDiagram-3UESZ5HK-1z9rqtVx.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-DiXmJWB0.js → stateDiagram-AJRCARHV-nneYkkHa.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-C-hpzcms.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-LRi7H35g.js → timeline-definition-PNZ67QCA-D6GmLlRi.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-DWQ1I022.js → vennDiagram-CIIHVFJN-TVefhiCa.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-BUb6dYqN.js → wardley-L42UT6IY-BgUuAeiM.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-BYE1B3xT.js → wardleyDiagram-YWT4CUSO-CyJ_l94o.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-D-pS2-Sa.js → xychartDiagram-2RQKCTM6-kajbbx7a.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-DCChB-1T.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CrNiYfSI.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CrNiYfSI.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-COOgTXIX.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-Dx4rzlyC.js","assets/transform-CpIVI4vC.js","assets/Team-CfUDkdc3.js","assets/CommentInput-DN3Cichs.js","assets/ContentRenderer-CjHOyYgJ.js","assets/DeliverableShareModal-CBSvxB-X.js","assets/modelCapabilities-DDtCBZ6o.js","assets/Team-DFuMZ0ql.css","assets/Settings-CawBnWuy.js","assets/Work-DrIXOW-P.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-BaAF4-w0.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 ese=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Lc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lf={exports:{}},Xl={};var Zx;function hA(){if(Zx)return Xl;Zx=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 ev;function gA(){return ev||(ev=1,lf.exports=hA()),lf.exports}var i=gA(),cf={exports:{}},$t={};var tv;function bA(){if(tv)return $t;tv=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,fe,z){this.props=V,this.context=fe,this.refs=C,this.updater=z||w}S.prototype.isReactComponent={},S.prototype.setState=function(V,fe){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,fe,"setState")},S.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function E(){}E.prototype=S.prototype;function _(V,fe,z){this.props=V,this.context=fe,this.refs=C,this.updater=z||w}var D=_.prototype=new E;D.constructor=_,T(D,S.prototype),D.isPureReactComponent=!0;var P=Array.isArray;function M(){}var I={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Q(V,fe,z){var je=z.ref;return{$$typeof:e,type:V,key:fe,ref:je!==void 0?je:null,props:z}}function $(V,fe){return Q(V.type,fe,V.props)}function Y(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function K(V){var fe={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(z){return fe[z]})}var ee=/\/+/g;function U(V,fe){return typeof V=="object"&&V!==null&&V.key!=null?K(""+V.key):fe.toString(36)}function te(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(M,M):(V.status="pending",V.then(function(fe){V.status==="pending"&&(V.status="fulfilled",V.value=fe)},function(fe){V.status==="pending"&&(V.status="rejected",V.reason=fe)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function L(V,fe,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,L(He(V._payload),fe,z,je,Ue)}}if(He)return Ue=Ue(V),He=je===""?"."+U(V,0):je,P(Ue)?(z="",He!=null&&(z=He.replace(ee,"$&/")+"/"),L(Ue,fe,z,"",function(Nt){return Nt})):Ue!=null&&(Y(Ue)&&(Ue=$(Ue,z+(Ue.key==null||V&&V.key===Ue.key?"":(""+Ue.key).replace(ee,"$&/")+"/")+He)),fe.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+U(je,dt),He+=L(je,fe,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+U(je,dt++),He+=L(je,fe,z,qe,Ue);else if(qe==="object"){if(typeof V.then=="function")return L(te(V),fe,z,je,Ue);throw fe=String(V),Error("Objects are not valid as a React child (found: "+(fe==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":fe)+"). If you meant to render a collection of children, use an array instead.")}return He}function J(V,fe,z){if(V==null)return V;var je=[],Ue=0;return L(V,je,"","",function(qe){return fe.call(z,qe,Ue++)}),je}function me(V){if(V._status===-1){var fe=V._result;fe=fe(),fe.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=fe)}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 fe=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(fe))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",V);return}console.error(V)},H={map:J,forEach:function(V,fe,z){J(V,function(){fe.apply(this,arguments)},z)},count:function(V){var fe=0;return J(V,function(){fe++}),fe},toArray:function(V){return J(V,function(fe){return fe})||[]},only:function(V){if(!Y(V))throw Error("React.Children.only expected to receive a single React element child.");return V}};return $t.Activity=g,$t.Children=H,$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,fe,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(fe!=null)for(qe in fe.key!==void 0&&(Ue=""+fe.key),fe)!G.call(fe,qe)||qe==="key"||qe==="__self"||qe==="__source"||qe==="ref"&&fe.ref===void 0||(je[qe]=fe[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 Q(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,fe,z){var je,Ue={},qe=null;if(fe!=null)for(je in fe.key!==void 0&&(qe=""+fe.key),fe)G.call(fe,je)&&je!=="key"&&je!=="__self"&&je!=="__source"&&(Ue[je]=fe[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 Q(V,qe,Ue)},$t.createRef=function(){return{current:null}},$t.forwardRef=function(V){return{$$typeof:d,render:V}},$t.isValidElement=Y,$t.lazy=function(V){return{$$typeof:h,_payload:{_status:-1,_result:V},_init:me}},$t.memo=function(V,fe){return{$$typeof:p,type:V,compare:fe===void 0?null:fe}},$t.startTransition=function(V){var fe=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(M,Ce)}catch(qe){Ce(qe)}finally{fe!==null&&z.types!==null&&(fe.types=z.types),I.T=fe}},$t.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},$t.use=function(V){return I.H.use(V)},$t.useActionState=function(V,fe,z){return I.H.useActionState(V,fe,z)},$t.useCallback=function(V,fe){return I.H.useCallback(V,fe)},$t.useContext=function(V){return I.H.useContext(V)},$t.useDebugValue=function(){},$t.useDeferredValue=function(V,fe){return I.H.useDeferredValue(V,fe)},$t.useEffect=function(V,fe){return I.H.useEffect(V,fe)},$t.useEffectEvent=function(V){return I.H.useEffectEvent(V)},$t.useId=function(){return I.H.useId()},$t.useImperativeHandle=function(V,fe,z){return I.H.useImperativeHandle(V,fe,z)},$t.useInsertionEffect=function(V,fe){return I.H.useInsertionEffect(V,fe)},$t.useLayoutEffect=function(V,fe){return I.H.useLayoutEffect(V,fe)},$t.useMemo=function(V,fe){return I.H.useMemo(V,fe)},$t.useOptimistic=function(V,fe){return I.H.useOptimistic(V,fe)},$t.useReducer=function(V,fe,z){return I.H.useReducer(V,fe,z)},$t.useRef=function(V){return I.H.useRef(V)},$t.useState=function(V){return I.H.useState(V)},$t.useSyncExternalStore=function(V,fe,z){return I.H.useSyncExternalStore(V,fe,z)},$t.useTransition=function(){return I.H.useTransition()},$t.version="19.2.4",$t}var nv;function Pm(){return nv||(nv=1,cf.exports=bA()),cf.exports}var k=Pm();const tse=Lc(k);var uf={exports:{}},Jl={},df={exports:{}},mf={};var av;function yA(){return av||(av=1,(function(e){function t(L,J){var me=L.length;L.push(J);e:for(;0<me;){var Ce=me-1>>>1,H=L[Ce];if(0<s(H,J))L[Ce]=J,L[me]=H,me=Ce;else break e}}function n(L){return L.length===0?null:L[0]}function a(L){if(L.length===0)return null;var J=L[0],me=L.pop();if(me!==J){L[0]=me;e:for(var Ce=0,H=L.length,V=H>>>1;Ce<V;){var fe=2*(Ce+1)-1,z=L[fe],je=fe+1,Ue=L[je];if(0>s(z,me))je<H&&0>s(Ue,z)?(L[Ce]=Ue,L[je]=me,Ce=je):(L[Ce]=z,L[fe]=me,Ce=fe);else if(je<H&&0>s(Ue,me))L[Ce]=Ue,L[je]=me,Ce=je;else break e}}return J}function s(L,J){var me=L.sortIndex-J.sortIndex;return me!==0?me:L.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 D(L){for(var J=n(p);J!==null;){if(J.callback===null)a(p);else if(J.startTime<=L)a(p),J.sortIndex=J.expirationTime,t(m,J);else break;J=n(p)}}function P(L){if(T=!1,D(L),!w)if(n(m)!==null)w=!0,M||(M=!0,K());else{var J=n(p);J!==null&&te(P,J.startTime-L)}}var M=!1,I=-1,G=5,Q=-1;function $(){return C?!0:!(e.unstable_now()-Q<G)}function Y(){if(C=!1,M){var L=e.unstable_now();Q=L;var J=!0;try{e:{w=!1,T&&(T=!1,E(I),I=-1),y=!0;var me=x;try{t:{for(D(L),g=n(m);g!==null&&!(g.expirationTime>L&&$());){var Ce=g.callback;if(typeof Ce=="function"){g.callback=null,x=g.priorityLevel;var H=Ce(g.expirationTime<=L);if(L=e.unstable_now(),typeof H=="function"){g.callback=H,D(L),J=!0;break t}g===n(m)&&a(m),D(L)}else a(m);g=n(m)}if(g!==null)J=!0;else{var V=n(p);V!==null&&te(P,V.startTime-L),J=!1}}break e}finally{g=null,x=me,y=!1}J=void 0}}finally{J?K():M=!1}}}var K;if(typeof _=="function")K=function(){_(Y)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,U=ee.port2;ee.port1.onmessage=Y,K=function(){U.postMessage(null)}}else K=function(){S(Y,0)};function te(L,J){I=S(function(){L(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(L){L.callback=null},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(L){switch(x){case 1:case 2:case 3:var J=3;break;default:J=x}var me=x;x=J;try{return L()}finally{x=me}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(L,J){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var me=x;x=L;try{return J()}finally{x=me}},e.unstable_scheduleCallback=function(L,J,me){var Ce=e.unstable_now();switch(typeof me=="object"&&me!==null?(me=me.delay,me=typeof me=="number"&&0<me?Ce+me:Ce):me=Ce,L){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=me+H,L={id:h++,callback:J,priorityLevel:L,startTime:me,expirationTime:H,sortIndex:-1},me>Ce?(L.sortIndex=me,t(p,L),n(m)===null&&L===n(p)&&(T?(E(I),I=-1):T=!0,te(P,me-Ce))):(L.sortIndex=H,t(m,L),w||y||(w=!0,M||(M=!0,K()))),L},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(L){var J=x;return function(){var me=x;x=J;try{return L.apply(this,arguments)}finally{x=me}}}})(mf)),mf}var rv;function xA(){return rv||(rv=1,df.exports=yA()),df.exports}var pf={exports:{}},ga={};var iv;function vA(){if(iv)return ga;iv=1;var e=Pm();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 sv;function Gk(){if(sv)return pf.exports;sv=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(),pf.exports=vA(),pf.exports}var ov;function wA(){if(ov)return Jl;ov=1;var e=xA(),t=Pm(),n=Gk();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"),D=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function K(r){return r===null||typeof r!="object"?null:(r=Y&&r[Y]||r["@@iterator"],typeof r=="function"?r:null)}var ee=Symbol.for("react.client.reference");function U(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 M:return"SuspenseList";case Q: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 D: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:U(r.type)||"Memo";case G:o=r._payload,r=r._init;try{return U(r(o))}catch{}}return null}var te=Array.isArray,L=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,me={pending:!1,data:null,method:null,action:null},Ce=[],H=-1;function V(r){return{current:r}}function fe(r){0>H||(r.current=Ce[H],Ce[H]=null,H--)}function z(r,o){H++,Ce[H]=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)?kx(r):0;break;default:if(r=o.tagName,o=o.namespaceURI)o=kx(o),r=Sx(o,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}fe(je),z(je,r)}function dt(){fe(je),fe(Ue),fe(qe)}function Nt(r){r.memoizedState!==null&&z(He,r);var o=je.current,u=Sx(o,r.type);o!==u&&(z(Ue,r),z(je,u))}function wt(r){Ue.current===r&&(fe(je),fe(Ue)),He.current===r&&(fe(He),Vl._currentValue=me)}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
|
-
`;lh=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return lh}async function jne(e,t,n){const a=await va(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=Ene();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 Mne(e,t){const{renderAsync:n}=await va(async()=>{const{renderAsync:s}=await import("./docx-preview-
|
|
847
|
+
`;lh=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return lh}async function jne(e,t,n){const a=await va(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=Ene();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 Mne(e,t){const{renderAsync:n}=await va(async()=>{const{renderAsync:s}=await import("./docx-preview-Be-Qo_ag.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 _ne(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(()=>BS),void 0).then(e=>({default:e.MarkdownMessage})));const Rne=k.lazy(()=>va(()=>import("./ContentRenderer-DxsnJJRX.js"),[]).then(e=>({default:e.ContentRenderer})));let Do=[],Bw=60;function Dne(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++Bw);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&&(Bw=60)}},[]),n}const Hw=500,Ji=new Map,Em=new Set,Jd=new Map;let Zd=null;function Lne(){if(Ji.size<=Hw)return;const e=Ji.size-Hw,t=Ji.keys();for(let n=0;n<e;n++){const{value:a,done:s}=t.next();if(s)break;Ji.delete(a)}}function $w(e,t){Ji.delete(e),Ji.set(e,t),Lne()}function qw(e){const t=Jd.get(e);if(t)for(const n of t)n()}function Ine(){Zd=null;const e=[...Em];Em.clear(),e.length!==0&&Ae.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))$w(n,a),qw(n)}).catch(()=>{for(const t of e)$w(t,{exists:!1,isFile:!1,type:"unknown"}),qw(t)})}function One(e){Ji.has(e)||Em.has(e)||(Em.add(e),Zd&&clearTimeout(Zd),Zd=setTimeout(Ine,30))}function Pne(e,t){let n=Jd.get(e);return n||(n=new Set,Jd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Jd.delete(e)}}function zne(e){const t=k.useCallback(s=>Pne(e,s),[e]),n=k.useCallback(()=>Ji.get(e),[e]),a=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{One(e)},[e]),a}function Bne(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function Hne({filePath:e,onClose:t}){const n=Dne(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(""),[_,D]=k.useState(null),[P,M]=k.useState(!1);k.useEffect(()=>{c(!0),m(null),h(""),D(null),Ae.files.preview(a).then(Y=>{if(Y.type==="directory"&&Array.isArray(Y.entries)){x("directory"),w(Y.name),D(Y.entries);return}x(Y.type),w(Y.name),C(Y.mimeType||""),h(typeof Y.content=="string"?Y.content:""),E(Y.streamUrl||(Y.path?Ae.files.streamUrl(Y.path):"")||(Y.type==="audio"||Y.type==="video"?Ae.files.streamUrl(a):""))}).catch(Y=>{m(String(Y?.message||Y))}).finally(()=>{c(!1)})},[a]);const I=y||a.split(/[/\\]/).pop()||a,G=g==="directory"||a!==e,Q=()=>s(Y=>Bne(Y)),$=()=>{navigator.clipboard?.writeText(a).then(()=>{M(!0),setTimeout(()=>M(!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:Y=>Y.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:[G&&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:Q,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:$,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(kne,{path:a,entries:_,onNavigate:Y=>s(Y),onOpenFile:Y=>s(Y),onReveal:Y=>Ae.files.reveal(Y),onCopyPath:Y=>{navigator.clipboard?.writeText(Y).then(()=>{M(!0),setTimeout(()=>M(!1),1500)}).catch(()=>{})}}),!l&&!d&&g==="office"&&S&&i.jsx(Cne,{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(Rne,{content:p,format:g==="text"?"text":g,className:"text-sm"})})]})]})}),document.body)}function $ne({path:e}){const t=zne(e),[n,a]=k.useState(null),s=$c(),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(Hne,{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 ch=null;function qne(){return ch||(ch=va(()=>import("./mermaid.core-BMAh3nnq.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),ch}function Fne(){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 Une(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 Gne(){return Fne()}function Kne(){return k.useSyncExternalStore(Une,Gne)}function LS({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=Kne();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 qne();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 Vne="/assets/viz-global-C_AyN6D9.js";let _d=!1,uh=null;function Wne(){return _d?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(_d=!0,e()):(n.addEventListener("load",()=>{_d=!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=Vne,a.onload=()=>{_d=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function Yne(){return uh||(uh=Wne().then(()=>va(()=>import("./plantuml-DezRDxd4.js"),[]))),uh}let Fw=Promise.resolve();function Qne(e,t){const n=Fw.then(()=>new Promise((a,s)=>{Yne().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,s,{dark:t})}).catch(s)}));return Fw=n.then(()=>{},()=>{}),n}function Xne(){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 Jne(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 Zne(){return k.useSyncExternalStore(Jne,()=>Xne())}function IS({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=Zne();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),Qne(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 gb(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 eae=[LS,IS];function tae(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return Qte(n)}return null}function gc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(gc).join("");if(k.isValidElement(e)){const t=e.props;return gc(t.children)}return""}function nae({children:e}){const{t}=ot("common"),n=tae(e),a=k.useRef(null),[s,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=gc(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)&&eae.includes(h.type))){const h=gc(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:Yte(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:gc(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 Uw="#mention:",jm="#entity:",aae=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,OS=/^(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 rae(e){return e.type==="text"&&(e.value??"").trim()===""}function iae(e){if(!e?.children)return null;const t=e.children.filter(a=>!rae(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(jm))return{id:a.slice(jm.length)};const l=a.match(OS);return l&&l[1]!=="workflow"?{id:l[2],type:ES(l[1]),label:s}:null}if(n.type==="element"&&n.tagName==="code"){const a=pg(n).trim();if(Nm(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Nm(a))return{id:a}}return null}const sae={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")||Vte(a))return i.jsx(dg,{code:a,language:"plantuml",children:i.jsx(IS,{code:a})});if(t?.includes("language-mermaid"))return i.jsx(dg,{code:a,language:"mermaid",children:i.jsx(LS,{code:a})});if(t?.includes("language-"))return i.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Nm(n))return i.jsx(hc,{id:n.trim()});const s=n.match(aae);return s?i.jsx(hc,{id:s[2],label:s[1]}):tne(n)?i.jsx($ne,{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(nae,{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})},oae=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function lae(e){const t=hb(e);return kS(e)&&oae.test(t.split("?")[0]??t)}function cae(e,t){const n=hb(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 uae(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function dae(e,t){return lae(e)?uae(cae(e,t)):null}const Lo=new Map,sc=new Map,mae=k.memo(function({src:t,alt:n,onPreview:a,basePath:s}){const l=k.useMemo(()=>dae(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),D=k.useCallback(M=>{sc.set(l,M),C(M),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(M=>M+1)},[l,c]);return k.useEffect(()=>{if(!c)return;const M=Lo.get(l);if(M){h(M),x(!0),w(!1),C(null);return}const I=sc.get(l);if(I!==void 0){w(!0),C(I),x(!1);return}const G=++_.current;w(!1),C(null),x(!1),h(null),(async()=>{try{const Q=await fetch(l,{credentials:"same-origin"});if(G!==_.current)return;if(!Q.ok){let K=`HTTP ${Q.status}`;try{const ee=await Q.json();ee.error&&(K=ee.error)}catch{}throw new Error(K)}const $=await Q.blob();if(G!==_.current)return;if($.size===0)throw new Error("Empty image response");if($.type&&!$.type.startsWith("image/")&&!$.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${$.type}`);const Y=URL.createObjectURL($);Lo.set(l,Y),h(Y),x(!0),w(!1),C(null)}catch(Q){if(G!==_.current)return;const $=Q instanceof Error?Q.message:String(Q);console.warn("[MarkdownImage] failed to load local image",l,Q),D($)}})()},[c,l,S]),k.useEffect(()=>{if(c)return;const M=sc.get(l);if(M!==void 0){w(!0),C(M),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:()=>{D("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 Gw(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function pae(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 fae(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 PS({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 Gw(e),y=await pae(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 Gw(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=fae(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 zS(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:s,hostAvailable:l,openRightPanel:c}=e,d=k.useCallback((m,p)=>{const h=Lw(p,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){nne(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(()=>({...sae,img:({src:m,alt:p})=>i.jsx(mae,{src:m??"",alt:p,onPreview:a,basePath:n},m??""),p:({children:m,node:p})=>{const h=iae(p);return h?i.jsx(bne,{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(Uw)){const g=decodeURIComponent(m.slice(Uw.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(jm))return i.jsx(hc,{id:m.slice(jm.length)});{const g=m?.match(OS);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=ES(x);if(w)return i.jsx(hc,{id:y,type:w,label:p})}}if(m&&Nm(m))return i.jsx(hc,{id:m.trim(),label:p});const h=Lw(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 Kw=[I5,P3,z3],Vw=[AS,[V3,{strict:"ignore"}],[dS,{detect:!0,ignoreMissing:!0}]];function fg(e){if(/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e))return e;const n=fb(e);return kS(n)?n:c5(e)}const hae=/(?:<thinking>| thinking)([\s\S]*?)<\/thinking>/g;function gae(e){const t=[];let n=e.replace(hae,(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 bae(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 yae({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=bae();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 gb(e);y(n(C?"markdown.copied":"markdown.failed")),s(!1)},T=async C=>{const S=t.current?.firstElementChild;if(!S)return;const E=NS(),_=sne(E),D=await rne(S,C,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),P=n(C==="light"?"markdown.themeLight":"markdown.themeDark");y(D.ok?D.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(one,{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}=gae(t),m=k.useRef(null),[p,h]=k.useState(null),g=$c(),x=k.useCallback(T=>{let C=ui(T,fS);return C=ui(C,Pte),C=ui(C,Zte),C=ui(C,$te),C=ui(C,qte),C=ui(C,S=>zte(S,s)),C=ui(C,bS),C},[s]),y=k.useMemo(()=>x(d),[d,x]),w=zS({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(yae,{content:t,contentRef:m}),i.jsx("div",{ref:m,children:i.jsx(lne,{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(()=>BS),void 0).then(e=>({default:e.MarkdownMessage})));const Rne=k.lazy(()=>va(()=>import("./ContentRenderer-CjHOyYgJ.js"),[]).then(e=>({default:e.ContentRenderer})));let Do=[],Bw=60;function Dne(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++Bw);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&&(Bw=60)}},[]),n}const Hw=500,Ji=new Map,Em=new Set,Jd=new Map;let Zd=null;function Lne(){if(Ji.size<=Hw)return;const e=Ji.size-Hw,t=Ji.keys();for(let n=0;n<e;n++){const{value:a,done:s}=t.next();if(s)break;Ji.delete(a)}}function $w(e,t){Ji.delete(e),Ji.set(e,t),Lne()}function qw(e){const t=Jd.get(e);if(t)for(const n of t)n()}function Ine(){Zd=null;const e=[...Em];Em.clear(),e.length!==0&&Ae.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))$w(n,a),qw(n)}).catch(()=>{for(const t of e)$w(t,{exists:!1,isFile:!1,type:"unknown"}),qw(t)})}function One(e){Ji.has(e)||Em.has(e)||(Em.add(e),Zd&&clearTimeout(Zd),Zd=setTimeout(Ine,30))}function Pne(e,t){let n=Jd.get(e);return n||(n=new Set,Jd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Jd.delete(e)}}function zne(e){const t=k.useCallback(s=>Pne(e,s),[e]),n=k.useCallback(()=>Ji.get(e),[e]),a=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{One(e)},[e]),a}function Bne(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function Hne({filePath:e,onClose:t}){const n=Dne(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(""),[_,D]=k.useState(null),[P,M]=k.useState(!1);k.useEffect(()=>{c(!0),m(null),h(""),D(null),Ae.files.preview(a).then(Y=>{if(Y.type==="directory"&&Array.isArray(Y.entries)){x("directory"),w(Y.name),D(Y.entries);return}x(Y.type),w(Y.name),C(Y.mimeType||""),h(typeof Y.content=="string"?Y.content:""),E(Y.streamUrl||(Y.path?Ae.files.streamUrl(Y.path):"")||(Y.type==="audio"||Y.type==="video"?Ae.files.streamUrl(a):""))}).catch(Y=>{m(String(Y?.message||Y))}).finally(()=>{c(!1)})},[a]);const I=y||a.split(/[/\\]/).pop()||a,G=g==="directory"||a!==e,Q=()=>s(Y=>Bne(Y)),$=()=>{navigator.clipboard?.writeText(a).then(()=>{M(!0),setTimeout(()=>M(!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:Y=>Y.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:[G&&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:Q,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:$,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(kne,{path:a,entries:_,onNavigate:Y=>s(Y),onOpenFile:Y=>s(Y),onReveal:Y=>Ae.files.reveal(Y),onCopyPath:Y=>{navigator.clipboard?.writeText(Y).then(()=>{M(!0),setTimeout(()=>M(!1),1500)}).catch(()=>{})}}),!l&&!d&&g==="office"&&S&&i.jsx(Cne,{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(Rne,{content:p,format:g==="text"?"text":g,className:"text-sm"})})]})]})}),document.body)}function $ne({path:e}){const t=zne(e),[n,a]=k.useState(null),s=$c(),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(Hne,{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 ch=null;function qne(){return ch||(ch=va(()=>import("./mermaid.core-Dx4rzlyC.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),ch}function Fne(){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 Une(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 Gne(){return Fne()}function Kne(){return k.useSyncExternalStore(Une,Gne)}function LS({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=Kne();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 qne();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 Vne="/assets/viz-global-C_AyN6D9.js";let _d=!1,uh=null;function Wne(){return _d?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(_d=!0,e()):(n.addEventListener("load",()=>{_d=!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=Vne,a.onload=()=>{_d=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function Yne(){return uh||(uh=Wne().then(()=>va(()=>import("./plantuml-DezRDxd4.js"),[]))),uh}let Fw=Promise.resolve();function Qne(e,t){const n=Fw.then(()=>new Promise((a,s)=>{Yne().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,s,{dark:t})}).catch(s)}));return Fw=n.then(()=>{},()=>{}),n}function Xne(){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 Jne(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 Zne(){return k.useSyncExternalStore(Jne,()=>Xne())}function IS({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=Zne();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),Qne(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 gb(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 eae=[LS,IS];function tae(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return Qte(n)}return null}function gc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(gc).join("");if(k.isValidElement(e)){const t=e.props;return gc(t.children)}return""}function nae({children:e}){const{t}=ot("common"),n=tae(e),a=k.useRef(null),[s,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=gc(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)&&eae.includes(h.type))){const h=gc(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:Yte(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:gc(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 Uw="#mention:",jm="#entity:",aae=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,OS=/^(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 rae(e){return e.type==="text"&&(e.value??"").trim()===""}function iae(e){if(!e?.children)return null;const t=e.children.filter(a=>!rae(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(jm))return{id:a.slice(jm.length)};const l=a.match(OS);return l&&l[1]!=="workflow"?{id:l[2],type:ES(l[1]),label:s}:null}if(n.type==="element"&&n.tagName==="code"){const a=pg(n).trim();if(Nm(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Nm(a))return{id:a}}return null}const sae={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")||Vte(a))return i.jsx(dg,{code:a,language:"plantuml",children:i.jsx(IS,{code:a})});if(t?.includes("language-mermaid"))return i.jsx(dg,{code:a,language:"mermaid",children:i.jsx(LS,{code:a})});if(t?.includes("language-"))return i.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Nm(n))return i.jsx(hc,{id:n.trim()});const s=n.match(aae);return s?i.jsx(hc,{id:s[2],label:s[1]}):tne(n)?i.jsx($ne,{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(nae,{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})},oae=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function lae(e){const t=hb(e);return kS(e)&&oae.test(t.split("?")[0]??t)}function cae(e,t){const n=hb(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 uae(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function dae(e,t){return lae(e)?uae(cae(e,t)):null}const Lo=new Map,sc=new Map,mae=k.memo(function({src:t,alt:n,onPreview:a,basePath:s}){const l=k.useMemo(()=>dae(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),D=k.useCallback(M=>{sc.set(l,M),C(M),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(M=>M+1)},[l,c]);return k.useEffect(()=>{if(!c)return;const M=Lo.get(l);if(M){h(M),x(!0),w(!1),C(null);return}const I=sc.get(l);if(I!==void 0){w(!0),C(I),x(!1);return}const G=++_.current;w(!1),C(null),x(!1),h(null),(async()=>{try{const Q=await fetch(l,{credentials:"same-origin"});if(G!==_.current)return;if(!Q.ok){let K=`HTTP ${Q.status}`;try{const ee=await Q.json();ee.error&&(K=ee.error)}catch{}throw new Error(K)}const $=await Q.blob();if(G!==_.current)return;if($.size===0)throw new Error("Empty image response");if($.type&&!$.type.startsWith("image/")&&!$.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${$.type}`);const Y=URL.createObjectURL($);Lo.set(l,Y),h(Y),x(!0),w(!1),C(null)}catch(Q){if(G!==_.current)return;const $=Q instanceof Error?Q.message:String(Q);console.warn("[MarkdownImage] failed to load local image",l,Q),D($)}})()},[c,l,S]),k.useEffect(()=>{if(c)return;const M=sc.get(l);if(M!==void 0){w(!0),C(M),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:()=>{D("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 Gw(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function pae(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 fae(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 PS({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 Gw(e),y=await pae(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 Gw(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=fae(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 zS(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:s,hostAvailable:l,openRightPanel:c}=e,d=k.useCallback((m,p)=>{const h=Lw(p,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){nne(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(()=>({...sae,img:({src:m,alt:p})=>i.jsx(mae,{src:m??"",alt:p,onPreview:a,basePath:n},m??""),p:({children:m,node:p})=>{const h=iae(p);return h?i.jsx(bne,{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(Uw)){const g=decodeURIComponent(m.slice(Uw.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(jm))return i.jsx(hc,{id:m.slice(jm.length)});{const g=m?.match(OS);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=ES(x);if(w)return i.jsx(hc,{id:y,type:w,label:p})}}if(m&&Nm(m))return i.jsx(hc,{id:m.trim(),label:p});const h=Lw(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 Kw=[I5,P3,z3],Vw=[AS,[V3,{strict:"ignore"}],[dS,{detect:!0,ignoreMissing:!0}]];function fg(e){if(/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e))return e;const n=fb(e);return kS(n)?n:c5(e)}const hae=/(?:<thinking>| thinking)([\s\S]*?)<\/thinking>/g;function gae(e){const t=[];let n=e.replace(hae,(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 bae(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 yae({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=bae();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 gb(e);y(n(C?"markdown.copied":"markdown.failed")),s(!1)},T=async C=>{const S=t.current?.firstElementChild;if(!S)return;const E=NS(),_=sne(E),D=await rne(S,C,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),P=n(C==="light"?"markdown.themeLight":"markdown.themeDark");y(D.ok?D.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(one,{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}=gae(t),m=k.useRef(null),[p,h]=k.useState(null),g=$c(),x=k.useCallback(T=>{let C=ui(T,fS);return C=ui(C,Pte),C=ui(C,Zte),C=ui(C,$te),C=ui(C,qte),C=ui(C,S=>zte(S,s)),C=ui(C,bS),C},[s]),y=k.useMemo(()=>x(d),[d,x]),w=zS({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(yae,{content:t,contentRef:m}),i.jsx("div",{ref:m,children:i.jsx(lne,{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:Kw,rehypePlugins:Vw,components:w,urlTransform:fg,children:x(T)})})})]})})(),i.jsx(qh,{remarkPlugins:Kw,rehypePlugins:Vw,components:w,urlTransform:fg,children:y})]})})}),p&&i.jsx(PS,{src:p,onClose:()=>h(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&xae(e.knownNames,t.knownNames));function xae(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 BS=Object.freeze(Object.defineProperty({__proto__:null,ImagePreviewModal:PS,MarkdownMessage:Ea,chatUrlTransform:fg},Symbol.toStringTag,{value:"Module"})),hg={suppressAdjustUntil:0};function Rc(e=2500){const t=typeof performance<"u"?performance.now():Date.now();hg.suppressAdjustUntil=Math.max(hg.suppressAdjustUntil,t+e)}function use(){return(typeof performance<"u"?performance.now():Date.now())<hg.suppressAdjustUntil}const Ww={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:"📜"},notebook_upsert:{label:"Updating notebook",icon:"📝"},kb_search:{label:"Searching knowledge base",icon:"📚"},kb_list:{label:"Listing knowledge base",icon:"📚"},kb_read:{label:"Reading knowledge base",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:"💾"},notebook_clear:{label:"Clearing notebook",icon:"📝"},notebook_read:{label:"Reading 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:"🔍"}},Yw={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",notebook_upsert:"edit",kb_search:"book-open",kb_list:"book-open",kb_read:"book-open",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",notebook_clear:"edit",notebook_read:"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=Ww[t]??Ww[e],a=Yw[t]??Yw[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 vae(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 Qw(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function HS(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 wae(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 dse(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 bb(e){const t=vae(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 $S(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 qS(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 FS={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 kae(e){return!!e&&e in FS}function rl({name:e,size:t=24,className:n=""}){const a=FS[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 Xw={"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"},Jw={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function em(e,t){const n=(e||"").toLowerCase();return Xw[n]?Xw[n]:t&&Jw[t]?Jw[t]:"layers"}function Sae(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 US(){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 Cae(){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 Zw({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(US,{})]})}function ek({activities:e,isActive:t,persistent:n}){const{t:a}=ot("common"),s=Sae(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(Zw,{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(Cae,{})]});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(US,{})]}),l&&i.jsx("div",{className:"mt-1 space-y-0.5",children:s.map((w,T)=>i.jsx(Zw,{item:w,idx:T,total:s.length},w.key))})]})}const Aae={"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"],Tae=new Set(["completed","failed","cancelled","timeout"]),tk={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function Nae(e){return Aae[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function Eae(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 jae(e){if(e==="completed"||Tae.has(e))return Uo.length;const t=Uo.indexOf(e);return t>=0?t:0}function Mae({session:e,className:t}){const n=Nae(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(()=>Eae(e,l),[e,l]),g=jae(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:tk[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:tk[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 whitespace-pre-wrap break-all font-mono",children:x})]})]})}function _ae({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 nk=150;function Rae({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>=nk?(s.current=d,a(e)):l.current||(l.current=setTimeout(()=>{s.current=Date.now(),l.current=null,a(e)},nk-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 Mm=8e3,Rd=120;function dh({text:e,className:t}){const{t:n}=ot("common"),[a,s]=k.useState(!1),l=e.length>Mm,c=!l||a?e:`${e.slice(0,Mm)}
|
|
@@ -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 Ld=new Map,ere=2e3;function Mse(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=Ld.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&&(Ld.size>=ere&&Ld.clear(),Ld.set(l,p)),p}function _se(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function Rse(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 Dse(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 Lse(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 Ise(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 tre=10,nre=23,ok={expanded:24,compact:12};function Ose(e){const t=e?ok.compact:ok.expanded;return tre*nre+t}function Pse(e,t){return e||t}function zse(e){return e?"justify-end":""}function Bse(e,t,n){return e?t.includes(e)?"detail":n?"missing":"loading":"missing"}function Hse({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 $se({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 qse({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 are(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const XS="markus:credit-notif-muted";let lk=0;function Fse(){try{if(localStorage.getItem(XS))return}catch{}const e=Date.now();e-lk<5*6e4||(lk=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function rre(){try{localStorage.setItem(XS,"1")}catch{}}function Use(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(are(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 Gse({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=qae(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 Kse({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 ire=/[.!?。!?…::]\s*$|["'”’)\]}】》]\s*$|\n\s*$/,sre=/^(?:\n|#{1,6}[ \t]|[-*+][ \t]|\d+[.)][ \t]|>|\||```|~~~|---)/;function ore(e,t){return!(!e.replace(/\s+$/,"")||ire.test(e)||!t.trim()||sre.test(t))}function lre(e,t,n){return/\s$/.test(e)||/^\s/.test(t)?e+t:n?.spaceNeeded?`${e} ${t}`:e+t}function cre(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&&ore(c.content,l.content)){c.content=lre(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 ure(e){return e.type!=="text"||e.metadata?.isThinking===!0}function JS(e){const t=Date.parse(e[0]?.createdAt??""),n=Date.parse(e[e.length-1]?.createdAt??"");return Number.isFinite(t)&&Number.isFinite(n)&&n>t?n-t:0}function dre(e){let t=0,n=0,a=0,s=null,l=0;for(const d of e){if(d.type==="text"&&d.metadata?.isThinking===!0){t++;continue}if(d.type==="tool_start"){n++,s=d.content;continue}if(d.type==="tool_end"){d.metadata?.success===!1&&l++,s=null;continue}d.type==="subagent_start"&&a++,d.type==="error"&&l++}const c=JS(e);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:c,errorCount:l}}function mre(e){const t=[];let n=[],a=0;const s=()=>{n.length!==0&&(t.push({kind:"process",key:`proc_${a}`,entries:n,summary:dre(n)}),n=[])};return e.forEach((l,c)=>{if(ure(l)){n.length===0&&(a=c),n.push(l);return}s(),t.push({kind:"text",key:`text_${c}`,entry:l})}),s(),t}function pre(e){for(let t=e.length-1;t>=0;t--)if(e[t].kind==="text")return t;return-1}function fre(e,t){if(t)return 0;const n=pre(e);return n>0?n:0}function hre(e,t){const n=Math.max(0,Math.round(e/1e3));return n<60?t("common:execution.workedForSeconds",{seconds:n}):t("common:execution.workedForMinutes",{minutes:Math.floor(n/60),seconds:n%60})}function ZS({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"})})}):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 gre({entries:e,summary:t,isStreaming:n,isLastBlock:a,hideApprovalCards:s,reconnecting:l}){const{t:c}=ot("common"),[d,m]=k.useState(!1),p=k.useMemo(()=>bg(e.map(bb).filter(C=>C!==null)),[e]),h=!!(n&&(a||t.running))||!!l,g=h?"running":"done",x=l?c("execution.reconnecting"):h&&t.runningTool?c("execution.processRun.runningTool",{tool:c(`execution.tools.${t.runningTool}`,{defaultValue:t.runningTool})}):null,y=[];t.thinkingCount>0&&y.push(c("execution.processRun.thinking")),t.toolCount>0&&y.push(c("execution.processRun.tools",{count:t.toolCount})),t.subagentCount>0&&y.push(c("execution.processRun.subagents",{count:t.subagentCount})),t.errorCount>0&&y.push(c("execution.processRun.errors",{count:t.errorCount})),t.elapsedMs>=1e3&&y.push($s(t.elapsedMs));const w=h?x??c("execution.thinkingEllipsis"):y.join(" · ")||c("execution.processRun.label"),T=c(`execution.processRun.state.${g}`);return i.jsxs("div",{className:"min-w-0",children:[i.jsxs("button",{type:"button",onClick:()=>m(C=>!C),"aria-expanded":d,"data-process-state":g,title:w,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:[h&&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 ${g==="running"?"text-brand-400":""}`,children:i.jsx(ZS,{state:g})}),i.jsx("span",{className:"sr-only",children:T}),i.jsx("span",{className:`relative min-w-0 truncate ${h&&!x?"activity-text-shimmer":""}`,children:h||y.length===0?w:y.map((C,S)=>i.jsxs("span",{children:[S>0?" · ":"",C]},C+S))}),i.jsx("svg",{className:`relative ml-auto w-3 h-3 shrink-0 transition-transform ${d?"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"})})]}),d&&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:p.length>0?p.map((C,S)=>i.jsx(yg,{entry:C,showTime:!1,hideApprovalCards:s},S)):i.jsx("div",{className:"py-1 text-[11px] text-fg-tertiary",children:c("execution.noToolDetail")})})]})}function ck(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 D={};/^\s*\n/.test(E)&&(D.paragraphBreak=!0),/\n\s*\n\s*$/.test(E)&&(D.paragraphAfter=!0),/\s$/.test(E)&&(D.trailingSpace=!0),/^\s/.test(E)&&(D.leadingSpace=!0),a.push({id:`cseg_${s}`,sourceType:"chat",sourceId:"",agentId:l,seq:s++,type:"text",content:_,createdAt:x,...Object.keys(D).length>0?{metadata:D}:{}})}g=""},T="<think>",C="</think>",S=E=>{let _=0,D=!1;for(;_<E.length;)if(D){const P=E.indexOf(C,_);P===-1?_=E.length:(D=!1,_=P+C.length)}else{const P=E.indexOf(T,_);P===-1?(g+=E.slice(_),_=E.length):(g+=E.slice(_,P),D=!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(xb(E.content).cleaned);return w(),cre(a)}const Vse=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,h]=k.useState(!1),g=P=>P.type==="text"?P.content.length+(P.thinking?.length??0):(P.result?.length??0)+(P.subagentLogs?.length??0)*1e3+(P.liveOutput?.length??0),x=d?d.length+":"+(d.length>0?g(d[d.length-1]):0):"",y=d?d.reduce((P,M)=>P+(M.type==="tool"?M.subagentLogs?.length??0:0),0):0,w=k.useMemo(()=>d&&d.length>0?ck(d,t.agentId,t.rawCreatedAt):[],[x,y,t.agentId,t.rawCreatedAt]),T=t.committedSegments,C=T?T.length+":"+(T.length>0?g(T[T.length-1]):0):"",S=T?T.reduce((P,M)=>P+(M.type==="tool"?M.subagentLogs?.length??0:0),0):0,E=k.useMemo(()=>n?w:T&&T.length>0?ck(T,t.agentId,t.rawCreatedAt):w,[n,C,S,t.agentId,t.rawCreatedAt,w]);if(d!==void 0&&d.length>0){const M=d.filter(L=>L.type==="text").map(L=>L.content).join(""),I=L=>L.replace(/\n*<!--\s*notify_context:\s*[\s\S]*?-->/g,"").replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim()||null,Q=(M?I(M):null)||(t.text?I(t.text):null),$=mre(E),Y=$.some(L=>L.kind==="text"),K=fre($,n),ee=K>0&&!p?K:0,U=hre(JS(E),c),te=[];for(const L of d){if(L.type!=="tool")continue;const J=$S(L.tool,L.result);if(J){te.push({key:`task-${J.taskId}`,kind:"task",info:J});continue}const me=qS(L.tool,L.result);me&&te.push({key:`req-${me.requirementId}`,kind:"req",info:me})}return i.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[K>0&&i.jsxs("button",{type:"button",onClick:()=>h(L=>!L),"aria-expanded":p,"data-worked-summary":"true",title:U,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:[i.jsx("span",{className:"relative shrink-0 flex items-center justify-center w-3 h-3",children:i.jsx(ZS,{state:"done"})}),i.jsx("span",{className:"relative min-w-0 truncate",children:U}),i.jsx("svg",{className:`relative ml-auto w-3 h-3 shrink-0 transition-transform ${p?"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"})})]}),$.slice(ee).map((L,J)=>{const me=J+ee;return L.kind==="text"?i.jsx(Ea,{content:L.entry.content,onMentionClick:s,knownNames:l},L.key):i.jsx(gre,{entries:L.entries,summary:L.summary,isStreaming:n,isLastBlock:me===$.length-1,hideApprovalCards:!0,reconnecting:!!t.reconnecting},L.key)}),$.length===0&&n&&i.jsx(ek,{activities:a,isActive:!0}),!Y&&Q&&i.jsx(Ea,{content:Q,onMentionClick:s,knownNames:l}),te.map(L=>L.kind==="task"?i.jsx(KS,{info:L.info},L.key):i.jsx(VS,{info:L.info},L.key)),!n&&!Q&&$.length===0&&te.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(L=>L.type==="text"&&L.content&&(L.content===t.text||L.content.startsWith("⚠")))&&i.jsxs("div",{className:"flex items-start gap-1.5 mt-2 text-[11px] text-fg-tertiary leading-relaxed",children:[i.jsxs("svg",{className:"w-3 h-3 mt-0.5 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[i.jsx("circle",{cx:"12",cy:"12",r:"9"}),i.jsx("path",{d:"M12 8v4.5M12 16h.01",strokeLinecap:"round"})]}),i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"text-fg-secondary",children:c("page.endedEarly")}),i.jsx("span",{className:"mx-1",children:"·"}),i.jsx("span",{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 _=(t.activities?.length??0)>0,D=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||_)&&i.jsx(ek,{activities:n?a:t.activities??[],isActive:n,persistent:!n&&_}),D?t.isError||D.startsWith("⚠")?i.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:D.replace(/^⚠\s*/,"")}):i.jsx(Ea,{content:D,onMentionClick:s,knownNames:l}):null,!n&&!D&&!_&&!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 bre(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 yre({approval:e,submitting:t,readOnly:n,onClose:a,onSubmit:s}){const{t:l}=ot(["team","common"]);Qo(!0);const c=k.useMemo(()=>bre(e),[e]),[d,m]=k.useState(0),[p,h]=k.useState(()=>{if(n&&e.answers&&e.answers.length>0){const P={};for(const M of e.answers)P[M.questionId]={selectedOptionIds:M.selectedOptionIds??[],text:M.text??""};return P}return{}}),g=c[d],x=d===c.length-1,y=c.length>1,w=P=>p[P]??{selectedOptionIds:[],text:""},T=(P,M)=>{h(I=>({...I,[P]:{...w(P),...M}}))},C=(P,M)=>{const I=w(P.id);if(P.allowMultiple){const G=I.selectedOptionIds.includes(M);T(P.id,{selectedOptionIds:G?I.selectedOptionIds.filter(Q=>Q!==M):[...I.selectedOptionIds,M],text:G?I.text:""})}else{const G=I.selectedOptionIds.includes(M);T(P.id,{selectedOptionIds:G?[]:[M],text:G?I.text:""})}},S=P=>{const M=w(P.id);return P.inputType==="choice"?M.selectedOptionIds.length>0?!0:!!(P.allowFreeform&&M.text.trim()):M.text.trim().length>0},E=c.every(S),_=()=>c.map(P=>{const M=w(P.id),I={questionId:P.id};return M.selectedOptionIds.length>0&&(I.selectedOptionIds=M.selectedOptionIds),M.text.trim()&&(I.text=M.text.trim()),I}),D=()=>{const P=_();let M=!0,I;if(!e.questions?.length&&e.options?.length){const Q=P[0];I=Q?.selectedOptionIds?.[0]??(Q?.text?"custom":void 0),M=I!=="reject"&&I!=="request_changes"}const G=P.map(Q=>Q.text).filter(Boolean).join(`
|
|
869
|
-
`)||void 0;s({approved:M,comment:G,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,M)=>i.jsx("button",{onClick:()=>m(M),className:`h-1.5 flex-1 rounded-full transition-colors ${M===d?"bg-brand-500":S(P)?"bg-green-500/60":"bg-border-default"}`,title:`${M+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,M)=>{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+M)}),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 M=P.target.value;T(g.id,{text:M,selectedOptionIds:M.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:D,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)}const xg=6e4,e6=60*xg,xre=24*e6;function Io(e,t){const n=new Date(e).getTime();if(!Number.isFinite(n))return"";const a=Date.now()-n;if(a<xg)return t("common:time.now");const s=Math.floor(a/xg);if(s<60)return t("common:time.minutesAgo",{count:s});const l=Math.floor(a/e6);return l<24?t("common:time.hoursAgo",{count:l}):t("common:time.daysAgo",{count:Math.floor(a/xre)})}function Wse(e,t){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";try{return new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(n)}catch{return n.toLocaleString()}}function Id(e){return Array.isArray(e.questions)&&e.questions.length>0}const Od={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},Oo={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"},uk={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"},dk="markus:template-updates-ack";let mh=!1,Pd=null;function vre(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function mk(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 zd(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 t6(e){const t=e.metadata;if(!(!t||typeof t.i18n!="object"||!t.i18n))return t.i18n}function pk(e,t){const n=t6(e);if(!n?.titleKey)return e.title;const a={...n.titleParams??{}};return t(`team:${n.titleKey}`,{...a,defaultValue:e.title})}function fk(e,t){const n=t6(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 ph(){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 wre({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),[_,D]=k.useState(null),[P,M]=k.useState(null),[I,G]=k.useState({}),[Q,$]=k.useState(0),[Y,K]=k.useState([]),ee=k.useRef(null),U=k.useRef(null),[te,L]=k.useState({top:0,left:0,width:448,maxHeight:576}),J=k.useRef(null),me=k.useRef(!1),[Ce,H]=k.useState(!0),[V,fe]=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[F,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(F.notifications),K(Xe.notifications);const ye=F.unreadCount??F.notifications.filter(tt=>!tt.read).length;if($(ye),H(F.totalCount!=null?F.notifications.length<F.totalCount:F.notifications.length>=dt),C(ge.approvals),!me.current){const tt=ge.approvals.filter(ft=>ft.status==="pending").length;J.current=tt,me.current=!0}}catch{}},[t]),Zt=k.useCallback(async()=>{if(!(V||!Ce)){fe(!0);try{const F=await Ae.notifications.list(t,!1,{limit:dt,offset:y.length});F.notifications.length>0&&w(ge=>[...ge,...F.notifications.filter(Xe=>!ge.some(ye=>ye.id===Xe.id))]),H(F.totalCount!=null?y.length+F.notifications.length<F.totalCount:F.notifications.length>=dt)}catch{}fe(!1)}},[t,y.length,V,Ce]),Wt=k.useCallback(F=>{const ge=F.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(()=>{});$(bt=>Math.max(0,bt-ft.length));const Ht=new Set(ft.map(bt=>bt.id));return K(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(),ph()}catch{}},[wt,m]),mt=k.useCallback(async()=>{if(!mh){mh=!0;try{const{updates:F}=await Ae.skills.updates();if(!F.length)return;const ge=vre(F);try{if(localStorage.getItem(dk)===ge)return}catch{}if(Pd===ge||rt.current.some(ye=>!ye.read&&mk(ye,ge)))return;try{const tt=(await Ae.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(ft=>mk(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(),Pd=ge;return}}catch{}Pd=ge,await Ae.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:F.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:ge,count:F.length,skills:F.map(ye=>ye.name)}}),wt(),ph()}catch{Pd=null}finally{mh=!1}}},[wt,m,t]);k.useEffect(()=>{wt();const F=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(F),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 F=setInterval(()=>{mt()},5*6e4),ge=()=>{mt()};return window.addEventListener("markus:data-changed",ge),()=>{clearInterval(F),window.removeEventListener("markus:data-changed",ge)}},[t]);const At=k.useCallback(()=>{if(!ee.current)return;const F=ee.current.getBoundingClientRect(),ge=window.innerWidth,Xe=window.innerHeight,ye=Math.min(448,ge-16),tt=Math.min(576,Xe-16);let ft=F.right+8,Ht=F.top;ft+ye>ge-8&&(ft=Math.max(8,ge-ye-8)),Ht+tt>Xe-8&&(Ht=Math.max(8,Xe-tt-8)),L({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 F=ge=>{ee.current?.contains(ge.target)||U.current?.contains(ge.target)||h(!1)};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[p]),k.useEffect(()=>{if(!p)return;ut("unread");const F=T.some(Xe=>Xe.status==="pending"),ge=y.some(Xe=>!Xe.read);x(F&&!ge?"approvals":!F&&ge?"notifications":je.current)},[p]);const Dt=new Set(T.filter(F=>F.status==="pending").map(F=>F.id)),ln=new Set(T.map(F=>F.id)),ce=F=>F.type==="approval_request"&&!!F.metadata?.approvalId&&ln.has(F.metadata.approvalId),et=F=>[...F].sort((ge,Xe)=>new Date(Xe.createdAt).getTime()-new Date(ge.createdAt).getTime()),nt=y.filter(F=>!ce(F)),we=Y.filter(F=>!ce(F)),Me=et(nt),Ne=et(we),se=He==="all"?Me:Ne,q=m(He==="unread"?"team:notifications.noUnread":"team:notifications.noNotifications"),ae=Ne.length,Se=Dt.size,De=ae+Se;k.useEffect(()=>{J.current!==null&&Se>J.current&&ph(),J.current=Se},[Se]);const Pe=async F=>{await Ae.notifications.markRead(F),w(ge=>ge.map(Xe=>Xe.id===F?{...Xe,read:!0}:Xe)),K(ge=>ge.filter(Xe=>Xe.id!==F)),$(ge=>Math.max(0,ge-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},X=F=>{const ge=F.metadata??{},Xe=F.actionType,ye=F.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(F.type){case"approval_request":{const tt=ge.approvalId,ft=tt?T.find(_e=>_e.id===tt):void 0;if(ft&&Id(ft)){D(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(dk,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}},Z=async F=>{const ge=F.metadata??{},Xe=F.actionType,ye=F.type==="agent_report"&&!ge.creditExhausted&&!ge.templateUpdates&&(Xe==="open_chat"||!!ge.agentId&&Xe!=="navigate");!F.read&&!ye&&Pe(F.id);const tt=ge.taskId,ft=ge.requirementId;if(!ye&&(tt||ft)){const Ht=y.filter(bt=>bt.id!==F.id&&!bt.read&&(tt&&bt.metadata?.taskId===tt||ft&&bt.metadata?.requirementId===ft));for(const bt of Ht)Pe(bt.id)}X(F)},ue=async(F,ge,Xe,ye,tt)=>{E(F);try{const{approval:ft}=await Ae.approvals.respond(F,ge,t,Xe,ye,tt);C(_e=>_e.map(ht=>ht.id===F?ft:ht)),D(null),M(null),G(_e=>{const ht={..._e};return delete ht[F],ht});const Ht=ft.details?.taskId,bt=ft.details?.requirementId,le=y.filter(_e=>!_e.read&&(_e.type==="approval_request"&&_e.metadata?.approvalId===F||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)),$(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(F=>F.map(ge=>({...ge,read:!0}))),K([]),$(0),li("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const F=nt.filter(ge=>!ge.read);await Promise.all(F.map(ge=>Ae.notifications.markRead(ge.id))),w(ge=>ge.map(Xe=>({...Xe,read:!0}))),K([]),$(0),li("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ie=F=>{const ge=F.details?.subType;return ge==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):ge==="requirement"||F.details?.requirementId?m("team:notifications.approvalType.requirement"):ge==="task_review"?m("team:notifications.approvalType.taskReview"):ge==="task"||F.details?.taskId?m("team:notifications.approvalType.task"):F.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},Ge=F=>{const ge=F.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:F.agentName,title:F.title,priority:tt,defaultValue:F.description});if(Xe==="requirement_resubmit")return m("team:notifications.approvalDesc.requirementResubmitted",{agentName:F.agentName,title:F.title,priority:tt,defaultValue:F.description});if(Xe==="task")return m("team:notifications.approvalDesc.taskCreate",{agentName:F.agentName,title:F.title,priority:tt,defaultValue:F.description});if(Xe==="task_review"){const ft=`Task "${F.title}" has been submitted for your review.`;if(F.description.startsWith(ft))return m("team:notifications.approvalDesc.taskReview",{title:F.title})+F.description.slice(ft.length)}return F.description},kt=F=>{const ge=[];ge.push(F.agentName);const Xe=F.details?.taskTitle,ye=F.details?.taskId;Xe?ge.push(Xe):ye&&ge.push(`${m("team:notifications.approvalType.task")} ${ye.slice(0,8)}`);const tt=F.details?.requirementId;return tt&&!ye&&ge.push(`${m("team:notifications.approvalType.requirement")} ${tt.slice(0,8)}`),ge.join(" · ")},Rt=[...T].sort((F,ge)=>new Date(ge.requestedAt).getTime()-new Date(F.requestedAt).getTime()),Mt=Rt.filter(F=>F.status==="pending"),Ot=Rt.filter(F=>F.status!=="pending"),Un=F=>{const ge=F.details?.taskId,Xe=F.details?.requirementId,ye=F.details?.agentId??F.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=F=>i.jsxs("button",{disabled:S===F.id,onClick:()=>D(F),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"}),F.questions&&F.questions.length>1?` (${F.questions.length})`:""]}),Ee=_?i.jsx(yre,{approval:_,submitting:S===_.id,readOnly:_.status!=="pending",onClose:()=>D(null),onSubmit:F=>ue(_.id,F.approved,F.comment,F.selectedOption,F.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(F=>i.jsx("button",{onClick:()=>ut(F),"aria-pressed":He===F,title:F==="unread"?m("team:notifications.noUnread"):void 0,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${He===F?"bg-surface-base text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:F==="unread"?m("team:notifications.filterUnread")+(ae>0?` (${ae})`:""):m("team:notifications.filterAll")},F))}),Q>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"),ae>0?` (${ae})`:""]}),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:F=>{if(g!=="notifications"||!Ce||V)return;const ge=F.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(F=>{const ge=F.details?.command,Xe=ge?Ge(F).replace(/\s*Command:.*$/,""):Ge(F);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(F),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:Oo.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Ie(F)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ie(F)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:F.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Io(F.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:F.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(Id(F))return ie(F);const ye=F.details?.subType,tt=ye==="task"||ye==="requirement"||ye==="requirement_resubmit",ft=F.options&&F.options.length>0,Ht=(I[F.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:[F.options.map((le,_e)=>i.jsxs("button",{disabled:S===F.id,onClick:()=>ue(F.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[F.id]??"",onChange:le=>G(_e=>({..._e,[F.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&(I[F.id]??"").trim()&&ue(F.id,!0,(I[F.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===F.id||!(I[F.id]??"").trim(),onClick:()=>ue(F.id,!0,(I[F.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===F.id,onClick:()=>ue(F.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===F.id,onClick:()=>ue(F.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!==F.id&&i.jsxs("button",{disabled:S===F.id,onClick:()=>M(F.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===F.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[F.id]??"",onChange:bt=>G(le=>({...le,[F.id]:bt.target.value})),onKeyDown:bt=>{bt.key==="Enter"&&(I[F.id]??"").trim()&&ue(F.id,!1,(I[F.id]??"").trim(),"needs_adjustment"),bt.key==="Escape"&&M(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===F.id||!(I[F.id]??"").trim(),onClick:()=>ue(F.id,!1,(I[F.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:()=>M(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[F.id]??"",onChange:bt=>G(le=>({...le,[F.id]:bt.target.value})),onKeyDown:bt=>{bt.key==="Enter"&&ue(F.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===F.id,onClick:()=>ue(F.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===F.id,onClick:()=>ue(F.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")})]})]})})()]},F.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(F=>i.jsxs("button",{onClick:()=>Id(F)?D(F):Un(F),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 ${F.status==="approved"?"bg-green-500":F.status==="cancelled"||F.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ie(F)&&i.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ie(F)}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:F.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${F.status==="approved"?"text-green-500":F.status==="cancelled"||F.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${F.status}`,{defaultValue:F.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(F)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Io(F.respondedAt??F.requestedAt,m)})]}),F.responseComment&&i.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",F.responseComment,"”"]})]},F.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(F=>{const ge=uk[F.type]??"text-fg-tertiary";return i.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Z(F),onKeyDown:Xe=>{(Xe.key==="Enter"||Xe.key===" ")&&(Xe.preventDefault(),Z(F))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${F.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:Oo[F.type]??Oo.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!F.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Od[F.priority]??Od.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:pk(F,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(Ea,{content:fk(F,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:Io(F.createdAt,m)}),zd(F,m)&&i.jsx("span",{className:`text-[10px] font-medium ${ge}`,children:zd(F,m)})]})]})]},F.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(F=>{F?.mute&&rre()},[]),Pt=k.useCallback(F=>{Bt(F),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:F=>{Pt(F),at.navigate(de.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:F=>{const ge=`${st.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Pt(F),fi(ge)}}):null;if(n){const F=["approvals","notifications"],ge=F.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<F.length-1&&x(F[ge+1]),Ht>0&&ge>0&&x(F[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:F.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"),ae>0?` (${ae})`:""]})},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:Oo.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:Io(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(Id(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=>G(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:()=>M(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=>G(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"&&M(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:()=>M(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=>G(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:Io(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=uk[ye.type]??"text-fg-tertiary";return i.jsxs("button",{onClick:()=>Z(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:Oo[ye.type]??Oo.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 ${Od[ye.priority]??Od.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:pk(ye,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(Ea,{content:fk(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:Io(ye.createdAt,m)}),zd(ye,m)&&i.jsx("span",{className:`text-[10px] font-medium ${tt}`,children:zd(ye,m)})]})]})]},ye.id)})})})]})})]})]})}if(s){const F=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:F})}),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:U,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:te.top,left:te.left,width:te.width,maxHeight:te.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:U,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:te.top,left:te.left,width:te.width,maxHeight:te.maxHeight},children:pt}),document.body),it]})}function Bd({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 fh=200;function kre({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}=b4(d),_=k.useCallback(()=>{if(!y.current)return;const K=y.current.getBoundingClientRect(),ee=window.innerWidth,U=window.innerHeight,te=w.current?.offsetHeight??220;let L=K.right+8;L+fh>ee-8&&(L=Math.max(8,K.left-fh-8));let J=K.top-te-8;J<8&&(J=Math.min(K.bottom+8,U-te-8)),x({top:Math.max(8,J),left:L})},[]);k.useLayoutEffect(()=>{if(!d)return;_();const K=requestAnimationFrame(()=>_());return()=>cancelAnimationFrame(K)},[d,_,s]),k.useEffect(()=>{if(!d)return;const K=U=>{const te=U.target;y.current?.contains(te)||w.current?.contains(te)||m(!1)},ee=()=>_();return document.addEventListener("mousedown",K),window.addEventListener("resize",ee),window.addEventListener("scroll",ee,!0),()=>{document.removeEventListener("mousedown",K),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0)}},[d,_]);const D=e?.name||C?.displayName||C?.username||c("common:userPlaceholder"),P=e?.email||C?.email||"",M=f4(e?.avatarUrl,C?.avatarUrl),I=T?"bg-emerald-500":"bg-fg-muted",G=T?C?.username?c("sidebar.hubConnectedAs",{username:C.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),Q=!!(T&&C?.username&&e?.name&&C.username.toLowerCase()!==e.name.toLowerCase()&&C.email?.toLowerCase()!==e.email?.toLowerCase()),$=()=>{m(!1),E({validate:!0}),at.navigate(de.SETTINGS,{tab:"account"})},Y=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:fh},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:D}),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(Bd,{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:$,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:G}),Q&&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(Bd,{d:Sc[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(Bd,{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(Bd,{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(K=>!K),title:D,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${s?"p-0.5":""}`,children:[i.jsx(Zi,{name:D,avatarUrl:M,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:G})]}),l&&!s&&i.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.11.3-rc.0"]}),Y,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 Sre({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 Cre({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:iU.map((p,h)=>{const g=s4.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(wre,{sidebarMode:!0,collapsed:a,userId:n?.id,label:m(y.id),iconPath:Sc[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(Sre,{d:Sc[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(kre,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const Are=6e4,Tre=2e3;let Ar={},Yi={};const vg=new Set,_m=new Set;let n6=0;const wg=new Map;let bc=null,Hd=0,tm=null;function Dc(){for(const e of vg)e()}function hk(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 Nre(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 vb(e,t){const n=Date.now(),a=wg.get(e)??0;!t?.force&&n-a<Tre||(wg.set(e,n),e in Ar&&(delete Ar[e],Dc()),Ae.unread.markRead(e,new Date().toISOString()).catch(()=>{}))}async function kg(){try{const e=await Ae.unread.getCounts(),{counts:t,staleActiveKeys:n}=Nre(e.counts??{},_m);Ar=t,Yi=e.sessionAgentMap??{},Dc();for(const a of n)vb(a)}catch{}}function Ere(){bc||(kg(),bc=setInterval(kg,Are),tm=Ir.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(_m.has(t)){vb(t);return}Date.now()>n6&&(Ar[t]=(Ar[t]??0)+1,Dc())}}))}function jre(){bc&&(clearInterval(bc),bc=null),tm&&(tm(),tm=null)}function Mre(e){const t=e?.enabled??!0,[n,a]=k.useState(Ar),[s,l]=k.useState(Yi),c=k.useCallback(async()=>{await kg()},[]),d=k.useCallback(async w=>{const T=new Date().toISOString();delete Ar[w],Dc();try{await Ae.unread.markRead(w,T)}catch{}},[]),m=k.useCallback(async()=>{Ar={},Dc();try{await Ae.unread.markAllRead()}catch{}},[]),p=k.useCallback(w=>{_m.add(w)},[]),h=k.useCallback(w=>{_m.delete(w),n6=Date.now()+150,wg.delete(w),vb(w,{force:!0})},[]);k.useEffect(()=>{if(!t)return;Hd++,Ere();let w=Yi;const T=()=>{a(C=>hk(C,Ar)?C:{...Ar}),w!==Yi&&(w=Yi,l(C=>hk(C,Yi)?C:{...Yi}))};return vg.add(T),a({...Ar}),l({...Yi}),()=>{vg.delete(T),Hd--,Hd<=0&&(Hd=0,jre())}},[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 Yse(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 _re(e){return e.startsWith("channel:dm:a2a:")}function Rre(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(_re(a))continue;n+=s}return n}function Dre({currentPage:e,onNavigate:t,userId:n}){const{t:a}=ot("nav"),[s,l]=k.useState(0),{counts:c,sessionAgentMap:d}=Mre({enabled:!0}),m=k.useMemo(()=>Rre(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:oU.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:Sc[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 Rm=new Map;function Ns(e,t){Rm.has(e)||Rm.set(e,t().catch(()=>{}))}function Ls(e){const t=Rm.get(e);return Rm.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 a6(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}const Lre={agent:258,team:205,skill:32,connector:162};function wb(e,t){const n=Lre[e],a=a6(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 gk=["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 r6(e){return gk[a6(e+"g")%gk.length]}function i6(e){return e?e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("data:")||/\.(png|jpe?g|gif|webp|svg)$/i.test(e):!1}function Ire(e){return!e||i6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function Ore(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 bk(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const yk={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"}},Pre=["development","devops","management","productivity","browser","custom","general"],zre=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],Bre={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 hh({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:D=>g(D.target.value),onBlur:y,onKeyDown:T,className:`${_} resize-y min-h-[60px]`,placeholder:l}):i.jsx("input",{ref:x,value:h,onChange:D=>g(D.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 Hre({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 $re({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 Sg({content:e}){const t=[I5,P3,z3],n=[AS,[V3,{strict:"ignore"}],[dS,{detect:!0,ignoreMissing:!0}]],a=zS({}),s=k.useMemo(()=>{let l=ui(e,fS);return l=ui(l,bS),l},[e]);return i.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
869
|
+
`)||void 0;s({approved:M,comment:G,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,M)=>i.jsx("button",{onClick:()=>m(M),className:`h-1.5 flex-1 rounded-full transition-colors ${M===d?"bg-brand-500":S(P)?"bg-green-500/60":"bg-border-default"}`,title:`${M+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,M)=>{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+M)}),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 M=P.target.value;T(g.id,{text:M,selectedOptionIds:M.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:D,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)}const xg=6e4,e6=60*xg,xre=24*e6;function Io(e,t){const n=new Date(e).getTime();if(!Number.isFinite(n))return"";const a=Date.now()-n;if(a<xg)return t("common:time.now");const s=Math.floor(a/xg);if(s<60)return t("common:time.minutesAgo",{count:s});const l=Math.floor(a/e6);return l<24?t("common:time.hoursAgo",{count:l}):t("common:time.daysAgo",{count:Math.floor(a/xre)})}function Wse(e,t){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";try{return new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(n)}catch{return n.toLocaleString()}}function Id(e){return Array.isArray(e.questions)&&e.questions.length>0}const Od={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},Oo={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"},uk={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"},dk="markus:template-updates-ack";let mh=!1,Pd=null;function vre(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function mk(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 zd(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 t6(e){const t=e.metadata;if(!(!t||typeof t.i18n!="object"||!t.i18n))return t.i18n}function pk(e,t){const n=t6(e);if(!n?.titleKey)return e.title;const a={...n.titleParams??{}};return t(`team:${n.titleKey}`,{...a,defaultValue:e.title})}function fk(e,t){const n=t6(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 ph(){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 wre({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),[_,D]=k.useState(null),[P,M]=k.useState(null),[I,G]=k.useState({}),[Q,$]=k.useState(0),[Y,K]=k.useState([]),ee=k.useRef(null),U=k.useRef(null),[te,L]=k.useState({top:0,left:0,width:448,maxHeight:576}),J=k.useRef(null),me=k.useRef(!1),[Ce,H]=k.useState(!0),[V,fe]=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[F,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(F.notifications),K(Xe.notifications);const ye=F.unreadCount??F.notifications.filter(tt=>!tt.read).length;if($(ye),H(F.totalCount!=null?F.notifications.length<F.totalCount:F.notifications.length>=dt),C(ge.approvals),!me.current){const tt=ge.approvals.filter(ft=>ft.status==="pending").length;J.current=tt,me.current=!0}}catch{}},[t]),Zt=k.useCallback(async()=>{if(!(V||!Ce)){fe(!0);try{const F=await Ae.notifications.list(t,!1,{limit:dt,offset:y.length});F.notifications.length>0&&w(ge=>[...ge,...F.notifications.filter(Xe=>!ge.some(ye=>ye.id===Xe.id))]),H(F.totalCount!=null?y.length+F.notifications.length<F.totalCount:F.notifications.length>=dt)}catch{}fe(!1)}},[t,y.length,V,Ce]),Wt=k.useCallback(F=>{const ge=F.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(()=>{});$(bt=>Math.max(0,bt-ft.length));const Ht=new Set(ft.map(bt=>bt.id));return K(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(),ph()}catch{}},[wt,m]),mt=k.useCallback(async()=>{if(!mh){mh=!0;try{const{updates:F}=await Ae.skills.updates();if(!F.length)return;const ge=vre(F);try{if(localStorage.getItem(dk)===ge)return}catch{}if(Pd===ge||rt.current.some(ye=>!ye.read&&mk(ye,ge)))return;try{const tt=(await Ae.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(ft=>mk(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(),Pd=ge;return}}catch{}Pd=ge,await Ae.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:F.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:ge,count:F.length,skills:F.map(ye=>ye.name)}}),wt(),ph()}catch{Pd=null}finally{mh=!1}}},[wt,m,t]);k.useEffect(()=>{wt();const F=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(F),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 F=setInterval(()=>{mt()},5*6e4),ge=()=>{mt()};return window.addEventListener("markus:data-changed",ge),()=>{clearInterval(F),window.removeEventListener("markus:data-changed",ge)}},[t]);const At=k.useCallback(()=>{if(!ee.current)return;const F=ee.current.getBoundingClientRect(),ge=window.innerWidth,Xe=window.innerHeight,ye=Math.min(448,ge-16),tt=Math.min(576,Xe-16);let ft=F.right+8,Ht=F.top;ft+ye>ge-8&&(ft=Math.max(8,ge-ye-8)),Ht+tt>Xe-8&&(Ht=Math.max(8,Xe-tt-8)),L({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 F=ge=>{ee.current?.contains(ge.target)||U.current?.contains(ge.target)||h(!1)};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[p]),k.useEffect(()=>{if(!p)return;ut("unread");const F=T.some(Xe=>Xe.status==="pending"),ge=y.some(Xe=>!Xe.read);x(F&&!ge?"approvals":!F&&ge?"notifications":je.current)},[p]);const Dt=new Set(T.filter(F=>F.status==="pending").map(F=>F.id)),ln=new Set(T.map(F=>F.id)),ce=F=>F.type==="approval_request"&&!!F.metadata?.approvalId&&ln.has(F.metadata.approvalId),et=F=>[...F].sort((ge,Xe)=>new Date(Xe.createdAt).getTime()-new Date(ge.createdAt).getTime()),nt=y.filter(F=>!ce(F)),we=Y.filter(F=>!ce(F)),Me=et(nt),Ne=et(we),se=He==="all"?Me:Ne,q=m(He==="unread"?"team:notifications.noUnread":"team:notifications.noNotifications"),ae=Ne.length,Se=Dt.size,De=ae+Se;k.useEffect(()=>{J.current!==null&&Se>J.current&&ph(),J.current=Se},[Se]);const Pe=async F=>{await Ae.notifications.markRead(F),w(ge=>ge.map(Xe=>Xe.id===F?{...Xe,read:!0}:Xe)),K(ge=>ge.filter(Xe=>Xe.id!==F)),$(ge=>Math.max(0,ge-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},X=F=>{const ge=F.metadata??{},Xe=F.actionType,ye=F.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(F.type){case"approval_request":{const tt=ge.approvalId,ft=tt?T.find(_e=>_e.id===tt):void 0;if(ft&&Id(ft)){D(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(dk,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}},Z=async F=>{const ge=F.metadata??{},Xe=F.actionType,ye=F.type==="agent_report"&&!ge.creditExhausted&&!ge.templateUpdates&&(Xe==="open_chat"||!!ge.agentId&&Xe!=="navigate");!F.read&&!ye&&Pe(F.id);const tt=ge.taskId,ft=ge.requirementId;if(!ye&&(tt||ft)){const Ht=y.filter(bt=>bt.id!==F.id&&!bt.read&&(tt&&bt.metadata?.taskId===tt||ft&&bt.metadata?.requirementId===ft));for(const bt of Ht)Pe(bt.id)}X(F)},ue=async(F,ge,Xe,ye,tt)=>{E(F);try{const{approval:ft}=await Ae.approvals.respond(F,ge,t,Xe,ye,tt);C(_e=>_e.map(ht=>ht.id===F?ft:ht)),D(null),M(null),G(_e=>{const ht={..._e};return delete ht[F],ht});const Ht=ft.details?.taskId,bt=ft.details?.requirementId,le=y.filter(_e=>!_e.read&&(_e.type==="approval_request"&&_e.metadata?.approvalId===F||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)),$(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(F=>F.map(ge=>({...ge,read:!0}))),K([]),$(0),li("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const F=nt.filter(ge=>!ge.read);await Promise.all(F.map(ge=>Ae.notifications.markRead(ge.id))),w(ge=>ge.map(Xe=>({...Xe,read:!0}))),K([]),$(0),li("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ie=F=>{const ge=F.details?.subType;return ge==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):ge==="requirement"||F.details?.requirementId?m("team:notifications.approvalType.requirement"):ge==="task_review"?m("team:notifications.approvalType.taskReview"):ge==="task"||F.details?.taskId?m("team:notifications.approvalType.task"):F.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},Ge=F=>{const ge=F.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:F.agentName,title:F.title,priority:tt,defaultValue:F.description});if(Xe==="requirement_resubmit")return m("team:notifications.approvalDesc.requirementResubmitted",{agentName:F.agentName,title:F.title,priority:tt,defaultValue:F.description});if(Xe==="task")return m("team:notifications.approvalDesc.taskCreate",{agentName:F.agentName,title:F.title,priority:tt,defaultValue:F.description});if(Xe==="task_review"){const ft=`Task "${F.title}" has been submitted for your review.`;if(F.description.startsWith(ft))return m("team:notifications.approvalDesc.taskReview",{title:F.title})+F.description.slice(ft.length)}return F.description},kt=F=>{const ge=[];ge.push(F.agentName);const Xe=F.details?.taskTitle,ye=F.details?.taskId;Xe?ge.push(Xe):ye&&ge.push(`${m("team:notifications.approvalType.task")} ${ye.slice(0,8)}`);const tt=F.details?.requirementId;return tt&&!ye&&ge.push(`${m("team:notifications.approvalType.requirement")} ${tt.slice(0,8)}`),ge.join(" · ")},Rt=[...T].sort((F,ge)=>new Date(ge.requestedAt).getTime()-new Date(F.requestedAt).getTime()),Mt=Rt.filter(F=>F.status==="pending"),Ot=Rt.filter(F=>F.status!=="pending"),Un=F=>{const ge=F.details?.taskId,Xe=F.details?.requirementId,ye=F.details?.agentId??F.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=F=>i.jsxs("button",{disabled:S===F.id,onClick:()=>D(F),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"}),F.questions&&F.questions.length>1?` (${F.questions.length})`:""]}),Ee=_?i.jsx(yre,{approval:_,submitting:S===_.id,readOnly:_.status!=="pending",onClose:()=>D(null),onSubmit:F=>ue(_.id,F.approved,F.comment,F.selectedOption,F.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(F=>i.jsx("button",{onClick:()=>ut(F),"aria-pressed":He===F,title:F==="unread"?m("team:notifications.noUnread"):void 0,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${He===F?"bg-surface-base text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:F==="unread"?m("team:notifications.filterUnread")+(ae>0?` (${ae})`:""):m("team:notifications.filterAll")},F))}),Q>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"),ae>0?` (${ae})`:""]}),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:F=>{if(g!=="notifications"||!Ce||V)return;const ge=F.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(F=>{const ge=F.details?.command,Xe=ge?Ge(F).replace(/\s*Command:.*$/,""):Ge(F);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(F),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:Oo.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Ie(F)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ie(F)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:F.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Io(F.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:F.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(Id(F))return ie(F);const ye=F.details?.subType,tt=ye==="task"||ye==="requirement"||ye==="requirement_resubmit",ft=F.options&&F.options.length>0,Ht=(I[F.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:[F.options.map((le,_e)=>i.jsxs("button",{disabled:S===F.id,onClick:()=>ue(F.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[F.id]??"",onChange:le=>G(_e=>({..._e,[F.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&(I[F.id]??"").trim()&&ue(F.id,!0,(I[F.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===F.id||!(I[F.id]??"").trim(),onClick:()=>ue(F.id,!0,(I[F.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===F.id,onClick:()=>ue(F.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===F.id,onClick:()=>ue(F.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!==F.id&&i.jsxs("button",{disabled:S===F.id,onClick:()=>M(F.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===F.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[F.id]??"",onChange:bt=>G(le=>({...le,[F.id]:bt.target.value})),onKeyDown:bt=>{bt.key==="Enter"&&(I[F.id]??"").trim()&&ue(F.id,!1,(I[F.id]??"").trim(),"needs_adjustment"),bt.key==="Escape"&&M(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===F.id||!(I[F.id]??"").trim(),onClick:()=>ue(F.id,!1,(I[F.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:()=>M(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[F.id]??"",onChange:bt=>G(le=>({...le,[F.id]:bt.target.value})),onKeyDown:bt=>{bt.key==="Enter"&&ue(F.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===F.id,onClick:()=>ue(F.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===F.id,onClick:()=>ue(F.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")})]})]})})()]},F.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(F=>i.jsxs("button",{onClick:()=>Id(F)?D(F):Un(F),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 ${F.status==="approved"?"bg-green-500":F.status==="cancelled"||F.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ie(F)&&i.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ie(F)}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:F.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${F.status==="approved"?"text-green-500":F.status==="cancelled"||F.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${F.status}`,{defaultValue:F.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(F)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Io(F.respondedAt??F.requestedAt,m)})]}),F.responseComment&&i.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",F.responseComment,"”"]})]},F.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(F=>{const ge=uk[F.type]??"text-fg-tertiary";return i.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Z(F),onKeyDown:Xe=>{(Xe.key==="Enter"||Xe.key===" ")&&(Xe.preventDefault(),Z(F))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${F.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:Oo[F.type]??Oo.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!F.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Od[F.priority]??Od.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:pk(F,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(Ea,{content:fk(F,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:Io(F.createdAt,m)}),zd(F,m)&&i.jsx("span",{className:`text-[10px] font-medium ${ge}`,children:zd(F,m)})]})]})]},F.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(F=>{F?.mute&&rre()},[]),Pt=k.useCallback(F=>{Bt(F),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:F=>{Pt(F),at.navigate(de.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:F=>{const ge=`${st.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Pt(F),fi(ge)}}):null;if(n){const F=["approvals","notifications"],ge=F.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<F.length-1&&x(F[ge+1]),Ht>0&&ge>0&&x(F[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:F.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"),ae>0?` (${ae})`:""]})},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:Oo.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:Io(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(Id(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=>G(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:()=>M(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=>G(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"&&M(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:()=>M(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=>G(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:Io(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=uk[ye.type]??"text-fg-tertiary";return i.jsxs("button",{onClick:()=>Z(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:Oo[ye.type]??Oo.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 ${Od[ye.priority]??Od.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:pk(ye,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(Ea,{content:fk(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:Io(ye.createdAt,m)}),zd(ye,m)&&i.jsx("span",{className:`text-[10px] font-medium ${tt}`,children:zd(ye,m)})]})]})]},ye.id)})})})]})})]})]})}if(s){const F=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:F})}),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:U,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:te.top,left:te.left,width:te.width,maxHeight:te.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:U,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:te.top,left:te.left,width:te.width,maxHeight:te.maxHeight},children:pt}),document.body),it]})}function Bd({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 fh=200;function kre({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}=b4(d),_=k.useCallback(()=>{if(!y.current)return;const K=y.current.getBoundingClientRect(),ee=window.innerWidth,U=window.innerHeight,te=w.current?.offsetHeight??220;let L=K.right+8;L+fh>ee-8&&(L=Math.max(8,K.left-fh-8));let J=K.top-te-8;J<8&&(J=Math.min(K.bottom+8,U-te-8)),x({top:Math.max(8,J),left:L})},[]);k.useLayoutEffect(()=>{if(!d)return;_();const K=requestAnimationFrame(()=>_());return()=>cancelAnimationFrame(K)},[d,_,s]),k.useEffect(()=>{if(!d)return;const K=U=>{const te=U.target;y.current?.contains(te)||w.current?.contains(te)||m(!1)},ee=()=>_();return document.addEventListener("mousedown",K),window.addEventListener("resize",ee),window.addEventListener("scroll",ee,!0),()=>{document.removeEventListener("mousedown",K),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0)}},[d,_]);const D=e?.name||C?.displayName||C?.username||c("common:userPlaceholder"),P=e?.email||C?.email||"",M=f4(e?.avatarUrl,C?.avatarUrl),I=T?"bg-emerald-500":"bg-fg-muted",G=T?C?.username?c("sidebar.hubConnectedAs",{username:C.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),Q=!!(T&&C?.username&&e?.name&&C.username.toLowerCase()!==e.name.toLowerCase()&&C.email?.toLowerCase()!==e.email?.toLowerCase()),$=()=>{m(!1),E({validate:!0}),at.navigate(de.SETTINGS,{tab:"account"})},Y=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:fh},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:D}),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(Bd,{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:$,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:G}),Q&&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(Bd,{d:Sc[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(Bd,{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(Bd,{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(K=>!K),title:D,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${s?"p-0.5":""}`,children:[i.jsx(Zi,{name:D,avatarUrl:M,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:G})]}),l&&!s&&i.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.11.3"]}),Y,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 Sre({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 Cre({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:iU.map((p,h)=>{const g=s4.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(wre,{sidebarMode:!0,collapsed:a,userId:n?.id,label:m(y.id),iconPath:Sc[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(Sre,{d:Sc[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(kre,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const Are=6e4,Tre=2e3;let Ar={},Yi={};const vg=new Set,_m=new Set;let n6=0;const wg=new Map;let bc=null,Hd=0,tm=null;function Dc(){for(const e of vg)e()}function hk(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 Nre(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 vb(e,t){const n=Date.now(),a=wg.get(e)??0;!t?.force&&n-a<Tre||(wg.set(e,n),e in Ar&&(delete Ar[e],Dc()),Ae.unread.markRead(e,new Date().toISOString()).catch(()=>{}))}async function kg(){try{const e=await Ae.unread.getCounts(),{counts:t,staleActiveKeys:n}=Nre(e.counts??{},_m);Ar=t,Yi=e.sessionAgentMap??{},Dc();for(const a of n)vb(a)}catch{}}function Ere(){bc||(kg(),bc=setInterval(kg,Are),tm=Ir.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(_m.has(t)){vb(t);return}Date.now()>n6&&(Ar[t]=(Ar[t]??0)+1,Dc())}}))}function jre(){bc&&(clearInterval(bc),bc=null),tm&&(tm(),tm=null)}function Mre(e){const t=e?.enabled??!0,[n,a]=k.useState(Ar),[s,l]=k.useState(Yi),c=k.useCallback(async()=>{await kg()},[]),d=k.useCallback(async w=>{const T=new Date().toISOString();delete Ar[w],Dc();try{await Ae.unread.markRead(w,T)}catch{}},[]),m=k.useCallback(async()=>{Ar={},Dc();try{await Ae.unread.markAllRead()}catch{}},[]),p=k.useCallback(w=>{_m.add(w)},[]),h=k.useCallback(w=>{_m.delete(w),n6=Date.now()+150,wg.delete(w),vb(w,{force:!0})},[]);k.useEffect(()=>{if(!t)return;Hd++,Ere();let w=Yi;const T=()=>{a(C=>hk(C,Ar)?C:{...Ar}),w!==Yi&&(w=Yi,l(C=>hk(C,Yi)?C:{...Yi}))};return vg.add(T),a({...Ar}),l({...Yi}),()=>{vg.delete(T),Hd--,Hd<=0&&(Hd=0,jre())}},[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 Yse(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 _re(e){return e.startsWith("channel:dm:a2a:")}function Rre(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(_re(a))continue;n+=s}return n}function Dre({currentPage:e,onNavigate:t,userId:n}){const{t:a}=ot("nav"),[s,l]=k.useState(0),{counts:c,sessionAgentMap:d}=Mre({enabled:!0}),m=k.useMemo(()=>Rre(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:oU.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:Sc[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 Rm=new Map;function Ns(e,t){Rm.has(e)||Rm.set(e,t().catch(()=>{}))}function Ls(e){const t=Rm.get(e);return Rm.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 a6(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}const Lre={agent:258,team:205,skill:32,connector:162};function wb(e,t){const n=Lre[e],a=a6(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 gk=["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 r6(e){return gk[a6(e+"g")%gk.length]}function i6(e){return e?e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("data:")||/\.(png|jpe?g|gif|webp|svg)$/i.test(e):!1}function Ire(e){return!e||i6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function Ore(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 bk(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const yk={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"}},Pre=["development","devops","management","productivity","browser","custom","general"],zre=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],Bre={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 hh({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:D=>g(D.target.value),onBlur:y,onKeyDown:T,className:`${_} resize-y min-h-[60px]`,placeholder:l}):i.jsx("input",{ref:x,value:h,onChange:D=>g(D.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 Hre({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 $re({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 Sg({content:e}){const t=[I5,P3,z3],n=[AS,[V3,{strict:"ignore"}],[dS,{detect:!0,ignoreMissing:!0}]],a=zS({}),s=k.useMemo(()=>{let l=ui(e,fS);return l=ui(l,bS),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:M.visibility})},disabled:G,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(G?"share.updating":"share.resubmit")]})]}),!M.moderationStatus&&M.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")]}),Z&&i.jsxs("a",{href:Z,target:"_blank",rel:"noopener noreferrer",onClick:Ie=>{Go()&&(Ie.preventDefault(),fi(Z))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${M.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":M.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:[M.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"})]}):M.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"})]}),M.visibility==="org"?m("visibility.sharedOrg"):M.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),Be&&i.jsx("button",{onClick:()=>{we({visibility:M.visibility})},disabled:G,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:G?m("share.updating"):m("share.updateVersion",{version:ue})})]})})(),!s&&!M.shared&&i.jsx("button",{onClick:()=>J(!0),disabled:G,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(G?"share.sharing":"share.toHub")})]})]}),!s&&$&&!K&&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&&K&&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 X=(ut||"1.0.0").split(".");return X[2]=String(Number(X[2]??0)+1),X.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:X=>{X.key==="Enter"&&et("version",X.target.value)}}),i.jsx("button",{onClick:X=>{const Z=X.target.parentElement?.querySelector("input");Z&&et("version",Z.value)},className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("common:confirm")}),i.jsx("button",{onClick:()=>ee(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),M.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(!me),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=${fe}`,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 X=rt||"";if(X&&[...X].length<=2&&new RegExp("\\p{Emoji}","u").test(X))return X;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:r6(je||t||e),fill:ue})})})()}),!s&&me&&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:X=>{X.key==="Enter"&&(et("icon",X.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 X=>{const Z=X.target.files?.[0];if(!Z)return;const ue=new FormData;ue.append("image",Z);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)}Y(!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:zre.map(X=>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:X.label}),i.jsx("div",{className:"flex flex-wrap gap-0.5",children:X.emojis.map(Z=>i.jsx("button",{onClick:()=>{et("icon",Z),Ce(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${rt===Z?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:Z},Z))})]},X.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(hh,{value:je,onChange:X=>et("displayName",X),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(hh,{value:ut,onChange:X=>et("version",X),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:s})]}),i.jsx(hh,{value:qe,onChange:X=>et("description",X),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(Hre,{value:Nt,options:Pre,onChange:X=>et("category",X),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:s}),i.jsx($re,{tags:Zt,onChange:X=>et("tags",X),readOnly:s})]})]})]}),i.jsx("div",{className:"mb-8",children:i.jsx(Fre,{images:q,artifactType:e,artifactName:t,onUpload:Me,onRemove:Ne,readOnly:s,cacheBust:fe})}),d&&i.jsx("div",{className:"mb-8",children:d}),e==="team"&&C.team&&i.jsx("div",{className:"mb-8",children:i.jsx(Ure,{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(Dm,{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(X=>{const Z=Bre[X];return i.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${Z?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[i.jsx("span",{className:"font-mono text-[10px]",children:Z?.icon??"?"})," ",X]},X)})})]}),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(([X,Z])=>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:X}),i.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof Z=="object"?JSON.stringify(Z).slice(0,80):String(Z)})]})]},X))})]}),ae&&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(Sg,{content:ae})})]})]}),Pe.length>0&&i.jsx(Dm,{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((X,Z)=>X+Z.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(X=>X.role==="manager").reduce((X,Z)=>X+Z.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(X=>X.role!=="manager").reduce((X,Z)=>X+Z.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(X=>i.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:X},X))})]})]})]}),C.dependencies&&(C.dependencies.skills?.length||C.dependencies.env?.length)?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(X=>i.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:X},X))})]}):null,C.dependencies.env?.length?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(X=>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:X},X))})]}):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&&U&&i.jsx(Kre,{onClose:()=>te(!1),onConfirm:(X,Z)=>{te(!1),we({donationsEnabled:!1,priceCents:X==="paid"?Z:void 0})},isUpdate:M.shared}),!s&&L&&i.jsx(Gre,{onClose:()=>J(!1),onConfirm:(X,Z,ue,Be)=>{J(!1),we({visibility:X,orgId:Z,priceCents:ue,donationsEnabled:Be})}}),H&&i.jsx(ba,{alertOnly:!0,variant:H.variant??"primary",title:H.title,message:H.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 Gre({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:s6.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 s6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Kre({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:s6.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 Lm(e,t){return!e||!i6(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function Vre({type:e,seed:t,icon:n,hubBase:a,size:s=44,className:l="",rounded:c="rounded-xl"}){const d=il(e),m=Lm(n,a),p=k.useMemo(()=>wb(d,t),[d,t]),h=k.useMemo(()=>r6(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}`}):Ire(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&&kae(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 Im({name:e,username:t,avatarUrl:n,hubBase:a,size:s=24,className:l="",verified:c}){const d=t||e||"markus",m=Lm(n,a),[p,h]=k.useState(!1),g=m&&!p?m:Ore(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 Wre({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 vk({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:D,showTypeBadge:P=!0,hideStats:M=!1,cornerLabel:I,actions:G,footerLeft:Q,headerAction:$,onClick:Y,className:K=""}=e,ee=il(t),U=Bs[ee],te=s||n,L=(C??0)>0,J=!!Lm(c||void 0,d),me=wb(ee,te),Ce=p??m?.displayName??m?.username??"",[H,V]=k.useState(null),fe=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}):L?i.jsx("span",{className:"badge-paid",children:bk(C,S)}):null;if(J){const z=Lm(c||void 0,d);return i.jsxs("div",{onClick:Y,style:{aspectRatio:H??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${Y?"cursor-pointer":""} ${D?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${K}`,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(Wre,{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}):$?null:i.jsx("span",{className:L?"badge-paid":"badge-free",children:bk(C,S)}),$]})]}),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(Im,{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))]}),(!M||G)&&i.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[M?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(vk,{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)]})]}),G&&i.jsx("div",{className:"flex items-center gap-2",onClick:je=>je.stopPropagation(),children:G})]})]})]})}return i.jsxs("div",{onClick:Y,className:`group asset-card card-shine relative flex flex-col ${Y?"cursor-pointer":""} ${D?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${K}`,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, ${U.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:me}}),$&&i.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:z=>z.stopPropagation(),children:$}),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(Vre,{type:ee,seed:te,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 ${$?"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]}),fe&&i.jsx("span",{className:"ml-auto shrink-0",children:fe})]}),(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(Im,{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:U.accent},children:U.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=Q??(M?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(vk,{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&&!G?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}),G&&i.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:G})]})})()]})]})}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 Yre(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const Qre=[{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 Xre(){const[e,t]=k.useState(()=>{const a=window.location.hash.slice(1).split("/");return wc(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("/");wc(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 o6="markus_builder_shared_map";function Jre(){try{const e=localStorage.getItem(o6);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function $d(e){try{localStorage.setItem(o6,JSON.stringify(Object.fromEntries(e)))}catch{}}function l6({authUser:e}={}){const{t}=ot(["builder","common"]),n=Xo(),a=Xre(),[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),[D,P]=k.useState(null),[M,I]=k.useState(Jre),[G,Q]=k.useState(null),[$,Y]=k.useState(null),[K,ee]=k.useState(null),[U,te]=k.useState(null),[L,J]=k.useState(null),[me,Ce]=k.useState("creations"),[H,V]=k.useState([]),[fe,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 ae of ce)ae.type===q&&(se.slug===ae.name||se.name===(ae.meta.displayName||ae.meta.name||ae.name))&&Ne.set(`${ae.type}/${ae.name}`,{id:se.id,name:se.name,slug:se.slug||ae.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[ae,Se]of Ne)q.set(ae,Se);return $d(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),Y({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),Y({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||Tc(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})),$d(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 ae={...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&&(ae={...JSON.parse(Rt),...ae,name:Me,displayName:ae.displayName})}catch{}const Se=ae.displayName||ae.name||Me,De=ae.description||"",Pe=ae.category||"general",X=Array.isArray(ae.tags)?ae.tags:[];let Z=ae.icon||void 0;const ue=ae.version||"1.0.0";if(Z&&!Z.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)){const Rt=Z.split("/").pop()??Z;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&&(Z=hn.url)}}catch{}}let Be;const Ie=[],Ge=Array.isArray(ae.screenshots)?ae.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||ae.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:X,icon:Z,version:ue,config:{...ae,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}),$d(Ot),Ot}),(kt.visibility??et?.visibility??"public")!=="org"?Y({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&&Y({title:t("common:share"),message:t("share.convertedSlug",{previous:ce.name,slug:Ne}),variant:"primary"}))}catch(we){console.error("Share failed:",we),Y({title:t("common:share"),message:t("shareFailed",{error:we instanceof Error?we.message:String(we)}),variant:"danger"})}finally{y(null)}},$e=async()=>{if(!G)return;const{key:ce}=G,et=M.get(ce);if(Q(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),$d(Me),Me})}catch(we){console.error("Hub delete failed:",we),Y({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(()=>{me!=="orgAssets"||H.length>0||st.myOrgs().then(ce=>{V(ce.memberships),ce.memberships.length>0&&!fe&&z(ce.memberships[0].id)}).catch(()=>{})},[me,H.length,fe]),k.useEffect(()=>{me!=="orgAssets"||!fe||(He(!0),st.browseItems({orgId:fe,limit:100}).then(ce=>Ue(ce.items??[])).catch(()=>Ue([])).finally(()=>He(!1)))},[me,fe]);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:Qre.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 ${me==="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 ${me==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),me==="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))}),me==="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))})]})}),me==="orgAssets"&&H.length>0&&i.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:H.map(ce=>i.jsx("button",{onClick:()=>z(ce.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${fe===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))}),me==="orgAssets"&&(H.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)})})),me==="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=M.get(we),se=ce.meta.version||"1.0.0",q=!!Ne,ae=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:()=>{Y({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:[ae&&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:()=>Q({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")]})]}),X=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"})]})}),Z=ce.meta.icon,Be=!!Z&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)?Z.startsWith("http")||Z.startsWith("/")?Z:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(Z.split("/").pop()??"")}?v=${ce.updatedAt??""}`:Z;return 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:Yre(ce.path)}),i.jsx("span",{className:"shrink-0",children:"·"}),i.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:X,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)}),D&&i.jsx(ba,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:D.meta.displayName||D.meta.name||D.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ce=D;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)}),G&&i.jsx(ba,{title:t("confirmUnshare"),message:t("removeFromHub",{name:G.name}),confirmLabel:t("unshare"),onConfirm:()=>{$e()},onCancel:()=>Q(null)}),$&&i.jsx(ba,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)}),K&&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=K;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=K;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")})]})]})}),U&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>te(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(eie,{isUpdate:M.has(`${U.type}/${U.name}`),onCancel:()=>te(null),onConfirm:(ce,et)=>{const nt=U;te(null),rt(nt,{priceCents:et>0?et:void 0})}})})}),L&&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(Zre,{onCancel:()=>J(null),onConfirm:(ce,et,nt,we)=>{const Me=L;J(null),rt(Me,{visibility:ce,orgId:et,priceCents:nt,donationsEnabled:we})}})})})]})})}function Zre({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:c6.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 c6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function eie({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:c6.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 tie=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:l6},Symbol.toStringTag,{value:"Module"}));async function u6(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 nie(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 Om(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}const aie={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function rie({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),[D,P]=k.useState(new Map),[M,I]=k.useState(new Set),[G,Q]=k.useState(null),[$,Y]=k.useState(null),K=k.useCallback(async()=>{try{const[te,L]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),J=new Map;for(const me of te.artifacts){if(me.type!=="agent")continue;const Ce=!!L.installed[`agent/${me.name}`];J.set(me.name,{installed:Ce,localVersion:me.meta.version||void 0,localUpdatedAt:me.updatedAt})}P(J)}catch{}},[]),ee=k.useCallback(async()=>{_(!0);try{const te=c?st.search({type:"agent",q:c,limit:50}):Ls(qa.hubAgents)??st.search({type:"agent",limit:50}),L=new URLSearchParams;c&&L.set("q",c);const J=fetch("/api/templates?"+L.toString()).then(V=>V.json()).catch(()=>({templates:[]})),[me,Ce]=await Promise.all([te.catch(()=>({items:[],total:0})),J,K(),st.isAuthenticated()?st.purchases.mine().then(V=>I(new Set(V.purchases.map(fe=>fe.itemId)))).catch(()=>{}):Promise.resolve()]),H=await u6(me?.items??[],t);g(H.items),p(Array.isArray(Ce.templates)?Ce.templates:[]),H.missing&&n?.()}catch{p([]),g([])}finally{_(!1)}},[c,K,t,n]);k.useEffect(()=>{ee()},[ee]),k.useEffect(()=>{if(!x){T({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(te=>te.json()).then(te=>T(te.files??{})).catch(()=>T({}))},[x]);const U=async(te,L,J)=>{try{const me=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:te,name:L,orgId:"default",teamId:J})});if(!me.ok)throw new Error(`Failed: ${me.status}`);S(!1),y(null)}catch(me){Y({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${me}`,variant:"danger"})}};if(G)return i.jsx(qs,{type:G.type,name:G.name,onBack:()=>Q(null)});if(x){const te={type:"agent",name:x.id,displayName:Om(x,l),version:x.version,description:wk(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}},L=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 ${aie[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,me)=>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})]})]},me))})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(qs,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:te,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:L}),C&&i.jsx(kk,{template:x,lang:l,onClose:()=>S(!1),onHire:U}),$&&i.jsx(ba,{alertOnly:!0,variant:$.variant??"danger",title:$.title,message:$.message,onConfirm:()=>Y(null),onCancel:()=>Y(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:te=>d(te.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),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((te,L)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},L))}):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(te=>i.jsx(vr,{type:"agent",name:Om(te,l),description:wk(te,l),seed:te.id,icon:te.icon,version:te.version,category:te.category,tags:te.tags,authorLabel:te.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(te)},te.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(te=>i.jsx(iie,{item:te,localInfo:D.get(qc(te)),purchased:lm(te,M),onStatusChange:K,highlight:te.id===t,onHighlightDone:n,onViewDetail:L=>Q({type:"agent",name:L})},te.id))})]})]})}),C&&x&&i.jsx(kk,{template:x,lang:l,onClose:()=>S(!1),onHire:U}),$&&i.jsx(ba,{alertOnly:!0,variant:$.variant??"danger",title:$.title,message:$.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function qc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return dm(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=qc(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 kb(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 iie({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 G=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(G)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&nie(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async G=>{if(G.stopPropagation(),!m){p(!0),g("");try{await Is(e),g(C?d("card.upgraded"):d("card.installed")+"!"),a()}catch(Q){const $=Q instanceof Error?Q.message:"";$.includes("402")||$.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},_=async G=>{if(G.stopPropagation(),!m){p(!0),g("");try{await kb(e,$=>{$==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),a()):g("")}catch(Q){g(Q instanceof Error?Q.message:d("card.failed"))}finally{p(!1)}}},D=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,P=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,M=()=>{T&&c?c(qc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:G=>{E(G)},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:G=>{E(G)},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:G=>{_(G)},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")," ",D]})}):i.jsx("button",{onClick:G=>{E(G)},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:M,actions:I})})}function kk({template:e,lang:t,onClose:n,onHire:a}){const{t:s}=ot(["store"]),[l,c]=k.useState(`${Om(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:Om(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 bh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Sk(e,t){return e.i18n?.[t]?.description||e.description}function Ck(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function sie(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 oie({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),[_,D]=k.useState(null),[P,M]=k.useState(new Map),[I,G]=k.useState(new Set),[Q,$]=k.useState(null),Y=k.useCallback(async()=>{try{const[U,te]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),L=new Map;for(const J of U.artifacts){if(J.type!=="team")continue;const me=!!te.installed[`team/${J.name}`];L.set(J.name,{installed:me,localVersion:J.meta.version||void 0,localUpdatedAt:J.updatedAt})}M(L)}catch{}},[]),K=k.useCallback(async()=>{C(!0);try{const U=l?st.search({type:"team",q:l,limit:50}):Ls(qa.hubTeams)??st.search({type:"team",limit:50}),[te,L]=await Promise.all([U.catch(()=>({items:[],total:0})),Ae.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),Y(),st.isAuthenticated()?st.purchases.mine().then(me=>G(new Set(me.purchases.map(Ce=>Ce.itemId)))).catch(()=>{}):Promise.resolve()]),J=await u6(te?.items??[],e);h(J.items),m(L?.templates??[]),J.missing&&t?.()}catch{m([]),h([])}finally{C(!1)}},[l,Y,e,t]);k.useEffect(()=>{K()},[K]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(U=>U.json()).then(U=>w(U.files??{})).catch(()=>w({}))},[g]);const ee=async U=>{E(!0),D(null);try{const L=(await Ae.teams.create(U.name,U.description)).team.id;let J,me=0;const Ce=[];for(const V of U.members){const fe=V.count??1;for(let z=0;z<fe;z++){const je=V.name??`${U.name} Agent ${z+1}`,Ue=fe>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:L,agentRole:V.role??"worker",skills:V.skills??[]})});if(He.ok){me++;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(L,{managerId:J,managerType:"agent"}).catch(()=>{});const H=Ce.length>0?` (${Ce.length} failed: ${Ce[0]})`:"";D({ok:me>0,message:`Team "${bh(U,s)}" deployed with ${me} agent(s)${H}`})}catch(te){D({ok:!1,message:`Failed: ${te}`})}finally{E(!1)}};if(Q)return i.jsx(qs,{type:Q.type,name:Q.name,onBack:()=>$(null)});if(g){const U={...y};g.announcements&&(U["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(U["NORMS.md"]=g.norms);const te={type:"team",name:g.id,displayName:bh(g,s),version:g.version,description:Sk(g,s),author:g.author,category:g.category??"general",tags:g.tags??[],files:U,team:{members:g.members.map(J=>({name:Ck(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??[]}))}},L=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,me)=>{const Ce=Ck(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(H=>i.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:H},H)),J.skills.length>3&&i.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",J.skills.length-3]})]})]},me)})})]});return i.jsx(i.Fragment,{children:i.jsx(qs,{type:"team",name:g.id,onBack:()=>{x(null),D(null)},readOnly:!0,initialManifest:te,contentSlot:L,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:U=>c(U.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((U,te)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},te))}):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(U=>i.jsx(vr,{type:"team",name:bh(U,s),description:Sk(U,s),seed:U.id,icon:U.icon||"users",version:U.version,category:U.category,tags:U.tags,authorLabel:U.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(U)},U.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(U=>i.jsx(lie,{item:U,localInfo:P.get(qc(U)),purchased:lm(U,I),onStatusChange:Y,highlight:U.id===e,onHighlightDone:t,onViewDetail:te=>$({type:"team",name:te})},U.id))})]})]})})]})}function lie({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 G=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(G)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&sie(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async G=>{if(G.stopPropagation(),!m){p(!0),g("");try{await Is(e),g(C?d("card.upgraded"):d("card.installed")+"!"),a()}catch(Q){const $=Q instanceof Error?Q.message:"";$.includes("402")||$.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},D=async G=>{if(G.stopPropagation(),!m){p(!0),g("");try{await kb(e,$=>{$==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),a()):g("")}catch(Q){g(Q instanceof Error?Q.message:d("card.failed"))}finally{p(!1)}}},P=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,M=()=>{T&&c?c(qc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:G=>{_(G)},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:G=>{_(G)},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:G=>{D(G)},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:G=>{_(G)},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:M,actions:I})})}function yh(e,t){return e.i18n?.[t]?.displayName||e.name}function xh(e,t){return e.i18n?.[t]?.description||e.description||""}function d6(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 cie={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 uie({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&&d6(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 kb(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 Ak({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||em(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(uie,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s})})})}function die({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),[D,P]=k.useState(1),[M,I]=k.useState([]),[G,Q]=k.useState(""),[$,Y]=k.useState("score"),[K,ee]=k.useState(""),[U,te]=k.useState(!1),[L,J]=k.useState([]),[me,Ce]=k.useState(!1),[H,V]=k.useState([]),[fe,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,ae="success")=>{p({text:q,type:ae}),setTimeout(()=>p(null),ae==="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=>{te(!0);try{const ae=await Ae.skills.registrySkillhub({q:q?.q,category:q?.category,page:q?.page??1,limit:24,sort:q?.sort??$});S(ae.skills),_(ae.total),ae.categories?.length&&I(ae.categories)}catch{}te(!1)},[$]),et=k.useCallback(async q=>{Ue(!0);try{const ae=await Ae.skills.registrySkillssh(q);V(ae.skills)}catch{}Ue(!1)},[]),nt=k.useCallback(async q=>{Wt(!0);try{const ae=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([ae,Se,st.isAuthenticated()?st.purchases.mine().then(ue=>wt(new Set(ue.purchases.map(Be=>Be.itemId)))).catch(()=>{}):Promise.resolve()]);let X=De?.items??[],Z=Pe?.items??[];if(e){const ue=X.some(Ie=>Ie.id===e),Be=Z.some(Ie=>Ie.id===e);if(!ue&&!Be)try{const{item:Ie}=await st.getItem(e);Ie?.subtype==="connector"?Z=[Ie,...Z]:Ie?X=[Ie,...X]:t?.()}catch{t?.()}else ue&&(X=[X.find(Ge=>Ge.id===e),...X.filter(Ge=>Ge.id!==e)]),Be&&(Z=[Z.find(Ge=>Ge.id===e),...Z.filter(Ge=>Ge.id!==e)])}He(X),dt(Z)}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(ae=>new Set(ae).add(q.name));try{const ae=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 (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{At(`Download failed for "${q.name}". You can try manually from: ${q.homepage}`,"error")}g(ae=>{const Se=new Set(ae);return Se.delete(q.name),Se})},Me=async q=>{g(ae=>new Set(ae).add(q.name));try{const ae=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 (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{At(`Download failed for "${q.name}". You can try manually from: ${q.url}`,"error")}g(ae=>{const Se=new Set(ae);return Se.delete(q.name),Se})},Ne=async q=>{g(ae=>new Set(ae).add(q.name));try{const ae=await Ae.skills.install({name:q.name,source:"builtin"});await Dt(),await ln(),At(`"${q.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ae){At(`Install failed for "${q.name}": ${ae}`,"error")}g(ae=>{const Se=new Set(ae);return Se.delete(q.name),Se})},se=H.filter(q=>{if(!fe)return!0;const ae=fe.toLowerCase();return q.name.toLowerCase().includes(ae)||q.repo.toLowerCase().includes(ae)});if(w){const q=w,ae={};q.instructions&&(ae["SKILL.md"]=q.instructions);const Se={type:"skill",name:q.name,displayName:yh(q,s),version:q.version,description:xh(q,s),author:q.author??"",category:q.category??"general",tags:q.tags,files:ae,skill:{skillFile:q.instructions?"SKILL.md":"",requiredPermissions:q.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},De=q.installed&&q.installedVersion&&d6(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 ${cie[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(X=>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:X},X))})]}),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(X=>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:X},X))})]})]})]});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(),ae=q?L.filter(Pe=>yh(Pe,s).toLowerCase().includes(q)||xh(Pe,s).toLowerCase().includes(q)):L,Se=me&&Zt,De=ae.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,X)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},X))}):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:[ae.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:ae.length})})]}),i.jsx(Fa,{columns:3,children:ae.map(Pe=>i.jsx(vr,{type:"skill",name:yh(Pe,s),description:xh(Pe,s),seed:Pe.name,icon:em(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(Ak,{item:Pe,installedSkills:x,purchased:lm(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(Ak,{item:Pe,type:"connector",installedSkills:x,purchased:lm(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:G,onChange:q=>{Q(q.target.value),P(1),ce({q:K||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")}),M.map(q=>i.jsx("option",{value:q,children:q},q))]}),i.jsxs("select",{value:$,onChange:q=>{Y(q.target.value),P(1),ce({q:K||void 0,category:G||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:K,onChange:q=>ee(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(P(1),ce({q:K||void 0,category:G||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:K||void 0,category:G||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"})]}),U?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 ae=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:em(q.slug||q.name,q.tags?.[0]),version:q.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:q.tags,installed:ae,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:ae?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:D<=1,onClick:()=>{const q=D-1;P(q),ce({q:K||void 0,category:G||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:D,total:Math.ceil(E/24)})}),i.jsx("button",{disabled:D>=Math.ceil(E/24),onClick:()=>{const q=D+1;P(q),ce({q:K||void 0,category:G||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:fe,onChange:q=>z(q.target.value),onKeyDown:q=>{q.key==="Enter"&&fe.trim()&&et(fe)},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:()=>{fe.trim()&&et(fe)},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 ae=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:em(q.name),authorLabel:`${q.author}/${q.repo}`,showTypeBadge:!1,installed:ae,hideStats:!0,cornerLabel:ae?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:ae?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 mie=["agent","team","skill","connector"];function vh({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 pie({item:e,onOpen:t}){const n=il(e.subtype==="connector"?"connector":e.itemType),a=wb(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(Im,{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 Tk({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 Nk(){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 fie({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:mie.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(pie,{item:g,onOpen:()=>h(g)},g.id))}):null,i.jsxs("section",{children:[i.jsx(vh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),s?i.jsx(Nk,{}):d.length>0?i.jsx(Tk,{items:d,onOpen:h}):i.jsx(hie,{})]}),i.jsxs("section",{children:[i.jsx(vh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),s?i.jsx(Nk,{}):m.length>0?i.jsx(Tk,{items:m,onOpen:h}):null]}),p.length>0&&i.jsxs("section",{children:[i.jsx(vh,{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(Im,{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 hie(){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 qd(e,t,n){return e.i18n?.[n]?.[t]}function gie(){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),D=k.useCallback(async()=>{y(!0);try{const[I,G,Q,$]=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:[]}))]),Y={};for(const U of Q.updates)Y[U.name]={availableVersion:U.availableVersion,installedVersion:U.installedVersion,displayName:U.displayName,description:U.description};d(Y);const K=I.artifacts.filter(U=>{const te=`${U.type}/${U.name}`;return!!G.installed[te]}),ee=new Set(K.filter(U=>U.type==="skill").map(U=>U.name));for(const U of $.skills)!U.installed||ee.has(U.name)||!(G.installed[`skill/${U.name}`]||Y[U.name])&&!U.updateAvailable||!G.installed[`skill/${U.name}`]&&!Y[U.name]||(K.push({type:"skill",name:U.name,meta:{displayName:U.i18n?.[a]?.displayName||U.name,description:U.i18n?.[a]?.description||U.description||"",version:U.installedVersion||U.version,author:U.author,category:U.category,tags:U.tags,i18n:U.i18n},path:"",updatedAt:""}),ee.add(U.name));for(const[U,te]of Object.entries(Y))ee.has(U)||(K.push({type:"skill",name:U,meta:{displayName:te.displayName||U,description:te.description||"",version:te.installedVersion},path:"",updatedAt:""}),ee.add(U));l(K)}catch{}y(!1)},[a]);k.useEffect(()=>{D()},[D]),k.useEffect(()=>{const I=()=>{D()};return window.addEventListener("markus:data-changed",I),()=>window.removeEventListener("markus:data-changed",I)},[D]),k.useEffect(()=>{if(!h)return;const I=setTimeout(()=>g(null),3e3);return()=>clearTimeout(I)},[h]);const P=async(I,G)=>{if(!m.has(I)){p(Q=>new Set(Q).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:G}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await D()}catch{g({text:e("installedTab.updateFailed",{name:I}),type:"error"})}p(Q=>{const $=new Set(Q);return $.delete(I),$})}},M=s.filter(I=>{if(C!=="all"&&I.type!==C)return!1;if(!w)return!0;const G=w.toLowerCase(),Q=(qd(I.meta,"displayName",a)||I.meta.displayName||I.name).toLowerCase(),$=(qd(I.meta,"description",a)||I.meta.description||"").toLowerCase();return Q.includes(G)||$.includes(G)}).sort((I,G)=>{const Q=I.type==="skill"&&c[I.name]?1:0;return(G.type==="skill"&&c[G.name]?1:0)-Q});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")}):M.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:M.map(I=>{const G=qd(I.meta,"displayName",a)||I.meta.displayName||I.name,Q=qd(I.meta,"description",a)||I.meta.description||"",$=I.meta.version||"",Y=I.meta.author||"",K=I.meta.tags??[],ee=I.meta.category||"",U=I.meta.icon,te=U&&/\.(png|jpe?g|gif|webp|svg)$/i.test(U)&&!U.startsWith("http")&&!U.startsWith("data:")&&!U.startsWith("/")?`/api/builder/artifacts/${I.type}s/${encodeURIComponent(I.name)}/${U}`:U,L=I.type==="skill"?c[I.name]:void 0;return i.jsx(vr,{type:I.type,name:G,description:Q,seed:I.name,icon:te,author:null,authorLabel:Y||void 0,version:L?L.installedVersion:$,category:ee,tags:K,installed:!L,hideStats:!0,cornerLabel:L?e("installedTab.updateAvailable"):void 0,onClick:()=>{I.path&&_({type:I.type,name:I.name})},actions:L?i.jsx("button",{type:"button",disabled:m.has(I.name),onClick:()=>{P(I.name,L.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(I.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:L.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 bie=50,yie=30;function xie(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<bie||Math.atan2(x,g)*(180/Math.PI)>yie)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 vie=["builder","discover","agents","teams","skills","installed"],wie={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Cg(e){return!!e&&vie.includes(e)}function Ek(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Cg(t)?t:"builder",installId:e}}function kie({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(Ek),[s,l]=k.useState(a.tab),[c,d]=k.useState(a.installId),m=xie(n,s,l);k.useEffect(()=>{const h=Ek();h.installId&&(d(h.installId),Cg(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");Cg(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(wie[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(y4,{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(l6,{authUser:e}),s==="discover"&&i.jsx(fie,{onOpenType:p}),s==="agents"&&i.jsx(rie,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),s==="teams"&&i.jsx(oie,{highlightItemId:c,onHighlightDone:()=>d(null)}),s==="skills"&&i.jsx(die,{highlightItemId:c,onHighlightDone:()=>d(null)}),s==="installed"&&i.jsx(gie,{})]})]})}const jk="usageType",wh="profile";function Sie({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(""),[D,P]=k.useState(!1),[M,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&&Y(At=>At||l("usageType.defaultOrgName",{name:mt}))}).catch(()=>{}),Ae.settings.getOrg().then(({org:$e})=>{$e?.name&&$e.name!=="My Organization"&&Y($e.name)}).catch(()=>{}),jn()&&Ae.hubOrgs.invitations().then($e=>{$e.invitations?.length>0&&Ce($e.invitations)}).catch(()=>{})},[]);const[G,Q]=k.useState(null),[$,Y]=k.useState(""),[K,ee]=k.useState(!1),[U,te]=k.useState(!1),[L,J]=k.useState(""),[me,Ce]=k.useState([]),[H,V]=k.useState(null),[fe,z]=k.useState(null),je=async()=>{const $e=$.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)}te(!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(hT,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:i.jsx("strong",{className:"text-fg-primary"})}})})},{id:jk,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:()=>{Q("personal"),te(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${G==="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:()=>{Q("organization"),te(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${G==="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."})})]})]})]}),G==="organization"&&i.jsxs("div",{className:"space-y-4 mt-4",children:[me.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")}),me.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),te(!0)}catch{}finally{V(null)}},disabled:H===$e.orgId||fe===$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:fe===$e.orgId?l("usageType.accepted"):H===$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:$,onChange:$e=>{Y($e.target.value),te(!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"})]}),L&&i.jsx("p",{className:"text-xs text-red-500",children:L}),i.jsx("button",{onClick:()=>{je()},disabled:K||!$.trim()||U,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(K?"common:saving":U?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:wh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:D?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(g4,{currentUrl:M,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!==wh):dt,wt=Nt.findIndex($e=>$e.id===jk),Zt=Nt.findIndex($e=>$e.id===wh),Wt=()=>{c===wt&&wt>=0&&!G||c===wt&&G==="organization"&&!U||c===Zt&&Zt>=0&&!D||(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&&!D||wt>=0&&c===wt&&(!G||G==="organization"&&!U),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Zt>=0&&c===Zt&&!D||wt>=0&&c===wt&&(!G||G==="organization"&&!U)?"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 Mk="markus:legal-consent",Cie="https://markus.global";function Aie({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=Y=>{const K=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${Cie}${Y}${K}`},_=()=>{try{localStorage.setItem(Mk,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},D=()=>C?(_(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),P=async()=>{const Y=jn(),K=xr();if(!Y||!K){d(n("login.hubUnavailable"));return}const ee=await Ae.auth.hubLogin(Y,K);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})},M=async(Y,K=!1)=>{if(!(!K&&!D())){d(""),l(Y??"hub");try{if(K&&jn()&&xr()){await P();return}await Ha({method:Y,force:!0}),await P()}catch(ee){const U=ee instanceof Error?ee.message:"";if(!U.includes("cancelled")){if(!K&&jn())return M(Y,!0);d(U||n("login.hubUnavailable"))}}finally{l(null)}}},I=()=>{bU(),l(null),d("")};k.useEffect(()=>{const Y=window.markusDesktop;if(!Y?.peekPendingDeepLinkAuth&&!Y?.consumePendingDeepLinkAuth)return;let K=!1;return(async()=>{const ee=Y.peekPendingDeepLinkAuth?await Y.peekPendingDeepLinkAuth():null;if(K||!ee)return;let U=!1;try{U=!!localStorage.getItem(Mk)}catch{}if(!C&&!U){d(n("login.consentRequired"));return}U&&!C&&S(!0),_();const te=Y.consumePendingDeepLinkAuth?await Y.consumePendingDeepLinkAuth():ee;if(!(K||!te)){d(""),l("hub");try{if(!await gU(te)||!jn()||!xr()){d(n("login.hubUnavailable"));return}await P()}catch{d(n("login.hubUnavailable"))}finally{K||l(null)}}})().catch(()=>{}),()=>{K=!0}},[C]);const G=async Y=>{if(Y.preventDefault(),!(!h.trim()||!x)&&D()){d(""),l("local");try{const{user:K,needsOnboarding:ee}=await Ae.auth.login(h.trim(),x);e(K,ee??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},Q=n(t?"login.welcomeBack":"login.getStarted"),$="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:Q})]}),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:G,className:"space-y-3",children:[i.jsx("input",{type:"email",value:h,onChange:Y=>g(Y.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:Y=>y(Y.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:()=>M("google"),disabled:!!s,className:$,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:()=>M("github"),disabled:!!s,className:$,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:()=>M("email"),disabled:!!s,className:$,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:Y=>{S(Y.target.checked),Y.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 Tie({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 Nie({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 Eie({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=D=>{if(!h.current)return;const P=D.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 Qse=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Ag="markus-theme";function _k(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 jie(){try{const e=localStorage.getItem(Ag);if(e==="midnight")return localStorage.setItem(Ag,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function Mie(){const[e,t]=k.useState(jie),n=k.useCallback(a=>{t(a);try{localStorage.setItem(Ag,a)}catch{}_k(a)},[]);return k.useEffect(()=>{_k(e)},[e]),{mode:e,setMode:n}}const nm={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},_ie={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},Rie=["agents","tasks","requirements","projects","deliverables","workflows"];let Rk="",Dk="all",Lk=nm,Ik=!1;function Die({onClose:e,currentPage:t}){const{t:n}=ot(["common","home","work"]);Qo(!0);const[a,s]=k.useState(Rk),[l,c]=k.useState(Dk),[d,m]=k.useState(Lk),[p,h]=k.useState(!1),[g,x]=k.useState(Ik),[y,w]=k.useState(-1);k.useEffect(()=>{Rk=a},[a]),k.useEffect(()=>{Dk=l},[l]),k.useEffect(()=>{Lk=d},[d]),k.useEffect(()=>{Ik=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(nm),x(!1),w(-1);return}h(!0),x(!0),w(-1);const U=ee.toLowerCase();try{const[te,L,J,me,Ce,H]=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=te.status==="fulfilled"?te.value.agents.filter(He=>He.name?.toLowerCase().includes(U)||He.role?.toLowerCase().includes(U)):[],fe=L.status==="fulfilled"?L.value.tasks:[],z=J.status==="fulfilled"?J.value.requirements.filter(He=>He.title?.toLowerCase().includes(U)||He.description?.toLowerCase().includes(U)):[],je=me.status==="fulfilled"?me.value.projects.filter(He=>He.name?.toLowerCase().includes(U)||He.description?.toLowerCase().includes(U)):[],Ue=Ce.status==="fulfilled"?Ce.value.results:[],qe=[];if(H.status==="fulfilled"){const He=await Promise.allSettled(H.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(U)||(dt.displayName||"").toLowerCase().includes(U)||dt.description?.toLowerCase().includes(U))&&qe.push(dt)}m({agents:V,tasks:fe,requirements:z,projects:je,deliverables:Ue,workflows:qe})}catch{m(nm)}finally{h(!1)}},[]),D=ee=>{s(ee),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>_(ee),400)},P=k.useCallback((ee,U)=>{e(),at.navigate(ee,U)},[e]),M=[{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(()=>_ie[t||""]||Rie,[t]),G=k.useMemo(()=>{const ee=[],U=l==="all"?8:void 0,te=L=>{if(l!=="all"&&l!==L)return;const J=d[L].length;if(L==="workflows"){const me=U?d.workflows.slice(0,U):d.workflows;for(const Ce of me)ee.push({id:Ce.name,type:"workflow",page:de.WORK,params:{boardType:"workflows"}})}else{const me=d[L],Ce=U?me.slice(0,U):me;for(const H of Ce)switch(L){case"agents":ee.push({id:H.id,type:"agent",page:de.TEAM,params:{agentId:H.id}});break;case"tasks":ee.push({id:H.id,type:"task",page:de.WORK,params:{openTask:H.id}});break;case"requirements":ee.push({id:H.id,type:"requirement",page:de.WORK,params:{openRequirement:H.id}});break;case"projects":ee.push({id:H.id,type:"project",page:de.WORK,params:{projectId:H.id}});break;case"deliverables":ee.push({id:H.id,type:"deliverable",page:de.DELIVERABLES,params:{openDeliverable:H.id}});break}}U&&J>U&&ee.push({id:`more_${L}`,type:"showMore",page:"",expandCategory:L,totalCount:J})};for(const L of I)te(L);return ee},[d,l,I]),Q=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 U=ee.querySelector(`[data-idx="${y}"]`);U&&U.scrollIntoView({block:"nearest"})},[y]);const $=k.useCallback(ee=>{if(ee.key==="Escape"){e();return}if(ee.key==="Tab"){ee.preventDefault();const L=M.map(Ce=>Ce.id),J=L.indexOf(l),me=ee.shiftKey?J<=0?L.length-1:J-1:J>=L.length-1?0:J+1;c(L[me]),w(-1);return}const U=ee.ctrlKey&&ee.key==="n"||ee.key==="ArrowDown",te=ee.ctrlKey&&ee.key==="p"||ee.key==="ArrowUp";if(U||te){ee.preventDefault(),w(L=>{const J=G.length-1;return J<0?-1:U?L>=J?0:L+1:L<=0?J:L-1});return}ee.key==="Enter"&&(ee.preventDefault(),y>=0&&y<G.length&&Q(G[y]))},[e,G,y,Q,M,l]);k.useEffect(()=>(document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)),[$]);const Y=G.length>0;let K=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=>D(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(nm),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:M.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&&!Y&&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&&Y&&i.jsx("div",{className:"space-y-4",children:I.map(ee=>{if(l!=="all"&&l!==ee)return null;const U=l==="all"?8:void 0,te=L=>{const J=K++,me=L==="agents"?d.agents.length:L==="tasks"?d.tasks.length:L==="requirements"?d.requirements.length:L==="projects"?d.projects.length:L==="workflows"?d.workflows.length:d.deliverables.length;return i.jsxs("button",{"data-idx":J,onClick:()=>{c(L),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:"查看全部"})," (",me,")"]})};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:(U?d.agents.slice(0,U):d.agents).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.TEAM,{agentId:L.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:L.name||"Agent",avatarUrl:L.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:L.name}),i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:L.role||L.status})]}),i.jsx(Lie,{status:L.status})]},L.id)})}),U&&d.agents.length>U&&te("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:(U?d.tasks.slice(0,U):d.tasks).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{openTask:L.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(Iie,{status:L.status}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:L.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.status," · ",L.priority||""]})]})]},L.id)})}),U&&d.tasks.length>U&&te("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:(U?d.requirements.slice(0,U):d.requirements).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{openRequirement:L.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 ${L.status==="approved"?"text-green-500 bg-green-500/15":L.status==="pending"?"text-amber-500 bg-amber-500/15":L.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children: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:L.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.status," · ",L.priority||""]})]})]},L.id)})}),U&&d.requirements.length>U&&te("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:(U?d.projects.slice(0,U):d.projects).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{projectId:L.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:L.name}),L.description&&i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:L.description})]})]},L.id)})}),U&&d.projects.length>U&&te("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:(U?d.deliverables.slice(0,U):d.deliverables).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.DELIVERABLES,{openDeliverable:L.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:L.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.type," · ",L.status]})]})]},L.id)})}),U&&d.deliverables.length>U&&te("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:(U?d.workflows.slice(0,U):d.workflows).map(L=>{const J=K++;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:L.displayName||L.name}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.stepCount," steps · v",L.version]})]})]},L.name)})}),U&&d.workflows.length>U&&te("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 Lie({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 Iie({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 Oie=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function Pie(e){return e===de.TEAM?"team":e===de.WORK?"work":e===de.DELIVERABLES?"deliverables":e===de.STORE?"store":"any"}function zie({open:e,onClose:t,page:n}){const{t:a}=ot("common"),s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=Pie(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:Oie.map(c=>{const d=DU.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:w4(m.keys,s,m.bare)})]},m.id))})]},c)})})]})}):null}function Bie({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(()=>f4(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(g4,{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 Ok=k.lazy(()=>va(()=>import("./Team-COBxn96h.js"),__vite__mapDeps([2,3,4,5,6,7])).then(e=>({default:e.TeamPage}))),Pk=k.lazy(()=>va(()=>import("./Settings-DIa-_qre.js"),__vite__mapDeps([8,6])).then(e=>({default:e.Settings}))),Hie=k.lazy(()=>va(()=>import("./Store-JWjwXfTU.js"),[]).then(e=>({default:e.StorePage}))),$ie=k.lazy(()=>va(()=>Promise.resolve().then(()=>tie),void 0).then(e=>({default:e.AgentBuilder}))),zk=k.lazy(()=>va(()=>import("./Work-BScJUqWL.js"),__vite__mapDeps([9,4,1,10,3,11])).then(e=>({default:e.WorkPage}))),Bk=k.lazy(()=>va(()=>import("./Deliverables-tlLsJnxZ.js"),__vite__mapDeps([12,4,5])).then(e=>({default:e.DeliverablesPage}))),qie=k.lazy(()=>va(()=>import("./Notifications-4KXYRdkr.js"),[]).then(e=>({default:e.NotificationsPage}))),Fie=k.lazy(()=>va(()=>import("./Search-CPFwZv1U.js"),[]).then(e=>({default:e.SearchPage}))),Uie={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function Gie(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 Kie(){return i.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const Vie=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:Uie,children:i.jsx(k.Suspense,{fallback:i.jsx(Kie,{}),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}),Fd={};function m6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?i4[e]??e:e}function Hk(){return m6(kc())}function Wie(){const{t:e}=ot("common"),[t,n]=k.useState(Hk),[a,s]=k.useState(!1),[l,c]=k.useState(!0),d=Xo(),m=Mie(),p=Eie({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([Hk()])),[x,y]=k.useState("loading"),[w,T]=k.useState(!1),[C,S]=k.useState(null),[E,_]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[D,P]=k.useState(!1),[M,I]=k.useState(!1),[G,Q]=k.useState(null),[$,Y]=k.useState(!1),[K,ee]=k.useState(null),[U,te]=k.useState(()=>{const X=localStorage.getItem("markus_update_dismissed");return X||null}),[L,J]=k.useState(!1),[me,Ce]=k.useState(!1),H=$c(),V=H?.leftCollapsed??!1,fe=H?.toggleLeftCollapsed,z=H?.setLeftCollapsed,je=H?.keyboardPane??"l0",Ue=H?.setKeyboardPane,qe=H?.l0FocusPageId??null,He=H?.setL0FocusPageId,ut=k.useRef(t);ut.current=t;const dt=k.useRef(de.HOME),Nt=H?.toggleRightPanel,wt=H?.toggleTerminalPanel,Zt=H?.cycleRightPanelTab,Wt=H?.activateRightPanelTabAt,rt=H?.openNewRightPanelTab,$e=H?.rightPanelOpen??!1,mt=H?.activeRightPanelTabId??null,At=H?.openRightPanel,Dt=H?.closeRightPanelTab,ln=H?.updateRightPanelBrowserTab,ce=H?.updateRightPanelTerminalTab,et=k.useRef(H?.rightPanelTabs);et.current=H?.rightPanelTabs,k.useEffect(()=>{const X=window.markusDesktop?.browser?.onPageEvent;if(!(!X||!At))return X(Z=>{if(Z.type==="closed"){const ue=et.current?.find(Be=>Be.payload.kind==="url"&&Be.payload.browserId===Z.browserId);ue&&Dt&&Dt(ue.id);return}if(Z.type==="navigated"){if(Z.url&&Cc(Z.url))return;Z.browserId&&ln&&ln(Z.browserId,{url:Z.url,title:Z.title||Z.url});return}if(Z.type==="opened"||Z.type==="selected"){if(!Z.url&&!Z.browserId||Z.browserId.startsWith("eb_")||Mte(Z.browserId)||Z.url&&Cc(Z.url))return;At({kind:"url",url:Z.url||"about:blank",title:Z.title||Z.url||"Browser",browserId:Z.browserId,pageId:Z.pageId})}})},[At,Dt,ln]),k.useEffect(()=>{const X=window.markusDesktop?.terminal?.onEvent;if(!(!X||!At))return X(Z=>{if(Z.type==="closed"){const ue=et.current?.find(Be=>Be.payload.kind==="terminal"&&Be.payload.terminalId===Z.id);ue&&Dt&&Dt(ue.id);return}if(Z.type==="cwd"){Z.cwd&&ce?.(Z.id,{cwd:Z.cwd});return}if(Z.type==="selected"){(Z.title||Z.cwd)&&ce?.(Z.id,{title:Z.title,cwd:Z.cwd});return}if(Z.type==="opened"){if(pb.has(Z.id)){(Z.title||Z.cwd)&&ce?.(Z.id,{title:Z.title,cwd:Z.cwd});return}_s(Z.id),At({kind:"terminal",terminalId:Z.id,title:Z.title||"Terminal",cwd:Z.cwd})}})},[At,Dt,ce]);const nt=H?.handleTerminalExit;k.useEffect(()=>{const X=window.markusDesktop?.terminal?.onExit;if(!(!X||!nt))return X(Z=>{nt(Z.id)})},[nt]),k.useLayoutEffect(()=>{const X=t===de.TEAM&&$e&&H?.rightPanelMode==="browser";vf(X)},[t,$e,H?.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 X=navigator.platform.toUpperCase().includes("MAC"),Z=Be=>{X&&Be.metaKey&&!Be.ctrlKey&&Be.key==="p"?(Be.preventDefault(),J(Ie=>!Ie)):!X&&Be.ctrlKey&&!Be.metaKey&&Be.key==="p"&&(Be.preventDefault(),J(Ie=>!Ie))},ue=()=>J(!0);return document.addEventListener("keydown",Z),window.addEventListener("markus:open-search",ue),()=>{document.removeEventListener("keydown",Z),window.removeEventListener("markus:open-search",ue)}},[d]);const Me=k.useCallback(()=>!$e||!mt||!Dt?!1:(Dt(mt),!0),[$e,mt,Dt]);k.useEffect(()=>{const X=window.markusDesktop?.onAppShortcut?.(Z=>{if(Z.type==="close-tab"){Me();return}Z.type==="new-tab"&&rt?.()});return()=>{X?.()}},[Me,rt]),k.useEffect(()=>{if(d||!fe||!Nt)return;const X=navigator.platform.toUpperCase().includes("MAC"),Z=ue=>{if(!(X?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(),fe()}else if(t===de.TEAM&&Ie==="l"){if(!X&&Bv(ue.target)||X&&Bv(ue.target)&&ue.ctrlKey)return;ue.preventDefault(),Nt()}else t===de.TEAM&&Ie==="j"&&wt&&(ue.preventDefault(),wt())};return document.addEventListener("keydown",Z,!0),()=>document.removeEventListener("keydown",Z,!0)},[d,t,fe,Nt,wt,Zt,Wt,$e,Me,rt]);const Ne=k.useCallback((X,Z)=>{let ue=wc(X);d?ue=i4[ue]??ue:ue===de.NOTIFICATIONS&&(ue=de.HOME),ue!==de.TEAM&&vf(!1);const Be=kc(),Ie=window.location.hash.slice(1);Ie!==Nh(Be)?Fd[Be]=Ie:delete Fd[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&&Z?.tab){const Rt=`settings/${Z.tab}`;Fd[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?Fd[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((X,Z)=>Ne(X,Z))},[Ne]),k.useEffect(()=>{je==="l0"&&t!==de.SETTINGS&&He?.(t)},[je,t,He]),k.useEffect(()=>{if(d||!Ue||!He)return;const X=Z=>{if(Z.metaKey||Z.ctrlKey||Z.altKey||zv(Z.target))return;const ue=Z.key.length===1?Z.key.toLowerCase():Z.key;if(t===de.SETTINGS&&(ue==="h"||ue==="ArrowLeft")){Z.preventDefault(),Z.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"){Z.preventDefault(),Z.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"){Z.preventDefault(),Z.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(!sU.has(Ge)){Z.preventDefault(),Z.stopImmediatePropagation();return}Z.preventDefault(),Z.stopImmediatePropagation(),Ge!==t&&Ne(Ge),z?.(!1),Ue("l1");return}(ue==="h"||ue==="ArrowLeft")&&(Z.preventDefault(),Z.stopImmediatePropagation())};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[d,je,qe,t,Ne,Ue,He,z]),k.useEffect(()=>{const X=()=>T(!0);return window.addEventListener("markus:open-edit-profile",X),()=>window.removeEventListener("markus:open-edit-profile",X)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==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(X=>{if(X.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),X.page){const Z=wc(X.page);X.params&&Object.entries(X.params).forEach(([ue,Be])=>localStorage.setItem(`markus_nav_${ue}`,Be)),Ne(Z),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Z,params:X.params}}))}})},[Ne]);const se=k.useCallback(()=>{fetch("/api/settings/llm").then(X=>X.ok?X.json():null).then(X=>{if(X?.providers){const Z=Object.values(X.providers).some(ue=>ue.configured);Q(Z)}}).catch(()=>{})},[]),q=k.useCallback((X,Z)=>{if(!X)return;const Be=Z&&{agent:"agents",team:"teams",skill:"skills"}[Z]||"agents";localStorage.setItem("markus_nav_installItem",X),localStorage.setItem("markus_nav_storeTab",Be);const Ie=new URLSearchParams(window.location.search);Ie.get("install")||(Ie.set("install",X),Z&&Ie.set("type",Z));const Ge=Ie.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Ge}${Ps(de.STORE)}`);const kt=()=>at.navigate(de.STORE,{storeTab:Be,installItem:X});kt(),setTimeout(kt,500),setTimeout(kt,1500)},[]);k.useEffect(()=>{const X=new URLSearchParams(window.location.search),Z=X.get("install");Z&&q(Z,X.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),Gie(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=m6(kc());Ge!==de.TEAM&&vf(!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 X=x!=="loading"&&x!==null?x.id:void 0;if(!X)return;const Z=navigator.platform.toUpperCase().includes("MAC"),ue=Be=>{if(zv(Be.target))return;const Ie={key:Be.key,code:Be.code,metaKey:Be.metaKey,ctrlKey:Be.ctrlKey,altKey:Be.altKey,shiftKey:Be.shiftKey};_U(Ie,X,Z)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",ue,!0),()=>window.removeEventListener("keydown",ue,!0)},[x]);const ae=x!=="loading"&&x!==null?x:void 0,Se=k.useMemo(()=>d?{[de.HOME]:i.jsx(Fv,{authUser:ae}),[de.TEAM]:i.jsx(Ok,{authUser:ae}),[de.BUILDER]:i.jsx(kie,{authUser:ae}),[de.SETTINGS]:i.jsx(Pk,{theme:m.mode,onThemeChange:m.setMode,authUser:ae,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},onUserUpdated:X=>y(X)}),[de.WORK]:i.jsx(zk,{authUser:ae}),[de.DELIVERABLES]:i.jsx(Bk,{authUser:ae}),[de.NOTIFICATIONS]:i.jsx(qie,{authUser:ae}),[de.SEARCH]:i.jsx(Fie,{})}:{[de.HOME]:i.jsx(Fv,{authUser:ae}),[de.TEAM]:i.jsx(Ok,{authUser:ae}),[de.SETTINGS]:i.jsx(Pk,{theme:m.mode,onThemeChange:m.setMode,authUser:ae,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},onUserUpdated:X=>y(X)}),[de.STORE]:i.jsx(Hie,{authUser:ae}),[de.BUILDER]:i.jsx($ie,{authUser:ae}),[de.WORK]:i.jsx(zk,{authUser:ae}),[de.DELIVERABLES]:i.jsx(Bk,{authUser:ae})},[ae?.id,ae?.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(Tie,{token:Pe[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),s(!0),P(!0),y("loading"),Ae.auth.me().then(X=>{Hv(X.user.id),y(X.user)}).catch(()=>y(null))}}):x===null?i.jsx(Aie,{hasOwner:E.hasOwner,hasMultipleUsers:E.hasMultipleUsers,onLogin:(X,Z,ue)=>{y(X),Ir.connect(X.id),Z?(Hv(X.id),s(!0),ue?.fromHub&&P(!0)):(s(!1),_h(X.id)?(Rh(X.id),Ae.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),y({...X,preferences:{...X.preferences,guideHidden:!0}})):y(X))}}):M?i.jsx(Nie,{onComplete:()=>I(!1),isFirstTime:!0}):a?i.jsx(Sie,{theme:m.mode,onThemeChange:m.setMode,skipProfile:D,onProfileUpdated:X=>{const Z={id:X.id,name:X.name,email:X.email,role:X.role,orgId:X.orgId??"default",avatarUrl:X.avatarUrl};y(Z)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),s(!1),P(!1),Ae.auth.me().then(X=>y(X.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(Cre,{currentPage:t,onNavigate:X=>{Ne(X),c(!1),Ue?.("l0"),He?.(X)},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:[G===!1&&!$&&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:()=>Y(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),K&&U!==K.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:K.latestVersion,current:K.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:()=>{te(K.latestVersion),localStorage.setItem("markus_update_dismissed",K.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(X=>h.has(X)?i.jsx(Vie,{id:X,activePage:t,children:Se[X]},X):null)})]}),d&&t!==de.SETTINGS&&t!==de.SEARCH&&i.jsx(Dre,{currentPage:t,onNavigate:Ne,userId:ae?.id}),d&&i.jsx(EU,{authUser:ae,onNavigate:Ne,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)}}),!d&&L&&i.jsx(Die,{onClose:()=>J(!1),currentPage:t}),!d&&i.jsx(zie,{open:me,onClose:()=>Ce(!1),page:t}),w&&ae&&i.jsx(Bie,{authUser:ae,onClose:()=>T(!1),onUserUpdated:X=>y(X),onSaved:X=>{T(!1),y(X)}})]})}const $k="data-anim-paused",qk="data-anim-tick",Fk=8,Yie=250;function Qie(){return document.visibilityState!=="visible"||document.hidden}let yc=null,Po=0;function Xie(){yc===null&&(Po=Po%Fk,document.documentElement.setAttribute(qk,String(Po)),yc=window.setInterval(()=>{Po=(Po+1)%Fk,document.documentElement.setAttribute(qk,String(Po))},Yie))}function Jie(){yc!==null&&(window.clearInterval(yc),yc=null)}function kh(){const e=document.documentElement;Qie()?(e.setAttribute($k,"true"),Jie()):(e.removeAttribute($k),Xie())}let Uk=!1;function Zie(){Uk||typeof document>"u"||(Uk=!0,kh(),document.addEventListener("visibilitychange",kh,{passive:!0}),window.addEventListener("pageshow",kh,{passive:!0}))}Zie();SA.createRoot(document.getElementById("root")).render(i.jsx(k.StrictMode,{children:i.jsx(Ote,{children:i.jsx(Wie,{})})}));export{Qse as $,Zi as A,Qo as B,li as C,kne as D,Ps as E,ba as F,uU as G,sse as H,gie as I,bb as J,dse as K,bg as L,y4 as M,wre as N,Cne as O,de as P,yg as Q,tse as R,fie as S,rie as T,Rae as U,_ae as V,ose as W,pse as X,mse as Y,Go as Z,va as _,Xo as a,Ose as a$,nse as a0,xr as a1,Io as a2,Wse as a3,hT as a4,Ase as a5,lU as a6,ase as a7,rse as a8,_s as a9,Gae as aA,fse as aB,ise as aC,Kae as aD,Mre as aE,Yse as aF,Ise as aG,Bse as aH,use as aI,kse as aJ,xb as aK,w4 as aL,g4 as aM,Mse as aN,_se as aO,Rse as aP,$se as aQ,ek as aR,lne as aS,Vse as aT,Hse as aU,Gse as aV,qse as aW,pk as aX,fk as aY,yre as aZ,Kse as a_,jd as aa,fi as ab,dm as ac,Use as ad,dne as ae,Ow as af,Hae as ag,zs as ah,rl as ai,Ese as aj,Tse as ak,vse as al,wse as am,Nse as an,Cse as ao,Sse as ap,hse as aq,yse as ar,Jae as as,xse as at,gse as au,jse as av,are as aw,Fse as ax,WS as ay,bse as az,kU as b,zse as b0,PS as b1,Bv as b2,Dse as b3,Lse as b4,Pse as b5,cse as b6,BS as b7,$c as c,xie as d,oie as e,die as f,Is as g,st as h,zv as i,i as j,zr as k,Ae as l,Eie as m,at as n,jn as o,wc as p,Ea as q,k as r,gb as s,Ha as t,ot as u,ese as v,Ir as w,Lc as x,Pm as y,bT 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:[ae&&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:()=>Q({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")]})]}),X=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"})]})}),Z=ce.meta.icon,Be=!!Z&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)?Z.startsWith("http")||Z.startsWith("/")?Z:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(Z.split("/").pop()??"")}?v=${ce.updatedAt??""}`:Z;return 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:Yre(ce.path)}),i.jsx("span",{className:"shrink-0",children:"·"}),i.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:X,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)}),D&&i.jsx(ba,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:D.meta.displayName||D.meta.name||D.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ce=D;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)}),G&&i.jsx(ba,{title:t("confirmUnshare"),message:t("removeFromHub",{name:G.name}),confirmLabel:t("unshare"),onConfirm:()=>{$e()},onCancel:()=>Q(null)}),$&&i.jsx(ba,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)}),K&&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=K;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=K;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")})]})]})}),U&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>te(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(eie,{isUpdate:M.has(`${U.type}/${U.name}`),onCancel:()=>te(null),onConfirm:(ce,et)=>{const nt=U;te(null),rt(nt,{priceCents:et>0?et:void 0})}})})}),L&&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(Zre,{onCancel:()=>J(null),onConfirm:(ce,et,nt,we)=>{const Me=L;J(null),rt(Me,{visibility:ce,orgId:et,priceCents:nt,donationsEnabled:we})}})})})]})})}function Zre({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:c6.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 c6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function eie({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:c6.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 tie=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:l6},Symbol.toStringTag,{value:"Module"}));async function u6(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 nie(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 Om(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}const aie={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function rie({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),[D,P]=k.useState(new Map),[M,I]=k.useState(new Set),[G,Q]=k.useState(null),[$,Y]=k.useState(null),K=k.useCallback(async()=>{try{const[te,L]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),J=new Map;for(const me of te.artifacts){if(me.type!=="agent")continue;const Ce=!!L.installed[`agent/${me.name}`];J.set(me.name,{installed:Ce,localVersion:me.meta.version||void 0,localUpdatedAt:me.updatedAt})}P(J)}catch{}},[]),ee=k.useCallback(async()=>{_(!0);try{const te=c?st.search({type:"agent",q:c,limit:50}):Ls(qa.hubAgents)??st.search({type:"agent",limit:50}),L=new URLSearchParams;c&&L.set("q",c);const J=fetch("/api/templates?"+L.toString()).then(V=>V.json()).catch(()=>({templates:[]})),[me,Ce]=await Promise.all([te.catch(()=>({items:[],total:0})),J,K(),st.isAuthenticated()?st.purchases.mine().then(V=>I(new Set(V.purchases.map(fe=>fe.itemId)))).catch(()=>{}):Promise.resolve()]),H=await u6(me?.items??[],t);g(H.items),p(Array.isArray(Ce.templates)?Ce.templates:[]),H.missing&&n?.()}catch{p([]),g([])}finally{_(!1)}},[c,K,t,n]);k.useEffect(()=>{ee()},[ee]),k.useEffect(()=>{if(!x){T({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(te=>te.json()).then(te=>T(te.files??{})).catch(()=>T({}))},[x]);const U=async(te,L,J)=>{try{const me=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:te,name:L,orgId:"default",teamId:J})});if(!me.ok)throw new Error(`Failed: ${me.status}`);S(!1),y(null)}catch(me){Y({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${me}`,variant:"danger"})}};if(G)return i.jsx(qs,{type:G.type,name:G.name,onBack:()=>Q(null)});if(x){const te={type:"agent",name:x.id,displayName:Om(x,l),version:x.version,description:wk(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}},L=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 ${aie[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,me)=>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})]})]},me))})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(qs,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:te,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:L}),C&&i.jsx(kk,{template:x,lang:l,onClose:()=>S(!1),onHire:U}),$&&i.jsx(ba,{alertOnly:!0,variant:$.variant??"danger",title:$.title,message:$.message,onConfirm:()=>Y(null),onCancel:()=>Y(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:te=>d(te.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),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((te,L)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},L))}):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(te=>i.jsx(vr,{type:"agent",name:Om(te,l),description:wk(te,l),seed:te.id,icon:te.icon,version:te.version,category:te.category,tags:te.tags,authorLabel:te.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(te)},te.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(te=>i.jsx(iie,{item:te,localInfo:D.get(qc(te)),purchased:lm(te,M),onStatusChange:K,highlight:te.id===t,onHighlightDone:n,onViewDetail:L=>Q({type:"agent",name:L})},te.id))})]})]})}),C&&x&&i.jsx(kk,{template:x,lang:l,onClose:()=>S(!1),onHire:U}),$&&i.jsx(ba,{alertOnly:!0,variant:$.variant??"danger",title:$.title,message:$.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function qc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return dm(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=qc(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 kb(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 iie({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 G=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(G)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&nie(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async G=>{if(G.stopPropagation(),!m){p(!0),g("");try{await Is(e),g(C?d("card.upgraded"):d("card.installed")+"!"),a()}catch(Q){const $=Q instanceof Error?Q.message:"";$.includes("402")||$.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},_=async G=>{if(G.stopPropagation(),!m){p(!0),g("");try{await kb(e,$=>{$==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),a()):g("")}catch(Q){g(Q instanceof Error?Q.message:d("card.failed"))}finally{p(!1)}}},D=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,P=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,M=()=>{T&&c?c(qc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:G=>{E(G)},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:G=>{E(G)},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:G=>{_(G)},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")," ",D]})}):i.jsx("button",{onClick:G=>{E(G)},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:M,actions:I})})}function kk({template:e,lang:t,onClose:n,onHire:a}){const{t:s}=ot(["store"]),[l,c]=k.useState(`${Om(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:Om(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 bh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Sk(e,t){return e.i18n?.[t]?.description||e.description}function Ck(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function sie(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 oie({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),[_,D]=k.useState(null),[P,M]=k.useState(new Map),[I,G]=k.useState(new Set),[Q,$]=k.useState(null),Y=k.useCallback(async()=>{try{const[U,te]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),L=new Map;for(const J of U.artifacts){if(J.type!=="team")continue;const me=!!te.installed[`team/${J.name}`];L.set(J.name,{installed:me,localVersion:J.meta.version||void 0,localUpdatedAt:J.updatedAt})}M(L)}catch{}},[]),K=k.useCallback(async()=>{C(!0);try{const U=l?st.search({type:"team",q:l,limit:50}):Ls(qa.hubTeams)??st.search({type:"team",limit:50}),[te,L]=await Promise.all([U.catch(()=>({items:[],total:0})),Ae.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),Y(),st.isAuthenticated()?st.purchases.mine().then(me=>G(new Set(me.purchases.map(Ce=>Ce.itemId)))).catch(()=>{}):Promise.resolve()]),J=await u6(te?.items??[],e);h(J.items),m(L?.templates??[]),J.missing&&t?.()}catch{m([]),h([])}finally{C(!1)}},[l,Y,e,t]);k.useEffect(()=>{K()},[K]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(U=>U.json()).then(U=>w(U.files??{})).catch(()=>w({}))},[g]);const ee=async U=>{E(!0),D(null);try{const L=(await Ae.teams.create(U.name,U.description)).team.id;let J,me=0;const Ce=[];for(const V of U.members){const fe=V.count??1;for(let z=0;z<fe;z++){const je=V.name??`${U.name} Agent ${z+1}`,Ue=fe>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:L,agentRole:V.role??"worker",skills:V.skills??[]})});if(He.ok){me++;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(L,{managerId:J,managerType:"agent"}).catch(()=>{});const H=Ce.length>0?` (${Ce.length} failed: ${Ce[0]})`:"";D({ok:me>0,message:`Team "${bh(U,s)}" deployed with ${me} agent(s)${H}`})}catch(te){D({ok:!1,message:`Failed: ${te}`})}finally{E(!1)}};if(Q)return i.jsx(qs,{type:Q.type,name:Q.name,onBack:()=>$(null)});if(g){const U={...y};g.announcements&&(U["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(U["NORMS.md"]=g.norms);const te={type:"team",name:g.id,displayName:bh(g,s),version:g.version,description:Sk(g,s),author:g.author,category:g.category??"general",tags:g.tags??[],files:U,team:{members:g.members.map(J=>({name:Ck(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??[]}))}},L=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,me)=>{const Ce=Ck(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(H=>i.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:H},H)),J.skills.length>3&&i.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",J.skills.length-3]})]})]},me)})})]});return i.jsx(i.Fragment,{children:i.jsx(qs,{type:"team",name:g.id,onBack:()=>{x(null),D(null)},readOnly:!0,initialManifest:te,contentSlot:L,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:U=>c(U.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((U,te)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},te))}):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(U=>i.jsx(vr,{type:"team",name:bh(U,s),description:Sk(U,s),seed:U.id,icon:U.icon||"users",version:U.version,category:U.category,tags:U.tags,authorLabel:U.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(U)},U.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(U=>i.jsx(lie,{item:U,localInfo:P.get(qc(U)),purchased:lm(U,I),onStatusChange:Y,highlight:U.id===e,onHighlightDone:t,onViewDetail:te=>$({type:"team",name:te})},U.id))})]})]})})]})}function lie({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 G=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(G)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&sie(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async G=>{if(G.stopPropagation(),!m){p(!0),g("");try{await Is(e),g(C?d("card.upgraded"):d("card.installed")+"!"),a()}catch(Q){const $=Q instanceof Error?Q.message:"";$.includes("402")||$.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},D=async G=>{if(G.stopPropagation(),!m){p(!0),g("");try{await kb(e,$=>{$==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),a()):g("")}catch(Q){g(Q instanceof Error?Q.message:d("card.failed"))}finally{p(!1)}}},P=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,M=()=>{T&&c?c(qc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:G=>{_(G)},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:G=>{_(G)},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:G=>{D(G)},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:G=>{_(G)},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:M,actions:I})})}function yh(e,t){return e.i18n?.[t]?.displayName||e.name}function xh(e,t){return e.i18n?.[t]?.description||e.description||""}function d6(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 cie={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 uie({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&&d6(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 kb(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 Ak({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||em(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(uie,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s})})})}function die({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),[D,P]=k.useState(1),[M,I]=k.useState([]),[G,Q]=k.useState(""),[$,Y]=k.useState("score"),[K,ee]=k.useState(""),[U,te]=k.useState(!1),[L,J]=k.useState([]),[me,Ce]=k.useState(!1),[H,V]=k.useState([]),[fe,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,ae="success")=>{p({text:q,type:ae}),setTimeout(()=>p(null),ae==="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=>{te(!0);try{const ae=await Ae.skills.registrySkillhub({q:q?.q,category:q?.category,page:q?.page??1,limit:24,sort:q?.sort??$});S(ae.skills),_(ae.total),ae.categories?.length&&I(ae.categories)}catch{}te(!1)},[$]),et=k.useCallback(async q=>{Ue(!0);try{const ae=await Ae.skills.registrySkillssh(q);V(ae.skills)}catch{}Ue(!1)},[]),nt=k.useCallback(async q=>{Wt(!0);try{const ae=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([ae,Se,st.isAuthenticated()?st.purchases.mine().then(ue=>wt(new Set(ue.purchases.map(Be=>Be.itemId)))).catch(()=>{}):Promise.resolve()]);let X=De?.items??[],Z=Pe?.items??[];if(e){const ue=X.some(Ie=>Ie.id===e),Be=Z.some(Ie=>Ie.id===e);if(!ue&&!Be)try{const{item:Ie}=await st.getItem(e);Ie?.subtype==="connector"?Z=[Ie,...Z]:Ie?X=[Ie,...X]:t?.()}catch{t?.()}else ue&&(X=[X.find(Ge=>Ge.id===e),...X.filter(Ge=>Ge.id!==e)]),Be&&(Z=[Z.find(Ge=>Ge.id===e),...Z.filter(Ge=>Ge.id!==e)])}He(X),dt(Z)}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(ae=>new Set(ae).add(q.name));try{const ae=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 (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{At(`Download failed for "${q.name}". You can try manually from: ${q.homepage}`,"error")}g(ae=>{const Se=new Set(ae);return Se.delete(q.name),Se})},Me=async q=>{g(ae=>new Set(ae).add(q.name));try{const ae=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 (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{At(`Download failed for "${q.name}". You can try manually from: ${q.url}`,"error")}g(ae=>{const Se=new Set(ae);return Se.delete(q.name),Se})},Ne=async q=>{g(ae=>new Set(ae).add(q.name));try{const ae=await Ae.skills.install({name:q.name,source:"builtin"});await Dt(),await ln(),At(`"${q.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ae){At(`Install failed for "${q.name}": ${ae}`,"error")}g(ae=>{const Se=new Set(ae);return Se.delete(q.name),Se})},se=H.filter(q=>{if(!fe)return!0;const ae=fe.toLowerCase();return q.name.toLowerCase().includes(ae)||q.repo.toLowerCase().includes(ae)});if(w){const q=w,ae={};q.instructions&&(ae["SKILL.md"]=q.instructions);const Se={type:"skill",name:q.name,displayName:yh(q,s),version:q.version,description:xh(q,s),author:q.author??"",category:q.category??"general",tags:q.tags,files:ae,skill:{skillFile:q.instructions?"SKILL.md":"",requiredPermissions:q.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},De=q.installed&&q.installedVersion&&d6(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 ${cie[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(X=>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:X},X))})]}),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(X=>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:X},X))})]})]})]});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(),ae=q?L.filter(Pe=>yh(Pe,s).toLowerCase().includes(q)||xh(Pe,s).toLowerCase().includes(q)):L,Se=me&&Zt,De=ae.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,X)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},X))}):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:[ae.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:ae.length})})]}),i.jsx(Fa,{columns:3,children:ae.map(Pe=>i.jsx(vr,{type:"skill",name:yh(Pe,s),description:xh(Pe,s),seed:Pe.name,icon:em(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(Ak,{item:Pe,installedSkills:x,purchased:lm(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(Ak,{item:Pe,type:"connector",installedSkills:x,purchased:lm(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:G,onChange:q=>{Q(q.target.value),P(1),ce({q:K||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")}),M.map(q=>i.jsx("option",{value:q,children:q},q))]}),i.jsxs("select",{value:$,onChange:q=>{Y(q.target.value),P(1),ce({q:K||void 0,category:G||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:K,onChange:q=>ee(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(P(1),ce({q:K||void 0,category:G||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:K||void 0,category:G||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"})]}),U?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 ae=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:em(q.slug||q.name,q.tags?.[0]),version:q.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:q.tags,installed:ae,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:ae?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:D<=1,onClick:()=>{const q=D-1;P(q),ce({q:K||void 0,category:G||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:D,total:Math.ceil(E/24)})}),i.jsx("button",{disabled:D>=Math.ceil(E/24),onClick:()=>{const q=D+1;P(q),ce({q:K||void 0,category:G||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:fe,onChange:q=>z(q.target.value),onKeyDown:q=>{q.key==="Enter"&&fe.trim()&&et(fe)},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:()=>{fe.trim()&&et(fe)},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 ae=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:em(q.name),authorLabel:`${q.author}/${q.repo}`,showTypeBadge:!1,installed:ae,hideStats:!0,cornerLabel:ae?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:ae?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 mie=["agent","team","skill","connector"];function vh({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 pie({item:e,onOpen:t}){const n=il(e.subtype==="connector"?"connector":e.itemType),a=wb(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(Im,{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 Tk({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 Nk(){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 fie({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:mie.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(pie,{item:g,onOpen:()=>h(g)},g.id))}):null,i.jsxs("section",{children:[i.jsx(vh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),s?i.jsx(Nk,{}):d.length>0?i.jsx(Tk,{items:d,onOpen:h}):i.jsx(hie,{})]}),i.jsxs("section",{children:[i.jsx(vh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),s?i.jsx(Nk,{}):m.length>0?i.jsx(Tk,{items:m,onOpen:h}):null]}),p.length>0&&i.jsxs("section",{children:[i.jsx(vh,{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(Im,{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 hie(){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 qd(e,t,n){return e.i18n?.[n]?.[t]}function gie(){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),D=k.useCallback(async()=>{y(!0);try{const[I,G,Q,$]=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:[]}))]),Y={};for(const U of Q.updates)Y[U.name]={availableVersion:U.availableVersion,installedVersion:U.installedVersion,displayName:U.displayName,description:U.description};d(Y);const K=I.artifacts.filter(U=>{const te=`${U.type}/${U.name}`;return!!G.installed[te]}),ee=new Set(K.filter(U=>U.type==="skill").map(U=>U.name));for(const U of $.skills)!U.installed||ee.has(U.name)||!(G.installed[`skill/${U.name}`]||Y[U.name])&&!U.updateAvailable||!G.installed[`skill/${U.name}`]&&!Y[U.name]||(K.push({type:"skill",name:U.name,meta:{displayName:U.i18n?.[a]?.displayName||U.name,description:U.i18n?.[a]?.description||U.description||"",version:U.installedVersion||U.version,author:U.author,category:U.category,tags:U.tags,i18n:U.i18n},path:"",updatedAt:""}),ee.add(U.name));for(const[U,te]of Object.entries(Y))ee.has(U)||(K.push({type:"skill",name:U,meta:{displayName:te.displayName||U,description:te.description||"",version:te.installedVersion},path:"",updatedAt:""}),ee.add(U));l(K)}catch{}y(!1)},[a]);k.useEffect(()=>{D()},[D]),k.useEffect(()=>{const I=()=>{D()};return window.addEventListener("markus:data-changed",I),()=>window.removeEventListener("markus:data-changed",I)},[D]),k.useEffect(()=>{if(!h)return;const I=setTimeout(()=>g(null),3e3);return()=>clearTimeout(I)},[h]);const P=async(I,G)=>{if(!m.has(I)){p(Q=>new Set(Q).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:G}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await D()}catch{g({text:e("installedTab.updateFailed",{name:I}),type:"error"})}p(Q=>{const $=new Set(Q);return $.delete(I),$})}},M=s.filter(I=>{if(C!=="all"&&I.type!==C)return!1;if(!w)return!0;const G=w.toLowerCase(),Q=(qd(I.meta,"displayName",a)||I.meta.displayName||I.name).toLowerCase(),$=(qd(I.meta,"description",a)||I.meta.description||"").toLowerCase();return Q.includes(G)||$.includes(G)}).sort((I,G)=>{const Q=I.type==="skill"&&c[I.name]?1:0;return(G.type==="skill"&&c[G.name]?1:0)-Q});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")}):M.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:M.map(I=>{const G=qd(I.meta,"displayName",a)||I.meta.displayName||I.name,Q=qd(I.meta,"description",a)||I.meta.description||"",$=I.meta.version||"",Y=I.meta.author||"",K=I.meta.tags??[],ee=I.meta.category||"",U=I.meta.icon,te=U&&/\.(png|jpe?g|gif|webp|svg)$/i.test(U)&&!U.startsWith("http")&&!U.startsWith("data:")&&!U.startsWith("/")?`/api/builder/artifacts/${I.type}s/${encodeURIComponent(I.name)}/${U}`:U,L=I.type==="skill"?c[I.name]:void 0;return i.jsx(vr,{type:I.type,name:G,description:Q,seed:I.name,icon:te,author:null,authorLabel:Y||void 0,version:L?L.installedVersion:$,category:ee,tags:K,installed:!L,hideStats:!0,cornerLabel:L?e("installedTab.updateAvailable"):void 0,onClick:()=>{I.path&&_({type:I.type,name:I.name})},actions:L?i.jsx("button",{type:"button",disabled:m.has(I.name),onClick:()=>{P(I.name,L.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(I.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:L.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 bie=50,yie=30;function xie(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<bie||Math.atan2(x,g)*(180/Math.PI)>yie)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 vie=["builder","discover","agents","teams","skills","installed"],wie={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Cg(e){return!!e&&vie.includes(e)}function Ek(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Cg(t)?t:"builder",installId:e}}function kie({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(Ek),[s,l]=k.useState(a.tab),[c,d]=k.useState(a.installId),m=xie(n,s,l);k.useEffect(()=>{const h=Ek();h.installId&&(d(h.installId),Cg(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");Cg(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(wie[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(y4,{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(l6,{authUser:e}),s==="discover"&&i.jsx(fie,{onOpenType:p}),s==="agents"&&i.jsx(rie,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),s==="teams"&&i.jsx(oie,{highlightItemId:c,onHighlightDone:()=>d(null)}),s==="skills"&&i.jsx(die,{highlightItemId:c,onHighlightDone:()=>d(null)}),s==="installed"&&i.jsx(gie,{})]})]})}const jk="usageType",wh="profile";function Sie({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(""),[D,P]=k.useState(!1),[M,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&&Y(At=>At||l("usageType.defaultOrgName",{name:mt}))}).catch(()=>{}),Ae.settings.getOrg().then(({org:$e})=>{$e?.name&&$e.name!=="My Organization"&&Y($e.name)}).catch(()=>{}),jn()&&Ae.hubOrgs.invitations().then($e=>{$e.invitations?.length>0&&Ce($e.invitations)}).catch(()=>{})},[]);const[G,Q]=k.useState(null),[$,Y]=k.useState(""),[K,ee]=k.useState(!1),[U,te]=k.useState(!1),[L,J]=k.useState(""),[me,Ce]=k.useState([]),[H,V]=k.useState(null),[fe,z]=k.useState(null),je=async()=>{const $e=$.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)}te(!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(hT,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:i.jsx("strong",{className:"text-fg-primary"})}})})},{id:jk,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:()=>{Q("personal"),te(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${G==="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:()=>{Q("organization"),te(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${G==="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."})})]})]})]}),G==="organization"&&i.jsxs("div",{className:"space-y-4 mt-4",children:[me.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")}),me.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),te(!0)}catch{}finally{V(null)}},disabled:H===$e.orgId||fe===$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:fe===$e.orgId?l("usageType.accepted"):H===$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:$,onChange:$e=>{Y($e.target.value),te(!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"})]}),L&&i.jsx("p",{className:"text-xs text-red-500",children:L}),i.jsx("button",{onClick:()=>{je()},disabled:K||!$.trim()||U,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(K?"common:saving":U?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:wh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:D?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(g4,{currentUrl:M,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!==wh):dt,wt=Nt.findIndex($e=>$e.id===jk),Zt=Nt.findIndex($e=>$e.id===wh),Wt=()=>{c===wt&&wt>=0&&!G||c===wt&&G==="organization"&&!U||c===Zt&&Zt>=0&&!D||(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&&!D||wt>=0&&c===wt&&(!G||G==="organization"&&!U),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Zt>=0&&c===Zt&&!D||wt>=0&&c===wt&&(!G||G==="organization"&&!U)?"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 Mk="markus:legal-consent",Cie="https://markus.global";function Aie({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=Y=>{const K=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${Cie}${Y}${K}`},_=()=>{try{localStorage.setItem(Mk,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},D=()=>C?(_(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),P=async()=>{const Y=jn(),K=xr();if(!Y||!K){d(n("login.hubUnavailable"));return}const ee=await Ae.auth.hubLogin(Y,K);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})},M=async(Y,K=!1)=>{if(!(!K&&!D())){d(""),l(Y??"hub");try{if(K&&jn()&&xr()){await P();return}await Ha({method:Y,force:!0}),await P()}catch(ee){const U=ee instanceof Error?ee.message:"";if(!U.includes("cancelled")){if(!K&&jn())return M(Y,!0);d(U||n("login.hubUnavailable"))}}finally{l(null)}}},I=()=>{bU(),l(null),d("")};k.useEffect(()=>{const Y=window.markusDesktop;if(!Y?.peekPendingDeepLinkAuth&&!Y?.consumePendingDeepLinkAuth)return;let K=!1;return(async()=>{const ee=Y.peekPendingDeepLinkAuth?await Y.peekPendingDeepLinkAuth():null;if(K||!ee)return;let U=!1;try{U=!!localStorage.getItem(Mk)}catch{}if(!C&&!U){d(n("login.consentRequired"));return}U&&!C&&S(!0),_();const te=Y.consumePendingDeepLinkAuth?await Y.consumePendingDeepLinkAuth():ee;if(!(K||!te)){d(""),l("hub");try{if(!await gU(te)||!jn()||!xr()){d(n("login.hubUnavailable"));return}await P()}catch{d(n("login.hubUnavailable"))}finally{K||l(null)}}})().catch(()=>{}),()=>{K=!0}},[C]);const G=async Y=>{if(Y.preventDefault(),!(!h.trim()||!x)&&D()){d(""),l("local");try{const{user:K,needsOnboarding:ee}=await Ae.auth.login(h.trim(),x);e(K,ee??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},Q=n(t?"login.welcomeBack":"login.getStarted"),$="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:Q})]}),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:G,className:"space-y-3",children:[i.jsx("input",{type:"email",value:h,onChange:Y=>g(Y.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:Y=>y(Y.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:()=>M("google"),disabled:!!s,className:$,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:()=>M("github"),disabled:!!s,className:$,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:()=>M("email"),disabled:!!s,className:$,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:Y=>{S(Y.target.checked),Y.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 Tie({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 Nie({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 Eie({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=D=>{if(!h.current)return;const P=D.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 Qse=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Ag="markus-theme";function _k(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 jie(){try{const e=localStorage.getItem(Ag);if(e==="midnight")return localStorage.setItem(Ag,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function Mie(){const[e,t]=k.useState(jie),n=k.useCallback(a=>{t(a);try{localStorage.setItem(Ag,a)}catch{}_k(a)},[]);return k.useEffect(()=>{_k(e)},[e]),{mode:e,setMode:n}}const nm={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},_ie={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},Rie=["agents","tasks","requirements","projects","deliverables","workflows"];let Rk="",Dk="all",Lk=nm,Ik=!1;function Die({onClose:e,currentPage:t}){const{t:n}=ot(["common","home","work"]);Qo(!0);const[a,s]=k.useState(Rk),[l,c]=k.useState(Dk),[d,m]=k.useState(Lk),[p,h]=k.useState(!1),[g,x]=k.useState(Ik),[y,w]=k.useState(-1);k.useEffect(()=>{Rk=a},[a]),k.useEffect(()=>{Dk=l},[l]),k.useEffect(()=>{Lk=d},[d]),k.useEffect(()=>{Ik=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(nm),x(!1),w(-1);return}h(!0),x(!0),w(-1);const U=ee.toLowerCase();try{const[te,L,J,me,Ce,H]=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=te.status==="fulfilled"?te.value.agents.filter(He=>He.name?.toLowerCase().includes(U)||He.role?.toLowerCase().includes(U)):[],fe=L.status==="fulfilled"?L.value.tasks:[],z=J.status==="fulfilled"?J.value.requirements.filter(He=>He.title?.toLowerCase().includes(U)||He.description?.toLowerCase().includes(U)):[],je=me.status==="fulfilled"?me.value.projects.filter(He=>He.name?.toLowerCase().includes(U)||He.description?.toLowerCase().includes(U)):[],Ue=Ce.status==="fulfilled"?Ce.value.results:[],qe=[];if(H.status==="fulfilled"){const He=await Promise.allSettled(H.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(U)||(dt.displayName||"").toLowerCase().includes(U)||dt.description?.toLowerCase().includes(U))&&qe.push(dt)}m({agents:V,tasks:fe,requirements:z,projects:je,deliverables:Ue,workflows:qe})}catch{m(nm)}finally{h(!1)}},[]),D=ee=>{s(ee),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>_(ee),400)},P=k.useCallback((ee,U)=>{e(),at.navigate(ee,U)},[e]),M=[{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(()=>_ie[t||""]||Rie,[t]),G=k.useMemo(()=>{const ee=[],U=l==="all"?8:void 0,te=L=>{if(l!=="all"&&l!==L)return;const J=d[L].length;if(L==="workflows"){const me=U?d.workflows.slice(0,U):d.workflows;for(const Ce of me)ee.push({id:Ce.name,type:"workflow",page:de.WORK,params:{boardType:"workflows"}})}else{const me=d[L],Ce=U?me.slice(0,U):me;for(const H of Ce)switch(L){case"agents":ee.push({id:H.id,type:"agent",page:de.TEAM,params:{agentId:H.id}});break;case"tasks":ee.push({id:H.id,type:"task",page:de.WORK,params:{openTask:H.id}});break;case"requirements":ee.push({id:H.id,type:"requirement",page:de.WORK,params:{openRequirement:H.id}});break;case"projects":ee.push({id:H.id,type:"project",page:de.WORK,params:{projectId:H.id}});break;case"deliverables":ee.push({id:H.id,type:"deliverable",page:de.DELIVERABLES,params:{openDeliverable:H.id}});break}}U&&J>U&&ee.push({id:`more_${L}`,type:"showMore",page:"",expandCategory:L,totalCount:J})};for(const L of I)te(L);return ee},[d,l,I]),Q=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 U=ee.querySelector(`[data-idx="${y}"]`);U&&U.scrollIntoView({block:"nearest"})},[y]);const $=k.useCallback(ee=>{if(ee.key==="Escape"){e();return}if(ee.key==="Tab"){ee.preventDefault();const L=M.map(Ce=>Ce.id),J=L.indexOf(l),me=ee.shiftKey?J<=0?L.length-1:J-1:J>=L.length-1?0:J+1;c(L[me]),w(-1);return}const U=ee.ctrlKey&&ee.key==="n"||ee.key==="ArrowDown",te=ee.ctrlKey&&ee.key==="p"||ee.key==="ArrowUp";if(U||te){ee.preventDefault(),w(L=>{const J=G.length-1;return J<0?-1:U?L>=J?0:L+1:L<=0?J:L-1});return}ee.key==="Enter"&&(ee.preventDefault(),y>=0&&y<G.length&&Q(G[y]))},[e,G,y,Q,M,l]);k.useEffect(()=>(document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)),[$]);const Y=G.length>0;let K=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=>D(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(nm),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:M.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&&!Y&&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&&Y&&i.jsx("div",{className:"space-y-4",children:I.map(ee=>{if(l!=="all"&&l!==ee)return null;const U=l==="all"?8:void 0,te=L=>{const J=K++,me=L==="agents"?d.agents.length:L==="tasks"?d.tasks.length:L==="requirements"?d.requirements.length:L==="projects"?d.projects.length:L==="workflows"?d.workflows.length:d.deliverables.length;return i.jsxs("button",{"data-idx":J,onClick:()=>{c(L),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:"查看全部"})," (",me,")"]})};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:(U?d.agents.slice(0,U):d.agents).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.TEAM,{agentId:L.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:L.name||"Agent",avatarUrl:L.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:L.name}),i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:L.role||L.status})]}),i.jsx(Lie,{status:L.status})]},L.id)})}),U&&d.agents.length>U&&te("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:(U?d.tasks.slice(0,U):d.tasks).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{openTask:L.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(Iie,{status:L.status}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:L.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.status," · ",L.priority||""]})]})]},L.id)})}),U&&d.tasks.length>U&&te("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:(U?d.requirements.slice(0,U):d.requirements).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{openRequirement:L.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 ${L.status==="approved"?"text-green-500 bg-green-500/15":L.status==="pending"?"text-amber-500 bg-amber-500/15":L.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children: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:L.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.status," · ",L.priority||""]})]})]},L.id)})}),U&&d.requirements.length>U&&te("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:(U?d.projects.slice(0,U):d.projects).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{projectId:L.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:L.name}),L.description&&i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:L.description})]})]},L.id)})}),U&&d.projects.length>U&&te("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:(U?d.deliverables.slice(0,U):d.deliverables).map(L=>{const J=K++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.DELIVERABLES,{openDeliverable:L.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:L.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.type," · ",L.status]})]})]},L.id)})}),U&&d.deliverables.length>U&&te("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:(U?d.workflows.slice(0,U):d.workflows).map(L=>{const J=K++;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:L.displayName||L.name}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.stepCount," steps · v",L.version]})]})]},L.name)})}),U&&d.workflows.length>U&&te("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 Lie({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 Iie({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 Oie=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function Pie(e){return e===de.TEAM?"team":e===de.WORK?"work":e===de.DELIVERABLES?"deliverables":e===de.STORE?"store":"any"}function zie({open:e,onClose:t,page:n}){const{t:a}=ot("common"),s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=Pie(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:Oie.map(c=>{const d=DU.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:w4(m.keys,s,m.bare)})]},m.id))})]},c)})})]})}):null}function Bie({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(()=>f4(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(g4,{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 Ok=k.lazy(()=>va(()=>import("./Team-CfUDkdc3.js"),__vite__mapDeps([2,3,4,5,6,7])).then(e=>({default:e.TeamPage}))),Pk=k.lazy(()=>va(()=>import("./Settings-CawBnWuy.js"),__vite__mapDeps([8,6])).then(e=>({default:e.Settings}))),Hie=k.lazy(()=>va(()=>import("./Store-BWi97VP9.js"),[]).then(e=>({default:e.StorePage}))),$ie=k.lazy(()=>va(()=>Promise.resolve().then(()=>tie),void 0).then(e=>({default:e.AgentBuilder}))),zk=k.lazy(()=>va(()=>import("./Work-DrIXOW-P.js"),__vite__mapDeps([9,4,1,10,3,11])).then(e=>({default:e.WorkPage}))),Bk=k.lazy(()=>va(()=>import("./Deliverables-BaAF4-w0.js"),__vite__mapDeps([12,4,5])).then(e=>({default:e.DeliverablesPage}))),qie=k.lazy(()=>va(()=>import("./Notifications-CCsdBfdg.js"),[]).then(e=>({default:e.NotificationsPage}))),Fie=k.lazy(()=>va(()=>import("./Search-BiBdevAU.js"),[]).then(e=>({default:e.SearchPage}))),Uie={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function Gie(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 Kie(){return i.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const Vie=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:Uie,children:i.jsx(k.Suspense,{fallback:i.jsx(Kie,{}),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}),Fd={};function m6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?i4[e]??e:e}function Hk(){return m6(kc())}function Wie(){const{t:e}=ot("common"),[t,n]=k.useState(Hk),[a,s]=k.useState(!1),[l,c]=k.useState(!0),d=Xo(),m=Mie(),p=Eie({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([Hk()])),[x,y]=k.useState("loading"),[w,T]=k.useState(!1),[C,S]=k.useState(null),[E,_]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[D,P]=k.useState(!1),[M,I]=k.useState(!1),[G,Q]=k.useState(null),[$,Y]=k.useState(!1),[K,ee]=k.useState(null),[U,te]=k.useState(()=>{const X=localStorage.getItem("markus_update_dismissed");return X||null}),[L,J]=k.useState(!1),[me,Ce]=k.useState(!1),H=$c(),V=H?.leftCollapsed??!1,fe=H?.toggleLeftCollapsed,z=H?.setLeftCollapsed,je=H?.keyboardPane??"l0",Ue=H?.setKeyboardPane,qe=H?.l0FocusPageId??null,He=H?.setL0FocusPageId,ut=k.useRef(t);ut.current=t;const dt=k.useRef(de.HOME),Nt=H?.toggleRightPanel,wt=H?.toggleTerminalPanel,Zt=H?.cycleRightPanelTab,Wt=H?.activateRightPanelTabAt,rt=H?.openNewRightPanelTab,$e=H?.rightPanelOpen??!1,mt=H?.activeRightPanelTabId??null,At=H?.openRightPanel,Dt=H?.closeRightPanelTab,ln=H?.updateRightPanelBrowserTab,ce=H?.updateRightPanelTerminalTab,et=k.useRef(H?.rightPanelTabs);et.current=H?.rightPanelTabs,k.useEffect(()=>{const X=window.markusDesktop?.browser?.onPageEvent;if(!(!X||!At))return X(Z=>{if(Z.type==="closed"){const ue=et.current?.find(Be=>Be.payload.kind==="url"&&Be.payload.browserId===Z.browserId);ue&&Dt&&Dt(ue.id);return}if(Z.type==="navigated"){if(Z.url&&Cc(Z.url))return;Z.browserId&&ln&&ln(Z.browserId,{url:Z.url,title:Z.title||Z.url});return}if(Z.type==="opened"||Z.type==="selected"){if(!Z.url&&!Z.browserId||Z.browserId.startsWith("eb_")||Mte(Z.browserId)||Z.url&&Cc(Z.url))return;At({kind:"url",url:Z.url||"about:blank",title:Z.title||Z.url||"Browser",browserId:Z.browserId,pageId:Z.pageId})}})},[At,Dt,ln]),k.useEffect(()=>{const X=window.markusDesktop?.terminal?.onEvent;if(!(!X||!At))return X(Z=>{if(Z.type==="closed"){const ue=et.current?.find(Be=>Be.payload.kind==="terminal"&&Be.payload.terminalId===Z.id);ue&&Dt&&Dt(ue.id);return}if(Z.type==="cwd"){Z.cwd&&ce?.(Z.id,{cwd:Z.cwd});return}if(Z.type==="selected"){(Z.title||Z.cwd)&&ce?.(Z.id,{title:Z.title,cwd:Z.cwd});return}if(Z.type==="opened"){if(pb.has(Z.id)){(Z.title||Z.cwd)&&ce?.(Z.id,{title:Z.title,cwd:Z.cwd});return}_s(Z.id),At({kind:"terminal",terminalId:Z.id,title:Z.title||"Terminal",cwd:Z.cwd})}})},[At,Dt,ce]);const nt=H?.handleTerminalExit;k.useEffect(()=>{const X=window.markusDesktop?.terminal?.onExit;if(!(!X||!nt))return X(Z=>{nt(Z.id)})},[nt]),k.useLayoutEffect(()=>{const X=t===de.TEAM&&$e&&H?.rightPanelMode==="browser";vf(X)},[t,$e,H?.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 X=navigator.platform.toUpperCase().includes("MAC"),Z=Be=>{X&&Be.metaKey&&!Be.ctrlKey&&Be.key==="p"?(Be.preventDefault(),J(Ie=>!Ie)):!X&&Be.ctrlKey&&!Be.metaKey&&Be.key==="p"&&(Be.preventDefault(),J(Ie=>!Ie))},ue=()=>J(!0);return document.addEventListener("keydown",Z),window.addEventListener("markus:open-search",ue),()=>{document.removeEventListener("keydown",Z),window.removeEventListener("markus:open-search",ue)}},[d]);const Me=k.useCallback(()=>!$e||!mt||!Dt?!1:(Dt(mt),!0),[$e,mt,Dt]);k.useEffect(()=>{const X=window.markusDesktop?.onAppShortcut?.(Z=>{if(Z.type==="close-tab"){Me();return}Z.type==="new-tab"&&rt?.()});return()=>{X?.()}},[Me,rt]),k.useEffect(()=>{if(d||!fe||!Nt)return;const X=navigator.platform.toUpperCase().includes("MAC"),Z=ue=>{if(!(X?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(),fe()}else if(t===de.TEAM&&Ie==="l"){if(!X&&Bv(ue.target)||X&&Bv(ue.target)&&ue.ctrlKey)return;ue.preventDefault(),Nt()}else t===de.TEAM&&Ie==="j"&&wt&&(ue.preventDefault(),wt())};return document.addEventListener("keydown",Z,!0),()=>document.removeEventListener("keydown",Z,!0)},[d,t,fe,Nt,wt,Zt,Wt,$e,Me,rt]);const Ne=k.useCallback((X,Z)=>{let ue=wc(X);d?ue=i4[ue]??ue:ue===de.NOTIFICATIONS&&(ue=de.HOME),ue!==de.TEAM&&vf(!1);const Be=kc(),Ie=window.location.hash.slice(1);Ie!==Nh(Be)?Fd[Be]=Ie:delete Fd[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&&Z?.tab){const Rt=`settings/${Z.tab}`;Fd[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?Fd[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((X,Z)=>Ne(X,Z))},[Ne]),k.useEffect(()=>{je==="l0"&&t!==de.SETTINGS&&He?.(t)},[je,t,He]),k.useEffect(()=>{if(d||!Ue||!He)return;const X=Z=>{if(Z.metaKey||Z.ctrlKey||Z.altKey||zv(Z.target))return;const ue=Z.key.length===1?Z.key.toLowerCase():Z.key;if(t===de.SETTINGS&&(ue==="h"||ue==="ArrowLeft")){Z.preventDefault(),Z.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"){Z.preventDefault(),Z.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"){Z.preventDefault(),Z.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(!sU.has(Ge)){Z.preventDefault(),Z.stopImmediatePropagation();return}Z.preventDefault(),Z.stopImmediatePropagation(),Ge!==t&&Ne(Ge),z?.(!1),Ue("l1");return}(ue==="h"||ue==="ArrowLeft")&&(Z.preventDefault(),Z.stopImmediatePropagation())};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[d,je,qe,t,Ne,Ue,He,z]),k.useEffect(()=>{const X=()=>T(!0);return window.addEventListener("markus:open-edit-profile",X),()=>window.removeEventListener("markus:open-edit-profile",X)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==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(X=>{if(X.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),X.page){const Z=wc(X.page);X.params&&Object.entries(X.params).forEach(([ue,Be])=>localStorage.setItem(`markus_nav_${ue}`,Be)),Ne(Z),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Z,params:X.params}}))}})},[Ne]);const se=k.useCallback(()=>{fetch("/api/settings/llm").then(X=>X.ok?X.json():null).then(X=>{if(X?.providers){const Z=Object.values(X.providers).some(ue=>ue.configured);Q(Z)}}).catch(()=>{})},[]),q=k.useCallback((X,Z)=>{if(!X)return;const Be=Z&&{agent:"agents",team:"teams",skill:"skills"}[Z]||"agents";localStorage.setItem("markus_nav_installItem",X),localStorage.setItem("markus_nav_storeTab",Be);const Ie=new URLSearchParams(window.location.search);Ie.get("install")||(Ie.set("install",X),Z&&Ie.set("type",Z));const Ge=Ie.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Ge}${Ps(de.STORE)}`);const kt=()=>at.navigate(de.STORE,{storeTab:Be,installItem:X});kt(),setTimeout(kt,500),setTimeout(kt,1500)},[]);k.useEffect(()=>{const X=new URLSearchParams(window.location.search),Z=X.get("install");Z&&q(Z,X.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),Gie(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=m6(kc());Ge!==de.TEAM&&vf(!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 X=x!=="loading"&&x!==null?x.id:void 0;if(!X)return;const Z=navigator.platform.toUpperCase().includes("MAC"),ue=Be=>{if(zv(Be.target))return;const Ie={key:Be.key,code:Be.code,metaKey:Be.metaKey,ctrlKey:Be.ctrlKey,altKey:Be.altKey,shiftKey:Be.shiftKey};_U(Ie,X,Z)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",ue,!0),()=>window.removeEventListener("keydown",ue,!0)},[x]);const ae=x!=="loading"&&x!==null?x:void 0,Se=k.useMemo(()=>d?{[de.HOME]:i.jsx(Fv,{authUser:ae}),[de.TEAM]:i.jsx(Ok,{authUser:ae}),[de.BUILDER]:i.jsx(kie,{authUser:ae}),[de.SETTINGS]:i.jsx(Pk,{theme:m.mode,onThemeChange:m.setMode,authUser:ae,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},onUserUpdated:X=>y(X)}),[de.WORK]:i.jsx(zk,{authUser:ae}),[de.DELIVERABLES]:i.jsx(Bk,{authUser:ae}),[de.NOTIFICATIONS]:i.jsx(qie,{authUser:ae}),[de.SEARCH]:i.jsx(Fie,{})}:{[de.HOME]:i.jsx(Fv,{authUser:ae}),[de.TEAM]:i.jsx(Ok,{authUser:ae}),[de.SETTINGS]:i.jsx(Pk,{theme:m.mode,onThemeChange:m.setMode,authUser:ae,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},onUserUpdated:X=>y(X)}),[de.STORE]:i.jsx(Hie,{authUser:ae}),[de.BUILDER]:i.jsx($ie,{authUser:ae}),[de.WORK]:i.jsx(zk,{authUser:ae}),[de.DELIVERABLES]:i.jsx(Bk,{authUser:ae})},[ae?.id,ae?.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(Tie,{token:Pe[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),s(!0),P(!0),y("loading"),Ae.auth.me().then(X=>{Hv(X.user.id),y(X.user)}).catch(()=>y(null))}}):x===null?i.jsx(Aie,{hasOwner:E.hasOwner,hasMultipleUsers:E.hasMultipleUsers,onLogin:(X,Z,ue)=>{y(X),Ir.connect(X.id),Z?(Hv(X.id),s(!0),ue?.fromHub&&P(!0)):(s(!1),_h(X.id)?(Rh(X.id),Ae.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),y({...X,preferences:{...X.preferences,guideHidden:!0}})):y(X))}}):M?i.jsx(Nie,{onComplete:()=>I(!1),isFirstTime:!0}):a?i.jsx(Sie,{theme:m.mode,onThemeChange:m.setMode,skipProfile:D,onProfileUpdated:X=>{const Z={id:X.id,name:X.name,email:X.email,role:X.role,orgId:X.orgId??"default",avatarUrl:X.avatarUrl};y(Z)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),s(!1),P(!1),Ae.auth.me().then(X=>y(X.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(Cre,{currentPage:t,onNavigate:X=>{Ne(X),c(!1),Ue?.("l0"),He?.(X)},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:[G===!1&&!$&&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:()=>Y(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),K&&U!==K.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:K.latestVersion,current:K.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:()=>{te(K.latestVersion),localStorage.setItem("markus_update_dismissed",K.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(X=>h.has(X)?i.jsx(Vie,{id:X,activePage:t,children:Se[X]},X):null)})]}),d&&t!==de.SETTINGS&&t!==de.SEARCH&&i.jsx(Dre,{currentPage:t,onNavigate:Ne,userId:ae?.id}),d&&i.jsx(EU,{authUser:ae,onNavigate:Ne,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)}}),!d&&L&&i.jsx(Die,{onClose:()=>J(!1),currentPage:t}),!d&&i.jsx(zie,{open:me,onClose:()=>Ce(!1),page:t}),w&&ae&&i.jsx(Bie,{authUser:ae,onClose:()=>T(!1),onUserUpdated:X=>y(X),onSaved:X=>{T(!1),y(X)}})]})}const $k="data-anim-paused",qk="data-anim-tick",Fk=8,Yie=250;function Qie(){return document.visibilityState!=="visible"||document.hidden}let yc=null,Po=0;function Xie(){yc===null&&(Po=Po%Fk,document.documentElement.setAttribute(qk,String(Po)),yc=window.setInterval(()=>{Po=(Po+1)%Fk,document.documentElement.setAttribute(qk,String(Po))},Yie))}function Jie(){yc!==null&&(window.clearInterval(yc),yc=null)}function kh(){const e=document.documentElement;Qie()?(e.setAttribute($k,"true"),Jie()):(e.removeAttribute($k),Xie())}let Uk=!1;function Zie(){Uk||typeof document>"u"||(Uk=!0,kh(),document.addEventListener("visibilitychange",kh,{passive:!0}),window.addEventListener("pageshow",kh,{passive:!0}))}Zie();SA.createRoot(document.getElementById("root")).render(i.jsx(k.StrictMode,{children:i.jsx(Ote,{children:i.jsx(Wie,{})})}));export{Qse as $,Zi as A,Qo as B,li as C,kne as D,Ps as E,ba as F,uU as G,sse as H,gie as I,bb as J,dse as K,bg as L,y4 as M,wre as N,Cne as O,de as P,yg as Q,tse as R,fie as S,rie as T,Rae as U,_ae as V,ose as W,pse as X,mse as Y,Go as Z,va as _,Xo as a,Ose as a$,nse as a0,xr as a1,Io as a2,Wse as a3,hT as a4,Ase as a5,lU as a6,ase as a7,rse as a8,_s as a9,Gae as aA,fse as aB,ise as aC,Kae as aD,Mre as aE,Yse as aF,Ise as aG,Bse as aH,use as aI,kse as aJ,xb as aK,w4 as aL,g4 as aM,Mse as aN,_se as aO,Rse as aP,$se as aQ,ek as aR,lne as aS,Vse as aT,Hse as aU,Gse as aV,qse as aW,pk as aX,fk as aY,yre as aZ,Kse as a_,jd as aa,fi as ab,dm as ac,Use as ad,dne as ae,Ow as af,Hae as ag,zs as ah,rl as ai,Ese as aj,Tse as ak,vse as al,wse as am,Nse as an,Cse as ao,Sse as ap,hse as aq,yse as ar,Jae as as,xse as at,gse as au,jse as av,are as aw,Fse as ax,WS as ay,bse as az,kU as b,zse as b0,PS as b1,Bv as b2,Dse as b3,Lse as b4,Pse as b5,cse as b6,BS as b7,$c as c,xie as d,oie as e,die as f,Is as g,st as h,zv as i,i as j,zr as k,Ae as l,Eie as m,at as n,jn as o,wc as p,Ea as q,k as r,gb as s,Ha as t,ot as u,ese as v,Ir as w,Lc as x,Pm as y,bT as z};
|