@markus-global/cli 0.12.0-rc.0 → 0.12.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/markus.mjs +9 -8
- package/dist/web-ui/assets/{AsyncState-BebkDWbq.js → AsyncState-Brx503Qq.js} +1 -1
- package/dist/web-ui/assets/{CommentInput-BRZWIC3U.js → CommentInput-CyyImwaF.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-PGP8H_Zz.js → ContentRenderer-CpiisvVQ.js} +2 -2
- package/dist/web-ui/assets/{DeliverableShareModal-CcigVYGz.js → DeliverableShareModal-BbvcR0LN.js} +1 -1
- package/dist/web-ui/assets/{Deliverables-CQwXaCA4.js → Deliverables-DIeYy6k7.js} +1 -1
- package/dist/web-ui/assets/{Notifications-BvHJCIRG.js → Notifications-BoPgYIh8.js} +1 -1
- package/dist/web-ui/assets/{Search-BA-aXh7i.js → Search-Bc44e8vT.js} +1 -1
- package/dist/web-ui/assets/{SendToChat-CAfyKhpq.js → SendToChat-BHNwDw6Q.js} +1 -1
- package/dist/web-ui/assets/{Settings-icFp6tNI.js → Settings-5tk3XjBZ.js} +1 -1
- package/dist/web-ui/assets/{Store-DKwOcmMu.js → Store-CMxzEtXt.js} +1 -1
- package/dist/web-ui/assets/{Switch-C7lFnHA7.js → Switch-C1h7-ixU.js} +1 -1
- package/dist/web-ui/assets/{Team-DyqXLZ-X.js → Team-Dcl-5Zvh.js} +4 -4
- package/dist/web-ui/assets/{Work-BXGrda4S.js → Work-Dj9tQYXg.js} +1 -1
- package/dist/web-ui/assets/{arc-Dnk6N-Zc.js → arc-BA1zZ3ag.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CV8JIXXD.js → architectureDiagram-3BPJPVTR-DTUETQs3.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-D9pKmrXH.js → blockDiagram-GPEHLZMM-D5dvIq_3.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-Q26HvIpY.js → c4Diagram-AAUBKEIU-CBurhkOF.js} +1 -1
- package/dist/web-ui/assets/channel-CYxqacYz.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-BSjFVwnx.js → chunk-2J33WTMH-JDr6ZP1p.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-BZXv4MQp.js → chunk-4BX2VUAB-CsXt6Gd5.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-CeKd3oeJ.js → chunk-55IACEB6-BPhC3YgG.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-DP1tSQo5.js → chunk-727SXJPM-BgceLEQx.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-DqEncn7j.js → chunk-AQP2D5EJ-Bq58a84v.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-tuDUJ9Xx.js → chunk-FMBD7UC4-DyMa3olF.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-DoC8aLWB.js → chunk-ND2GUHAM-BsgTeDYu.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-74zpvcgs.js → chunk-QZHKN3VN-BQpJPCpr.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-mygctjMz.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-mygctjMz.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-DjYUalC1.js → cose-bilkent-S5V4N54A-BCbssvKI.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-oSewacE8.js → dagre-BM42HDAG-CT9IdAY4.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-C1fiWe46.js → diagram-2AECGRRQ-x2pwUpLt.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-9G_q6hCa.js → diagram-5GNKFQAL-d9_JOrSK.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-CSm-lJp-.js → diagram-KO2AKTUF-CAVFWSkN.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-BTAORcHx.js → diagram-LMA3HP47-DQEHXvkq.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-DbcCkDfo.js → diagram-OG6HWLK6-BW62W4O-.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-DjqdA44x.js → docx-preview-pqFDBX8M.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DFa-B8-u.js → erDiagram-TEJ5UH35-yYImCEy2.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-WCTnaK9M.js → flowDiagram-I6XJVG4X-Cpk1pKF0.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-DbW1CoJJ.js → ganttDiagram-6RSMTGT7-BnwH90c8.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-1faDfO29.js → gitGraphDiagram-PVQCEYII-ELEziEhc.js} +1 -1
- package/dist/web-ui/assets/{index-B8h1PPzP.js → index-Dt7RN5t2.js} +5 -5
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DfXKP4tQ.js → infoDiagram-5YYISTIA-48XZ0hV0.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-D6FOsFQ5.js → ishikawaDiagram-YF4QCWOH-B0wQJGwe.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-DXpxntIF.js → journeyDiagram-JHISSGLW-BNsrI94Q.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-Dt7FBCF3.js → kanban-definition-UN3LZRKU-Cp8eSqCe.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-sTcSUoRD.js → mermaid.core-BYCWrkC-.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-CvOU23ga.js → mindmap-definition-RKZ34NQL-Ccay8RYS.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-DUedtXVj.js → pieDiagram-4H26LBE5-BUzaEdin.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-CqpHHRca.js → quadrantDiagram-W4KKPZXB-BtM1AkZX.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CKZYvVDJ.js → requirementDiagram-4Y6WPE33-eqO2tGIB.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-gZ0nzDfs.js → sankeyDiagram-5OEKKPKP-M6qPg2gI.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-DN3XdBkW.js → sequenceDiagram-3UESZ5HK-DtIYVpzR.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-BvtafGxO.js → stateDiagram-AJRCARHV-CLVsjtbI.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BfZl6BED.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-BrR919lp.js → timeline-definition-PNZ67QCA-CUwncHES.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-B7CTm4yM.js → vennDiagram-CIIHVFJN-KDkzNQIk.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-CyqFngx_.js → wardley-L42UT6IY-BqliL5Bv.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-BCqEPBJ5.js → wardleyDiagram-YWT4CUSO-B4qeGz2Q.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-BmT6Cmz-.js → xychartDiagram-2RQKCTM6-3877u0ek.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-BZs6ereM.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-C9JIxJeJ.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-C9JIxJeJ.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-B2nWDV5R.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-BYCWrkC-.js","assets/transform-CpIVI4vC.js","assets/Team-Dcl-5Zvh.js","assets/AsyncState-Brx503Qq.js","assets/CommentInput-CyyImwaF.js","assets/ContentRenderer-CpiisvVQ.js","assets/DeliverableShareModal-BbvcR0LN.js","assets/Switch-C1h7-ixU.js","assets/Team-DFuMZ0ql.css","assets/Settings-5tk3XjBZ.js","assets/Work-Dj9tQYXg.js","assets/SendToChat-BHNwDw6Q.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-DIeYy6k7.js","assets/Search-Bc44e8vT.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 Ooe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bf={exports:{}},Zl={};var hx;function KA(){if(hx)return Zl;hx=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 u in s)u!=="key"&&(l[u]=s[u])}else l=s;return s=l.ref,{$$typeof:e,type:a,key:c,ref:s!==void 0?s:null,props:l}}return Zl.Fragment=t,Zl.jsx=n,Zl.jsxs=n,Zl}var gx;function VA(){return gx||(gx=1,bf.exports=KA()),bf.exports}var i=VA(),yf={exports:{}},Gt={};var bx;function WA(){if(bx)return Gt;bx=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"),u=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"),v=Symbol.iterator;function y(q){return q===null||typeof q!="object"?null:(q=v&&q[v]||q["@@iterator"],typeof q=="function"?q:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,C={};function S(q,le,L){this.props=q,this.context=le,this.refs=C,this.updater=L||k}S.prototype.isReactComponent={},S.prototype.setState=function(q,le){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,le,"setState")},S.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function E(){}E.prototype=S.prototype;function _(q,le,L){this.props=q,this.context=le,this.refs=C,this.updater=L||k}var D=_.prototype=new E;D.constructor=_,T(D,S.prototype),D.isPureReactComponent=!0;var z=Array.isArray;function M(){}var I={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function W(q,le,L){var Ce=L.ref;return{$$typeof:e,type:q,key:le,ref:Ce!==void 0?Ce:null,props:L}}function H(q,le){return W(q.type,le,q.props)}function Y(q){return typeof q=="object"&&q!==null&&q.$$typeof===e}function ne(q){var le={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(L){return le[L]})}var V=/\/+/g;function F(q,le){return typeof q=="object"&&q!==null&&q.key!=null?ne(""+q.key):le.toString(36)}function J(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(M,M):(q.status="pending",q.then(function(le){q.status==="pending"&&(q.status="fulfilled",q.value=le)},function(le){q.status==="pending"&&(q.status="rejected",q.reason=le)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function P(q,le,L,Ce,Ge){var Ve=typeof q;(Ve==="undefined"||Ve==="boolean")&&(q=null);var Qe=!1;if(q===null)Qe=!0;else switch(Ve){case"bigint":case"string":case"number":Qe=!0;break;case"object":switch(q.$$typeof){case e:case t:Qe=!0;break;case h:return Qe=q._init,P(Qe(q._payload),le,L,Ce,Ge)}}if(Qe)return Ge=Ge(q),Qe=Ce===""?"."+F(q,0):Ce,z(Ge)?(L="",Qe!=null&&(L=Qe.replace(V,"$&/")+"/"),P(Ge,le,L,"",function(Tt){return Tt})):Ge!=null&&(Y(Ge)&&(Ge=H(Ge,L+(Ge.key==null||q&&q.key===Ge.key?"":(""+Ge.key).replace(V,"$&/")+"/")+Qe)),le.push(Ge)),1;Qe=0;var it=Ce===""?".":Ce+":";if(z(q))for(var mt=0;mt<q.length;mt++)Ce=q[mt],Ve=it+F(Ce,mt),Qe+=P(Ce,le,L,Ve,Ge);else if(mt=y(q),typeof mt=="function")for(q=mt.call(q),mt=0;!(Ce=q.next()).done;)Ce=Ce.value,Ve=it+F(Ce,mt++),Qe+=P(Ce,le,L,Ve,Ge);else if(Ve==="object"){if(typeof q.then=="function")return P(J(q),le,L,Ce,Ge);throw le=String(q),Error("Objects are not valid as a React child (found: "+(le==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":le)+"). If you meant to render a collection of children, use an array instead.")}return Qe}function X(q,le,L){if(q==null)return q;var Ce=[],Ge=0;return P(q,Ce,"","",function(Ve){return le.call(L,Ve,Ge++)}),Ce}function oe(q){if(q._status===-1){var le=q._result;le=le(),le.then(function(L){(q._status===0||q._status===-1)&&(q._status=1,q._result=L)},function(L){(q._status===0||q._status===-1)&&(q._status=2,q._result=L)}),q._status===-1&&(q._status=0,q._result=le)}if(q._status===1)return q._result.default;throw q._result}var Ae=typeof reportError=="function"?reportError:function(q){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var le=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof q=="object"&&q!==null&&typeof q.message=="string"?String(q.message):String(q),error:q});if(!window.dispatchEvent(le))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",q);return}console.error(q)},G={map:X,forEach:function(q,le,L){X(q,function(){le.apply(this,arguments)},L)},count:function(q){var le=0;return X(q,function(){le++}),le},toArray:function(q){return X(q,function(le){return le})||[]},only:function(q){if(!Y(q))throw Error("React.Children.only expected to receive a single React element child.");return q}};return Gt.Activity=g,Gt.Children=G,Gt.Component=S,Gt.Fragment=n,Gt.Profiler=s,Gt.PureComponent=_,Gt.StrictMode=a,Gt.Suspense=m,Gt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,Gt.__COMPILER_RUNTIME={__proto__:null,c:function(q){return I.H.useMemoCache(q)}},Gt.cache=function(q){return function(){return q.apply(null,arguments)}},Gt.cacheSignal=function(){return null},Gt.cloneElement=function(q,le,L){if(q==null)throw Error("The argument must be a React element, but you passed "+q+".");var Ce=T({},q.props),Ge=q.key;if(le!=null)for(Ve in le.key!==void 0&&(Ge=""+le.key),le)!U.call(le,Ve)||Ve==="key"||Ve==="__self"||Ve==="__source"||Ve==="ref"&&le.ref===void 0||(Ce[Ve]=le[Ve]);var Ve=arguments.length-2;if(Ve===1)Ce.children=L;else if(1<Ve){for(var Qe=Array(Ve),it=0;it<Ve;it++)Qe[it]=arguments[it+2];Ce.children=Qe}return W(q.type,Ge,Ce)},Gt.createContext=function(q){return q={$$typeof:c,_currentValue:q,_currentValue2:q,_threadCount:0,Provider:null,Consumer:null},q.Provider=q,q.Consumer={$$typeof:l,_context:q},q},Gt.createElement=function(q,le,L){var Ce,Ge={},Ve=null;if(le!=null)for(Ce in le.key!==void 0&&(Ve=""+le.key),le)U.call(le,Ce)&&Ce!=="key"&&Ce!=="__self"&&Ce!=="__source"&&(Ge[Ce]=le[Ce]);var Qe=arguments.length-2;if(Qe===1)Ge.children=L;else if(1<Qe){for(var it=Array(Qe),mt=0;mt<Qe;mt++)it[mt]=arguments[mt+2];Ge.children=it}if(q&&q.defaultProps)for(Ce in Qe=q.defaultProps,Qe)Ge[Ce]===void 0&&(Ge[Ce]=Qe[Ce]);return W(q,Ve,Ge)},Gt.createRef=function(){return{current:null}},Gt.forwardRef=function(q){return{$$typeof:u,render:q}},Gt.isValidElement=Y,Gt.lazy=function(q){return{$$typeof:h,_payload:{_status:-1,_result:q},_init:oe}},Gt.memo=function(q,le){return{$$typeof:p,type:q,compare:le===void 0?null:le}},Gt.startTransition=function(q){var le=I.T,L={};I.T=L;try{var Ce=q(),Ge=I.S;Ge!==null&&Ge(L,Ce),typeof Ce=="object"&&Ce!==null&&typeof Ce.then=="function"&&Ce.then(M,Ae)}catch(Ve){Ae(Ve)}finally{le!==null&&L.types!==null&&(le.types=L.types),I.T=le}},Gt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},Gt.use=function(q){return I.H.use(q)},Gt.useActionState=function(q,le,L){return I.H.useActionState(q,le,L)},Gt.useCallback=function(q,le){return I.H.useCallback(q,le)},Gt.useContext=function(q){return I.H.useContext(q)},Gt.useDebugValue=function(){},Gt.useDeferredValue=function(q,le){return I.H.useDeferredValue(q,le)},Gt.useEffect=function(q,le){return I.H.useEffect(q,le)},Gt.useEffectEvent=function(q){return I.H.useEffectEvent(q)},Gt.useId=function(){return I.H.useId()},Gt.useImperativeHandle=function(q,le,L){return I.H.useImperativeHandle(q,le,L)},Gt.useInsertionEffect=function(q,le){return I.H.useInsertionEffect(q,le)},Gt.useLayoutEffect=function(q,le){return I.H.useLayoutEffect(q,le)},Gt.useMemo=function(q,le){return I.H.useMemo(q,le)},Gt.useOptimistic=function(q,le){return I.H.useOptimistic(q,le)},Gt.useReducer=function(q,le,L){return I.H.useReducer(q,le,L)},Gt.useRef=function(q){return I.H.useRef(q)},Gt.useState=function(q){return I.H.useState(q)},Gt.useSyncExternalStore=function(q,le,L){return I.H.useSyncExternalStore(q,le,L)},Gt.useTransition=function(){return I.H.useTransition()},Gt.version="19.2.4",Gt}var yx;function Km(){return yx||(yx=1,yf.exports=WA()),yf.exports}var w=Km();const Poe=Pc(w);var vf={exports:{}},ec={},xf={exports:{}},kf={};var vx;function YA(){return vx||(vx=1,(function(e){function t(P,X){var oe=P.length;P.push(X);e:for(;0<oe;){var Ae=oe-1>>>1,G=P[Ae];if(0<s(G,X))P[Ae]=X,P[oe]=G,oe=Ae;else break e}}function n(P){return P.length===0?null:P[0]}function a(P){if(P.length===0)return null;var X=P[0],oe=P.pop();if(oe!==X){P[0]=oe;e:for(var Ae=0,G=P.length,q=G>>>1;Ae<q;){var le=2*(Ae+1)-1,L=P[le],Ce=le+1,Ge=P[Ce];if(0>s(L,oe))Ce<G&&0>s(Ge,L)?(P[Ae]=Ge,P[Ce]=oe,Ae=Ce):(P[Ae]=L,P[le]=oe,Ae=le);else if(Ce<G&&0>s(Ge,oe))P[Ae]=Ge,P[Ce]=oe,Ae=Ce;else break e}}return X}function s(P,X){var oe=P.sortIndex-X.sortIndex;return oe!==0?oe:P.id-X.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,u=c.now();e.unstable_now=function(){return c.now()-u}}var m=[],p=[],h=1,g=null,v=3,y=!1,k=!1,T=!1,C=!1,S=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function D(P){for(var X=n(p);X!==null;){if(X.callback===null)a(p);else if(X.startTime<=P)a(p),X.sortIndex=X.expirationTime,t(m,X);else break;X=n(p)}}function z(P){if(T=!1,D(P),!k)if(n(m)!==null)k=!0,M||(M=!0,ne());else{var X=n(p);X!==null&&J(z,X.startTime-P)}}var M=!1,I=-1,U=5,W=-1;function H(){return C?!0:!(e.unstable_now()-W<U)}function Y(){if(C=!1,M){var P=e.unstable_now();W=P;var X=!0;try{e:{k=!1,T&&(T=!1,E(I),I=-1),y=!0;var oe=v;try{t:{for(D(P),g=n(m);g!==null&&!(g.expirationTime>P&&H());){var Ae=g.callback;if(typeof Ae=="function"){g.callback=null,v=g.priorityLevel;var G=Ae(g.expirationTime<=P);if(P=e.unstable_now(),typeof G=="function"){g.callback=G,D(P),X=!0;break t}g===n(m)&&a(m),D(P)}else a(m);g=n(m)}if(g!==null)X=!0;else{var q=n(p);q!==null&&J(z,q.startTime-P),X=!1}}break e}finally{g=null,v=oe,y=!1}X=void 0}}finally{X?ne():M=!1}}}var ne;if(typeof _=="function")ne=function(){_(Y)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,F=V.port2;V.port1.onmessage=Y,ne=function(){F.postMessage(null)}}else ne=function(){S(Y,0)};function J(P,X){I=S(function(){P(e.unstable_now())},X)}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(P){P.callback=null},e.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<P?Math.floor(1e3/P):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function(P){switch(v){case 1:case 2:case 3:var X=3;break;default:X=v}var oe=v;v=X;try{return P()}finally{v=oe}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(P,X){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var oe=v;v=P;try{return X()}finally{v=oe}},e.unstable_scheduleCallback=function(P,X,oe){var Ae=e.unstable_now();switch(typeof oe=="object"&&oe!==null?(oe=oe.delay,oe=typeof oe=="number"&&0<oe?Ae+oe:Ae):oe=Ae,P){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=oe+G,P={id:h++,callback:X,priorityLevel:P,startTime:oe,expirationTime:G,sortIndex:-1},oe>Ae?(P.sortIndex=oe,t(p,P),n(m)===null&&P===n(p)&&(T?(E(I),I=-1):T=!0,J(z,oe-Ae))):(P.sortIndex=G,t(m,P),k||y||(k=!0,M||(M=!0,ne()))),P},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(P){var X=v;return function(){var oe=v;v=X;try{return P.apply(this,arguments)}finally{v=oe}}}})(kf)),kf}var xx;function QA(){return xx||(xx=1,xf.exports=YA()),xf.exports}var wf={exports:{}},ka={};var kx;function XA(){if(kx)return ka;kx=1;var e=Km();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 u(m,p){if(m==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return ka.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,ka.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)},ka.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()}},ka.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))},ka.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},ka.preinit=function(m,p){if(typeof m=="string"&&p&&typeof p.as=="string"){var h=p.as,g=u(h,p.crossOrigin),v=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:v,fetchPriority:y}):h==="script"&&a.d.X(m,{crossOrigin:g,integrity:v,fetchPriority:y,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},ka.preinitModule=function(m,p){if(typeof m=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var h=u(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)},ka.preload=function(m,p){if(typeof m=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var h=p.as,g=u(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})}},ka.preloadModule=function(m,p){if(typeof m=="string")if(p){var h=u(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)},ka.requestFormReset=function(m){a.d.r(m)},ka.unstable_batchedUpdates=function(m,p){return m(p)},ka.useFormState=function(m,p,h){return c.H.useFormState(m,p,h)},ka.useFormStatus=function(){return c.H.useHostTransitionStatus()},ka.version="19.2.4",ka}var wx;function p4(){if(wx)return wf.exports;wx=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(),wf.exports=XA(),wf.exports}var Sx;function JA(){if(Sx)return ec;Sx=1;var e=QA(),t=Km(),n=p4();function a(r){var o="https://react.dev/errors/"+r;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)o+="&args[]="+encodeURIComponent(arguments[d])}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,d=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(d=o.return),r=o.return;while(r)}return o.tag===3?d: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 u(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 d=r,f=o;;){var b=d.return;if(b===null)break;var x=b.alternate;if(x===null){if(f=b.return,f!==null){d=f;continue}break}if(b.child===x.child){for(x=b.child;x;){if(x===d)return m(b),r;if(x===f)return m(b),o;x=x.sibling}throw Error(a(188))}if(d.return!==f.return)d=b,f=x;else{for(var j=!1,O=b.child;O;){if(O===d){j=!0,d=b,f=x;break}if(O===f){j=!0,f=b,d=x;break}O=O.sibling}if(!j){for(O=x.child;O;){if(O===d){j=!0,d=x,f=b;break}if(O===f){j=!0,f=x,d=b;break}O=O.sibling}if(!j)throw Error(a(189))}}if(d.alternate!==f)throw Error(a(190))}if(d.tag!==3)throw Error(a(188));return d.stateNode.current===d?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,v=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),k=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"),z=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),H=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function ne(r){return r===null||typeof r!="object"?null:(r=Y&&r[Y]||r["@@iterator"],typeof r=="function"?r:null)}var V=Symbol.for("react.client.reference");function F(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===V?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 z:return"Suspense";case M:return"SuspenseList";case W:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case k: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:F(r.type)||"Memo";case U:o=r._payload,r=r._init;try{return F(r(o))}catch{}}return null}var J=Array.isArray,P=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe={pending:!1,data:null,method:null,action:null},Ae=[],G=-1;function q(r){return{current:r}}function le(r){0>G||(r.current=Ae[G],Ae[G]=null,G--)}function L(r,o){G++,Ae[G]=r.current,r.current=o}var Ce=q(null),Ge=q(null),Ve=q(null),Qe=q(null);function it(r,o){switch(L(Ve,o),L(Ge,r),L(Ce,null),o.nodeType){case 9:case 11:r=(r=o.documentElement)&&(r=r.namespaceURI)?zv(r):0;break;default:if(r=o.tagName,o=o.namespaceURI)o=zv(o),r=Bv(o,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}le(Ce),L(Ce,r)}function mt(){le(Ce),le(Ge),le(Ve)}function Tt(r){r.memoizedState!==null&&L(Qe,r);var o=Ce.current,d=Bv(o,r.type);o!==d&&(L(Ge,r),L(Ce,d))}function Dt(r){Ge.current===r&&(le(Ce),le(Ge)),Qe.current===r&&(le(Qe),Yl._currentValue=oe)}var Pt,fn;function Nt(r){if(Pt===void 0)try{throw Error()}catch(d){var o=d.stack.trim().match(/\n( *(at )?)/);Pt=o&&o[1]||"",fn=-1<d.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<d.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+Pt+r+fn}var Ue=!1;function ht(r,o){if(!r||Ue)return"";Ue=!0;var d=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(Ee){var we=Ee}Reflect.construct(r,[],Oe)}else{try{Oe.call()}catch(Ee){we=Ee}r.call(Oe.prototype)}}else{try{throw Error()}catch(Ee){we=Ee}(Oe=r())&&typeof Oe.catch=="function"&&Oe.catch(function(){})}}catch(Ee){if(Ee&&we&&typeof Ee.stack=="string")return[Ee.stack,we.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 x=f.DetermineComponentFrameRoot(),j=x[0],O=x[1];if(j&&O){var ae=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
|
-
`;yh=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return yh}async function dre(e,t,n){const a=await Aa(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=cre();const s=await a.getDocument({url:e}).promise,l=[];for(let c=1;c<=s.numPages;c++){const u=await s.getPage(c),m=u.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 u.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 ure(e,t){const{renderAsync:n}=await Aa(async()=>{const{renderAsync:s}=await import("./docx-preview-
|
|
847
|
+
`;yh=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return yh}async function dre(e,t,n){const a=await Aa(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=cre();const s=await a.getDocument({url:e}).promise,l=[];for(let c=1;c<=s.numPages;c++){const u=await s.getPage(c),m=u.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 u.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 ure(e,t){const{renderAsync:n}=await Aa(async()=>{const{renderAsync:s}=await import("./docx-preview-pqFDBX8M.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 mre(e,t){const n=await Aa(()=>import("./xlsx-CNerDvZX.js"),[]),a=await fetch(e).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);return u.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=""}}w.lazy(()=>Aa(()=>Promise.resolve().then(()=>mC),void 0).then(e=>({default:e.MarkdownMessage})));const pre=w.lazy(()=>Aa(()=>import("./ContentRenderer-PGP8H_Zz.js"),[]).then(e=>({default:e.ContentRenderer})));let Lo=[],sw=60;function fre(e){const t=w.useRef(e);t.current=e;const[n]=w.useState(()=>++sw);return w.useEffect(()=>{const a=()=>t.current();Lo.push(a);const s=l=>{l.key==="Escape"&&Lo[Lo.length-1]===a&&(l.preventDefault(),a())};return window.addEventListener("keydown",s,!0),()=>{window.removeEventListener("keydown",s,!0),Lo=Lo.filter(l=>l!==a),Lo.length===0&&(sw=60)}},[]),n}const ow=500,ts=new Map,Pm=new Set,sm=new Map;let om=null;function hre(){if(ts.size<=ow)return;const e=ts.size-ow,t=ts.keys();for(let n=0;n<e;n++){const{value:a,done:s}=t.next();if(s)break;ts.delete(a)}}function lw(e,t){ts.delete(e),ts.set(e,t),hre()}function cw(e){const t=sm.get(e);if(t)for(const n of t)n()}function gre(){om=null;const e=[...Pm];Pm.clear(),e.length!==0&&Ne.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))lw(n,a),cw(n)}).catch(()=>{for(const t of e)lw(t,{exists:!1,isFile:!1,type:"unknown"}),cw(t)})}function bre(e){ts.has(e)||Pm.has(e)||(Pm.add(e),om&&clearTimeout(om),om=setTimeout(gre,30))}function yre(e,t){let n=sm.get(e);return n||(n=new Set,sm.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&sm.delete(e)}}function vre(e){const t=w.useCallback(s=>yre(e,s),[e]),n=w.useCallback(()=>ts.get(e),[e]),a=w.useSyncExternalStore(t,n,n);return w.useEffect(()=>{bre(e)},[e]),a}function xre(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function kre({filePath:e,onClose:t}){const n=fre(t),[a,s]=w.useState(e),[l,c]=w.useState(!0),[u,m]=w.useState(null),[p,h]=w.useState(""),[g,v]=w.useState(""),[y,k]=w.useState(""),[T,C]=w.useState(""),[S,E]=w.useState(""),[_,D]=w.useState(null),[z,M]=w.useState(!1);w.useEffect(()=>{c(!0),m(null),h(""),D(null),Ne.files.preview(a).then(Y=>{if(Y.type==="directory"&&Array.isArray(Y.entries)){v("directory"),k(Y.name),D(Y.entries);return}v(Y.type),k(Y.name),C(Y.mimeType||""),h(typeof Y.content=="string"?Y.content:""),E(Y.streamUrl||(Y.path?Ne.files.streamUrl(Y.path):"")||(Y.type==="audio"||Y.type==="video"?Ne.files.streamUrl(a):""))}).catch(Y=>{m(String(Y?.message||Y))}).finally(()=>{c(!1)})},[a]);const I=y||a.split(/[/\\]/).pop()||a,U=g==="directory"||a!==e,W=()=>s(Y=>xre(Y)),H=()=>{navigator.clipboard?.writeText(a).then(()=>{M(!0),setTimeout(()=>M(!1),1500)}).catch(()=>{})};return $r.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:[U&&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:W,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:H,title:"复制路径",children:z?"✓ 已复制":"复制路径"}),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:()=>Ne.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"})}),u&&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:u})]}),!l&&!u&&g==="directory"&&_&&i.jsx(are,{path:a,entries:_,onNavigate:Y=>s(Y),onOpenFile:Y=>s(Y),onReveal:Y=>Ne.files.reveal(Y),onCopyPath:Y=>{navigator.clipboard?.writeText(Y).then(()=>{M(!0),setTimeout(()=>M(!1),1500)}).catch(()=>{})}}),!l&&!u&&g==="office"&&S&&i.jsx(ire,{data:{format:(a.split(".").pop()||"pdf").toLowerCase(),streamUrl:S,name:I},reference:a,onFallback:()=>{Ne.files.reveal(a)}}),!l&&!u&&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&&!u&&g==="audio"&&S&&i.jsx("audio",{controls:!0,preload:"metadata",src:S,className:"w-full"}),!l&&!u&&g==="video"&&S&&i.jsx("video",{controls:!0,preload:"metadata",src:S,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!l&&!u&&(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:()=>{Ne.files.reveal(a)},children:"Reveal in file explorer"})]}),!l&&!u&&p&&g!=="image"&&g!=="audio"&&g!=="video"&&g!=="binary"&&g!=="directory"&&i.jsx(w.Suspense,{fallback:i.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:i.jsx(pre,{content:p,format:g==="text"?"text":g,className:"text-sm"})})]})]})}),document.body)}function wre({path:e}){const t=vre(e),[n,a]=w.useState(null),s=Uc(),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",u=w.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(s?.hostAvailable){s.openRightPanel({kind:"file",path:e});return}a(e)}else Ne.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:u,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(kre,{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 vh=null;function Sre(){return vh||(vh=Aa(()=>import("./mermaid.core-sTcSUoRD.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),vh}function Cre(){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 Are(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 Tre(){return Cre()}function Nre(){return w.useSyncExternalStore(Are,Tre)}function oC({code:e}){const{t}=lt("common"),n=w.useRef(null),[a,s]=w.useState(null),[l,c]=w.useState(!0),u=w.useId(),m=w.useRef(0),p=w.useRef(null),h=Nre();return w.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 v=await Sre();if(g)return;v.default.initialize({startOnLoad:!1,theme:h?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${u.replace(/:/g,"")}-${m.current}`,{svg:k}=await v.default.render(y,e.trim());if(g)return;n.current&&(n.current.innerHTML=k,p.current={code:e,dark:h})}catch(v){g||s(v instanceof Error?v.message:String(v))}finally{g||c(!1)}})(),()=>{g=!0}},[e,u,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 Ere="/assets/viz-global-C_AyN6D9.js";let Du=!1,xh=null;function jre(){return Du?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(Du=!0,e()):(n.addEventListener("load",()=>{Du=!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=Ere,a.onload=()=>{Du=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function Mre(){return xh||(xh=jre().then(()=>Aa(()=>import("./plantuml-DezRDxd4.js"),[]))),xh}let dw=Promise.resolve();function _re(e,t){const n=dw.then(()=>new Promise((a,s)=>{Mre().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,s,{dark:t})}).catch(s)}));return dw=n.then(()=>{},()=>{}),n}function Rre(){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 Dre(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 Ire(){return w.useSyncExternalStore(Dre,()=>Rre())}function lC({code:e}){const{t}=lt("common"),[n,a]=w.useState(null),[s,l]=w.useState(null),[c,u]=w.useState(!0),m=w.useRef(null),p=Ire();return w.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===p)return;let h=!1;return u(!0),l(null),_re(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||u(!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 Ag({code:e,language:t,children:n}){const{t:a}=lt("common"),[s,l]=w.useState("rendered"),[c,u]=w.useState(!1),m=w.useCallback(async()=>{await Rb(e)&&(u(!0),setTimeout(()=>u(!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 Lre=[oC,lC];function Ore(e){for(const t of w.Children.toArray(e))if(w.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return Tae(n)}return null}function vc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(vc).join("");if(w.isValidElement(e)){const t=e.props;return vc(t.children)}return""}function Pre({children:e}){const{t}=lt("common"),n=Ore(e),a=w.useRef(null),[s,l]=w.useState(!1),[c,u]=w.useState("rendered"),m=w.useCallback(async()=>{let h;c==="source"?h=vc(e):h=a.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(h),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(w.Children.toArray(e).some(h=>w.isValidElement(h)&&Lre.includes(h.type))){const h=vc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return i.jsx(Ag,{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:Aae(n)}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>u("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:()=>u("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:w.Children.map(e,h=>w.isValidElement(h)?w.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:vc(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:",zm="#entity:",zre=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,cC=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Tg="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function Ng(e){return e.type==="text"?e.value??"":(e.children??[]).map(Ng).join("")}function Bre(e){return e.type==="text"&&(e.value??"").trim()===""}function Hre(e){if(!e?.children)return null;const t=e.children.filter(a=>!Bre(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=Ng(n);if(a.startsWith(zm))return{id:a.slice(zm.length)};const l=a.match(cC);return l&&l[1]!=="workflow"?{id:l[2],type:tC(l[1]),label:s}:null}if(n.type==="element"&&n.tagName==="code"){const a=Ng(n).trim();if(Om(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Om(a))return{id:a}}return null}const $re={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")||Sae(a))return i.jsx(Ag,{code:a,language:"plantuml",children:i.jsx(lC,{code:a})});if(t?.includes("language-mermaid"))return i.jsx(Ag,{code:a,language:"mermaid",children:i.jsx(oC,{code:a})});if(t?.includes("language-"))return i.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Om(n))return i.jsx(yc,{id:n.trim()});const s=n.match(zre);return s?i.jsx(yc,{id:s[2],label:s[1]}):_ae(n)?i.jsx(wre,{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(Pre,{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:Tg,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})},qre=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function Fre(e){const t=_b(e);return Y3(e)&&qre.test(t.split("?")[0]??t)}function Ure(e,t){const n=_b(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 Gre(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function Kre(e,t){return Fre(e)?Gre(Ure(e,t)):null}const Oo=new Map,lc=new Map,Vre=w.memo(function({src:t,alt:n,onPreview:a,basePath:s}){const l=w.useMemo(()=>Kre(t,s)??t,[t,s]),c=l.startsWith("/api/files/image?"),u=Oo.get(l),m=lc.get(l),[p,h]=w.useState(u??(c?null:l)),[g,v]=w.useState(!!u),[y,k]=w.useState(!!m),[T,C]=w.useState(m??null),[S,E]=w.useState(0),_=w.useRef(0),D=w.useCallback(M=>{lc.set(l,M),C(M),k(!0),v(!1)},[l]),z=w.useCallback(()=>{Oo.delete(l),lc.delete(l),k(!1),C(null),v(!1),h(c?null:`${l}${l.includes("?")?"&":"?"}retry=${Date.now()}`),E(M=>M+1)},[l,c]);return w.useEffect(()=>{if(!c)return;const M=Oo.get(l);if(M){h(M),v(!0),k(!1),C(null);return}const I=lc.get(l);if(I!==void 0){k(!0),C(I),v(!1);return}const U=++_.current;k(!1),C(null),v(!1),h(null),(async()=>{try{const W=await fetch(l,{credentials:"same-origin"});if(U!==_.current)return;if(!W.ok){let ne=`HTTP ${W.status}`;try{const V=await W.json();V.error&&(ne=V.error)}catch{}throw new Error(ne)}const H=await W.blob();if(U!==_.current)return;if(H.size===0)throw new Error("Empty image response");if(H.type&&!H.type.startsWith("image/")&&!H.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${H.type}`);const Y=URL.createObjectURL(H);Oo.set(l,Y),h(Y),v(!0),k(!1),C(null)}catch(W){if(U!==_.current)return;const H=W instanceof Error?W.message:String(W);console.warn("[MarkdownImage] failed to load local image",l,W),D(H)}})()},[c,l,S]),w.useEffect(()=>{if(c)return;const M=lc.get(l);if(M!==void 0){k(!0),C(M),v(!1);return}h(l),v(!!Oo.get(l)),k(!1),C(null)},[l,c,S]),y?i.jsxs("button",{type:"button",onClick:z,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||Oo.set(l,l),v(!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 mw(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function Wre(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 Yre(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 dC({src:e,onClose:t}){const{t:n}=lt("common"),[a,s]=w.useState(null),[l,c]=w.useState(null);Jo(!0),w.useEffect(()=>{const g=v=>{v.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const u=w.useCallback(g=>{s(g),window.setTimeout(()=>s(null),1600)},[]),m=w.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const v=await mw(e),y=await Wre(v);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),u(n("imageCopied"))}catch{u(n("imageCopyFailed"))}finally{c(null)}}},[l,u,e,n]),p=w.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const v=await mw(e),y=URL.createObjectURL(v),k=document.createElement("a");k.href=y,k.download=Yre(e,v),document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(y),u(n("imageDownloaded"))}catch{u(n("imageDownloadFailed"))}finally{c(null)}}},[l,u,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 $r.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 uC(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:s,hostAvailable:l,openRightPanel:c}=e,u=w.useCallback((m,p)=>{const h=ew(p,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){Rae(s?.current??null,h.id);return}if(h.kind==="file"){l&&c?c({kind:"file",path:h.path,title:h.path.split(/[/\\]/).pop()}):Ne.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}gi(h.url)}}},[n,s,l,c]);return w.useMemo(()=>({...$re,img:({src:m,alt:p})=>i.jsx(Vre,{src:m??"",alt:p,onPreview:a,basePath:n},m??""),p:({children:m,node:p})=>{const h=Hre(p);return h?i.jsx(Jae,{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?v=>{v.preventDefault(),v.stopPropagation(),t(g,v)}:void 0,title:g,children:p})}if(m?.startsWith(zm))return i.jsx(yc,{id:m.slice(zm.length)});{const g=m?.match(cC);if(g){const[,v,y]=g;if(v==="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(),st.navigate(se.WORK,{boardType:"workflows"})},title:`workflow: ${y}`,children:[i.jsx("span",{className:"text-[10px]",children:"⚙️"}),i.jsx("span",{children:p})]});const k=tC(v);if(k)return i.jsx(yc,{id:y,type:k,label:p})}}if(m&&Om(m))return i.jsx(yc,{id:m.trim(),label:p});const h=ew(m,n);return h.kind==="fragment"||h.kind==="file"||h.kind==="external"?i.jsx("a",{href:m,className:Tg,onClick:g=>u(g,m),title:h.kind==="fragment"?`#${h.id}`:h.kind==="file"?h.path:h.url,children:p}):i.jsx("a",{href:m,className:Tg,onClick:g=>{Vo()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&g.preventDefault()},children:p})}}),[t,n,a,u])}const pw=[lS,d3,u3],fw=[J3,[x3,{strict:"ignore"}],[z3,{detect:!0,ignoreMissing:!0}]];function Eg(e){if(/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e))return e;const n=Mb(e);return Y3(n)?n:O5(e)}const Qre=/(?:<thinking>| thinking)([\s\S]*?)<\/thinking>/g;function Xre(e){const t=[];let n=e.replace(Qre,(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 Jre(e=640){const[t,n]=w.useState(()=>window.innerWidth<e);return w.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 Zre({content:e,contentRef:t}){const{t:n}=lt("common"),[a,s]=w.useState(!1),[l,c]=w.useState(!1),[u,m]=w.useState(!1),[p,h]=w.useState(null),g=w.useRef(null),v=Jre();w.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=w.useCallback(C=>{h(C),setTimeout(()=>h(null),1500)},[]),k=async()=>{const C=await Rb(e);y(n(C?"markdown.copied":"markdown.failed")),s(!1)},T=async C=>{const S=t.current?.firstElementChild;if(!S)return;const E=eC(),_=Oae(E),D=await Iae(S,C,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),z=n(C==="light"?"markdown.themeLight":"markdown.themeDark");y(D.ok?D.method==="html"?n("markdown.htmlCopied",{theme:z}):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:u?i.jsx(Pae,{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:k,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(v?"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(v?"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(v?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const va=w.memo(function({content:t,className:n="",onMentionClick:a,knownNames:s,basePath:l}){const{thinking:c,rest:u}=Xre(t),m=w.useRef(null),[p,h]=w.useState(null),g=Uc(),v=w.useCallback(T=>{let C=mi(T,$3);return C=mi(C,pae),C=mi(C,jae),C=mi(C,bae),C=mi(C,yae),C=mi(C,S=>fae(S,s)),C=mi(C,U3),C},[s]),y=w.useMemo(()=>v(u),[u,v]),k=uC({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(Zre,{content:t,contentRef:m}),i.jsx("div",{ref:m,children:i.jsx(zae,{resetKeys:[y],fallback:i.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-2 sm:pr-8 text-fg-secondary ${n}`,children:u}),children:i.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-2 sm:pr-8 text-fg-secondary ${n}`,children:[c.length>0&&(()=>{const T=c.join(`
|
|
854
|
+
`,t.prepend(c),()=>{t.innerHTML=""}}w.lazy(()=>Aa(()=>Promise.resolve().then(()=>mC),void 0).then(e=>({default:e.MarkdownMessage})));const pre=w.lazy(()=>Aa(()=>import("./ContentRenderer-CpiisvVQ.js"),[]).then(e=>({default:e.ContentRenderer})));let Lo=[],sw=60;function fre(e){const t=w.useRef(e);t.current=e;const[n]=w.useState(()=>++sw);return w.useEffect(()=>{const a=()=>t.current();Lo.push(a);const s=l=>{l.key==="Escape"&&Lo[Lo.length-1]===a&&(l.preventDefault(),a())};return window.addEventListener("keydown",s,!0),()=>{window.removeEventListener("keydown",s,!0),Lo=Lo.filter(l=>l!==a),Lo.length===0&&(sw=60)}},[]),n}const ow=500,ts=new Map,Pm=new Set,sm=new Map;let om=null;function hre(){if(ts.size<=ow)return;const e=ts.size-ow,t=ts.keys();for(let n=0;n<e;n++){const{value:a,done:s}=t.next();if(s)break;ts.delete(a)}}function lw(e,t){ts.delete(e),ts.set(e,t),hre()}function cw(e){const t=sm.get(e);if(t)for(const n of t)n()}function gre(){om=null;const e=[...Pm];Pm.clear(),e.length!==0&&Ne.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))lw(n,a),cw(n)}).catch(()=>{for(const t of e)lw(t,{exists:!1,isFile:!1,type:"unknown"}),cw(t)})}function bre(e){ts.has(e)||Pm.has(e)||(Pm.add(e),om&&clearTimeout(om),om=setTimeout(gre,30))}function yre(e,t){let n=sm.get(e);return n||(n=new Set,sm.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&sm.delete(e)}}function vre(e){const t=w.useCallback(s=>yre(e,s),[e]),n=w.useCallback(()=>ts.get(e),[e]),a=w.useSyncExternalStore(t,n,n);return w.useEffect(()=>{bre(e)},[e]),a}function xre(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function kre({filePath:e,onClose:t}){const n=fre(t),[a,s]=w.useState(e),[l,c]=w.useState(!0),[u,m]=w.useState(null),[p,h]=w.useState(""),[g,v]=w.useState(""),[y,k]=w.useState(""),[T,C]=w.useState(""),[S,E]=w.useState(""),[_,D]=w.useState(null),[z,M]=w.useState(!1);w.useEffect(()=>{c(!0),m(null),h(""),D(null),Ne.files.preview(a).then(Y=>{if(Y.type==="directory"&&Array.isArray(Y.entries)){v("directory"),k(Y.name),D(Y.entries);return}v(Y.type),k(Y.name),C(Y.mimeType||""),h(typeof Y.content=="string"?Y.content:""),E(Y.streamUrl||(Y.path?Ne.files.streamUrl(Y.path):"")||(Y.type==="audio"||Y.type==="video"?Ne.files.streamUrl(a):""))}).catch(Y=>{m(String(Y?.message||Y))}).finally(()=>{c(!1)})},[a]);const I=y||a.split(/[/\\]/).pop()||a,U=g==="directory"||a!==e,W=()=>s(Y=>xre(Y)),H=()=>{navigator.clipboard?.writeText(a).then(()=>{M(!0),setTimeout(()=>M(!1),1500)}).catch(()=>{})};return $r.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:[U&&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:W,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:H,title:"复制路径",children:z?"✓ 已复制":"复制路径"}),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:()=>Ne.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"})}),u&&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:u})]}),!l&&!u&&g==="directory"&&_&&i.jsx(are,{path:a,entries:_,onNavigate:Y=>s(Y),onOpenFile:Y=>s(Y),onReveal:Y=>Ne.files.reveal(Y),onCopyPath:Y=>{navigator.clipboard?.writeText(Y).then(()=>{M(!0),setTimeout(()=>M(!1),1500)}).catch(()=>{})}}),!l&&!u&&g==="office"&&S&&i.jsx(ire,{data:{format:(a.split(".").pop()||"pdf").toLowerCase(),streamUrl:S,name:I},reference:a,onFallback:()=>{Ne.files.reveal(a)}}),!l&&!u&&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&&!u&&g==="audio"&&S&&i.jsx("audio",{controls:!0,preload:"metadata",src:S,className:"w-full"}),!l&&!u&&g==="video"&&S&&i.jsx("video",{controls:!0,preload:"metadata",src:S,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!l&&!u&&(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:()=>{Ne.files.reveal(a)},children:"Reveal in file explorer"})]}),!l&&!u&&p&&g!=="image"&&g!=="audio"&&g!=="video"&&g!=="binary"&&g!=="directory"&&i.jsx(w.Suspense,{fallback:i.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:i.jsx(pre,{content:p,format:g==="text"?"text":g,className:"text-sm"})})]})]})}),document.body)}function wre({path:e}){const t=vre(e),[n,a]=w.useState(null),s=Uc(),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",u=w.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(s?.hostAvailable){s.openRightPanel({kind:"file",path:e});return}a(e)}else Ne.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:u,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(kre,{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 vh=null;function Sre(){return vh||(vh=Aa(()=>import("./mermaid.core-BYCWrkC-.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),vh}function Cre(){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 Are(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 Tre(){return Cre()}function Nre(){return w.useSyncExternalStore(Are,Tre)}function oC({code:e}){const{t}=lt("common"),n=w.useRef(null),[a,s]=w.useState(null),[l,c]=w.useState(!0),u=w.useId(),m=w.useRef(0),p=w.useRef(null),h=Nre();return w.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 v=await Sre();if(g)return;v.default.initialize({startOnLoad:!1,theme:h?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${u.replace(/:/g,"")}-${m.current}`,{svg:k}=await v.default.render(y,e.trim());if(g)return;n.current&&(n.current.innerHTML=k,p.current={code:e,dark:h})}catch(v){g||s(v instanceof Error?v.message:String(v))}finally{g||c(!1)}})(),()=>{g=!0}},[e,u,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 Ere="/assets/viz-global-C_AyN6D9.js";let Du=!1,xh=null;function jre(){return Du?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(Du=!0,e()):(n.addEventListener("load",()=>{Du=!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=Ere,a.onload=()=>{Du=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function Mre(){return xh||(xh=jre().then(()=>Aa(()=>import("./plantuml-DezRDxd4.js"),[]))),xh}let dw=Promise.resolve();function _re(e,t){const n=dw.then(()=>new Promise((a,s)=>{Mre().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,s,{dark:t})}).catch(s)}));return dw=n.then(()=>{},()=>{}),n}function Rre(){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 Dre(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 Ire(){return w.useSyncExternalStore(Dre,()=>Rre())}function lC({code:e}){const{t}=lt("common"),[n,a]=w.useState(null),[s,l]=w.useState(null),[c,u]=w.useState(!0),m=w.useRef(null),p=Ire();return w.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===p)return;let h=!1;return u(!0),l(null),_re(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||u(!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 Ag({code:e,language:t,children:n}){const{t:a}=lt("common"),[s,l]=w.useState("rendered"),[c,u]=w.useState(!1),m=w.useCallback(async()=>{await Rb(e)&&(u(!0),setTimeout(()=>u(!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 Lre=[oC,lC];function Ore(e){for(const t of w.Children.toArray(e))if(w.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return Tae(n)}return null}function vc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(vc).join("");if(w.isValidElement(e)){const t=e.props;return vc(t.children)}return""}function Pre({children:e}){const{t}=lt("common"),n=Ore(e),a=w.useRef(null),[s,l]=w.useState(!1),[c,u]=w.useState("rendered"),m=w.useCallback(async()=>{let h;c==="source"?h=vc(e):h=a.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(h),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(w.Children.toArray(e).some(h=>w.isValidElement(h)&&Lre.includes(h.type))){const h=vc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return i.jsx(Ag,{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:Aae(n)}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>u("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:()=>u("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:w.Children.map(e,h=>w.isValidElement(h)?w.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:vc(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:",zm="#entity:",zre=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,cC=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Tg="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function Ng(e){return e.type==="text"?e.value??"":(e.children??[]).map(Ng).join("")}function Bre(e){return e.type==="text"&&(e.value??"").trim()===""}function Hre(e){if(!e?.children)return null;const t=e.children.filter(a=>!Bre(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=Ng(n);if(a.startsWith(zm))return{id:a.slice(zm.length)};const l=a.match(cC);return l&&l[1]!=="workflow"?{id:l[2],type:tC(l[1]),label:s}:null}if(n.type==="element"&&n.tagName==="code"){const a=Ng(n).trim();if(Om(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Om(a))return{id:a}}return null}const $re={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")||Sae(a))return i.jsx(Ag,{code:a,language:"plantuml",children:i.jsx(lC,{code:a})});if(t?.includes("language-mermaid"))return i.jsx(Ag,{code:a,language:"mermaid",children:i.jsx(oC,{code:a})});if(t?.includes("language-"))return i.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Om(n))return i.jsx(yc,{id:n.trim()});const s=n.match(zre);return s?i.jsx(yc,{id:s[2],label:s[1]}):_ae(n)?i.jsx(wre,{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(Pre,{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:Tg,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})},qre=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function Fre(e){const t=_b(e);return Y3(e)&&qre.test(t.split("?")[0]??t)}function Ure(e,t){const n=_b(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 Gre(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function Kre(e,t){return Fre(e)?Gre(Ure(e,t)):null}const Oo=new Map,lc=new Map,Vre=w.memo(function({src:t,alt:n,onPreview:a,basePath:s}){const l=w.useMemo(()=>Kre(t,s)??t,[t,s]),c=l.startsWith("/api/files/image?"),u=Oo.get(l),m=lc.get(l),[p,h]=w.useState(u??(c?null:l)),[g,v]=w.useState(!!u),[y,k]=w.useState(!!m),[T,C]=w.useState(m??null),[S,E]=w.useState(0),_=w.useRef(0),D=w.useCallback(M=>{lc.set(l,M),C(M),k(!0),v(!1)},[l]),z=w.useCallback(()=>{Oo.delete(l),lc.delete(l),k(!1),C(null),v(!1),h(c?null:`${l}${l.includes("?")?"&":"?"}retry=${Date.now()}`),E(M=>M+1)},[l,c]);return w.useEffect(()=>{if(!c)return;const M=Oo.get(l);if(M){h(M),v(!0),k(!1),C(null);return}const I=lc.get(l);if(I!==void 0){k(!0),C(I),v(!1);return}const U=++_.current;k(!1),C(null),v(!1),h(null),(async()=>{try{const W=await fetch(l,{credentials:"same-origin"});if(U!==_.current)return;if(!W.ok){let ne=`HTTP ${W.status}`;try{const V=await W.json();V.error&&(ne=V.error)}catch{}throw new Error(ne)}const H=await W.blob();if(U!==_.current)return;if(H.size===0)throw new Error("Empty image response");if(H.type&&!H.type.startsWith("image/")&&!H.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${H.type}`);const Y=URL.createObjectURL(H);Oo.set(l,Y),h(Y),v(!0),k(!1),C(null)}catch(W){if(U!==_.current)return;const H=W instanceof Error?W.message:String(W);console.warn("[MarkdownImage] failed to load local image",l,W),D(H)}})()},[c,l,S]),w.useEffect(()=>{if(c)return;const M=lc.get(l);if(M!==void 0){k(!0),C(M),v(!1);return}h(l),v(!!Oo.get(l)),k(!1),C(null)},[l,c,S]),y?i.jsxs("button",{type:"button",onClick:z,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||Oo.set(l,l),v(!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 mw(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function Wre(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 Yre(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 dC({src:e,onClose:t}){const{t:n}=lt("common"),[a,s]=w.useState(null),[l,c]=w.useState(null);Jo(!0),w.useEffect(()=>{const g=v=>{v.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const u=w.useCallback(g=>{s(g),window.setTimeout(()=>s(null),1600)},[]),m=w.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const v=await mw(e),y=await Wre(v);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),u(n("imageCopied"))}catch{u(n("imageCopyFailed"))}finally{c(null)}}},[l,u,e,n]),p=w.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const v=await mw(e),y=URL.createObjectURL(v),k=document.createElement("a");k.href=y,k.download=Yre(e,v),document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(y),u(n("imageDownloaded"))}catch{u(n("imageDownloadFailed"))}finally{c(null)}}},[l,u,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 $r.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 uC(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:s,hostAvailable:l,openRightPanel:c}=e,u=w.useCallback((m,p)=>{const h=ew(p,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){Rae(s?.current??null,h.id);return}if(h.kind==="file"){l&&c?c({kind:"file",path:h.path,title:h.path.split(/[/\\]/).pop()}):Ne.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}gi(h.url)}}},[n,s,l,c]);return w.useMemo(()=>({...$re,img:({src:m,alt:p})=>i.jsx(Vre,{src:m??"",alt:p,onPreview:a,basePath:n},m??""),p:({children:m,node:p})=>{const h=Hre(p);return h?i.jsx(Jae,{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?v=>{v.preventDefault(),v.stopPropagation(),t(g,v)}:void 0,title:g,children:p})}if(m?.startsWith(zm))return i.jsx(yc,{id:m.slice(zm.length)});{const g=m?.match(cC);if(g){const[,v,y]=g;if(v==="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(),st.navigate(se.WORK,{boardType:"workflows"})},title:`workflow: ${y}`,children:[i.jsx("span",{className:"text-[10px]",children:"⚙️"}),i.jsx("span",{children:p})]});const k=tC(v);if(k)return i.jsx(yc,{id:y,type:k,label:p})}}if(m&&Om(m))return i.jsx(yc,{id:m.trim(),label:p});const h=ew(m,n);return h.kind==="fragment"||h.kind==="file"||h.kind==="external"?i.jsx("a",{href:m,className:Tg,onClick:g=>u(g,m),title:h.kind==="fragment"?`#${h.id}`:h.kind==="file"?h.path:h.url,children:p}):i.jsx("a",{href:m,className:Tg,onClick:g=>{Vo()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&g.preventDefault()},children:p})}}),[t,n,a,u])}const pw=[lS,d3,u3],fw=[J3,[x3,{strict:"ignore"}],[z3,{detect:!0,ignoreMissing:!0}]];function Eg(e){if(/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e))return e;const n=Mb(e);return Y3(n)?n:O5(e)}const Qre=/(?:<thinking>| thinking)([\s\S]*?)<\/thinking>/g;function Xre(e){const t=[];let n=e.replace(Qre,(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 Jre(e=640){const[t,n]=w.useState(()=>window.innerWidth<e);return w.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 Zre({content:e,contentRef:t}){const{t:n}=lt("common"),[a,s]=w.useState(!1),[l,c]=w.useState(!1),[u,m]=w.useState(!1),[p,h]=w.useState(null),g=w.useRef(null),v=Jre();w.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=w.useCallback(C=>{h(C),setTimeout(()=>h(null),1500)},[]),k=async()=>{const C=await Rb(e);y(n(C?"markdown.copied":"markdown.failed")),s(!1)},T=async C=>{const S=t.current?.firstElementChild;if(!S)return;const E=eC(),_=Oae(E),D=await Iae(S,C,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),z=n(C==="light"?"markdown.themeLight":"markdown.themeDark");y(D.ok?D.method==="html"?n("markdown.htmlCopied",{theme:z}):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:u?i.jsx(Pae,{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:k,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(v?"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(v?"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(v?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const va=w.memo(function({content:t,className:n="",onMentionClick:a,knownNames:s,basePath:l}){const{thinking:c,rest:u}=Xre(t),m=w.useRef(null),[p,h]=w.useState(null),g=Uc(),v=w.useCallback(T=>{let C=mi(T,$3);return C=mi(C,pae),C=mi(C,jae),C=mi(C,bae),C=mi(C,yae),C=mi(C,S=>fae(S,s)),C=mi(C,U3),C},[s]),y=w.useMemo(()=>v(u),[u,v]),k=uC({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(Zre,{content:t,contentRef:m}),i.jsx("div",{ref:m,children:i.jsx(zae,{resetKeys:[y],fallback:i.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-2 sm:pr-8 text-fg-secondary ${n}`,children:u}),children:i.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-2 sm: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(ng,{remarkPlugins:pw,rehypePlugins:fw,components:k,urlTransform:Eg,children:v(T)})})})]})})(),i.jsx(ng,{remarkPlugins:pw,rehypePlugins:fw,components:k,urlTransform:Eg,children:y})]})})}),p&&i.jsx(dC,{src:p,onClose:()=>h(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&eie(e.knownNames,t.knownNames));function eie(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 mC=Object.freeze(Object.defineProperty({__proto__:null,ImagePreviewModal:dC,MarkdownMessage:va,chatUrlTransform:Eg},Symbol.toStringTag,{value:"Module"})),jg={suppressAdjustUntil:0};function Lc(e=2500){const t=typeof performance<"u"?performance.now():Date.now();jg.suppressAdjustUntil=Math.max(jg.suppressAdjustUntil,t+e)}function Zoe(){return(typeof performance<"u"?performance.now():Date.now())<jg.suppressAdjustUntil}const hw={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:"🔍"}},gw={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 Hs(e){const t=e.includes("__")?e.split("__").pop():e,n=hw[t]??hw[e],a=gw[t]??gw[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 Fs(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function tie(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 Mg(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function bw(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function pC(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 nie(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 _g(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 Db(e){const t=tie(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 fC(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 hC(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 gC={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 aie(e){return!!e&&e in gC}function sl({name:e,size:t=24,className:n=""}){const a=gC[e];return a?i.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":!0,children:a}):null}const yw={"coding-tools":"terminal",markitdown:"file-text","markus-admin-cli":"terminal",codex:"code","team-building":"users","claude-code":"code","skill-building":"wrench","workflow-building":"layers","chrome-devtools":"globe","markus-hub-connector":"link","cursor-agent":"bot","agent-building":"bot","feishu-interaction":"message-square","content-publishing":"edit","research-report":"book-open","daily-digest":"newspaper"},vw={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function lm(e,t){const n=(e||"").toLowerCase();return yw[n]?yw[n]:t&&vw[t]?vw[t]:"layers"}function rie(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 bC(){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 iie(){return i.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>i.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function xw({item:e}){const{t}=lt("common"),n=Hs(e.tool);return i.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[i.jsx(sl,{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(bC,{})]})}function kw({activities:e,isActive:t,persistent:n}){const{t:a}=lt("common"),s=rie(e),[l,c]=w.useState(!1),u=s.length>0,m=u&&s.every(k=>k.status!=="running");if(n&&m){const k=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})}),k>0&&i.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",a("activity.failed",{count:k})]}),!l&&i.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[s.slice(0,5).map(C=>{const S=Hs(C.tool);return i.jsx(sl,{name:S.iconName,size:13,className:`shrink-0 ${C.status==="error"?"text-red-500":"text-green-500"}`},C.key)}),s.length>5&&i.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",s.length-5]})]})]}),l&&i.jsx("div",{className:"mt-2 space-y-0.5",children:s.map((C,S)=>i.jsx(xw,{item:C,idx:S,total:s.length},C.key))})]})}if(!u)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(iie,{})]});const p=s.filter(k=>k.status==="error").length;let h=null;for(let k=s.length-1;k>=0;k--)if(s[k].status==="running"){h=s[k];break}const g=s[s.length-1];let v;if(h){const k=Hs(h.tool);v=`${a(`execution.tools.${k.key}`,{defaultValue:k.label})}…`}else if(t&&m)v=a("activity.writingResponse");else{const k=Hs(g.tool);v=a(`execution.tools.${k.key}`,{defaultValue:k.label})}const y=!!h||t&&m;return i.jsxs("div",{className:"mb-1",children:[i.jsxs("button",{onClick:k=>{k.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:v}),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(bC,{})]}),l&&i.jsx("div",{className:"mt-1 space-y-0.5",children:s.map((k,T)=>i.jsx(xw,{item:k,idx:T,total:s.length},k.key))})]})}const sie={"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"}},Ko=["created","context_injected","running"],oie=new Set(["completed","failed","cancelled","timeout"]),ww={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function lie(e){return sie[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function cie(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 die(e){if(e==="completed"||oie.has(e))return Ko.length;const t=Ko.indexOf(e);return t>=0?t:0}function uie({session:e,className:t}){const n=lie(e.tool),[a,s]=w.useState(!1),[l,c]=w.useState(()=>Date.now()),u=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;w.useEffect(()=>{if(!u)return;const k=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(k)},[u]);const h=w.useMemo(()=>cie(e,l),[e,l]),g=die(e.status),v=e.result?.rawOutput??(p||m?e.result?.summary:void 0),y=u?"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 ${u?"text-brand-500":m?"text-red-500":p?"text-green-500":"text-fg-tertiary"}`,children:ww[e.status]??e.status}),h!=null&&i.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:Fs(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})]}),u&&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:[Ko.map((k,T)=>{const C=g>T||g===T&&!u&&p,S=g===T&&u,E=m&&T===Ko.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:ww[k]}),T<Ko.length-1&&i.jsx("div",{className:`h-px flex-1 ${C?"bg-green-500/50":"bg-border-default/60"}`})]},k)}),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)&&u&&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&&!u&&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"]})]})]}),v&&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:v})]})]})}function mie({label:e}){const{t}=lt("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 Sw=150;function pie({content:e,className:t}){const[n,a]=w.useState(e),s=w.useRef(0),l=w.useRef(null);w.useEffect(()=>{const u=Date.now(),m=u-s.current;return m>=Sw?(s.current=u,a(e)):l.current||(l.current=setTimeout(()=>{s.current=Date.now(),l.current=null,a(e)},Sw-m)),()=>{l.current&&(clearTimeout(l.current),l.current=null)}},[e]);const c=w.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(va,{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 Bm=8e3,Iu=120;function kh({text:e,className:t}){const{t:n}=lt("common"),[a,s]=w.useState(!1),l=e.length>Bm,c=!l||a?e:`${e.slice(0,Bm)}
|
|
@@ -867,7 +867,7 @@ await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).t
|
|
|
867
867
|
|
|
868
868
|
`:"")+E:a.push({id:`cseg_${s}`,sourceType:"chat",sourceId:"",agentId:l,seq:s++,type:"text",content:E,createdAt:v,metadata:{isThinking:!0}})}h=""},k=()=>{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:v,...Object.keys(D).length>0?{metadata:D}:{}})}g=""},T="<think>",C="</think>",S=E=>{let _=0,D=!1;for(;_<E.length;)if(D){const z=E.indexOf(C,_);z===-1?_=E.length:(D=!1,_=z+C.length)}else{const z=E.indexOf(T,_);z===-1?(g+=E.slice(_),_=E.length):(g+=E.slice(_,z),D=!0,_=z+T.length)}};for(const E of e)if(v=p(E),E.type==="tool"){k();const _=E.createdAt&&E.durationMs?new Date(new Date(E.createdAt).getTime()-E.durationMs).toISOString():v;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:v})}else E.thinking&&(k(),h+=E.thinking,y()),S(Lb(E.content).cleaned);return k(),qie(a)}const Ple=w.memo(function({msg:t,isStreaming:n,liveActivities:a,onMentionClick:s,knownNames:l}){const{t:c}=lt(["team","common"]),u=t.isStopped,[m,p]=w.useState(!1),[h,g]=w.useState(null),v=w.useRef(!1),y=w.useCallback(()=>{!t.needsDetail||!t.sessionId||v.current||(v.current=!0,Ne.sessions.getMessageDetail(t.sessionId,t.id).then(({message:W})=>{const H=W.metadata?.segments;H?.length&&g(SC(H))}).catch(()=>{}))},[t.needsDetail,t.sessionId,t.id]);w.useEffect(()=>{m&&y()},[m,y]);const k=h??t.segments,T=W=>W.type==="text"?W.content.length+(W.thinking?.length??0):(W.result?.length??0)+(W.subagentLogs?.length??0)*1e3+(W.liveOutput?.length??0),C=k?k.length+":"+(k.length>0?T(k[k.length-1]):0):"",S=k?k.reduce((W,H)=>W+(H.type==="tool"?H.subagentLogs?.length??0:0),0):0,E=w.useMemo(()=>k&&k.length>0?Mw(k,t.agentId,t.rawCreatedAt):[],[C,S,t.agentId,t.rawCreatedAt]),_=t.committedSegments,D=_?_.length+":"+(_.length>0?T(_[_.length-1]):0):"",z=_?_.reduce((W,H)=>W+(H.type==="tool"?H.subagentLogs?.length??0:0),0):0,M=w.useMemo(()=>n?E:_&&_.length>0?Mw(_,t.agentId,t.rawCreatedAt):E,[n,D,z,t.agentId,t.rawCreatedAt,E]);if(k!==void 0&&k.length>0){const H=k.filter(q=>q.type==="text").map(q=>q.content).join(""),Y=q=>q.replace(/\n*<!--\s*notify_context:\s*[\s\S]*?-->/g,"").replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim()||null,V=(H?Y(H):null)||(t.text?Y(t.text):null),F=EC(M),J=F.some(q=>q.kind==="text"),P=!!(u||t.isError),X=Kie(F,n,P),oe=X>0&&!m?X:0,Ae=Vie(NC(M),c),G=[];for(const q of k){if(q.type!=="tool")continue;const le=fC(q.tool,q.result);if(le){G.push({key:`task-${le.taskId}`,kind:"task",info:le});continue}const L=hC(q.tool,q.result);L&&G.push({key:`req-${L.requirementId}`,kind:"req",info:L})}return i.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[X>0&&i.jsxs("button",{type:"button",onClick:()=>p(q=>!q),"aria-expanded":m,"data-worked-summary":"true",title:Ae,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(jC,{state:"done"})}),i.jsx("span",{className:"relative min-w-0 truncate",children:Ae}),i.jsx("svg",{className:`relative ml-auto w-3 h-3 shrink-0 transition-transform ${m?"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"})})]}),F.slice(oe).map((q,le)=>{const L=le+oe;return q.kind==="text"?i.jsx(va,{content:q.entry.content,onMentionClick:s,knownNames:l},q.key):i.jsx(MC,{entries:q.entries,summary:q.summary,isStreaming:n,isLastBlock:L===F.length-1,hideApprovalCards:!0,reconnecting:!!t.reconnecting,onExpand:y},q.key)}),F.length===0&&n&&i.jsx(kw,{activities:a,isActive:!0}),!J&&V&&i.jsx(va,{content:V,onMentionClick:s,knownNames:l}),G.map(q=>q.kind==="task"?i.jsx(vC,{info:q.info},q.key):i.jsx(xC,{info:q.info},q.key)),!n&&!V&&F.length===0&&G.length===0&&!u&&t.emptyReply===!0&&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&&!k?.some(q=>q.type==="text"&&q.content&&(q.content===t.text||q.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*/,"")})]})]}),u&&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 I=(t.activities?.length??0)>0,U=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)&&i.jsx(kw,{activities:n?a:t.activities??[],isActive:n,persistent:!n&&I}),U?t.isError||U.startsWith("⚠")?i.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:U.replace(/^⚠\s*/,"")}):i.jsx(va,{content:U,onMentionClick:s,knownNames:l}):null,!n&&!U&&!I&&!u&&t.sender==="agent"&&t.emptyReply===!0&&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")})}),u&&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 Wie(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 Yie({approval:e,submitting:t,readOnly:n,onClose:a,onSubmit:s}){const{t:l}=lt(["team","common"]);Jo(!0);const c=w.useMemo(()=>Wie(e),[e]),[u,m]=w.useState(0),[p,h]=w.useState(()=>{if(n&&e.answers&&e.answers.length>0){const z={};for(const M of e.answers)z[M.questionId]={selectedOptionIds:M.selectedOptionIds??[],text:M.text??""};return z}return{}}),g=c[u],v=u===c.length-1,y=c.length>1,k=z=>p[z]??{selectedOptionIds:[],text:""},T=(z,M)=>{h(I=>({...I,[z]:{...k(z),...M}}))},C=(z,M)=>{const I=k(z.id);if(z.allowMultiple){const U=I.selectedOptionIds.includes(M);T(z.id,{selectedOptionIds:U?I.selectedOptionIds.filter(W=>W!==M):[...I.selectedOptionIds,M],text:U?I.text:""})}else{const U=I.selectedOptionIds.includes(M);T(z.id,{selectedOptionIds:U?[]:[M],text:U?I.text:""})}},S=z=>{const M=k(z.id);return z.inputType==="choice"?M.selectedOptionIds.length>0?!0:!!(z.allowFreeform&&M.text.trim()):M.text.trim().length>0},E=c.every(S),_=()=>c.map(z=>{const M=k(z.id),I={questionId:z.id};return M.selectedOptionIds.length>0&&(I.selectedOptionIds=M.selectedOptionIds),M.text.trim()&&(I.text=M.text.trim()),I}),D=()=>{const z=_();let M=!0,I;if(!e.questions?.length&&e.options?.length){const W=z[0];I=W?.selectedOptionIds?.[0]??(W?.text?"custom":void 0),M=I!=="reject"&&I!=="request_changes"}const U=z.map(W=>W.text).filter(Boolean).join(`
|
|
869
869
|
`)||void 0;s({approved:M,comment:U,selectedOption:I,answers:z})};return $r.createPortal(i.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:z=>{z.target===z.currentTarget&&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((z,M)=>i.jsx("button",{onClick:()=>m(M),className:`h-1.5 flex-1 rounded-full transition-colors ${M===u?"bg-brand-500":S(z)?"bg-green-500/60":"bg-border-default"}`,title:`${M+1}. ${z.prompt.slice(0,40)}`},z.id))}),y&&i.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:u+1,total:c.length,defaultValue:`Question ${u+1} of ${c.length}`})}),i.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:i.jsx(va,{content:g.prompt})}),g.inputType==="choice"&&g.options&&i.jsx("div",{className:"space-y-2",children:g.options.map((z,M)=>{const I=k(g.id).selectedOptionIds.includes(z.id);return i.jsxs("button",{onClick:n?void 0:()=>C(g,z.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(va,{content:z.label}),z.description&&i.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:i.jsx(va,{content:z.description})})]})]},z.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||k(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:k(g.id).text,onChange:z=>{const M=z.target.value;T(g.id,{text:M,selectedOptionIds:M.trim()&&g.inputType==="choice"?[]:k(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&&u>0&&i.jsx("button",{onClick:()=>m(z=>Math.max(0,z-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("team:userInput.previous",{defaultValue:"Previous"})})}),i.jsx("div",{className:"flex items-center gap-2",children:y&&!v?i.jsx("button",{disabled:!n&&!S(g),onClick:()=>m(z=>Math.min(c.length-1,z+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:l("team:userInput.next",{defaultValue:"Next"})}):n?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 Dg=6e4,_C=60*Dg,Qie=24*_C;function Po(e,t){const n=new Date(e).getTime();if(!Number.isFinite(n))return"";const a=Date.now()-n;if(a<Dg)return t("common:time.now");const s=Math.floor(a/Dg);if(s<60)return t("common:time.minutesAgo",{count:s});const l=Math.floor(a/_C);return l<24?t("common:time.hoursAgo",{count:l}):t("common:time.daysAgo",{count:Math.floor(a/Qie)})}function zle(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 Pu(e){return Array.isArray(e.questions)&&e.questions.length>0}const zu={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},zo={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"},_w={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"},Rw="markus:template-updates-ack";let wh=!1,Bu=null;function Xie(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function Dw(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 Hu(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 RC(e){const t=e.metadata;if(!(!t||typeof t.i18n!="object"||!t.i18n))return t.i18n}function Jie(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function Iw(e,t){const n=RC(e);if(!n?.titleKey)return e.title;const a={...n.titleParams??{}};return t(`team:${n.titleKey}`,{...a,defaultValue:e.title})}function Lw(e,t){const n=RC(e);if(!n?.bodyKey)return e.body;const a={};for(const[s,l]of Object.entries(n.bodyParams??{}))if(s==="priority")a[s]=t(`common:priority.${l}`,{defaultValue:l});else if(s==="status"||s==="statusKey"){const c=Jie(l);a[s]=t(`common:status.${l}`,{defaultValue:c===l?l:t(`common:status.${c}`,{defaultValue:l})})}else a[s]=l;return t(`team:${n.bodyKey}`,{...a,defaultValue:e.body})}function $u(e){return e==="approved"?{dot:"bg-green-500",text:"text-green-500"}:e==="cancelled"||e==="expired"?{dot:"bg-gray-400",text:"text-fg-muted"}:{dot:"bg-red-500",text:"text-red-500"}}function Ow(e,t){return t(`common:approvalStatus.${e}`,{defaultValue:e})}function Sh(){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 Zie({collapsed:e,userId:t,embeddedMode:n,onClose:a,sidebarMode:s,isActive:l,label:c,iconPath:u}){const{t:m}=lt(["team","common"]),[p,h]=w.useState(!1),[g,v]=w.useState("approvals"),[y,k]=w.useState([]),[T,C]=w.useState([]),[S,E]=w.useState(null),[_,D]=w.useState(null),[z,M]=w.useState(null),[I,U]=w.useState({}),[W,H]=w.useState(0),[Y,ne]=w.useState([]),V=w.useRef(null),F=w.useRef(null),[J,P]=w.useState({top:0,left:0,width:448,maxHeight:576}),X=w.useRef(null),oe=w.useRef(!1),[Ae,G]=w.useState(!0),[q,le]=w.useState(!1),L=w.useRef(null),Ce=w.useRef("approvals"),Ge=w.useRef(g);Ge.current=g,w.useEffect(()=>{if(n)return cG(se.NOTIFICATIONS,()=>Ge.current==="approvals"?"approvals":"notifications")},[n]),w.useEffect(()=>bG((Q,be)=>{if(Q!==se.NOTIFICATIONS)return;const ke=be==="approvals"?"approvals":"notifications";v(ke),Ce.current=ke}),[]);const[Ve,Qe]=w.useState(!1),[it,mt]=w.useState("unread"),Tt=30,Dt=100,Pt=w.useCallback(async()=>{try{di("/approvals"),di("/notifications");const[Q,be,ke]=await Promise.all([Ne.notifications.list(t,!1,{limit:Tt,offset:0}),Ne.approvals.list(),Ne.notifications.list(t,!0,{limit:Dt,offset:0})]);k(Q.notifications),ne(ke.notifications);const gt=Q.unreadCount??Q.notifications.filter(ut=>!ut.read).length;if(H(gt),G(Q.totalCount!=null?Q.notifications.length<Q.totalCount:Q.notifications.length>=Tt),C(be.approvals),!oe.current){const ut=be.approvals.filter(bt=>bt.status==="pending").length;X.current=ut,oe.current=!0}}catch{}},[t]),fn=w.useCallback(async()=>{if(!(q||!Ae)){le(!0);try{const Q=await Ne.notifications.list(t,!1,{limit:Tt,offset:y.length});Q.notifications.length>0&&k(be=>[...be,...Q.notifications.filter(ke=>!be.some(gt=>gt.id===ke.id))]),G(Q.totalCount!=null?y.length+Q.notifications.length<Q.totalCount:Q.notifications.length>=Tt)}catch{}le(!1)}},[t,y.length,q,Ae]),Nt=w.useCallback(Q=>{const be=Q.detail;if(!be)return;const{taskId:ke,requirementId:gt}=be;!ke&&!gt||k(ut=>{const bt=ut.filter(xt=>!xt.read&&(ke&&xt.metadata?.taskId===ke||gt&&xt.metadata?.requirementId===gt));if(bt.length===0)return ut;for(const xt of bt)Ne.notifications.markRead(xt.id).catch(()=>{});H(xt=>Math.max(0,xt-bt.length));const Mt=new Set(bt.map(xt=>xt.id));return ne(xt=>xt.filter(Bt=>!Mt.has(Bt.id))),ut.map(xt=>bt.some(Bt=>Bt.id===xt.id)?{...xt,read:!0}:xt)})},[]),Ue=w.useRef(y);Ue.current=y;const ht=w.useCallback(async()=>{if(!Ue.current.some(be=>!be.read&&be.type==="system"&&be.metadata?.creditExhausted))try{await Ne.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),Pt(),Sh()}catch{}},[Pt,m]),Lt=w.useCallback(async()=>{if(!wh){wh=!0;try{const{updates:Q}=await Ne.skills.updates();if(!Q.length)return;const be=Xie(Q);try{if(localStorage.getItem(Rw)===be)return}catch{}if(Bu===be||Ue.current.some(gt=>!gt.read&&Dw(gt,be)))return;try{const ut=(await Ne.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(bt=>Dw(bt,be)).sort((bt,Mt)=>new Date(Mt.createdAt).getTime()-new Date(bt.createdAt).getTime());if(ut.length>0){for(const bt of ut.slice(1))Ne.notifications.markRead(bt.id).catch(()=>{});ut.length>1&&Pt(),Bu=be;return}}catch{}Bu=be,await Ne.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:Q.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:be,count:Q.length,skills:Q.map(gt=>gt.name)}}),Pt(),Sh()}catch{Bu=null}finally{wh=!1}}},[Pt,m,t]);w.useEffect(()=>{Pt();const Q=setInterval(Pt,6e4);let be=null;const ke=()=>{be||(be=setTimeout(()=>{be=null,Pt()},400))},gt=()=>ke(),ut=()=>{h(!0),Pt()};window.addEventListener("markus:notifications-changed",gt),window.addEventListener("markus:mark-read-by-ref",Nt),window.addEventListener("markus:open-notifications",ut),window.addEventListener("markus:credit-exhausted",ht);const bt=kr.on("notification",ke),Mt=kr.on("approval:requested",ke),xt=kr.on("approval:resolved",ke);return()=>{clearInterval(Q),be&&clearTimeout(be),window.removeEventListener("markus:notifications-changed",gt),window.removeEventListener("markus:mark-read-by-ref",Nt),window.removeEventListener("markus:open-notifications",ut),window.removeEventListener("markus:credit-exhausted",ht),bt(),Mt(),xt()}},[Pt,Nt,ht]),w.useEffect(()=>{Lt();const Q=setInterval(()=>{Lt()},5*6e4),be=()=>{Lt()};return window.addEventListener("markus:data-changed",be),()=>{clearInterval(Q),window.removeEventListener("markus:data-changed",be)}},[t]);const wt=w.useCallback(()=>{if(!V.current)return;const Q=V.current.getBoundingClientRect(),be=window.innerWidth,ke=window.innerHeight,gt=Math.min(448,be-16),ut=Math.min(576,ke-16);let bt=Q.right+8,Mt=Q.top;bt+gt>be-8&&(bt=Math.max(8,be-gt-8)),Mt+ut>ke-8&&(Mt=Math.max(8,ke-ut-8)),P({top:Mt,left:bt,width:gt,maxHeight:ut})},[]);w.useLayoutEffect(()=>{p&&wt()},[p,wt]),w.useEffect(()=>{if(p)return window.addEventListener("resize",wt),()=>window.removeEventListener("resize",wt)},[p,wt]),w.useEffect(()=>{if(!p)return;const Q=be=>{V.current?.contains(be.target)||F.current?.contains(be.target)||h(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[p]),w.useEffect(()=>{if(!p)return;mt("unread");const Q=T.some(ke=>ke.status==="pending"),be=y.some(ke=>!ke.read);v(Q&&!be?"approvals":!Q&&be?"notifications":Ce.current)},[p]);const Jt=new Set(T.filter(Q=>Q.status==="pending").map(Q=>Q.id)),ce=new Set(T.map(Q=>Q.id)),nt=Q=>Q.type==="approval_request"&&!!Q.metadata?.approvalId&&ce.has(Q.metadata.approvalId),et=Q=>[...Q].sort((be,ke)=>new Date(ke.createdAt).getTime()-new Date(be.createdAt).getTime()),xe=y.filter(Q=>!nt(Q)),_e=Y.filter(Q=>!nt(Q)),Ie=et(xe),re=et(_e),$=it==="all"?Ie:re,ie=m(it==="unread"?"team:notifications.noUnread":"team:notifications.noNotifications"),ge=re.length,De=Jt.size,Pe=ge+De;w.useEffect(()=>{X.current!==null&&De>X.current&&Sh(),X.current=De},[De]);const pe=async Q=>{await Ne.notifications.markRead(Q),k(be=>be.map(ke=>ke.id===Q?{...ke,read:!0}:ke)),ne(be=>be.filter(ke=>ke.id!==Q)),H(be=>Math.max(0,be-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},fe=Q=>{const be=Q.metadata??{},ke=Q.actionType,gt=Q.actionTarget;if(ke==="open_chat"&>)try{const ut=typeof gt=="string"?JSON.parse(gt):gt;if(ut.agentId){const bt={agentId:ut.agentId};ut.sessionId&&(bt.sessionId=ut.sessionId),st.navigate(se.TEAM,bt);return}}catch{}if(ke==="navigate"&>)try{const ut=typeof gt=="string"?JSON.parse(gt):gt;if(ut.path){if(ut.path.startsWith("/team")){const bt={},Mt=new URLSearchParams(ut.path.split("?")[1]||"");for(const[xt,Bt]of Mt.entries())bt[xt]=Bt;st.navigate(se.TEAM,bt);return}if(ut.path.startsWith("/work")){const bt={},Mt=new URLSearchParams(ut.path.split("?")[1]||"");for(const[xt,Bt]of Mt.entries())bt[xt]=Bt;st.navigate(se.WORK,bt);return}}}catch{}switch(Q.type){case"approval_request":{const ut=be.approvalId,bt=ut?T.find(cn=>cn.id===ut):void 0;if(bt&&Pu(bt)){D(bt);break}const Mt=bt?.details?.taskId??be.taskId,xt=bt?.details?.requirementId??be.requirementId,Bt=bt?.details?.agentId??bt?.agentId;Mt?st.navigate(se.WORK,{openTask:Mt}):xt?st.navigate(se.WORK,{openRequirement:xt}):Bt?st.navigate(se.TEAM,{agentId:Bt}):st.navigate(se.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":be.taskId?st.navigate(se.WORK,{openTask:be.taskId}):st.navigate(se.WORK);break;case"requirement_created":case"requirement_decision":be.requirementId?st.navigate(se.WORK,{openRequirement:be.requirementId}):st.navigate(se.WORK);break;case"agent_report":case"system":{if(be.creditExhausted){Qe(!0);return}if(be.templateUpdates){const ut=be.templateUpdatesFingerprint;if(ut)try{localStorage.setItem(Rw,ut)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),st.navigate(se.STORE);return}if(be.agentId){const ut={agentId:be.agentId};be.sessionId&&(ut.sessionId=be.sessionId),st.navigate(se.TEAM,ut)}else st.navigate(se.TEAM);break}case"direct_message":{const ut=be.senderId;ut?st.navigate(se.TEAM,{dm:ut}):st.navigate(se.TEAM);break}case"group_message":{const ut=be.channel;ut?st.navigate(se.TEAM,{channel:ut}):st.navigate(se.TEAM);break}default:be.taskId?st.navigate(se.WORK,{openTask:be.taskId}):be.requirementId?st.navigate(se.WORK,{openRequirement:be.requirementId}):be.projectId?st.navigate(se.WORK,{projectId:be.projectId}):be.agentId&&st.navigate(se.TEAM,{agentId:be.agentId});break}},$e=async Q=>{const be=Q.metadata??{},ke=Q.actionType,gt=Q.type==="agent_report"&&!be.creditExhausted&&!be.templateUpdates&&(ke==="open_chat"||!!be.agentId&&ke!=="navigate");!Q.read&&!gt&&pe(Q.id);const ut=be.taskId,bt=be.requirementId;if(!gt&&(ut||bt)){const Mt=y.filter(xt=>xt.id!==Q.id&&!xt.read&&(ut&&xt.metadata?.taskId===ut||bt&&xt.metadata?.requirementId===bt));for(const xt of Mt)pe(xt.id)}fe(Q)},Xe=async(Q,be,ke,gt,ut)=>{E(Q);try{const{approval:bt}=await Ne.approvals.respond(Q,be,t,ke,gt,ut);C(cn=>cn.map(tn=>tn.id===Q?bt:tn)),D(null),M(null),U(cn=>{const tn={...cn};return delete tn[Q],tn});const Mt=bt.details?.taskId,xt=bt.details?.requirementId,Bt=y.filter(cn=>!cn.read&&(cn.type==="approval_request"&&cn.metadata?.approvalId===Q||Mt&&cn.metadata?.taskId===Mt||xt&&cn.metadata?.requirementId===xt));if(Bt.length>0){for(const tn of Bt)Ne.notifications.markRead(tn.id).catch(()=>{});const cn=new Set(Bt.map(tn=>tn.id));k(tn=>tn.map(he=>cn.has(he.id)?{...he,read:!0}:he)),H(tn=>Math.max(0,tn-Bt.length))}di("/approvals"),di("/notifications"),di("/tasks"),di("/taskboard"),di("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Pt(),800)}catch{}E(null)},Je=async()=>{try{if(!t)return;await Ne.notifications.markAllRead(t),k(Q=>Q.map(be=>({...be,read:!0}))),ne([]),H(0),di("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const Q=xe.filter(be=>!be.read);await Promise.all(Q.map(be=>Ne.notifications.markRead(be.id))),k(be=>be.map(ke=>({...ke,read:!0}))),ne([]),H(0),di("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Se=Q=>{const be=Q.details?.subType;return be==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):be==="requirement"||Q.details?.requirementId?m("team:notifications.approvalType.requirement"):be==="task_review"?m("team:notifications.approvalType.taskReview"):be==="task"||Q.details?.taskId?m("team:notifications.approvalType.task"):Q.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},Te=Q=>{const be=Q.direction??_f(Q.id);return be==="approve"?m("team:notifications.optionLabels.approve",{defaultValue:Q.label}):be==="request_changes"?m("team:notifications.optionLabels.requestChanges",{defaultValue:Q.label}):be==="reject"?m("team:notifications.optionLabels.reject",{defaultValue:Q.label}):Q.label},Me=Q=>{const be=Q.details??{},ke=be.subType,gt=be.priority,ut=gt?m(`common:priority.${gt}`,{defaultValue:gt}):"";if(ke==="requirement")return m("team:notifications.approvalDesc.requirementProposed",{agentName:Q.agentName,title:Q.title,priority:ut,defaultValue:Q.description});if(ke==="requirement_resubmit")return m("team:notifications.approvalDesc.requirementResubmitted",{agentName:Q.agentName,title:Q.title,priority:ut,defaultValue:Q.description});if(ke==="task")return m("team:notifications.approvalDesc.taskCreate",{agentName:Q.agentName,title:Q.title,priority:ut,defaultValue:Q.description});if(ke==="task_review"){const bt=Q.description.indexOf(`
|
|
870
|
-
`),Mt=bt===-1?"":Q.description.slice(bt);return m("team:notifications.approvalDesc.taskReview",{title:Q.title,tail:Mt,defaultValue:Q.description})}return Q.description},at=Q=>{const be=[];be.push(Q.agentName);const ke=Q.details?.taskTitle,gt=Q.details?.taskId;ke?be.push(ke):gt&&be.push(`${m("team:notifications.approvalType.task")} ${gt.slice(0,8)}`);const ut=Q.details?.requirementId;return ut&&!gt&&be.push(`${m("team:notifications.approvalType.requirement")} ${ut.slice(0,8)}`),be.join(" · ")},yt=[...T].sort((Q,be)=>new Date(be.requestedAt).getTime()-new Date(Q.requestedAt).getTime()),pt=yt.filter(Q=>Q.status==="pending"),Rt=yt.filter(Q=>Q.status!=="pending"),Z=Q=>{const be=Q.details?.taskId,ke=Q.details?.requirementId,gt=Q.details?.agentId??Q.agentId;be?st.navigate(se.WORK,{openTask:be}):ke?st.navigate(se.WORK,{openRequirement:ke}):gt?st.navigate(se.TEAM,{agentId:gt}):st.navigate(se.WORK)},je=()=>{h(!1),a?.()},Be=Q=>i.jsxs("button",{disabled:S===Q.id,onClick:()=>D(Q),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"}),Q.questions&&Q.questions.length>1?` (${Q.questions.length})`:""]}),vt=_?i.jsx(Yie,{approval:_,submitting:S===_.id,readOnly:_.status!=="pending",onClose:()=>D(null),onSubmit:Q=>Xe(_.id,Q.approved,Q.comment,Q.selectedOption,Q.answers)}):null,en=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(Q=>i.jsx("button",{onClick:()=>mt(Q),"aria-pressed":it===Q,title:Q==="unread"?m("team:notifications.noUnread"):void 0,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${it===Q?"bg-surface-base text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:Q==="unread"?m("team:notifications.filterUnread")+(ge>0?` (${ge})`:""):m("team:notifications.filterAll")},Q))}),W>0&&i.jsx("button",{onClick:Je,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors shrink-0",children:m("team:notifications.markAllRead")})]}),Zt=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[i.jsxs("button",{onClick:()=>{v("approvals"),Ce.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.approvals"),De>0?` (${De})`:""]}),i.jsxs("button",{onClick:()=>{v("notifications"),Ce.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),ge>0?` (${ge})`:""]}),i.jsx("button",{onClick:je,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"&&en,i.jsxs("div",{ref:L,className:"flex-1 overflow-y-auto",onScroll:Q=>{if(g!=="notifications"||!Ae||q)return;const be=Q.currentTarget;be.scrollTop+be.clientHeight>=be.scrollHeight-80&&fn()},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:[pt.map(Q=>{const be=Q.details?.command,ke=be?Me(Q).replace(/\s*Command:.*$/,""):Me(Q);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:()=>Z(Q),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:zo.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Se(Q)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Se(Q)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Q.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Po(Q.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:Q.agentName})]})]}),i.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:i.jsx(va,{content:ke,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),be&&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:be})]}),(()=>{if(Pu(Q))return Be(Q);const gt=Q.details?.subType,ut=gt==="task"||gt==="requirement"||gt==="requirement_resubmit",bt=Q.options&&Q.options.length>0,Mt=(I[Q.id]??"").trim();if(bt){const xt=Te;return i.jsxs("div",{className:"space-y-1.5",children:[Q.options.map((Bt,cn)=>i.jsxs("button",{disabled:S===Q.id,onClick:()=>Xe(Q.id,_f(Bt.id)==="approve",Mt||void 0,Bt.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 ${Bt.id==="reject"||Bt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Bt.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+cn)}),xt(Bt)]},Bt.id)),i.jsxs("div",{className:"flex gap-1.5 mt-1",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:I[Q.id]??"",onChange:Bt=>U(cn=>({...cn,[Q.id]:Bt.target.value})),onKeyDown:Bt=>{Bt.key==="Enter"&&(I[Q.id]??"").trim()&&Xe(Q.id,!0,(I[Q.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===Q.id||!(I[Q.id]??"").trim(),onClick:()=>Xe(Q.id,!0,(I[Q.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 ut?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{disabled:S===Q.id,onClick:()=>Xe(Q.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===Q.id,onClick:()=>Xe(Q.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")]}),z!==Q.id&&i.jsxs("button",{disabled:S===Q.id,onClick:()=>M(Q.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")]})]}),z===Q.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[Q.id]??"",onChange:xt=>U(Bt=>({...Bt,[Q.id]:xt.target.value})),onKeyDown:xt=>{xt.key==="Enter"&&(I[Q.id]??"").trim()&&Xe(Q.id,!1,(I[Q.id]??"").trim(),"request_changes"),xt.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===Q.id||!(I[Q.id]??"").trim(),onClick:()=>Xe(Q.id,!1,(I[Q.id]??"").trim(),"request_changes"),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[Q.id]??"",onChange:xt=>U(Bt=>({...Bt,[Q.id]:xt.target.value})),onKeyDown:xt=>{xt.key==="Enter"&&Xe(Q.id,!0,Mt||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===Q.id,onClick:()=>Xe(Q.id,!0,Mt||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===Q.id,onClick:()=>Xe(Q.id,!1,Mt||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")})]})]})})()]},Q.id)}),Rt.length>0&&i.jsxs(i.Fragment,{children:[pt.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")}),Rt.slice(0,50).map(Q=>i.jsxs("button",{onClick:()=>Pu(Q)?D(Q):Z(Q),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${$u(Q.status).dot}`}),Se(Q)&&i.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Se(Q)}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:Q.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${$u(Q.status).text}`,children:Ow(Q.status,m)})]}),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:at(Q)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Po(Q.respondedAt??Q.requestedAt,m)})]}),Q.responseComment&&i.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",Q.responseComment,"”"]})]},Q.id))]})]})),g==="notifications"&&($.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:ie}):i.jsxs("div",{className:"divide-y divide-border-default/50",children:[$.map(Q=>{const be=_w[Q.type]??"text-fg-tertiary";return i.jsxs("div",{role:"button",tabIndex:0,onClick:()=>$e(Q),onKeyDown:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),$e(Q))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${Q.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:be,children:i.jsx("path",{d:zo[Q.type]??zo.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!Q.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${zu[Q.priority]??zu.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Iw(Q,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(va,{content:Lw(Q,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:Po(Q.createdAt,m)}),Hu(Q,m)&&i.jsx("span",{className:`text-[10px] font-medium ${be}`,children:Hu(Q,m)})]})]})]},Q.id)}),q&&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"})]})})]}))]})]}),dt=w.useCallback(Q=>{Q?.mute&&Pie()},[]),rt=w.useCallback(Q=>{dt(Q),Qe(!1)},[dt]),jt=Ve?i.jsx(wa,{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:Q=>{rt(Q),st.navigate(se.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:Q=>{const be=`${ot.getUrl().replace(/\/$/,"")}/settings?tab=billing`;rt(Q),gi(be)}}):null;if(n){const Q=["approvals","notifications"],be=Q.indexOf(g);return i.jsxs(i.Fragment,{children:[jt,i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[vt,i.jsx("div",{className:"flex border-b border-border-default shrink-0",children:Q.map(ke=>i.jsx("button",{onClick:()=>v(ke),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===ke?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:ke==="approvals"?i.jsxs(i.Fragment,{children:[m("team:notifications.approvals"),De>0?` (${De})`:""]}):i.jsxs(i.Fragment,{children:[m("team:notifications.notifications"),ge>0?` (${ge})`:""]})},ke))}),g==="notifications"&&en,i.jsx("div",{className:"flex-1 overflow-hidden relative",children:i.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${be*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:[pt.map(ke=>{const gt=ke.details?.command,ut=gt?Me(ke).replace(/\s*Command:.*$/,""):Me(ke);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:()=>Z(ke),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:zo.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Se(ke)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Se(ke)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:ke.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Po(ke.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:ke.agentName})]})]}),i.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:i.jsx(va,{content:ut,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),gt&&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:gt})]}),(()=>{if(Pu(ke))return Be(ke);const bt=ke.details?.subType,Mt=bt==="task"||bt==="requirement"||bt==="requirement_resubmit",xt=ke.options&&ke.options.length>0,Bt=(I[ke.id]??"").trim();if(xt){const cn=Te;return i.jsxs("div",{className:"space-y-1.5",children:[ke.options.map((tn,he)=>i.jsxs("button",{disabled:S===ke.id,onClick:()=>Xe(ke.id,_f(tn.id)==="approve",Bt||void 0,tn.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 ${tn.id==="reject"||tn.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:tn.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+he)}),cn(tn)]},tn.id)),i.jsxs("div",{className:"flex gap-1.5 mt-1",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:I[ke.id]??"",onChange:tn=>U(he=>({...he,[ke.id]:tn.target.value})),onKeyDown:tn=>{tn.key==="Enter"&&(I[ke.id]??"").trim()&&Xe(ke.id,!0,(I[ke.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===ke.id||!(I[ke.id]??"").trim(),onClick:()=>Xe(ke.id,!0,(I[ke.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 Mt?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{disabled:S===ke.id,onClick:()=>Xe(ke.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===ke.id,onClick:()=>Xe(ke.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")]}),z!==ke.id&&i.jsxs("button",{disabled:S===ke.id,onClick:()=>M(ke.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")]})]}),z===ke.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[ke.id]??"",onChange:cn=>U(tn=>({...tn,[ke.id]:cn.target.value})),onKeyDown:cn=>{cn.key==="Enter"&&(I[ke.id]??"").trim()&&Xe(ke.id,!1,(I[ke.id]??"").trim(),"request_changes"),cn.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===ke.id||!(I[ke.id]??"").trim(),onClick:()=>Xe(ke.id,!1,(I[ke.id]??"").trim(),"request_changes"),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[ke.id]??"",onChange:cn=>U(tn=>({...tn,[ke.id]:cn.target.value})),onKeyDown:cn=>{cn.key==="Enter"&&Xe(ke.id,!0,Bt||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===ke.id,onClick:()=>Xe(ke.id,!0,Bt||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===ke.id,onClick:()=>Xe(ke.id,!1,Bt||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")})]})]})})()]},ke.id)}),Rt.length>0&&i.jsxs(i.Fragment,{children:[pt.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")}),Rt.slice(0,50).map(ke=>i.jsxs("button",{onClick:()=>Z(ke),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 ${$u(ke.status).dot}`}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:ke.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${$u(ke.status).text}`,children:Ow(ke.status,m)})]}),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:at(ke)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Po(ke.respondedAt??ke.requestedAt,m)})]})]},ke.id))]})]})}),i.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:$.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:ie}):i.jsx("div",{className:"divide-y divide-border-default/50",children:$.slice(0,it==="unread"?Dt:50).map(ke=>{const gt=_w[ke.type]??"text-fg-tertiary";return i.jsxs("button",{onClick:()=>$e(ke),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${ke.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:gt,children:i.jsx("path",{d:zo[ke.type]??zo.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!ke.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${zu[ke.priority]??zu.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Iw(ke,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(va,{content:Lw(ke,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:Po(ke.createdAt,m)}),Hu(ke,m)&&i.jsx("span",{className:`text-[10px] font-medium ${gt}`,children:Hu(ke,m)})]})]})]},ke.id)})})})]})})]})]})}if(s){const Q=u||"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:[vt,i.jsxs("button",{ref:V,onClick:()=>{h(!p),p||Pt()},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:Q})}),e?i.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):i.jsx("span",{className:"truncate",children:c}),Pe>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:Pe>99?m("common:badgeOverLimit"):Pe})]}),p&&$r.createPortal(i.jsx("div",{ref:F,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:J.top,left:J.left,width:J.width,maxHeight:J.maxHeight},children:Zt}),document.body),jt]})}return i.jsxs(i.Fragment,{children:[vt,i.jsxs("button",{ref:V,onClick:()=>{h(!p),p||Pt()},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"})]}),Pe>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:Pe>99?m("common:badgeOverLimit"):Pe})]}),p&&$r.createPortal(i.jsx("div",{ref:F,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:J.top,left:J.left,width:J.width,maxHeight:J.maxHeight},children:Zt}),document.body),jt]})}function qu({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 Ch=200;function ese({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:a=!1,collapsed:s=!1,showVersion:l=!1}){const{t:c}=lt(["nav","common"]),[u,m]=w.useState(!1),[p,h]=w.useState(!1),[g,v]=w.useState({top:0,left:0}),y=w.useRef(null),k=w.useRef(null),{connected:T,user:C,credits:S,refresh:E}=U4(u),_=w.useCallback(()=>{if(!y.current)return;const ne=y.current.getBoundingClientRect(),V=window.innerWidth,F=window.innerHeight,J=k.current?.offsetHeight??220;let P=ne.right+8;P+Ch>V-8&&(P=Math.max(8,ne.left-Ch-8));let X=ne.top-J-8;X<8&&(X=Math.min(ne.bottom+8,F-J-8)),v({top:Math.max(8,X),left:P})},[]);w.useLayoutEffect(()=>{if(!u)return;_();const ne=requestAnimationFrame(()=>_());return()=>cancelAnimationFrame(ne)},[u,_,s]),w.useEffect(()=>{if(!u)return;const ne=F=>{const J=F.target;y.current?.contains(J)||k.current?.contains(J)||m(!1)},V=()=>_();return document.addEventListener("mousedown",ne),window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{document.removeEventListener("mousedown",ne),window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[u,_]);const D=e?.name||C?.displayName||C?.username||c("common:userPlaceholder"),z=e?.email||C?.email||"",M=$4(e?.avatarUrl,C?.avatarUrl),I=T?"bg-emerald-500":"bg-fg-muted",U=T?C?.username?c("sidebar.hubConnectedAs",{username:C.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),W=!!(T&&C?.username&&e?.name&&C.username.toLowerCase()!==e.name.toLowerCase()&&C.email?.toLowerCase()!==e.email?.toLowerCase()),H=()=>{m(!1),E({validate:!0}),st.navigate(se.SETTINGS,{tab:"account"})},Y=u&&$r.createPortal(i.jsxs("div",{ref:k,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:Ch},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}),z&&i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:z}),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(qu,{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:H,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:U}),W&&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),st.navigate(se.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(qu,{d:Tc[se.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(qu,{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(qu,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),c("common:signOut")]})]})]}),document.body);return i.jsxs("div",{className:`relative ${s?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[i.jsxs("button",{ref:y,type:"button",onClick:()=>m(ne=>!ne),title:D,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${s?"p-0.5":""}`,children:[i.jsx(ns,{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:U})]}),l&&!s&&i.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.12.0-rc.0"]}),Y,p&&t&&i.jsx(wa,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function tse({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 nse({currentPage:e,onNavigate:t,authUser:n,collapsed:a,onToggleCollapse:s,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:u}){const{t:m}=lt(["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:ZU.map((p,h)=>{const g=E4.filter(y=>y.section===p.key);if(g.length===0)return null;const v=m(`sections.${p.key}`);return i.jsx("div",{children:i.jsxs("div",{className:h>0?"mt-3":"",children:[!a&&v&&i.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:v}),a&&h>0&&i.jsx("div",{className:"my-3"}),g.map(y=>{if(y.id===se.NOTIFICATIONS)return i.jsx(Zie,{sidebarMode:!0,collapsed:a,userId:n?.id,label:m(y.id),iconPath:Tc[y.id],isActive:e===y.id},y.id);const k=e===y.id,T=u&&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":k?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[i.jsx(tse,{d:Tc[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(ese,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const ase=6e4,rse=2e3;let jr={},Ji={};const Ig=new Set,Hm=new Set;let DC=0;const Lg=new Map;let xc=null,Fu=0,cm=null;function Oc(){for(const e of Ig)e()}function Pw(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 ise(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 Ob(e,t){const n=Date.now(),a=Lg.get(e)??0;!t?.force&&n-a<rse||(Lg.set(e,n),e in jr&&(delete jr[e],Oc()),Ne.unread.markRead(e,new Date().toISOString()).catch(()=>{}))}async function Og(){try{const e=await Ne.unread.getCounts(),{counts:t,staleActiveKeys:n}=ise(e.counts??{},Hm);jr=t,Ji=e.sessionAgentMap??{},Oc();for(const a of n)Ob(a)}catch{}}function sse(){xc||(Og(),xc=setInterval(Og,ase),cm=kr.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(Hm.has(t)){Ob(t);return}Date.now()>DC&&(jr[t]=(jr[t]??0)+1,Oc())}}))}function ose(){xc&&(clearInterval(xc),xc=null),cm&&(cm(),cm=null)}function lse(e){const t=e?.enabled??!0,[n,a]=w.useState(jr),[s,l]=w.useState(Ji),c=w.useCallback(async()=>{await Og()},[]),u=w.useCallback(async k=>{const T=new Date().toISOString();delete jr[k],Oc();try{await Ne.unread.markRead(k,T)}catch{}},[]),m=w.useCallback(async()=>{jr={},Oc();try{await Ne.unread.markAllRead()}catch{}},[]),p=w.useCallback(k=>{Hm.add(k)},[]),h=w.useCallback(k=>{Hm.delete(k),DC=Date.now()+150,Lg.delete(k),Ob(k,{force:!0})},[]);w.useEffect(()=>{if(!t)return;Fu++,sse();let k=Ji;const T=()=>{a(C=>Pw(C,jr)?C:{...jr}),k!==Ji&&(k=Ji,l(C=>Pw(C,Ji)?C:{...Ji}))};return Ig.add(T),a({...jr}),l({...Ji}),()=>{Ig.delete(T),Fu--,Fu<=0&&(Fu=0,ose())}},[t]);const g=w.useMemo(()=>Object.values(n).reduce((k,T)=>k+T,0),[n]),v=w.useCallback(k=>n[`session:${k}`]??0,[n]),y=w.useCallback(k=>n[`channel:${k}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:s,getSessionUnread:v,getChannelUnread:y,markRead:u,markAllRead:m,refresh:c,setActiveKey:p,clearActiveKey:h}}function Ble(e,t){return w.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 cse(e){return e.startsWith("channel:dm:a2a:")}function dse(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(cse(a))continue;n+=s}return n}const use=6,mse=56;function pse({currentPage:e,onNavigate:t,userId:n}){const{t:a}=lt("nav"),[s,l]=w.useState(0),[c,u]=w.useState(!1),m=w.useRef(!1),p=w.useCallback(k=>{m.current!==k&&(m.current=k,u(k))},[]);w.useEffect(()=>{let k=window.scrollY,T=0;const C=()=>{T||(T=requestAnimationFrame(()=>{T=0;const S=window.scrollY,E=S-k;if(k=S,S<=mse){p(!1);return}E>use?p(!0):E<-6&&p(!1)}))};return window.addEventListener("scroll",C,{passive:!0}),()=>{window.removeEventListener("scroll",C),T&&cancelAnimationFrame(T)}},[p]),w.useEffect(()=>{p(!1)},[e,p]);const{counts:h,sessionAgentMap:g}=lse({enabled:!0}),v=w.useMemo(()=>dse(h,g),[h,g]),y=w.useCallback(async()=>{try{const k=await Ne.notifications.list(n,!1);l(k.unreadCount??k.notifications.filter(T=>!T.read).length)}catch{}},[n]);return w.useEffect(()=>{y();const k=setInterval(()=>{document.visibilityState==="visible"&&y()},3e4),T=()=>y();return window.addEventListener("markus:notifications-changed",T),()=>{clearInterval(k),window.removeEventListener("markus:notifications-changed",T)}},[y]),i.jsx("nav",{"data-mobile-bottom-nav":!0,className:`fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom transition-transform duration-300 ease-out will-change-transform ${c?"translate-y-[calc(100%+1px)]":"translate-y-0"}`,children:tG.map(k=>{const T=k.group.includes(e),C=k.id===se.NOTIFICATIONS,S=k.id===se.TEAM;return i.jsxs("button",{onClick:()=>t(k.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${T?"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:T?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:i.jsx("path",{d:Tc[k.id]})}),C&&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}),S&&v>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:v>99?"99+":v})]}),i.jsx("span",{className:`text-[10px] leading-tight ${T?"font-semibold":""}`,children:a(k.id)})]},k.id)})})}const $m=new Map;function js(e,t){$m.has(e)||$m.set(e,t().catch(()=>{}))}function Os(e){const t=$m.get(e);return $m.delete(e),t}const Ka={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},$s={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 ol(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function IC(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 fse={agent:258,team:205,skill:32,connector:162};function Pb(e,t){const n=fse[e],a=IC(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 zw=["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 LC(e){return zw[IC(e+"g")%zw.length]}function OC(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 hse(e){return!e||OC(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function gse(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 Fo(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 Bw(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const Hw={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"}},bse=["development","devops","management","productivity","browser","custom","general"],yse=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],vse={shell:{icon:">",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"},file:{icon:"◫",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"},network:{icon:"◎",color:"bg-purple-500/15 text-purple-400 border-purple-500/30"},browser:{icon:"◉",color:"bg-brand-500/15 text-brand-400 border-brand-500/30"}};function Ah({value:e,onChange:t,renderAs:n="span",className:a,editClassName:s,placeholder:l,multiline:c,readOnly:u}){const[m,p]=w.useState(!1),[h,g]=w.useState(e),v=w.useRef(null);if(w.useEffect(()=>{g(e)},[e]),w.useEffect(()=>{m&&v.current?.focus()},[m]),u){const _=e||l,z=`${a??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?i.jsx("h1",{className:z,children:_}):n==="p"?i.jsx("p",{className:z,children:_}):i.jsx("span",{className:z,children:_})}const y=()=>{p(!1),h!==e&&t(h)},k=()=>{g(e),p(!1)},T=_=>{_.key==="Escape"&&k(),_.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:v,value:h,onChange:D=>g(D.target.value),onBlur:y,onKeyDown:T,className:`${_} resize-y min-h-[60px]`,placeholder:l}):i.jsx("input",{ref:v,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 xse({value:e,options:t,onChange:n,className:a,readOnly:s}){const[l,c]=w.useState(!1),[u,m]=w.useState(e),p=w.useRef(null),h=w.useRef(null);if(w.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(u.toLowerCase())),v=y=>{const k=y.trim();k&&k!==e&&n(k),c(!1)};return l?i.jsxs("div",{ref:h,className:"relative inline-block",children:[i.jsx("input",{ref:p,value:u,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),v(u)):y.key==="Escape"&&c(!1)},onBlur:y=>{h.current?.contains(y.relatedTarget)||v(u)},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:k=>{k.preventDefault(),v(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 kse({tags:e,onChange:t,readOnly:n}){const{t:a}=lt(["builder"]),[s,l]=w.useState(!1),[c,u]=w.useState(""),m=w.useRef(null);if(w.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]),u("")}else h.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):h.key==="Escape"&&(l(!1),u(""))};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=>u(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 Pg({content:e}){const t=[lS,d3,u3],n=[J3,[x3,{strict:"ignore"}],[z3,{detect:!0,ignoreMissing:!0}]],a=uC({}),s=w.useMemo(()=>{let l=mi(e,$3);return l=mi(l,U3),l},[e]);return i.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
870
|
+
`),Mt=bt===-1?"":Q.description.slice(bt);return m("team:notifications.approvalDesc.taskReview",{title:Q.title,tail:Mt,defaultValue:Q.description})}return Q.description},at=Q=>{const be=[];be.push(Q.agentName);const ke=Q.details?.taskTitle,gt=Q.details?.taskId;ke?be.push(ke):gt&&be.push(`${m("team:notifications.approvalType.task")} ${gt.slice(0,8)}`);const ut=Q.details?.requirementId;return ut&&!gt&&be.push(`${m("team:notifications.approvalType.requirement")} ${ut.slice(0,8)}`),be.join(" · ")},yt=[...T].sort((Q,be)=>new Date(be.requestedAt).getTime()-new Date(Q.requestedAt).getTime()),pt=yt.filter(Q=>Q.status==="pending"),Rt=yt.filter(Q=>Q.status!=="pending"),Z=Q=>{const be=Q.details?.taskId,ke=Q.details?.requirementId,gt=Q.details?.agentId??Q.agentId;be?st.navigate(se.WORK,{openTask:be}):ke?st.navigate(se.WORK,{openRequirement:ke}):gt?st.navigate(se.TEAM,{agentId:gt}):st.navigate(se.WORK)},je=()=>{h(!1),a?.()},Be=Q=>i.jsxs("button",{disabled:S===Q.id,onClick:()=>D(Q),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"}),Q.questions&&Q.questions.length>1?` (${Q.questions.length})`:""]}),vt=_?i.jsx(Yie,{approval:_,submitting:S===_.id,readOnly:_.status!=="pending",onClose:()=>D(null),onSubmit:Q=>Xe(_.id,Q.approved,Q.comment,Q.selectedOption,Q.answers)}):null,en=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(Q=>i.jsx("button",{onClick:()=>mt(Q),"aria-pressed":it===Q,title:Q==="unread"?m("team:notifications.noUnread"):void 0,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${it===Q?"bg-surface-base text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:Q==="unread"?m("team:notifications.filterUnread")+(ge>0?` (${ge})`:""):m("team:notifications.filterAll")},Q))}),W>0&&i.jsx("button",{onClick:Je,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors shrink-0",children:m("team:notifications.markAllRead")})]}),Zt=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[i.jsxs("button",{onClick:()=>{v("approvals"),Ce.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.approvals"),De>0?` (${De})`:""]}),i.jsxs("button",{onClick:()=>{v("notifications"),Ce.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),ge>0?` (${ge})`:""]}),i.jsx("button",{onClick:je,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"&&en,i.jsxs("div",{ref:L,className:"flex-1 overflow-y-auto",onScroll:Q=>{if(g!=="notifications"||!Ae||q)return;const be=Q.currentTarget;be.scrollTop+be.clientHeight>=be.scrollHeight-80&&fn()},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:[pt.map(Q=>{const be=Q.details?.command,ke=be?Me(Q).replace(/\s*Command:.*$/,""):Me(Q);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:()=>Z(Q),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:zo.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Se(Q)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Se(Q)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Q.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Po(Q.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:Q.agentName})]})]}),i.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:i.jsx(va,{content:ke,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),be&&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:be})]}),(()=>{if(Pu(Q))return Be(Q);const gt=Q.details?.subType,ut=gt==="task"||gt==="requirement"||gt==="requirement_resubmit",bt=Q.options&&Q.options.length>0,Mt=(I[Q.id]??"").trim();if(bt){const xt=Te;return i.jsxs("div",{className:"space-y-1.5",children:[Q.options.map((Bt,cn)=>i.jsxs("button",{disabled:S===Q.id,onClick:()=>Xe(Q.id,_f(Bt.id)==="approve",Mt||void 0,Bt.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 ${Bt.id==="reject"||Bt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Bt.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+cn)}),xt(Bt)]},Bt.id)),i.jsxs("div",{className:"flex gap-1.5 mt-1",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:I[Q.id]??"",onChange:Bt=>U(cn=>({...cn,[Q.id]:Bt.target.value})),onKeyDown:Bt=>{Bt.key==="Enter"&&(I[Q.id]??"").trim()&&Xe(Q.id,!0,(I[Q.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===Q.id||!(I[Q.id]??"").trim(),onClick:()=>Xe(Q.id,!0,(I[Q.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 ut?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{disabled:S===Q.id,onClick:()=>Xe(Q.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===Q.id,onClick:()=>Xe(Q.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")]}),z!==Q.id&&i.jsxs("button",{disabled:S===Q.id,onClick:()=>M(Q.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")]})]}),z===Q.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[Q.id]??"",onChange:xt=>U(Bt=>({...Bt,[Q.id]:xt.target.value})),onKeyDown:xt=>{xt.key==="Enter"&&(I[Q.id]??"").trim()&&Xe(Q.id,!1,(I[Q.id]??"").trim(),"request_changes"),xt.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===Q.id||!(I[Q.id]??"").trim(),onClick:()=>Xe(Q.id,!1,(I[Q.id]??"").trim(),"request_changes"),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[Q.id]??"",onChange:xt=>U(Bt=>({...Bt,[Q.id]:xt.target.value})),onKeyDown:xt=>{xt.key==="Enter"&&Xe(Q.id,!0,Mt||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===Q.id,onClick:()=>Xe(Q.id,!0,Mt||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===Q.id,onClick:()=>Xe(Q.id,!1,Mt||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")})]})]})})()]},Q.id)}),Rt.length>0&&i.jsxs(i.Fragment,{children:[pt.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")}),Rt.slice(0,50).map(Q=>i.jsxs("button",{onClick:()=>Pu(Q)?D(Q):Z(Q),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${$u(Q.status).dot}`}),Se(Q)&&i.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Se(Q)}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:Q.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${$u(Q.status).text}`,children:Ow(Q.status,m)})]}),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:at(Q)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Po(Q.respondedAt??Q.requestedAt,m)})]}),Q.responseComment&&i.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",Q.responseComment,"”"]})]},Q.id))]})]})),g==="notifications"&&($.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:ie}):i.jsxs("div",{className:"divide-y divide-border-default/50",children:[$.map(Q=>{const be=_w[Q.type]??"text-fg-tertiary";return i.jsxs("div",{role:"button",tabIndex:0,onClick:()=>$e(Q),onKeyDown:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),$e(Q))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${Q.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:be,children:i.jsx("path",{d:zo[Q.type]??zo.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!Q.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${zu[Q.priority]??zu.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Iw(Q,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(va,{content:Lw(Q,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:Po(Q.createdAt,m)}),Hu(Q,m)&&i.jsx("span",{className:`text-[10px] font-medium ${be}`,children:Hu(Q,m)})]})]})]},Q.id)}),q&&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"})]})})]}))]})]}),dt=w.useCallback(Q=>{Q?.mute&&Pie()},[]),rt=w.useCallback(Q=>{dt(Q),Qe(!1)},[dt]),jt=Ve?i.jsx(wa,{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:Q=>{rt(Q),st.navigate(se.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:Q=>{const be=`${ot.getUrl().replace(/\/$/,"")}/settings?tab=billing`;rt(Q),gi(be)}}):null;if(n){const Q=["approvals","notifications"],be=Q.indexOf(g);return i.jsxs(i.Fragment,{children:[jt,i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[vt,i.jsx("div",{className:"flex border-b border-border-default shrink-0",children:Q.map(ke=>i.jsx("button",{onClick:()=>v(ke),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===ke?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:ke==="approvals"?i.jsxs(i.Fragment,{children:[m("team:notifications.approvals"),De>0?` (${De})`:""]}):i.jsxs(i.Fragment,{children:[m("team:notifications.notifications"),ge>0?` (${ge})`:""]})},ke))}),g==="notifications"&&en,i.jsx("div",{className:"flex-1 overflow-hidden relative",children:i.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${be*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:[pt.map(ke=>{const gt=ke.details?.command,ut=gt?Me(ke).replace(/\s*Command:.*$/,""):Me(ke);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:()=>Z(ke),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:zo.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Se(ke)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Se(ke)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:ke.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Po(ke.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:ke.agentName})]})]}),i.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:i.jsx(va,{content:ut,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),gt&&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:gt})]}),(()=>{if(Pu(ke))return Be(ke);const bt=ke.details?.subType,Mt=bt==="task"||bt==="requirement"||bt==="requirement_resubmit",xt=ke.options&&ke.options.length>0,Bt=(I[ke.id]??"").trim();if(xt){const cn=Te;return i.jsxs("div",{className:"space-y-1.5",children:[ke.options.map((tn,he)=>i.jsxs("button",{disabled:S===ke.id,onClick:()=>Xe(ke.id,_f(tn.id)==="approve",Bt||void 0,tn.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 ${tn.id==="reject"||tn.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:tn.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+he)}),cn(tn)]},tn.id)),i.jsxs("div",{className:"flex gap-1.5 mt-1",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:I[ke.id]??"",onChange:tn=>U(he=>({...he,[ke.id]:tn.target.value})),onKeyDown:tn=>{tn.key==="Enter"&&(I[ke.id]??"").trim()&&Xe(ke.id,!0,(I[ke.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===ke.id||!(I[ke.id]??"").trim(),onClick:()=>Xe(ke.id,!0,(I[ke.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 Mt?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{disabled:S===ke.id,onClick:()=>Xe(ke.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===ke.id,onClick:()=>Xe(ke.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")]}),z!==ke.id&&i.jsxs("button",{disabled:S===ke.id,onClick:()=>M(ke.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")]})]}),z===ke.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[ke.id]??"",onChange:cn=>U(tn=>({...tn,[ke.id]:cn.target.value})),onKeyDown:cn=>{cn.key==="Enter"&&(I[ke.id]??"").trim()&&Xe(ke.id,!1,(I[ke.id]??"").trim(),"request_changes"),cn.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===ke.id||!(I[ke.id]??"").trim(),onClick:()=>Xe(ke.id,!1,(I[ke.id]??"").trim(),"request_changes"),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[ke.id]??"",onChange:cn=>U(tn=>({...tn,[ke.id]:cn.target.value})),onKeyDown:cn=>{cn.key==="Enter"&&Xe(ke.id,!0,Bt||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===ke.id,onClick:()=>Xe(ke.id,!0,Bt||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===ke.id,onClick:()=>Xe(ke.id,!1,Bt||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")})]})]})})()]},ke.id)}),Rt.length>0&&i.jsxs(i.Fragment,{children:[pt.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")}),Rt.slice(0,50).map(ke=>i.jsxs("button",{onClick:()=>Z(ke),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 ${$u(ke.status).dot}`}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:ke.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${$u(ke.status).text}`,children:Ow(ke.status,m)})]}),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:at(ke)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Po(ke.respondedAt??ke.requestedAt,m)})]})]},ke.id))]})]})}),i.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:$.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:ie}):i.jsx("div",{className:"divide-y divide-border-default/50",children:$.slice(0,it==="unread"?Dt:50).map(ke=>{const gt=_w[ke.type]??"text-fg-tertiary";return i.jsxs("button",{onClick:()=>$e(ke),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${ke.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:gt,children:i.jsx("path",{d:zo[ke.type]??zo.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!ke.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${zu[ke.priority]??zu.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Iw(ke,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(va,{content:Lw(ke,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:Po(ke.createdAt,m)}),Hu(ke,m)&&i.jsx("span",{className:`text-[10px] font-medium ${gt}`,children:Hu(ke,m)})]})]})]},ke.id)})})})]})})]})]})}if(s){const Q=u||"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:[vt,i.jsxs("button",{ref:V,onClick:()=>{h(!p),p||Pt()},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:Q})}),e?i.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):i.jsx("span",{className:"truncate",children:c}),Pe>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:Pe>99?m("common:badgeOverLimit"):Pe})]}),p&&$r.createPortal(i.jsx("div",{ref:F,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:J.top,left:J.left,width:J.width,maxHeight:J.maxHeight},children:Zt}),document.body),jt]})}return i.jsxs(i.Fragment,{children:[vt,i.jsxs("button",{ref:V,onClick:()=>{h(!p),p||Pt()},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"})]}),Pe>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:Pe>99?m("common:badgeOverLimit"):Pe})]}),p&&$r.createPortal(i.jsx("div",{ref:F,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:J.top,left:J.left,width:J.width,maxHeight:J.maxHeight},children:Zt}),document.body),jt]})}function qu({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 Ch=200;function ese({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:a=!1,collapsed:s=!1,showVersion:l=!1}){const{t:c}=lt(["nav","common"]),[u,m]=w.useState(!1),[p,h]=w.useState(!1),[g,v]=w.useState({top:0,left:0}),y=w.useRef(null),k=w.useRef(null),{connected:T,user:C,credits:S,refresh:E}=U4(u),_=w.useCallback(()=>{if(!y.current)return;const ne=y.current.getBoundingClientRect(),V=window.innerWidth,F=window.innerHeight,J=k.current?.offsetHeight??220;let P=ne.right+8;P+Ch>V-8&&(P=Math.max(8,ne.left-Ch-8));let X=ne.top-J-8;X<8&&(X=Math.min(ne.bottom+8,F-J-8)),v({top:Math.max(8,X),left:P})},[]);w.useLayoutEffect(()=>{if(!u)return;_();const ne=requestAnimationFrame(()=>_());return()=>cancelAnimationFrame(ne)},[u,_,s]),w.useEffect(()=>{if(!u)return;const ne=F=>{const J=F.target;y.current?.contains(J)||k.current?.contains(J)||m(!1)},V=()=>_();return document.addEventListener("mousedown",ne),window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{document.removeEventListener("mousedown",ne),window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[u,_]);const D=e?.name||C?.displayName||C?.username||c("common:userPlaceholder"),z=e?.email||C?.email||"",M=$4(e?.avatarUrl,C?.avatarUrl),I=T?"bg-emerald-500":"bg-fg-muted",U=T?C?.username?c("sidebar.hubConnectedAs",{username:C.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),W=!!(T&&C?.username&&e?.name&&C.username.toLowerCase()!==e.name.toLowerCase()&&C.email?.toLowerCase()!==e.email?.toLowerCase()),H=()=>{m(!1),E({validate:!0}),st.navigate(se.SETTINGS,{tab:"account"})},Y=u&&$r.createPortal(i.jsxs("div",{ref:k,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:Ch},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}),z&&i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:z}),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(qu,{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:H,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:U}),W&&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),st.navigate(se.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(qu,{d:Tc[se.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(qu,{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(qu,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),c("common:signOut")]})]})]}),document.body);return i.jsxs("div",{className:`relative ${s?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[i.jsxs("button",{ref:y,type:"button",onClick:()=>m(ne=>!ne),title:D,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${s?"p-0.5":""}`,children:[i.jsx(ns,{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:U})]}),l&&!s&&i.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.12.0-rc.1"]}),Y,p&&t&&i.jsx(wa,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function tse({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 nse({currentPage:e,onNavigate:t,authUser:n,collapsed:a,onToggleCollapse:s,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:u}){const{t:m}=lt(["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:ZU.map((p,h)=>{const g=E4.filter(y=>y.section===p.key);if(g.length===0)return null;const v=m(`sections.${p.key}`);return i.jsx("div",{children:i.jsxs("div",{className:h>0?"mt-3":"",children:[!a&&v&&i.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:v}),a&&h>0&&i.jsx("div",{className:"my-3"}),g.map(y=>{if(y.id===se.NOTIFICATIONS)return i.jsx(Zie,{sidebarMode:!0,collapsed:a,userId:n?.id,label:m(y.id),iconPath:Tc[y.id],isActive:e===y.id},y.id);const k=e===y.id,T=u&&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":k?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[i.jsx(tse,{d:Tc[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(ese,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const ase=6e4,rse=2e3;let jr={},Ji={};const Ig=new Set,Hm=new Set;let DC=0;const Lg=new Map;let xc=null,Fu=0,cm=null;function Oc(){for(const e of Ig)e()}function Pw(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 ise(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 Ob(e,t){const n=Date.now(),a=Lg.get(e)??0;!t?.force&&n-a<rse||(Lg.set(e,n),e in jr&&(delete jr[e],Oc()),Ne.unread.markRead(e,new Date().toISOString()).catch(()=>{}))}async function Og(){try{const e=await Ne.unread.getCounts(),{counts:t,staleActiveKeys:n}=ise(e.counts??{},Hm);jr=t,Ji=e.sessionAgentMap??{},Oc();for(const a of n)Ob(a)}catch{}}function sse(){xc||(Og(),xc=setInterval(Og,ase),cm=kr.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(Hm.has(t)){Ob(t);return}Date.now()>DC&&(jr[t]=(jr[t]??0)+1,Oc())}}))}function ose(){xc&&(clearInterval(xc),xc=null),cm&&(cm(),cm=null)}function lse(e){const t=e?.enabled??!0,[n,a]=w.useState(jr),[s,l]=w.useState(Ji),c=w.useCallback(async()=>{await Og()},[]),u=w.useCallback(async k=>{const T=new Date().toISOString();delete jr[k],Oc();try{await Ne.unread.markRead(k,T)}catch{}},[]),m=w.useCallback(async()=>{jr={},Oc();try{await Ne.unread.markAllRead()}catch{}},[]),p=w.useCallback(k=>{Hm.add(k)},[]),h=w.useCallback(k=>{Hm.delete(k),DC=Date.now()+150,Lg.delete(k),Ob(k,{force:!0})},[]);w.useEffect(()=>{if(!t)return;Fu++,sse();let k=Ji;const T=()=>{a(C=>Pw(C,jr)?C:{...jr}),k!==Ji&&(k=Ji,l(C=>Pw(C,Ji)?C:{...Ji}))};return Ig.add(T),a({...jr}),l({...Ji}),()=>{Ig.delete(T),Fu--,Fu<=0&&(Fu=0,ose())}},[t]);const g=w.useMemo(()=>Object.values(n).reduce((k,T)=>k+T,0),[n]),v=w.useCallback(k=>n[`session:${k}`]??0,[n]),y=w.useCallback(k=>n[`channel:${k}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:s,getSessionUnread:v,getChannelUnread:y,markRead:u,markAllRead:m,refresh:c,setActiveKey:p,clearActiveKey:h}}function Ble(e,t){return w.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 cse(e){return e.startsWith("channel:dm:a2a:")}function dse(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(cse(a))continue;n+=s}return n}const use=6,mse=56;function pse({currentPage:e,onNavigate:t,userId:n}){const{t:a}=lt("nav"),[s,l]=w.useState(0),[c,u]=w.useState(!1),m=w.useRef(!1),p=w.useCallback(k=>{m.current!==k&&(m.current=k,u(k))},[]);w.useEffect(()=>{let k=window.scrollY,T=0;const C=()=>{T||(T=requestAnimationFrame(()=>{T=0;const S=window.scrollY,E=S-k;if(k=S,S<=mse){p(!1);return}E>use?p(!0):E<-6&&p(!1)}))};return window.addEventListener("scroll",C,{passive:!0}),()=>{window.removeEventListener("scroll",C),T&&cancelAnimationFrame(T)}},[p]),w.useEffect(()=>{p(!1)},[e,p]);const{counts:h,sessionAgentMap:g}=lse({enabled:!0}),v=w.useMemo(()=>dse(h,g),[h,g]),y=w.useCallback(async()=>{try{const k=await Ne.notifications.list(n,!1);l(k.unreadCount??k.notifications.filter(T=>!T.read).length)}catch{}},[n]);return w.useEffect(()=>{y();const k=setInterval(()=>{document.visibilityState==="visible"&&y()},3e4),T=()=>y();return window.addEventListener("markus:notifications-changed",T),()=>{clearInterval(k),window.removeEventListener("markus:notifications-changed",T)}},[y]),i.jsx("nav",{"data-mobile-bottom-nav":!0,className:`fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom transition-transform duration-300 ease-out will-change-transform ${c?"translate-y-[calc(100%+1px)]":"translate-y-0"}`,children:tG.map(k=>{const T=k.group.includes(e),C=k.id===se.NOTIFICATIONS,S=k.id===se.TEAM;return i.jsxs("button",{onClick:()=>t(k.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${T?"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:T?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:i.jsx("path",{d:Tc[k.id]})}),C&&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}),S&&v>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:v>99?"99+":v})]}),i.jsx("span",{className:`text-[10px] leading-tight ${T?"font-semibold":""}`,children:a(k.id)})]},k.id)})})}const $m=new Map;function js(e,t){$m.has(e)||$m.set(e,t().catch(()=>{}))}function Os(e){const t=$m.get(e);return $m.delete(e),t}const Ka={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},$s={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 ol(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function IC(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 fse={agent:258,team:205,skill:32,connector:162};function Pb(e,t){const n=fse[e],a=IC(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 zw=["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 LC(e){return zw[IC(e+"g")%zw.length]}function OC(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 hse(e){return!e||OC(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function gse(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 Fo(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 Bw(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const Hw={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"}},bse=["development","devops","management","productivity","browser","custom","general"],yse=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],vse={shell:{icon:">",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"},file:{icon:"◫",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"},network:{icon:"◎",color:"bg-purple-500/15 text-purple-400 border-purple-500/30"},browser:{icon:"◉",color:"bg-brand-500/15 text-brand-400 border-brand-500/30"}};function Ah({value:e,onChange:t,renderAs:n="span",className:a,editClassName:s,placeholder:l,multiline:c,readOnly:u}){const[m,p]=w.useState(!1),[h,g]=w.useState(e),v=w.useRef(null);if(w.useEffect(()=>{g(e)},[e]),w.useEffect(()=>{m&&v.current?.focus()},[m]),u){const _=e||l,z=`${a??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?i.jsx("h1",{className:z,children:_}):n==="p"?i.jsx("p",{className:z,children:_}):i.jsx("span",{className:z,children:_})}const y=()=>{p(!1),h!==e&&t(h)},k=()=>{g(e),p(!1)},T=_=>{_.key==="Escape"&&k(),_.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:v,value:h,onChange:D=>g(D.target.value),onBlur:y,onKeyDown:T,className:`${_} resize-y min-h-[60px]`,placeholder:l}):i.jsx("input",{ref:v,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 xse({value:e,options:t,onChange:n,className:a,readOnly:s}){const[l,c]=w.useState(!1),[u,m]=w.useState(e),p=w.useRef(null),h=w.useRef(null);if(w.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(u.toLowerCase())),v=y=>{const k=y.trim();k&&k!==e&&n(k),c(!1)};return l?i.jsxs("div",{ref:h,className:"relative inline-block",children:[i.jsx("input",{ref:p,value:u,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),v(u)):y.key==="Escape"&&c(!1)},onBlur:y=>{h.current?.contains(y.relatedTarget)||v(u)},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:k=>{k.preventDefault(),v(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 kse({tags:e,onChange:t,readOnly:n}){const{t:a}=lt(["builder"]),[s,l]=w.useState(!1),[c,u]=w.useState(""),m=w.useRef(null);if(w.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]),u("")}else h.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):h.key==="Escape"&&(l(!1),u(""))};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=>u(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 Pg({content:e}){const t=[lS,d3,u3],n=[J3,[x3,{strict:"ignore"}],[z3,{detect:!0,ignoreMissing:!0}]],a=uC({}),s=w.useMemo(()=>{let l=mi(e,$3);return l=mi(l,U3),l},[e]);return i.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
871
871
|
prose-headings:text-fg-primary prose-headings:font-semibold
|
|
872
872
|
prose-p:text-fg-secondary prose-p:leading-relaxed
|
|
873
873
|
prose-a:text-brand-400 prose-a:no-underline hover:prose-a:underline
|
|
@@ -880,4 +880,4 @@ await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).t
|
|
|
880
880
|
|
|
881
881
|
${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:()=>{xe({visibility:M.visibility})},disabled:U,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(U?"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")]}),fe&&i.jsxs("a",{href:fe,target:"_blank",rel:"noopener noreferrer",onClick:Je=>{Vo()&&(Je.preventDefault(),gi(fe))},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")]}),Xe&&i.jsx("button",{onClick:()=>{xe({visibility:M.visibility})},disabled:U,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:U?m("share.updating"):m("share.updateVersion",{version:$e})})]})})(),!s&&!M.shared&&i.jsx("button",{onClick:()=>X(!0),disabled:U,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(U?"share.sharing":"share.toHub")})]})]}),!s&&H&&!ne&&i.jsxs("div",{className:"mb-4 px-4 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20 flex items-center justify-between",children:[i.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),i.jsx("button",{onClick:()=>V(!0),className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("versionBump.bumpVersion")})]}),!s&&ne&&i.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),i.jsx("input",{type:"text",defaultValue:(()=>{const pe=(it||"1.0.0").split(".");return pe[2]=String(Number(pe[2]??0)+1),pe.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:pe=>{pe.key==="Enter"&&nt("version",pe.target.value)}}),i.jsx("button",{onClick:pe=>{const fe=pe.target.parentElement?.querySelector("input");fe&&nt("version",fe.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:()=>V(!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&&Ae(!oe),className:`w-16 h-16 rounded-xl ${re.bg} flex items-center justify-center text-3xl shrink-0 ${s?"":"cursor-pointer hover:ring-2"} ${re.ring} transition-all overflow-hidden`,children:Nt&&Nt.startsWith("images/")?i.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(v)}/images/${encodeURIComponent(Nt.replace("images/",""))}?v=${le}`,alt:"",className:"w-full h-full object-cover"}):Nt&&(Nt.startsWith("http")||Nt.startsWith("/"))?i.jsx("img",{src:Nt,alt:"",className:"w-full h-full object-cover"}):(()=>{const pe=Nt||"";if(pe&&[...pe].length<=2&&new RegExp("\\p{Emoji}","u").test(pe))return pe;const $e=$s[ol(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:LC(Ce||t||e),fill:$e})})})()}),!s&&oe&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Ae(!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:Nt,onKeyDown:pe=>{pe.key==="Enter"&&(nt("icon",pe.target.value),Ae(!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 pe=>{const fe=pe.target.files?.[0];if(!fe)return;const $e=new FormData;$e.append("image",fe);try{const Xe=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(v)}/images`,{method:"POST",body:$e,credentials:"include"});if(Xe.ok){const Se=(await Xe.json()).path;if(Ue(Se),Ae(!1),C){const Te={...C,icon:Se};S(Te),await Ne.builder.artifacts.save(e,Te)}Y(!0)}}catch{}}})]}),Nt&&i.jsx("button",{onClick:()=>{nt("icon",""),Ae(!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:yse.map(pe=>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:pe.label}),i.jsx("div",{className:"flex flex-wrap gap-0.5",children:pe.emojis.map(fe=>i.jsx("button",{onClick:()=>{nt("icon",fe),Ae(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${Nt===fe?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:fe},fe))})]},pe.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(Ah,{value:Ce,onChange:pe=>nt("displayName",pe),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 ${re.bg} ${re.color}`,children:re.label}),i.jsx(Ah,{value:it,onChange:pe=>nt("version",pe),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(Ah,{value:Ve,onChange:pe=>nt("description",pe),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(xse,{value:Tt,options:bse,onChange:pe=>nt("category",pe),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:s}),i.jsx(kse,{tags:Pt,onChange:pe=>nt("tags",pe),readOnly:s})]})]})]}),i.jsx("div",{className:"mb-8",children:i.jsx(Sse,{images:$,artifactType:e,artifactName:t,onUpload:_e,onRemove:Ie,readOnly:s,cacheBust:le})}),u&&i.jsx("div",{className:"mb-8",children:u}),e==="team"&&C.team&&i.jsx("div",{className:"mb-8",children:i.jsx(Cse,{members:C.team.members,teamTopFiles:De,files:k,artifactName:v,onFileSave:et,readOnly:s})}),e==="agent"&&ge.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(qm,{noHeader:!0,files:ge,onSave:et,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(pe=>{const fe=vse[pe];return i.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${fe?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[i.jsx("span",{className:"font-mono text-[10px]",children:fe?.icon??"?"})," ",pe]},pe)})})]}),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(([pe,fe])=>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:pe}),i.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof fe=="object"?JSON.stringify(fe).slice(0,80):String(fe)})]})]},pe))})]}),ie&&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(Pg,{content:ie})})]})]}),Pe.length>0&&i.jsx(qm,{files:Pe,onSave:et,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 ${re.color}`,children:re.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:Tt})]}),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:it})]}),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((pe,fe)=>pe+fe.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(pe=>pe.role==="manager").reduce((pe,fe)=>pe+fe.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(pe=>pe.role!=="manager").reduce((pe,fe)=>pe+fe.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(pe=>i.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:pe},pe))})]})]})]}),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(pe=>i.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:pe},pe))})]}):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(pe=>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:pe},pe))})]}):null]}):null,!s&&E&&i.jsxs("button",{onClick:()=>Ne.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&&F&&i.jsx(Tse,{onClose:()=>J(!1),onConfirm:(pe,fe)=>{J(!1),xe({donationsEnabled:!1,priceCents:pe==="paid"?fe:void 0})},isUpdate:M.shared}),!s&&P&&i.jsx(Ase,{onClose:()=>X(!1),onConfirm:(pe,fe,$e,Xe)=>{X(!1),xe({visibility:pe,orgId:fe,priceCents:$e,donationsEnabled:Xe})}}),G&&i.jsx(wa,{alertOnly:!0,variant:G.variant??"primary",title:G.title,message:G.message,onConfirm:()=>q(null),onCancel:()=>q(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 Ase({onClose:e,onConfirm:t}){const{t:n}=lt(["builder","common"]),[a,s]=w.useState("public"),[l,c]=w.useState([]),[u,m]=w.useState(""),[p,h]=w.useState(!1),[g,v]=w.useState(0),[y,k]=w.useState(!1);w.useEffect(()=>{a==="org"&&l.length===0&&(h(!0),ot.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:u,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:PC.map(S=>i.jsx("button",{type:"button",onClick:()=>v(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=>k(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"?u:void 0,T&&g>0?g:void 0,T?y:void 0),disabled:a==="org"&&!u,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 PC=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Tse({onClose:e,onConfirm:t,isUpdate:n}){const{t:a}=lt(["builder","common"]),[s,l]=w.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:PC.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 Fm(e,t){return!e||!OC(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function Nse({type:e,seed:t,icon:n,hubBase:a,size:s=44,className:l="",rounded:c="rounded-xl"}){const u=ol(e),m=Fm(n,a),p=w.useMemo(()=>Pb(u,t),[u,t]),h=w.useMemo(()=>LC(t),[t]),[g,v]=w.useState(!1);return m&&!g?i.jsx("img",{src:m,alt:"",onError:()=>v(!0),style:{width:s,height:s},className:`${c} object-cover shrink-0 ${l}`}):hse(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&&aie(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(sl,{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 Um({name:e,username:t,avatarUrl:n,hubBase:a,size:s=24,className:l="",verified:c}){const u=t||e||"markus",m=Fm(n,a),[p,h]=w.useState(!1),g=m&&!p?m:gse(u);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 Ese({type:e,className:t=""}){const n=ol(e),a=$s[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 qw({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 Cr(e){const{type:t,name:n,description:a,seed:s,icon:l,cover:c,hubBase:u,author:m,authorLabel:p,version:h,category:g,tags:v,rating:y=0,ratingCount:k=0,downloadCount:T=0,priceCents:C,currency:S="usd",installed:E,glowing:_,selected:D,showTypeBadge:z=!0,hideStats:M=!1,cornerLabel:I,actions:U,footerLeft:W,headerAction:H,onClick:Y,className:ne=""}=e,V=ol(t),F=$s[V],J=s||n,P=(C??0)>0,X=!!Fm(c||void 0,u),oe=Pb(V,J),Ae=p??m?.displayName??m?.username??"",[G,q]=w.useState(null),le=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}):P?i.jsx("span",{className:"badge-paid",children:Bw(C,S)}):null;if(X){const L=Fm(c||void 0,u);return i.jsxs("div",{onClick:Y,style:{aspectRatio:G??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":""} ${ne}`,children:[i.jsx("img",{src:L,alt:"",onLoad:Ce=>{const Ge=Ce.currentTarget;Ge.naturalWidth&&Ge.naturalHeight&&q(Math.min(1.9,Math.max(1,Ge.naturalWidth/Ge.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:z&&i.jsx(Ese,{type:V})}),i.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ce=>Ce.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}):H?null:i.jsx("span",{className:P?"badge-paid":"badge-free",children:Bw(C,S)}),H]})]}),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]})]}),Ae&&i.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&i.jsx(Um,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:u,size:15}),i.jsx("span",{className:"truncate",children:Ae})]}),a&&i.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:a}),(g||v&&v.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}),v?.slice(0,3).map(Ce=>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:Ce},Ce))]}),(!M||U)&&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(qw,{rating:y}),k>0&&i.jsxs("span",{className:"text-white/60",children:["(",Fo(k),")"]})]}),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"})}),Fo(T)]})]}),U&&i.jsx("div",{className:"flex items-center gap-2",onClick:Ce=>Ce.stopPropagation(),children:U})]})]})]})}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":""} ${ne}`,children:[i.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${F.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:oe}}),H&&i.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:L=>L.stopPropagation(),children:H}),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(Nse,{type:V,seed:J,icon:l,hubBase:u,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 ${H?"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]}),le&&i.jsx("span",{className:"ml-auto shrink-0",children:le})]}),(Ae||z)&&i.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&i.jsx(Um,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:u,size:15}),Ae&&i.jsx("span",{className:"truncate",children:Ae}),z&&i.jsxs(i.Fragment,{children:[Ae&&i.jsx("span",{className:"text-fg-muted",children:"·"}),i.jsx("span",{className:"font-semibold shrink-0",style:{color:F.accent},children:F.label})]})]})]})]}),a&&i.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:a}),(g||v&&v.length>0)&&i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&i.jsx("span",{className:"chip-accent capitalize",children:g}),v?.slice(0,3).map(L=>i.jsx("span",{className:"chip",children:L},L)),(v?.length??0)>3&&i.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(v?.length??0)-3]})]}),(()=>{const L=W??(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(qw,{rating:y}),i.jsx("span",{className:"text-fg-muted",children:k>0?`(${Fo(k)})`:""})]}),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"})}),Fo(T)]})]}));return!L&&!U?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:Ce=>Ce.stopPropagation(),children:[L&&i.jsx("div",{className:"min-w-0 flex items-center gap-2",children:L}),U&&i.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:U})]})})()]})]})}function Va({children:e,maxCardWidth:t=400,gap:n="1rem",className:a=""}){const s=w.useRef(null),[l,c]=w.useState(0);w.useEffect(()=>{const h=s.current;if(!h)return;c(h.clientWidth);const g=new ResizeObserver(v=>{for(const y of v)c(y.contentRect.width)});return g.observe(h),()=>g.disconnect()},[]);const u=Math.max(1,Math.ceil((l||t)/t)),m=w.Children.toArray(e),p=Array.from({length:u},()=>[]);return m.forEach((h,g)=>{p[g%u].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 jse(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const Mse=[{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 _se(){const[e,t]=w.useState(()=>{const a=window.location.hash.slice(1).split("/");return Cc(a[0])===se.BUILDER&&a[1]&&a[2]?{type:a[1],name:decodeURIComponent(a[2])}:null});return w.useEffect(()=>{const n=()=>{const s=window.location.hash.slice(1).split("/");Cc(s[0])===se.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 zC="markus_builder_shared_map";function Rse(){try{const e=localStorage.getItem(zC);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Uu(e){try{localStorage.setItem(zC,JSON.stringify(Object.fromEntries(e)))}catch{}}function BC({authUser:e}={}){const{t}=lt(["builder","common"]),n=Zo(),a=_se(),[s,l]=w.useState([]),[c,u]=w.useState([]),[m,p]=w.useState(!1),[h,g]=w.useState("all"),[v,y]=w.useState(null),[k,T]=w.useState(new Map),[C,S]=w.useState(null),[E,_]=w.useState(null),[D,z]=w.useState(null),[M,I]=w.useState(Rse),[U,W]=w.useState(null),[H,Y]=w.useState(null),[ne,V]=w.useState(null),[F,J]=w.useState(null),[P,X]=w.useState(null),[oe,Ae]=w.useState("creations"),[G,q]=w.useState([]),[le,L]=w.useState(""),[Ce,Ge]=w.useState([]),[Ve,Qe]=w.useState(!1),[it,mt]=w.useState("all"),Tt=w.useCallback(()=>{p(!0),Promise.all([(Os(Ka.builderArtifacts)??Ne.builder.artifacts.list()).then(ce=>ce?.artifacts??[]).catch(()=>[]),(Os(Ka.builderAgents)??Ne.agents.list()).then(ce=>ce?.agents??[]).catch(()=>[]),(Os(Ka.builderHubMyItems)??ot.myItems()).then(ce=>ce?.items??[]).catch(()=>[]),(Os(Ka.builderInstalled)??Ne.builder.artifacts.installed()).then(ce=>ce?.installed??{}).catch(()=>({}))]).then(([ce,nt,et,xe])=>{if(u(ce),l(nt),et.length>0){const Ie=new Map;for(const re of et){const $=re.itemType==="agent"?"agent":re.itemType==="team"?"team":"skill";for(const ie of ce)ie.type===$&&(re.slug===ie.name||re.name===(ie.meta.displayName||ie.meta.name||ie.name))&&Ie.set(`${ie.type}/${ie.name}`,{id:re.id,name:re.name,slug:re.slug||ie.name,version:re.version||"1.0.0",visibility:re.visibility??"public",moderationStatus:re.moderationStatus,moderationNote:re.moderationNote,pendingReview:re.pendingReview})}Ie.size>0&&I(re=>{const $=new Map(re);for(const[ie,ge]of Ie)$.set(ie,ge);return Uu($),$})}const _e=new Map;for(const Ie of ce){const re=`${Ie.type}/${Ie.name}`,$=xe[re];$&&_e.set(re,{agentId:$.agentId,agentIds:$.agentIds,teamId:$.teamId})}T(_e)}).finally(()=>p(!1))},[]);w.useEffect(()=>{Tt();const ce=nt=>{nt.detail?.page===se.BUILDER&&Tt()};return window.addEventListener("markus:navigate",ce),()=>window.removeEventListener("markus:navigate",ce)},[Tt]);const Dt=ce=>{const nt=s.find(et=>et.role==="Secretary"||et.name==="Secretary");nt?st.navigate(se.TEAM,{agentId:nt.id,prefillMessage:ce}):st.navigate(se.TEAM,{prefillMessage:ce})},Pt=async ce=>{const nt=`${ce.type}/${ce.name}`;if(!k.has(nt)){y({key:nt,action:"install"});try{const et=await Ne.builder.artifacts.install(ce.type,ce.name),xe={};et.agent&&typeof et.agent=="object"&&(xe.agentId=et.agent.id),et.team&&typeof et.team=="object"&&(xe.teamId=et.team.id),Array.isArray(et.agents)&&(xe.agentIds=et.agents.map(_e=>_e.id)),T(_e=>new Map(_e).set(nt,xe)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(et){console.error("Install failed:",et),Y({title:t("common:install"),message:t("installFailed",{error:String(et)}),variant:"danger"})}finally{y(null)}}},fn=async ce=>{const nt=`${ce.type}/${ce.name}`;if(k.has(nt)){y({key:nt,action:"uninstall"});try{await Ne.builder.artifacts.uninstall(ce.type,ce.name),T(et=>{const xe=new Map(et);return xe.delete(nt),xe}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(et){console.error("Uninstall failed:",et),Y({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(et)}),variant:"danger"})}finally{y(null)}}},Nt=async(ce,nt)=>{const et=`${ce.type}/${ce.name}`;y({key:et,action:"share"});try{const xe=await Ne.builder.artifacts.ensureSlugSafe(ce.type,ce.name,ce.meta.displayName||ce.meta.name||ce.name),_e=xe.name,Ie=xe.slug||jc(_e);if(!Ie)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 re=`${ce.type}/${_e}`;xe.converted&&(u(Me=>Me.map(at=>at.type===ce.type&&at.name===ce.name?{...at,name:_e,path:xe.path,meta:{...at.meta,name:_e,displayName:xe.displayName??at.meta.displayName??ce.name}}:at)),I(Me=>{const at=new Map(Me),yt=at.get(et);return yt&&(at.delete(et),at.set(re,{...yt,slug:Ie,name:xe.displayName??yt.name})),Uu(at),at}),T(Me=>{const at=new Map(Me),yt=at.get(et);return yt&&(at.delete(et),at.set(re,yt)),at}));const $=await Ne.builder.artifacts.get(ce.type,_e);let ie={...ce.meta,name:_e,displayName:xe.displayName??ce.meta.displayName??ce.name};try{const Me=$.files?.[`${ce.type}.json`]??$.files?.["agent.json"]??$.files?.["team.json"]??$.files?.["skill.json"];Me&&(ie={...JSON.parse(Me),...ie,name:_e,displayName:ie.displayName})}catch{}const ge=ie.displayName||ie.name||_e,De=ie.description||"",Pe=ie.category||"general",pe=Array.isArray(ie.tags)?ie.tags:[];let fe=ie.icon||void 0;const $e=ie.version||"1.0.0";if(fe&&!fe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(fe)){const Me=fe.split("/").pop()??fe;try{const at=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(_e)}/images/${encodeURIComponent(Me)}`);if(at.ok){const yt=await at.blob(),pt=new File([yt],Me,{type:yt.type}),Rt=await ot.uploadImage(pt);Rt?.url&&(fe=Rt.url)}}catch{}}let Xe;const Je=[],Se=Array.isArray(ie.screenshots)?ie.screenshots:[];for(let Me=0;Me<Se.length;Me++){const at=Se[Me],yt=at.split("/").pop()??at;try{const pt=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(_e)}/images/${encodeURIComponent(yt)}`);if(pt.ok){const Rt=await pt.blob(),Z=new File([Rt],yt,{type:Rt.type}),je=await ot.uploadImage(Z);je?.url&&(Je.push({url:je.url,alt:yt,order:Me}),(Me===0||ie.thumbnail===at)&&(Xe=je.url))}}catch{}}const Te=await ot.publishViaProxy({itemType:ce.type==="team"?"team":ce.type==="skill"?"skill":"agent",name:ge,slug:Ie,description:De,category:Pe,tags:pe,icon:fe,version:$e,config:{...ie,name:_e,displayName:ge},files:$.files&&Object.keys($.files).length>0?$.files:void 0,thumbnailUrl:Xe,images:Je.length>0?Je:void 0,priceCents:nt?.priceCents,donationsEnabled:nt?.donationsEnabled,visibility:nt?.visibility,orgId:nt?.orgId});Te.id&&(I(at=>{const yt=new Map(at);return yt.set(re,{id:Te.id,name:ge,slug:Te.slug??Ie,version:$e,visibility:Te.visibility??nt?.visibility??"public",moderationStatus:Te.moderationStatus,pendingReview:Te.pendingReview}),Uu(yt),yt}),(Te.visibility??nt?.visibility??"public")!=="org"?Y({title:t("common:share"),message:xe.converted?t("share.convertedAndSubmitted",{previous:ce.name,slug:Ie}):Te.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):xe.converted&&Y({title:t("common:share"),message:t("share.convertedSlug",{previous:ce.name,slug:Ie}),variant:"primary"}))}catch(xe){console.error("Share failed:",xe),Y({title:t("common:share"),message:t("shareFailed",{error:xe instanceof Error?xe.message:String(xe)}),variant:"danger"})}finally{y(null)}},Ue=async()=>{if(!U)return;const{key:ce}=U,nt=M.get(ce);if(W(null),!nt)return;const et=nt.id;y({key:ce,action:"hubDelete"});try{await ot.deleteItem(et),I(xe=>{const _e=new Map(xe);return _e.delete(ce),Uu(_e),_e})}catch(xe){console.error("Hub delete failed:",xe),Y({title:t("unshare"),message:t("hubDeleteFailed",{error:String(xe)}),variant:"danger"})}finally{y(null)}},ht=async()=>{if(!C)return;const ce=C,nt=`${ce.type}/${ce.name}`;S(null),y({key:nt,action:"delete"});try{await Ne.builder.artifacts.delete(ce.type,ce.name),u(et=>et.filter(xe=>!(xe.type===ce.type&&xe.name===ce.name))),T(et=>{const xe=new Map(et);return xe.delete(nt),xe}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(et){console.error("Delete failed:",et)}finally{y(null)}},Lt=h==="all"?c:c.filter(ce=>ce.type===h);w.useEffect(()=>{oe!=="orgAssets"||G.length>0||ot.myOrgs().then(ce=>{q(ce.memberships),ce.memberships.length>0&&!le&&L(ce.memberships[0].id)}).catch(()=>{})},[oe,G.length,le]),w.useEffect(()=>{oe!=="orgAssets"||!le||(Qe(!0),ot.browseItems({orgId:le,limit:100}).then(ce=>Ge(ce.items??[])).catch(()=>Ge([])).finally(()=>Qe(!1)))},[oe,le]);const wt=it==="all"?Ce:Ce.filter(ce=>ce.itemType===it),Jt=ce=>{history.pushState(null,"",Bs(se.BUILDER,`${ce.type}/${encodeURIComponent(ce.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return w.useEffect(()=>(Yx(se.BUILDER,a?1:0),()=>Yx(se.BUILDER,0)),[a]),a?i.jsx(Us,{type:a.type,name:a.name,authUser:e,onBack:()=>{history.pushState(null,"",Bs(se.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:Tt,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:Mse.map(ce=>{const nt=t(`prompts.${ce.id}Prompt`),et=t(`prompts.${ce.id}Examples`,{returnObjects:!0}),xe=Array.isArray(et)?et:[];return i.jsx("button",{onClick:()=>Dt(nt),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`)}),xe.length>0&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:xe.slice(0,2).map((_e,Ie)=>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:re=>{re.stopPropagation(),Dt(nt+_e)},children:["“",_e,"”"]},Ie))})]})]})},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:()=>Ae("creations"),className:`text-sm font-semibold transition-colors ${oe==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),i.jsx("button",{onClick:()=>Ae("orgAssets"),className:`text-sm font-semibold transition-colors ${oe==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),oe==="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))}),oe==="orgAssets"&&i.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>i.jsx("button",{onClick:()=>mt(ce),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${it===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))})]})}),oe==="orgAssets"&&G.length>0&&i.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:G.map(ce=>i.jsx("button",{onClick:()=>L(ce.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${le===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))}),oe==="orgAssets"&&(G.length===0&&!Ve?i.jsx("div",{className:"text-center py-12",children:i.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):Ve?i.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):wt.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(Va,{children:wt.map(ce=>{const nt=ce.author?.username&&ce.slug?`${ot.getUrl()}/@${encodeURIComponent(ce.author.username)}/${encodeURIComponent(ce.slug)}`:null;return i.jsx(Cr,{type:ce.itemType,name:ce.name,description:ce.description,seed:ce.slug||ce.id||ce.name,icon:ce.icon,cover:ce.thumbnailUrl,hubBase:ot.getUrl(),author:ce.author,version:ce.version,rating:parseFloat(ce.avgRating)||0,ratingCount:ce.ratingCount,downloadCount:ce.downloadCount,actions:nt?i.jsxs("a",{href:nt,target:"_blank",rel:"noopener noreferrer",onClick:et=>{et.stopPropagation(),Vo()&&(et.preventDefault(),gi(nt))},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)})})),oe==="creations"&&(m&&c.length===0?i.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):Lt.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(Va,{children:Lt.map(ce=>{const nt=ce.meta.displayName||ce.meta.name||ce.name,et=ce.meta.description||"",xe=`${ce.type}/${ce.name}`,_e=v?.key===xe?v.action:null,Ie=M.get(xe),re=ce.meta.version||"1.0.0",$=!!Ie,ie=$&&Ie.version!==re,ge=()=>{const Je=ot.getUser();return!Ie||!Je?null:`${ot.getUrl()}/@${encodeURIComponent(Je.username)}/${encodeURIComponent(Ie.slug)}`},De=$&&Ie?.moderationStatus==="rejected",Pe=i.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:Je=>Je.stopPropagation(),children:[k.has(xe)?i.jsxs("button",{onClick:()=>z(ce),disabled:!!_e,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(_e==="uninstall"?"common:uninstalling":"common:uninstall")]}):i.jsxs("button",{onClick:()=>_(ce),disabled:!!_e,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(_e==="install"?"common:installing":"common:install")]}),$&&De?i.jsxs(i.Fragment,{children:[i.jsxs("button",{onClick:()=>{Y({title:t("share.rejectedDetailTitle"),variant:"danger",message:`${t("share.rejectedReasonLabel")}${Ie?.moderationNote?Ie.moderationNote:t("share.rejectedNoReason")}
|
|
882
882
|
|
|
883
|
-
${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:()=>{Nt(ce,{visibility:Ie?.visibility??"public"})},disabled:!!_e,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(_e==="share"?"common:sharing":"share.resubmit")]})]}):$?i.jsxs(i.Fragment,{children:[ie&&i.jsxs("button",{onClick:()=>{const Je=Ie?.visibility??"public";Nt(ce,{visibility:Je})},disabled:!!_e,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"})]}),_e==="share"?t("common:sharing"):t("share.updateVersion",{version:re})]}),i.jsxs("a",{href:ge()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Je=>{const Se=ge();Vo()&&Se&&(Je.preventDefault(),gi(Se))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ie?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ie?.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:[Ie?.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"})]}):Ie?.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"})]}),Ie?.visibility==="org"?t("visibility.sharedOrg"):Ie?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),i.jsxs("button",{onClick:()=>W({key:xe,name:nt}),disabled:!!_e,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 ot.ensureAuth(),Array.isArray(ce.meta.screenshots)&&ce.meta.screenshots.length>0?X(ce):V(ce)},disabled:!!_e,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(_e==="share"?"common:sharing":"common:share")]})]}),pe=i.jsx("button",{onClick:()=>S(ce),disabled:!!_e,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"})]})}),fe=ce.meta.icon,Xe=!!fe&&/\.(png|jpe?g|gif|webp|svg)$/i.test(fe)?fe.startsWith("http")||fe.startsWith("/")?fe:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(fe.split("/").pop()??"")}?v=${ce.updatedAt??""}`:fe;return i.jsx(Cr,{type:ce.type,name:nt,description:et,seed:xe,icon:Xe,version:re,footerLeft:i.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[i.jsx("button",{onClick:Je=>{Je.stopPropagation(),Ne.system.openPath(ce.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ce.path,children:jse(ce.path)}),i.jsx("span",{className:"shrink-0",children:"·"}),i.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:pe,actions:Pe,onClick:()=>Jt(ce)},xe)})})),E&&i.jsx(wa,{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),Pt(ce)},onCancel:()=>_(null)}),D&&i.jsx(wa,{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;z(null),fn(ce)},onCancel:()=>z(null)}),C&&i.jsx(wa,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:C.meta.displayName||C.meta.name||C.name}),confirmLabel:t("common:delete"),onConfirm:ht,onCancel:()=>S(null)}),U&&i.jsx(wa,{title:t("confirmUnshare"),message:t("removeFromHub",{name:U.name}),confirmLabel:t("unshare"),onConfirm:()=>{Ue()},onCancel:()=>W(null)}),H&&i.jsx(wa,{alertOnly:!0,variant:H.variant??"primary",title:H.title,message:H.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)}),ne&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>V(null),children:i.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),i.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("button",{onClick:()=>{const ce=ne;V(null),X(ce)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),i.jsx("button",{onClick:()=>{const ce=ne;V(null),Jt(ce)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&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(Ise,{isUpdate:M.has(`${F.type}/${F.name}`),onCancel:()=>J(null),onConfirm:(ce,nt)=>{const et=F;J(null),Nt(et,{priceCents:nt>0?nt:void 0})}})})}),P&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>X(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(Dse,{onCancel:()=>X(null),onConfirm:(ce,nt,et,xe)=>{const _e=P;X(null),Nt(_e,{visibility:ce,orgId:nt,priceCents:et,donationsEnabled:xe})}})})})]})})}function Dse({onCancel:e,onConfirm:t}){const{t:n}=lt(["builder","common"]),[a,s]=w.useState("public"),[l,c]=w.useState([]),[u,m]=w.useState(""),[p,h]=w.useState(!1),[g,v]=w.useState(0),[y,k]=w.useState(!1);w.useEffect(()=>{a==="org"&&l.length===0&&(h(!0),ot.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:u,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:HC.map(S=>i.jsx("button",{type:"button",onClick:()=>v(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=>k(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"?u:void 0,T&&g>0?g:void 0,T?y:void 0),disabled:a==="org"&&!u,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 HC=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Ise({isUpdate:e,onCancel:t,onConfirm:n}){const{t:a}=lt(["builder","common"]),[s,l]=w.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:HC.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 Lse=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:BC},Symbol.toStringTag,{value:"Module"}));async function $C(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 ot.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 Ose(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 Gm(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Fw(e,t){return e.i18n?.[t]?.description||e.description}const Pse={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function zse({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:a,i18n:s}=lt(["store","common"]),l=s.language,[c,u]=w.useState(""),[m,p]=w.useState([]),[h,g]=w.useState([]),[v,y]=w.useState(null),[k,T]=w.useState({}),[C,S]=w.useState(!1),[E,_]=w.useState(!0),[D,z]=w.useState(new Map),[M,I]=w.useState(new Set),[U,W]=w.useState(null),[H,Y]=w.useState(null),ne=w.useCallback(async()=>{try{const[J,P]=await Promise.all([Ne.builder.artifacts.list().catch(()=>({artifacts:[]})),Ne.builder.artifacts.installed().catch(()=>({installed:{}}))]),X=new Map;for(const oe of J.artifacts){if(oe.type!=="agent")continue;const Ae=!!P.installed[`agent/${oe.name}`];X.set(oe.name,{installed:Ae,localVersion:oe.meta.version||void 0,localUpdatedAt:oe.updatedAt})}z(X)}catch{}},[]),V=w.useCallback(async()=>{_(!0);try{const J=c?ot.search({type:"agent",q:c,limit:50}):Os(Ka.hubAgents)??ot.search({type:"agent",limit:50}),P=new URLSearchParams;c&&P.set("q",c);const X=fetch("/api/templates?"+P.toString()).then(q=>q.json()).catch(()=>({templates:[]})),[oe,Ae]=await Promise.all([J.catch(()=>({items:[],total:0})),X,ne(),ot.isAuthenticated()?ot.purchases.mine().then(q=>I(new Set(q.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),G=await $C(oe?.items??[],t);g(G.items),p(Array.isArray(Ae.templates)?Ae.templates:[]),G.missing&&n?.()}catch{p([]),g([])}finally{_(!1)}},[c,ne,t,n]);w.useEffect(()=>{V()},[V]),w.useEffect(()=>{if(!v){T({});return}fetch(`/api/templates/${encodeURIComponent(v.id)}/files`,{credentials:"include"}).then(J=>J.json()).then(J=>T(J.files??{})).catch(()=>T({}))},[v]);const F=async(J,P,X)=>{try{const oe=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:J,name:P,orgId:"default",teamId:X})});if(!oe.ok)throw new Error(`Failed: ${oe.status}`);S(!1),y(null)}catch(oe){Y({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${oe}`,variant:"danger"})}};if(U)return i.jsx(Us,{type:U.type,name:U.name,onBack:()=>W(null)});if(v){const J={type:"agent",name:v.id,displayName:Gm(v,l),version:v.version,description:Fw(v,l),author:v.author,category:v.category,tags:v.tags,icon:v.icon,files:k,agent:{roleName:v.roleId,agentRole:v.agentRole==="manager"?"manager":"worker"},dependencies:{skills:v.skills}},P=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:v.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 ${Pse[v.agentRole]??""}`,children:v.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:[v.skills.map(X=>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:X},X)),v.skills.length===0&&i.jsx("span",{className:"text-xs text-fg-tertiary italic",children:a("agentStore.noSkills")})]})]})]}),v.starterTasks&&v.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:v.starterTasks.map((X,oe)=>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 ${X.priority==="high"?"bg-red-400":X.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm text-fg-primary",children:X.title}),X.description&&i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:X.description})]})]},oe))})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(Us,{type:"agent",name:v.id,onBack:()=>y(null),readOnly:!0,initialManifest:J,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:P}),C&&i.jsx(Uw,{template:v,lang:l,onClose:()=>S(!1),onHire:F}),H&&i.jsx(wa,{alertOnly:!0,variant:H.variant??"danger",title:H.title,message:H.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:J=>u(J.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),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((J,P)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},P))}):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(Va,{columns:3,children:m.map(J=>i.jsx(Cr,{type:"agent",name:Gm(J,l),description:Fw(J,l),seed:J.id,icon:J.icon,version:J.version,category:J.category,tags:J.tags,authorLabel:J.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(J)},J.id))})]}),h.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:a("agentStore.markusHub")}),i.jsx(Va,{columns:3,children:h.map(J=>i.jsx(Bse,{item:J,localInfo:D.get(Gc(J)),purchased:bm(J,M),onStatusChange:ne,highlight:J.id===t,onHighlightDone:n,onViewDetail:P=>W({type:"agent",name:P})},J.id))})]})]})}),C&&v&&i.jsx(Uw,{template:v,lang:l,onClose:()=>S(!1),onHire:F}),H&&i.jsx(wa,{alertOnly:!0,variant:H.variant??"danger",title:H.title,message:H.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Gc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return xm(n||e.name,"hub-pkg")}function Ps(e){return(async()=>{const t=await ot.download(e.id),n=t.name||e.name,a=t.config??{},s=Gc(e,a),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},u=(t.version||e.version||(typeof a.version=="string"?a.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Ne.builder.artifacts.import(l,s,t.files,c,u);else{const m={...a,...u?{version:u}:{},name:s,displayName:a.displayName||n,description:e.description,source:c};await Ne.builder.artifacts.save(l,m)}return await Ne.builder.artifacts.install(l,s),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function zb(e,t){t("checking"),await ot.ensureAuth();const n=await ot.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Ps(e),"installed";try{if((await ot.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await ot.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Ps(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const a=Vo();let s=null;return a?gi(n.checkoutUrl):s=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const u=Date.now(),m=300*1e3,p=setInterval(async()=>{if(Date.now()-u>m){clearInterval(p),l("cancelled");return}const g=!a&&s?s.closed:!1;try{if((await ot.purchases.checkout(e.id)).alreadyOwned){clearInterval(p),t("installing");try{await Ps(e),l("installed")}catch(y){c(y)}return}}catch{}if(g){clearInterval(p);try{if((await ot.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Ps(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function Bse({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:s,onHighlightDone:l,onViewDetail:c}){const{t:u}=lt(["store"]),[m,p]=w.useState(!1),[h,g]=w.useState(""),v=w.useRef(null),[y,k]=w.useState(!1);w.useEffect(()=>{if(s&&v.current){v.current.scrollIntoView({behavior:"smooth",block:"center"}),k(!0);const U=setTimeout(()=>{k(!1)},4e3);return()=>clearTimeout(U)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&Ose(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async U=>{if(U.stopPropagation(),!m){p(!0),g("");try{await Ps(e),g(C?u("card.upgraded"):u("card.installed")+"!"),a()}catch(W){const H=W instanceof Error?W.message:"";H.includes("402")||H.includes("Purchase required")?g(u("card.purchaseRequired")):g(u("card.failed"))}finally{p(!1)}}},_=async U=>{if(U.stopPropagation(),!m){p(!0),g("");try{await zb(e,H=>{H==="checkout_opened"?g(u("card.waitingPurchase","Waiting for purchase...")):H==="installing"&&g(u("card.installing"))})==="installed"?(g(u("card.installed")+"!"),a()):g("")}catch(W){g(W instanceof Error?W.message:u("card.failed"))}finally{p(!1)}}},D=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,z=e.slug&&e.author?.username?`${ot.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,M=()=>{T&&c?c(Gc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:U=>{E(U)},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?u("card.upgrading"):u("card.upgrade",{version:e.version})}):T?i.jsxs("button",{onClick:U=>{E(U)},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:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?i.jsx("button",{onClick:U=>{_(U)},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||u("card.installing"):i.jsxs(i.Fragment,{children:[u("card.buy","Buy")," ",D]})}):i.jsx("button",{onClick:U=>{E(U)},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:u(m?"card.installing":"card.install")}),h&&!(S&&!n)&&i.jsx("span",{className:`text-[10px] ${h===u("card.failed")||h===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return i.jsx("div",{ref:v,className:y?"animate-pulse":"",children:i.jsx(Cr,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:ot.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 Uw({template:e,lang:t,onClose:n,onHire:a}){const{t:s}=lt(["store"]),[l,c]=w.useState(`${Gm(e,t)} Agent`),[u,m]=w.useState(""),[p,h]=w.useState([]),[g,v]=w.useState(!1);w.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(k=>k.json()).then(k=>h(k.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){v(!0);try{await a(e.id,l.trim(),u||void 0)}finally{v(!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:k=>k.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:Gm(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:k=>c(k.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:u,onChange:k=>m(k.target.value),className:"input-field",children:[i.jsx("option",{value:"",children:s("hireModal.noTeam")}),p.map(k=>i.jsx("option",{value:k.id,children:k.name},k.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 Nh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Gw(e,t){return e.i18n?.[t]?.description||e.description}function Kw(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function Hse(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 $se({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=lt(["store","common"]),s=a.language,[l,c]=w.useState(""),[u,m]=w.useState([]),[p,h]=w.useState([]),[g,v]=w.useState(null),[y,k]=w.useState({}),[T,C]=w.useState(!0),[S,E]=w.useState(!1),[_,D]=w.useState(null),[z,M]=w.useState(new Map),[I,U]=w.useState(new Set),[W,H]=w.useState(null),Y=w.useCallback(async()=>{try{const[F,J]=await Promise.all([Ne.builder.artifacts.list().catch(()=>({artifacts:[]})),Ne.builder.artifacts.installed().catch(()=>({installed:{}}))]),P=new Map;for(const X of F.artifacts){if(X.type!=="team")continue;const oe=!!J.installed[`team/${X.name}`];P.set(X.name,{installed:oe,localVersion:X.meta.version||void 0,localUpdatedAt:X.updatedAt})}M(P)}catch{}},[]),ne=w.useCallback(async()=>{C(!0);try{const F=l?ot.search({type:"team",q:l,limit:50}):Os(Ka.hubTeams)??ot.search({type:"team",limit:50}),[J,P]=await Promise.all([F.catch(()=>({items:[],total:0})),Ne.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),Y(),ot.isAuthenticated()?ot.purchases.mine().then(oe=>U(new Set(oe.purchases.map(Ae=>Ae.itemId)))).catch(()=>{}):Promise.resolve()]),X=await $C(J?.items??[],e);h(X.items),m(P?.templates??[]),X.missing&&t?.()}catch{m([]),h([])}finally{C(!1)}},[l,Y,e,t]);w.useEffect(()=>{ne()},[ne]),w.useEffect(()=>{if(!g){k({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>k(F.files??{})).catch(()=>k({}))},[g]);const V=async F=>{E(!0),D(null);try{const P=(await Ne.teams.create(F.name,F.description)).team.id;let X,oe=0;const Ae=[];for(const q of F.members){const le=q.count??1;for(let L=0;L<le;L++){const Ce=q.name??`${F.name} Agent ${L+1}`,Ge=le>1?`${Ce} ${L+1}`:Ce,Ve=q.roleName??q.templateId;try{const Qe=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Ge,...Ve?{roleName:Ve}:{},orgId:"default",teamId:P,agentRole:q.role??"worker",skills:q.skills??[]})});if(Qe.ok){oe++;const it=await Qe.json();q.role==="manager"&&!X&&(X=it.agent?.id)}else{const it=await Qe.json().catch(()=>({error:`HTTP ${Qe.status}`}));Ae.push(`${Ge}: ${it.error??Qe.statusText}`)}}catch(Qe){Ae.push(`${Ge}: ${String(Qe)}`)}}}X&&await Ne.teams.update(P,{managerId:X,managerType:"agent"}).catch(()=>{});const G=Ae.length>0?` (${Ae.length} failed: ${Ae[0]})`:"";D({ok:oe>0,message:`Team "${Nh(F,s)}" deployed with ${oe} agent(s)${G}`})}catch(J){D({ok:!1,message:`Failed: ${J}`})}finally{E(!1)}};if(W)return i.jsx(Us,{type:W.type,name:W.name,onBack:()=>H(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const J={type:"team",name:g.id,displayName:Nh(g,s),version:g.version,description:Gw(g,s),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(X=>({name:Kw(g,X.name??X.roleName??X.templateId??"Agent",s),role:X.role??"worker",roleName:X.roleName??X.templateId,count:X.count??1,skills:X.skills??[]}))}},P=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((X,oe)=>{const Ae=Kw(g,X.name??X.roleName??X.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 ${X.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:(Ae[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:Ae}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${X.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:X.role??"worker"}),(X.count??1)>1&&i.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",X.count]})]}),(X.roleName||X.templateId)&&i.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:X.roleName??X.templateId})]}),X.skills&&X.skills.length>0&&i.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[X.skills.slice(0,3).map(G=>i.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:G},G)),X.skills.length>3&&i.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",X.skills.length-3]})]})]},oe)})})]});return i.jsx(i.Fragment,{children:i.jsx(Us,{type:"team",name:g.id,onBack:()=>{v(null),D(null)},readOnly:!0,initialManifest:J,contentSlot:P,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:()=>{V(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:F=>c(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),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((F,J)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},J))}):u.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:[u.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:u.length})})]}),i.jsx(Va,{columns:2,children:u.map(F=>i.jsx(Cr,{type:"team",name:Nh(F,s),description:Gw(F,s),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>v(F)},F.id))})]}),p.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),i.jsx(Va,{columns:2,children:p.map(F=>i.jsx(qse,{item:F,localInfo:z.get(Gc(F)),purchased:bm(F,I),onStatusChange:Y,highlight:F.id===e,onHighlightDone:t,onViewDetail:J=>H({type:"team",name:J})},F.id))})]})]})})]})}function qse({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:s,onHighlightDone:l,onViewDetail:c}){const{t:u}=lt(["store"]),[m,p]=w.useState(!1),[h,g]=w.useState(""),v=w.useRef(null),[y,k]=w.useState(!1);w.useEffect(()=>{if(s&&v.current){v.current.scrollIntoView({behavior:"smooth",block:"center"}),k(!0);const U=setTimeout(()=>{k(!1)},4e3);return()=>clearTimeout(U)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&Hse(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async U=>{if(U.stopPropagation(),!m){p(!0),g("");try{await Ps(e),g(C?u("card.upgraded"):u("card.installed")+"!"),a()}catch(W){const H=W instanceof Error?W.message:"";H.includes("402")||H.includes("Purchase required")?g(u("card.purchaseRequired")):g(u("card.failed"))}finally{p(!1)}}},D=async U=>{if(U.stopPropagation(),!m){p(!0),g("");try{await zb(e,H=>{H==="checkout_opened"?g(u("card.waitingPurchase","Waiting for purchase...")):H==="installing"&&g(u("card.installing"))})==="installed"?(g(u("card.installed")+"!"),a()):g("")}catch(W){g(W instanceof Error?W.message:u("card.failed"))}finally{p(!1)}}},z=e.slug&&e.author?.username?`${ot.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,M=()=>{T&&c?c(Gc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:U=>{_(U)},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?u("card.upgrading"):u("card.upgrade",{version:e.version})}):T?i.jsxs("button",{onClick:U=>{_(U)},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:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?i.jsx("button",{onClick:U=>{D(U)},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||u("card.installing"):i.jsxs(i.Fragment,{children:[u("card.buy","Buy")," ",E]})}):i.jsx("button",{onClick:U=>{_(U)},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:u(m?"card.installing":"card.install")}),h&&i.jsx("span",{className:`text-[10px] ${h===u("card.failed")||h===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return i.jsx("div",{ref:v,className:y?"animate-pulse":"",children:i.jsx(Cr,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:ot.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 Eh(e,t){return e.i18n?.[t]?.displayName||e.name}function jh(e,t){return e.i18n?.[t]?.description||e.description||""}function qC(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 Fse={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 Use({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s}){const{t:l}=lt(["store"]),[c,u]=w.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&&qC(e.version,p.version),v=(e.priceCents??0)>0,[y,k]=w.useState(""),T=async()=>{if(!c){u(!0),k("");try{await Ps(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{u(!1)}}},C=async()=>{if(!c){u(!0),k("");try{await zb(e,E=>{E==="checkout_opened"?k(l("card.waitingPurchase","Waiting for purchase...")):E==="installing"&&k(l("card.installing"))})==="installed"&&(a(`Purchased & installed ${e.name}`,"success"),s()),k("")}catch(S){a(S instanceof Error?S.message:l("card.failed"),"error"),k("")}finally{u(!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(v&&!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 Vw({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s,highlight:l,onHighlightDone:c,type:u="skill"}){const m=w.useRef(null),[p,h]=w.useState(!1);w.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?`${ot.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,v=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return i.jsx("div",{ref:m,className:p?"animate-pulse":"",children:i.jsx(Cr,{type:u,showTypeBadge:u!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||lm(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:ot.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:v,actions:i.jsx(Use,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s})})})}function Gse({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=lt(["store","common"]),s=a.language,l=Zo(),[c,u]=w.useState("skills"),[m,p]=w.useState(null),[h,g]=w.useState(new Set),[v,y]=w.useState([]),[k,T]=w.useState(null),[C,S]=w.useState([]),[E,_]=w.useState(0),[D,z]=w.useState(1),[M,I]=w.useState([]),[U,W]=w.useState(""),[H,Y]=w.useState("score"),[ne,V]=w.useState(""),[F,J]=w.useState(!1),[P,X]=w.useState([]),[oe,Ae]=w.useState(!1),[G,q]=w.useState([]),[le,L]=w.useState(""),[Ce,Ge]=w.useState(!1),[Ve,Qe]=w.useState([]),[it,mt]=w.useState([]),[Tt,Dt]=w.useState(new Set),[Pt,fn]=w.useState(!1),[Nt,Ue]=w.useState(""),ht=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],Lt=($,ie="success")=>{p({text:$,type:ie}),setTimeout(()=>p(null),ie==="error"?1e4:4e3)},wt=w.useCallback(async()=>{try{const $=await Ne.skills.list();y($.skills)}catch{}},[]),Jt=w.useCallback(async()=>{Ae(!0);try{const $=await Ne.skills.builtin();X($.skills)}catch{}Ae(!1)},[]),ce=w.useCallback(async $=>{J(!0);try{const ie=await Ne.skills.registrySkillhub({q:$?.q,category:$?.category,page:$?.page??1,limit:24,sort:$?.sort??H});S(ie.skills),_(ie.total),ie.categories?.length&&I(ie.categories)}catch{}J(!1)},[H]),nt=w.useCallback(async $=>{Ge(!0);try{const ie=await Ne.skills.registrySkillssh($);q(ie.skills)}catch{}Ge(!1)},[]),et=w.useCallback(async $=>{fn(!0);try{const ie=$?ot.search({type:"skill",q:$,limit:50}):Os(Ka.hubSkills)??ot.search({type:"skill",limit:50}),ge=ot.search({subtype:"connector",q:$||void 0,limit:50}).catch(()=>({items:[]})),[De,Pe]=await Promise.all([ie,ge,ot.isAuthenticated()?ot.purchases.mine().then($e=>Dt(new Set($e.purchases.map(Xe=>Xe.itemId)))).catch(()=>{}):Promise.resolve()]);let pe=De?.items??[],fe=Pe?.items??[];if(e){const $e=pe.some(Je=>Je.id===e),Xe=fe.some(Je=>Je.id===e);if(!$e&&!Xe)try{const{item:Je}=await ot.getItem(e);Je?.subtype==="connector"?fe=[Je,...fe]:Je?pe=[Je,...pe]:t?.()}catch{t?.()}else $e&&(pe=[pe.find(Se=>Se.id===e),...pe.filter(Se=>Se.id!==e)]),Xe&&(fe=[fe.find(Se=>Se.id===e),...fe.filter(Se=>Se.id!==e)])}Qe(pe),mt(fe)}catch{}fn(!1)},[e,t]);w.useEffect(()=>{wt(),Jt(),ce(),nt()},[]),w.useEffect(()=>{c==="skills"&&et(Nt)},[c,Nt,et]);const xe=async $=>{g(ie=>new Set(ie).add($.name));try{const ie=await Ne.skills.install({name:$.name,source:"skillhub",slug:$.slug,sourceUrl:$.homepage,description:$.description_zh??$.description,category:"custom",version:$.version});await wt(),Lt(`"${$.name}" installed (${ie.method}) → ${ie.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Lt(`Download failed for "${$.name}". You can try manually from: ${$.homepage}`,"error")}g(ie=>{const ge=new Set(ie);return ge.delete($.name),ge})},_e=async $=>{g(ie=>new Set(ie).add($.name));try{const ie=await Ne.skills.install({name:$.name,source:"skillssh",sourceUrl:$.url,githubRepo:`${$.author}/${$.repo}`,githubSkillPath:$.name});await wt(),Lt(`"${$.name}" installed (${ie.method}) → ${ie.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Lt(`Download failed for "${$.name}". You can try manually from: ${$.url}`,"error")}g(ie=>{const ge=new Set(ie);return ge.delete($.name),ge})},Ie=async $=>{g(ie=>new Set(ie).add($.name));try{const ie=await Ne.skills.install({name:$.name,source:"builtin"});await wt(),await Jt(),Lt(`"${$.name}" installed (${ie.method}) → ${ie.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ie){Lt(`Install failed for "${$.name}": ${ie}`,"error")}g(ie=>{const ge=new Set(ie);return ge.delete($.name),ge})},re=G.filter($=>{if(!le)return!0;const ie=le.toLowerCase();return $.name.toLowerCase().includes(ie)||$.repo.toLowerCase().includes(ie)});if(k){const $=k,ie={};$.instructions&&(ie["SKILL.md"]=$.instructions);const ge={type:"skill",name:$.name,displayName:Eh($,s),version:$.version,description:jh($,s),author:$.author??"",category:$.category??"general",tags:$.tags,files:ie,skill:{skillFile:$.instructions?"SKILL.md":"",requiredPermissions:$.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},De=$.installed&&$.installedVersion&&qC($.version,$.installedVersion)?i.jsx("button",{onClick:()=>{Ie($)},disabled:h.has($.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($.name)?n("card.upgrading"):n("card.upgrade",{version:$.version})}):$.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"),$.installedVersion?` v${$.installedVersion}`:""]}):i.jsx("button",{onClick:()=>{Ie($)},disabled:h.has($.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($.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:[$.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 ${Fse[$.category]??"bg-gray-500/15 text-fg-secondary"}`,children:$.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:$.version})]}),$.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"})]}),$.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:"✓"})]})]})]}),($.requiredPermissions.length>0||$.tags.length>0)&&i.jsxs("div",{className:"space-y-4",children:[$.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:$.requiredPermissions.map(pe=>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:pe},pe))})]}),$.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:$.tags.map(pe=>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:pe},pe))})]})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(Us,{type:"skill",name:$.name,onBack:()=>T(null),readOnly:!0,initialManifest:ge,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:ht.map($=>i.jsx("button",{onClick:()=>u($.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===$.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n($.labelKey)},$.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 $=Nt.trim().toLowerCase(),ie=$?P.filter(Pe=>Eh(Pe,s).toLowerCase().includes($)||jh(Pe,s).toLowerCase().includes($)):P,ge=oe&&Pt,De=ie.length===0&&Ve.length===0&&it.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:Nt,onChange:Pe=>Ue(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"}`})}),ge&&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,pe)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},pe))}):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:[ie.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:ie.length})})]}),i.jsx(Va,{columns:3,children:ie.map(Pe=>i.jsx(Cr,{type:"skill",name:Eh(Pe,s),description:jh(Pe,s),seed:Pe.name,icon:lm(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))})]}),Ve.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),i.jsx(Va,{columns:3,children:Ve.map(Pe=>i.jsx(Vw,{item:Pe,installedSkills:v,purchased:bm(Pe,Tt),onMsg:Lt,onRefresh:()=>{wt(),et(Nt)},highlight:Pe.id===e,onHighlightDone:t},Pe.id))})]}),it.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(Va,{columns:3,children:it.map(Pe=>i.jsx(Vw,{item:Pe,type:"connector",installedSkills:v,purchased:bm(Pe,Tt),onMsg:Lt,onRefresh:()=>{wt(),et(Nt)},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:U,onChange:$=>{W($.target.value),z(1),ce({q:ne||void 0,category:$.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($=>i.jsx("option",{value:$,children:$},$))]}),i.jsxs("select",{value:H,onChange:$=>{Y($.target.value),z(1),ce({q:ne||void 0,category:U||void 0,page:1,sort:$.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[i.jsx("option",{value:"score",children:n("skillStore.sortScore")}),i.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),i.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),i.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&i.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:i.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),i.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[i.jsx("input",{value:ne,onChange:$=>V($.target.value),onKeyDown:$=>{$.key==="Enter"&&(z(1),ce({q:ne||void 0,category:U||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:()=>{z(1),ce({q:ne||void 0,category:U||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?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(Va,{columns:3,children:C.map($=>{const ie=v.some(ge=>ge.name===$.name||ge.name===$.slug);return i.jsx(Cr,{type:"skill",name:$.name,description:$.description_zh??$.description??"",seed:$.slug,icon:lm($.slug||$.name,$.tags?.[0]),version:$.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:$.tags,installed:ie,hideStats:!0,onClick:()=>window.open($.homepage,"_blank","noopener,noreferrer"),footerLeft:i.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[$.stars>0&&i.jsxs("span",{className:"text-amber-600",children:["★ ",$.stars.toLocaleString()]}),$.downloads>0&&i.jsxs("span",{children:[$.downloads>=1e4?`${($.downloads/1e4).toFixed(1)}万`:$.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ie?void 0:i.jsx("button",{onClick:()=>{xe($)},disabled:h.has($.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($.name)?"...":n("card.install")})},$.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 $=D-1;z($),ce({q:ne||void 0,category:U||void 0,page:$})},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 $=D+1;z($),ce({q:ne||void 0,category:U||void 0,page:$})},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:le,onChange:$=>L($.target.value),onKeyDown:$=>{$.key==="Enter"&&le.trim()&&nt(le)},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:()=>{le.trim()&&nt(le)},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")})})]}),Ce?i.jsx("div",{className:"text-center text-fg-tertiary py-20",children:i.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):re.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(Va,{columns:3,children:re.map($=>{const ie=v.some(ge=>ge.name===$.name);return i.jsx(Cr,{type:"skill",name:$.name,description:$.description||"",seed:`${$.author}-${$.name}`,icon:lm($.name),authorLabel:`${$.author}/${$.repo}`,showTypeBadge:!1,installed:ie,hideStats:!0,cornerLabel:ie?void 0:"skills.sh",onClick:()=>window.open($.url,"_blank","noopener,noreferrer"),footerLeft:$.installs?i.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[$.installs," installs"]}):void 0,actions:ie?void 0:i.jsx("button",{onClick:()=>{_e($)},disabled:h.has($.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($.name)?"...":n("card.install")})},`${$.author}-${$.name}`)})})]})]})}const Kse=["agent","team","skill","connector"];function Mh({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 Vse({item:e,onOpen:t}){const n=ol(e.subtype==="connector"?"connector":e.itemType),a=Pb(n,e.slug||e.name),s=$s[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(Um,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:ot.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),i.jsxs("span",{children:["↓ ",Fo(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 Ww({items:e,onOpen:t}){return i.jsx(Va,{columns:3,children:e.map(n=>i.jsx(Cr,{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:ot.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 Yw(){return i.jsx(Va,{columns:3,children:Array.from({length:6}).map((e,t)=>i.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function Wse({onOpenType:e}){const{t}=lt(["store","common"]),[n,a]=w.useState([]),[s,l]=w.useState(!0);w.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const v=await ot.search({limit:60,sort:"popular"});g||a(v.items??[])}catch{g||a([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=w.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),u=w.useMemo(()=>[...n].sort((g,v)=>(v.trendingScore??v.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=w.useMemo(()=>[...n].sort((g,v)=>(v.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),p=w.useMemo(()=>{const g=new Map;for(const v of n){const y=v.author?.username||v.author?.id;if(!y)continue;const k=g.get(y)??{author:v.author,downloads:0,count:0};k.downloads+=v.downloadCount||0,k.count+=1,g.set(y,k)}return[...g.values()].sort((v,y)=>y.downloads-v.downloads).slice(0,6)},[n]),h=g=>e(ol(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:Kse.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 ${$s[g].gradient} hover:opacity-90 transition-opacity`,children:[$s[g].labelZh,i.jsx("span",{className:"opacity-70",children:$s[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(Vse,{item:g,onOpen:()=>h(g)},g.id))}):null,i.jsxs("section",{children:[i.jsx(Mh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),s?i.jsx(Yw,{}):u.length>0?i.jsx(Ww,{items:u,onOpen:h}):i.jsx(Yse,{})]}),i.jsxs("section",{children:[i.jsx(Mh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),s?i.jsx(Yw,{}):m.length>0?i.jsx(Ww,{items:m,onOpen:h}):null]}),p.length>0&&i.jsxs("section",{children:[i.jsx(Mh,{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,v)=>i.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[i.jsxs("div",{className:"relative",children:[i.jsx(Um,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:ot.getUrl(),size:48,verified:v<3}),v<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:v+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," 作品 · ↓ ",Fo(g.downloads)]})]},g.author?.username||v))})]})]})}function Yse(){const{t:e}=lt(["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 Gu(e,t,n){return e.i18n?.[n]?.[t]}function Qse(){const{t:e,i18n:t}=lt(["store","common"]),n=Zo(),a=t.language,[s,l]=w.useState([]),[c,u]=w.useState({}),[m,p]=w.useState(new Set),[h,g]=w.useState(null),[v,y]=w.useState(!0),[k,T]=w.useState(""),[C,S]=w.useState("all"),[E,_]=w.useState(null),D=w.useCallback(async()=>{y(!0);try{const[I,U,W,H]=await Promise.all([Ne.builder.artifacts.list().catch(()=>({artifacts:[]})),Ne.builder.artifacts.installed().catch(()=>({installed:{}})),Ne.skills.updates().catch(()=>({updates:[],count:0})),Ne.skills.builtin().catch(()=>({skills:[]}))]),Y={};for(const F of W.updates)Y[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};u(Y);const ne=I.artifacts.filter(F=>{const J=`${F.type}/${F.name}`;return!!U.installed[J]}),V=new Set(ne.filter(F=>F.type==="skill").map(F=>F.name));for(const F of H.skills)!F.installed||V.has(F.name)||!(U.installed[`skill/${F.name}`]||Y[F.name])&&!F.updateAvailable||!U.installed[`skill/${F.name}`]&&!Y[F.name]||(ne.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[a]?.displayName||F.name,description:F.i18n?.[a]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),V.add(F.name));for(const[F,J]of Object.entries(Y))V.has(F)||(ne.push({type:"skill",name:F,meta:{displayName:J.displayName||F,description:J.description||"",version:J.installedVersion},path:"",updatedAt:""}),V.add(F));l(ne)}catch{}y(!1)},[a]);w.useEffect(()=>{D()},[D]),w.useEffect(()=>{const I=()=>{D()};return window.addEventListener("markus:data-changed",I),()=>window.removeEventListener("markus:data-changed",I)},[D]),w.useEffect(()=>{if(!h)return;const I=setTimeout(()=>g(null),3e3);return()=>clearTimeout(I)},[h]);const z=async(I,U)=>{if(!m.has(I)){p(W=>new Set(W).add(I));try{await Ne.skills.install({name:I,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:I,version:U}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await D()}catch{g({text:e("installedTab.updateFailed",{name:I}),type:"error"})}p(W=>{const H=new Set(W);return H.delete(I),H})}},M=s.filter(I=>{if(C!=="all"&&I.type!==C)return!1;if(!k)return!0;const U=k.toLowerCase(),W=(Gu(I.meta,"displayName",a)||I.meta.displayName||I.name).toLowerCase(),H=(Gu(I.meta,"description",a)||I.meta.description||"").toLowerCase();return W.includes(U)||H.includes(U)}).sort((I,U)=>{const W=I.type==="skill"&&c[I.name]?1:0;return(U.type==="skill"&&c[U.name]?1:0)-W});return E?i.jsx(Us,{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:k,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:v?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(Va,{columns:3,children:M.map(I=>{const U=Gu(I.meta,"displayName",a)||I.meta.displayName||I.name,W=Gu(I.meta,"description",a)||I.meta.description||"",H=I.meta.version||"",Y=I.meta.author||"",ne=I.meta.tags??[],V=I.meta.category||"",F=I.meta.icon,J=F&&/\.(png|jpe?g|gif|webp|svg)$/i.test(F)&&!F.startsWith("http")&&!F.startsWith("data:")&&!F.startsWith("/")?`/api/builder/artifacts/${I.type}s/${encodeURIComponent(I.name)}/${F}`:F,P=I.type==="skill"?c[I.name]:void 0;return i.jsx(Cr,{type:I.type,name:U,description:W,seed:I.name,icon:J,author:null,authorLabel:Y||void 0,version:P?P.installedVersion:H,category:V,tags:ne,installed:!P,hideStats:!0,cornerLabel:P?e("installedTab.updateAvailable"):void 0,onClick:()=>{I.path&&_({type:I.type,name:I.name})},actions:P?i.jsx("button",{type:"button",disabled:m.has(I.name),onClick:()=>{z(I.name,P.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:P.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 Xse=50,Jse=30;function Zse(e,t,n,a){const s=w.useRef(0),l=w.useRef(0),c=w.useCallback(m=>{s.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),u=w.useCallback(m=>{const p=m.changedTouches[0].clientX-s.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(p),v=Math.abs(h);if(g<Xse||Math.atan2(v,g)*(180/Math.PI)>Jse)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 k=e.findIndex(T=>T.id===t);p<0&&k<e.length-1?n(e[k+1].id):p>0&&k>0?n(e[k-1].id):p>0&&k===0&&a?.onSwipeOutLeft?a.onSwipeOutLeft():p<0&&k===e.length-1&&a?.onSwipeOutRight&&a.onSwipeOutRight()},[e,t,n,a]);return{onTouchStart:c,onTouchEnd:u}}const eoe=["builder","discover","agents","teams","skills","installed"],toe={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function zg(e){return!!e&&eoe.includes(e)}function Qw(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:zg(t)?t:"builder",installId:e}}function noe({authUser:e}){const{t}=lt(["nav","store","common"]),n=w.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]=w.useState(Qw),[s,l]=w.useState(a.tab),[c,u]=w.useState(a.installId),m=Zse(n,s,l);w.useEffect(()=>{const h=Qw();h.installId&&(u(h.installId),zg(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),w.useEffect(()=>{const h=g=>{const v=g.detail,y=v.params?.storeTab??localStorage.getItem("markus_nav_storeTab");zg(y)&&l(y);const k=v.params?.installItem??localStorage.getItem("markus_nav_installItem");k&&u(k),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&&u(g),l(toe[h]??"agents")};return i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[i.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[i.jsx(G4,{className:"ml-2"}),n.map(h=>i.jsx("button",{onClick:()=>l(h.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="builder"&&i.jsx(BC,{authUser:e}),s==="discover"&&i.jsx(Wse,{onOpenType:p}),s==="agents"&&i.jsx(zse,{authUser:e,highlightItemId:c,onHighlightDone:()=>u(null)}),s==="teams"&&i.jsx($se,{highlightItemId:c,onHighlightDone:()=>u(null)}),s==="skills"&&i.jsx(Gse,{highlightItemId:c,onHighlightDone:()=>u(null)}),s==="installed"&&i.jsx(Qse,{})]})]})}const Xw="usageType",_h="profile";function aoe({onComplete:e,theme:t,onThemeChange:n,skipProfile:a,onProfileUpdated:s}){const{t:l}=lt(["onboarding","common"]),[c,u]=w.useState(0),[m,p]=w.useState(""),[h,g]=w.useState(""),[v,y]=w.useState(""),[k,T]=w.useState(""),[C,S]=w.useState(!1),[E,_]=w.useState(""),[D,z]=w.useState(!1),[M,I]=w.useState(null);w.useEffect(()=>{Ne.auth.me().then(({user:Ue})=>{Ue.name&&p(Ue.name),Ue.email&&g(Ue.email),Ue.avatarUrl&&I(Ue.avatarUrl);const ht=Ue.name||Ue.email?.split("@")[0]||"";ht&&Y(Lt=>Lt||l("usageType.defaultOrgName",{name:ht}))}).catch(()=>{}),Ne.settings.getOrg().then(({org:Ue})=>{Ue?.name&&Ue.name!=="My Organization"&&Y(Ue.name)}).catch(()=>{}),On()&&Ne.hubOrgs.invitations().then(Ue=>{Ue.invitations?.length>0&&Ae(Ue.invitations)}).catch(()=>{})},[]);const[U,W]=w.useState(null),[H,Y]=w.useState(""),[ne,V]=w.useState(!1),[F,J]=w.useState(!1),[P,X]=w.useState(""),[oe,Ae]=w.useState([]),[G,q]=w.useState(null),[le,L]=w.useState(null),Ce=async()=>{const Ue=H.trim();if(Ue){V(!0),X("");try{if(await Ne.settings.updateOrg(Ue),On()){const ht=await Ne.hubOrgs.mine(),Lt=ht.orgs?.find(wt=>wt.role==="owner")??ht.orgs?.[0];Lt?.id?await Ne.hubOrgs.update(Lt.id,{name:Ue}):await Ne.hubOrgs.create(Ue)}J(!0)}catch{X(l("usageType.orgNameSaveFailed"))}finally{V(!1)}}},[Ge,Ve]=w.useState(!0),Qe=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(v&&v.length<6){_(l("profile.errors.passwordTooShort"));return}if(v&&v!==k){_(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:Ue}=await Ne.auth.updateProfile(m.trim(),h.trim());v&&await Ne.auth.changePassword("",v),s?.(Ue),z(!0)}catch{_(l("profile.errors.saveFailed"))}finally{S(!1)}},it=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],mt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:i.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:i.jsx(KT,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:i.jsx("strong",{className:"text-fg-primary"})}})})},{id:Xw,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:()=>{W("personal"),J(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${U==="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:()=>{W("organization"),J(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${U==="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."})})]})]})]}),U==="organization"&&i.jsxs("div",{className:"space-y-4 mt-4",children:[oe.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")}),oe.map(Ue=>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:Ue.orgName}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:Ue.invitedBy})})]}),i.jsx("button",{onClick:async()=>{q(Ue.orgId);try{await Ne.hubOrgs.acceptInvitation(Ue.orgId),L(Ue.orgId),J(!0)}catch{}finally{q(null)}},disabled:G===Ue.orgId||le===Ue.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:le===Ue.orgId?l("usageType.accepted"):G===Ue.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},Ue.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:H,onChange:Ue=>{Y(Ue.target.value),J(!1),X("")},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"})]}),P&&i.jsx("p",{className:"text-xs text-red-500",children:P}),i.jsx("button",{onClick:()=>{Ce()},disabled:ne||!H.trim()||F,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(ne?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:_h,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(F4,{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:Ue=>p(Ue.target.value),placeholder:l("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),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:Ue=>g(Ue.target.value),placeholder:l("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),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:v,onChange:Ue=>y(Ue.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),v&&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:k,onChange:Ue=>T(Ue.target.value),placeholder:l("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),E&&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:()=>{Qe()},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:it.map(Ue=>i.jsxs("button",{onClick:()=>n(Ue.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===Ue.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[i.jsx("span",{className:"text-2xl",children:Ue.icon}),i.jsx("span",{className:"text-sm font-medium text-fg-primary",children:Ue.label}),i.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:Ue.desc})]},Ue.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:Ge,onChange:Ue=>Ve(Ue.target.checked),className:"accent-brand-500 shrink-0"}),i.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],Tt=a?mt.filter(Ue=>Ue.id!==_h):mt,Dt=Tt.findIndex(Ue=>Ue.id===Xw),Pt=Tt.findIndex(Ue=>Ue.id===_h),fn=()=>{c===Dt&&Dt>=0&&!U||c===Dt&&U==="organization"&&!F||c===Pt&&Pt>=0&&!D||(c<Tt.length-1?u(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ge})}).catch(()=>{}),e()))},Nt=Tt[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:Tt.map((Ue,ht)=>i.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ht<=c?"bg-brand-500":"bg-surface-elevated"}`},ht))}),i.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:Nt.title}),i.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:Nt.subtitle}),Nt.content,i.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?i.jsx("button",{onClick:()=>u(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:fn,disabled:Pt>=0&&c===Pt&&!D||Dt>=0&&c===Dt&&(!U||U==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Pt>=0&&c===Pt&&!D||Dt>=0&&c===Dt&&(!U||U==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===Tt.length-1?l("getStarted"):l("common:next")})]})]})})})}const Jw="markus:legal-consent",roe="https://markus.global";function ioe({onLogin:e,hasOwner:t}){const{t:n,i18n:a}=lt("auth"),[s,l]=w.useState(null),[c,u]=w.useState(""),[m,p]=w.useState(!1),[h,g]=w.useState(""),[v,y]=w.useState(""),[k,T]=w.useState(!1),[C,S]=w.useState(!1),E=Y=>{const ne=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${roe}${Y}${ne}`},_=()=>{try{localStorage.setItem(Jw,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},D=()=>C?(_(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),z=async()=>{const Y=On(),ne=Sr();if(!Y||!ne){u(n("login.hubUnavailable"));return}const V=await Ne.auth.hubLogin(Y,ne);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),V.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",V.cloudAiError?n("login.cloudAiNotReady",{error:V.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(V.user,V.needsOnboarding??!1,{fromHub:!0})},M=async(Y,ne=!1)=>{if(!(!ne&&!D())){u(""),l(Y??"hub");try{if(ne&&On()&&Sr()){await z();return}await Ua({method:Y,force:!0}),await z()}catch(V){const F=V instanceof Error?V.message:"";if(!F.includes("cancelled")){if(!ne&&On())return M(Y,!0);u(F||n("login.hubUnavailable"))}}finally{l(null)}}},I=()=>{VG(),l(null),u("")};w.useEffect(()=>{const Y=window.markusDesktop;if(!Y?.peekPendingDeepLinkAuth&&!Y?.consumePendingDeepLinkAuth)return;let ne=!1;return(async()=>{const V=Y.peekPendingDeepLinkAuth?await Y.peekPendingDeepLinkAuth():null;if(ne||!V)return;let F=!1;try{F=!!localStorage.getItem(Jw)}catch{}if(!C&&!F){u(n("login.consentRequired"));return}F&&!C&&S(!0),_();const J=Y.consumePendingDeepLinkAuth?await Y.consumePendingDeepLinkAuth():V;if(!(ne||!J)){u(""),l("hub");try{if(!await KG(J)||!On()||!Sr()){u(n("login.hubUnavailable"));return}await z()}catch{u(n("login.hubUnavailable"))}finally{ne||l(null)}}})().catch(()=>{}),()=>{ne=!0}},[C]);const U=async Y=>{if(Y.preventDefault(),!(!h.trim()||!v)&&D()){u(""),l("local");try{const{user:ne,needsOnboarding:V}=await Ne.auth.login(h.trim(),v);e(ne,V??!1)}catch{u(n("login.invalidCredentials"))}finally{l(null)}}},W=n(t?"login.welcomeBack":"login.getStarted"),H="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:W})]}),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:U,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:v,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||!v,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),u("")},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:H,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:H,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:H,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),u("")},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 ${k?"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 soe({token:e,onComplete:t}){const{t:n}=lt("auth"),[a,s]=w.useState(null),[l,c]=w.useState(""),[u,m]=w.useState(""),[p,h]=w.useState(""),[g,v]=w.useState(!1),[y,k]=w.useState(!1),[T,C]=w.useState(!1);w.useEffect(()=>{Ne.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!==u){h(n("invite.passwordsDoNotMatch"));return}v(!0);try{await Ne.auth.setup(e,l),k(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{v(!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:u,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||!u,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 ooe({onComplete:e,isFirstTime:t}){const{t:n}=lt("auth"),[a,s]=w.useState(""),[l,c]=w.useState(""),[u,m]=w.useState(""),[p,h]=w.useState(""),[g,v]=w.useState(!1),y=async k=>{if(k.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==u){h(n("changePassword.passwordsDoNotMatch"));return}v(!0);try{await Ne.auth.changePassword(a,l),e()}catch{h(n("changePassword.failedToChange"))}finally{v(!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:k=>s(k.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:k=>c(k.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:u,onChange:k=>m(k.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||!u,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 loe({side:e,defaultWidth:t,minWidth:n,maxWidth:a,collapsedWidth:s=0,storageKey:l}){const[c,u]=w.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]=w.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=w.useRef(!1),g=w.useRef(n),v=w.useRef(a);g.current=n,v.current=a,w.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),w.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),w.useEffect(()=>{u(T=>Math.max(n,Math.min(a,T)))},[n,a]);const y=w.useCallback(T=>{T.preventDefault(),h.current=!0;const C=T.clientX,S=c,E=D=>{if(!h.current)return;const z=D.clientX-C;u(Math.max(g.current,Math.min(v.current,S+z)))},_=()=>{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]),k=w.useCallback(()=>p(T=>!T),[]);return{width:m?s:c,rawWidth:c,collapsed:m,toggle:k,setCollapsed:p,setWidth:u,onResizeStart:y}}const Hle=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Bg="markus-theme";function Zw(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 coe(){try{const e=localStorage.getItem(Bg);if(e==="midnight")return localStorage.setItem(Bg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function doe(){const[e,t]=w.useState(coe),n=w.useCallback(a=>{t(a);try{localStorage.setItem(Bg,a)}catch{}Zw(a)},[]);return w.useEffect(()=>{Zw(e)},[e]),{mode:e,setMode:n}}let Hg=!1;const $g=new Set;function $le(e){if(Hg!==e){Hg=e;for(const t of $g)t()}}function uoe(e){return $g.add(e),()=>{$g.delete(e)}}function moe(){return Hg}const dm={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},poe={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},foe=["agents","tasks","requirements","projects","deliverables","workflows"];let e4="",t4="all",n4=dm,a4=!1;function hoe({onClose:e,currentPage:t}){const{t:n}=lt(["common","home","work"]);Jo(!0);const[a,s]=w.useState(e4),[l,c]=w.useState(t4),[u,m]=w.useState(n4),[p,h]=w.useState(!1),[g,v]=w.useState(a4),[y,k]=w.useState(-1);w.useEffect(()=>{e4=a},[a]),w.useEffect(()=>{t4=l},[l]),w.useEffect(()=>{n4=u},[u]),w.useEffect(()=>{a4=g},[g]);const T=w.useRef(null),C=w.useRef(void 0),S=w.useRef(null),E=w.useRef(null);w.useEffect(()=>{setTimeout(()=>{T.current?.focus(),T.current?.select()},100)},[]);const _=w.useCallback(async V=>{if(!V.trim()){m(dm),v(!1),k(-1);return}h(!0),v(!0),k(-1);const F=V.toLowerCase();try{const[J,P,X,oe,Ae,G]=await Promise.allSettled([Ne.agents.list({lean:!0}),Ne.tasks.list({search:V,pageSize:20}),Ne.requirements.list(),Ne.projects.list(),Ne.deliverables.search({q:V,limit:20}),Ne.teams.list()]),q=J.status==="fulfilled"?J.value.agents.filter(Qe=>Qe.name?.toLowerCase().includes(F)||Qe.role?.toLowerCase().includes(F)):[],le=P.status==="fulfilled"?P.value.tasks:[],L=X.status==="fulfilled"?X.value.requirements.filter(Qe=>Qe.title?.toLowerCase().includes(F)||Qe.description?.toLowerCase().includes(F)):[],Ce=oe.status==="fulfilled"?oe.value.projects.filter(Qe=>Qe.name?.toLowerCase().includes(F)||Qe.description?.toLowerCase().includes(F)):[],Ge=Ae.status==="fulfilled"?Ae.value.results:[],Ve=[];if(G.status==="fulfilled"){const Qe=await Promise.allSettled(G.value.teams.map(it=>Ne.workflows.list(it.id)));for(const it of Qe)if(it.status==="fulfilled")for(const mt of it.value.workflows)(mt.name.toLowerCase().includes(F)||(mt.displayName||"").toLowerCase().includes(F)||mt.description?.toLowerCase().includes(F))&&Ve.push(mt)}m({agents:q,tasks:le,requirements:L,projects:Ce,deliverables:Ge,workflows:Ve})}catch{m(dm)}finally{h(!1)}},[]),D=V=>{s(V),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>_(V),400)},z=w.useCallback((V,F)=>{e(),st.navigate(V,F)},[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=w.useMemo(()=>poe[t||""]||foe,[t]),U=w.useMemo(()=>{const V=[],F=l==="all"?8:void 0,J=P=>{if(l!=="all"&&l!==P)return;const X=u[P].length;if(P==="workflows"){const oe=F?u.workflows.slice(0,F):u.workflows;for(const Ae of oe)V.push({id:Ae.name,type:"workflow",page:se.WORK,params:{boardType:"workflows"}})}else{const oe=u[P],Ae=F?oe.slice(0,F):oe;for(const G of Ae)switch(P){case"agents":V.push({id:G.id,type:"agent",page:se.TEAM,params:{agentId:G.id}});break;case"tasks":V.push({id:G.id,type:"task",page:se.WORK,params:{openTask:G.id}});break;case"requirements":V.push({id:G.id,type:"requirement",page:se.WORK,params:{openRequirement:G.id}});break;case"projects":V.push({id:G.id,type:"project",page:se.WORK,params:{projectId:G.id}});break;case"deliverables":V.push({id:G.id,type:"deliverable",page:se.DELIVERABLES,params:{openDeliverable:G.id}});break}}F&&X>F&&V.push({id:`more_${P}`,type:"showMore",page:"",expandCategory:P,totalCount:X})};for(const P of I)J(P);return V},[u,l,I]),W=w.useCallback(V=>{if(V.type==="showMore"&&V.expandCategory){c(V.expandCategory),k(-1);return}z(V.page,V.params)},[z]);w.useEffect(()=>{const V=E.current;if(!V||y<0)return;const F=V.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const H=w.useCallback(V=>{if(V.key==="Escape"){e();return}if(V.key==="Tab"){V.preventDefault();const P=M.map(Ae=>Ae.id),X=P.indexOf(l),oe=V.shiftKey?X<=0?P.length-1:X-1:X>=P.length-1?0:X+1;c(P[oe]),k(-1);return}const F=V.ctrlKey&&V.key==="n"||V.key==="ArrowDown",J=V.ctrlKey&&V.key==="p"||V.key==="ArrowUp";if(F||J){V.preventDefault(),k(P=>{const X=U.length-1;return X<0?-1:F?P>=X?0:P+1:P<=0?X:P-1});return}V.key==="Enter"&&(V.preventDefault(),y>=0&&y<U.length&&W(U[y]))},[e,U,y,W,M,l]);w.useEffect(()=>(document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)),[H]);const Y=U.length>0;let ne=0;return i.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:V=>{V.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:V=>D(V.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(dm),v(!1),k(-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(V=>i.jsx("button",{onClick:()=>{c(V.id),k(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===V.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:V.label},V.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(V=>{if(l!=="all"&&l!==V)return null;const F=l==="all"?8:void 0,J=P=>{const X=ne++,oe=P==="agents"?u.agents.length:P==="tasks"?u.tasks.length:P==="requirements"?u.requirements.length:P==="projects"?u.projects.length:P==="workflows"?u.workflows.length:u.deliverables.length;return i.jsxs("button",{"data-idx":X,onClick:()=>{c(P),k(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${X===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:"查看全部"})," (",oe,")"]})};return V==="agents"&&u.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:(F?u.agents.slice(0,F):u.agents).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.TEAM,{agentId:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx(ns,{name:P.name||"Agent",avatarUrl:P.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:P.name}),i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:P.role||P.status})]}),i.jsx(goe,{status:P.status})]},P.id)})}),F&&u.agents.length>F&&J("agents")]},"agents"):V==="tasks"&&u.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:(F?u.tasks.slice(0,F):u.tasks).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.WORK,{openTask:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx(boe,{status:P.status}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:P.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[P.status," · ",P.priority||""]})]})]},P.id)})}),F&&u.tasks.length>F&&J("tasks")]},"tasks"):V==="requirements"&&u.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:(F?u.requirements.slice(0,F):u.requirements).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.WORK,{openRequirement:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===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 ${P.status==="approved"?"text-green-500 bg-green-500/15":P.status==="pending"?"text-amber-500 bg-amber-500/15":P.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:P.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[P.status," · ",P.priority||""]})]})]},P.id)})}),F&&u.requirements.length>F&&J("requirements")]},"requirements"):V==="projects"&&u.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:(F?u.projects.slice(0,F):u.projects).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.WORK,{projectId:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===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:P.name}),P.description&&i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:P.description})]})]},P.id)})}),F&&u.projects.length>F&&J("projects")]},"projects"):V==="deliverables"&&u.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:(F?u.deliverables.slice(0,F):u.deliverables).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.DELIVERABLES,{openDeliverable:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===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:P.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[P.type," · ",P.status]})]})]},P.id)})}),F&&u.deliverables.length>F&&J("deliverables")]},"deliverables"):V==="workflows"&&u.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:(F?u.workflows.slice(0,F):u.workflows).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===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:P.displayName||P.name}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[P.stepCount," steps · v",P.version]})]})]},P.name)})}),F&&u.workflows.length>F&&J("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 goe({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 boe({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 yoe=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function voe(e){return e===se.TEAM?"team":e===se.WORK?"work":e===se.DELIVERABLES?"deliverables":e===se.STORE?"store":"any"}function xoe({open:e,onClose:t,page:n}){const{t:a}=lt("common"),s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=voe(n);return w.useEffect(()=>{if(!e)return;const c=u=>{u.key==="Escape"&&(u.preventDefault(),u.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:yoe.map(c=>{const u=cK.filter(m=>{if(m.group!==c)return!1;const p=m.page??"any";return p==="any"?!0:p===l});return u.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:u.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 koe({authUser:e,onClose:t,onSaved:n,onUserUpdated:a}){const{t:s}=lt("common");Jo(!0);const[l,c]=w.useState(e.name||""),[u,m]=w.useState(e.email||""),[p,h]=w.useState(!1),[g,v]=w.useState(""),[y,k]=w.useState(()=>$4(e.avatarUrl,Sr()?.avatarUrl)),T=async C=>{if(C.preventDefault(),!l.trim()){v(s("profile.nameRequired"));return}if(u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u.trim())){v(s("profile.invalidEmail"));return}h(!0),v("");try{const{user:S}=await Ne.auth.updateProfile(l.trim(),u.trim());n({...S,avatarUrl:y??S.avatarUrl})}catch{v(s("profile.failedToSave"))}finally{h(!1)}};return i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:i.jsxs("form",{onSubmit:T,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:C=>C.stopPropagation(),children:[i.jsx("h3",{className:"text-base font-semibold mb-5",children:s("profile.editProfile")}),i.jsx("div",{className:"flex justify-center mb-5",children:i.jsx(F4,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:C=>{k(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:u,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 r4=w.lazy(()=>Aa(()=>import("./Team-DyqXLZ-X.js"),__vite__mapDeps([2,3,4,5,6,7,8])).then(e=>({default:e.TeamPage}))),i4=w.lazy(()=>Aa(()=>import("./Settings-icFp6tNI.js"),__vite__mapDeps([9,3,7])).then(e=>({default:e.Settings}))),woe=w.lazy(()=>Aa(()=>import("./Store-DKwOcmMu.js"),[]).then(e=>({default:e.StorePage}))),Soe=w.lazy(()=>Aa(()=>Promise.resolve().then(()=>Lse),void 0).then(e=>({default:e.AgentBuilder}))),s4=w.lazy(()=>Aa(()=>import("./Work-BXGrda4S.js"),__vite__mapDeps([10,11,3,5,1,12,4,13])).then(e=>({default:e.WorkPage}))),o4=w.lazy(()=>Aa(()=>import("./Deliverables-CQwXaCA4.js"),__vite__mapDeps([14,5,6,11])).then(e=>({default:e.DeliverablesPage}))),Coe=w.lazy(()=>Aa(()=>import("./Notifications-BvHJCIRG.js"),[]).then(e=>({default:e.NotificationsPage}))),Aoe=w.lazy(()=>Aa(()=>import("./Search-BA-aXh7i.js"),__vite__mapDeps([15,3])).then(e=>({default:e.SearchPage}))),Toe={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function Noe(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,a=e.preferences??{};if(a.locale===t&&a.timezone===n)return;Ne.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function Eoe({docScroll:e}={}){return i.jsx("div",{className:`flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse ${e?"min-h-[50dvh]":""}`,children:"Loading..."})}const joe=w.memo(function({id:t,activePage:n,docScroll:a,children:s}){const l=t===n;return i.jsx("div",{"data-page-slot":!0,className:a?"block overflow-hidden":"flex-1 overflow-hidden flex flex-col",style:l?void 0:Toe,children:i.jsx(w.Suspense,{fallback:i.jsx(Eoe,{docScroll:a}),children:s})})},(e,t)=>{if(e.docScroll!==t.docScroll)return!1;const n=e.id===e.activePage,a=t.id===t.activePage;return n!==a?!1:a?e.children===t.children:!0}),Ku={};function FC(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?N4[e]??e:e}function l4(){return FC(Ac())}function Moe(){const{t:e}=lt("common"),[t,n]=w.useState(l4),[a,s]=w.useState(!1),[l,c]=w.useState(!0),u=Zo(),m=w.useSyncExternalStore(uoe,moe,()=>!1),p=u&&!(t===se.TEAM&&m),h=w.useSyncExternalStore(iG,R4,sG),g=u&&t!==se.SETTINGS&&t!==se.SEARCH&&_4(h,t);w.useEffect(()=>{const Se=document.documentElement;return Se.classList.toggle("mobile-doc-scroll",p),()=>{Se.classList.remove("mobile-doc-scroll")}},[p]),w.useLayoutEffect(()=>{p&&window.scrollTo(0,0)},[t,p]);const v=doe(),y=loe({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[k,T]=w.useState(()=>new Set([l4()])),[C,S]=w.useState("loading"),[E,_]=w.useState(!1),[D,z]=w.useState(null),[M,I]=w.useState({hasOwner:!1,hasMultipleUsers:!1}),[U,W]=w.useState(!1),[H,Y]=w.useState(!1),[ne,V]=w.useState(null),[F,J]=w.useState(!1),[P,X]=w.useState(null),[oe,Ae]=w.useState(()=>{const Se=localStorage.getItem("markus_update_dismissed");return Se||null}),[G,q]=w.useState(!1),[le,L]=w.useState(!1),Ce=Uc(),Ge=Ce?.leftCollapsed??!1,Ve=Ce?.toggleLeftCollapsed,Qe=Ce?.setLeftCollapsed,it=Ce?.keyboardPane??"l0",mt=Ce?.setKeyboardPane,Tt=Ce?.l0FocusPageId??null,Dt=Ce?.setL0FocusPageId,Pt=w.useRef(t);Pt.current=t;const fn=w.useRef(se.HOME),Nt=Ce?.toggleRightPanel,Ue=Ce?.toggleTerminalPanel,ht=Ce?.cycleRightPanelTab,Lt=Ce?.activateRightPanelTabAt,wt=Ce?.openNewRightPanelTab,Jt=Ce?.rightPanelOpen??!1,ce=Ce?.activeRightPanelTabId??null,nt=Ce?.openRightPanel,et=Ce?.closeRightPanelTab,xe=Ce?.updateRightPanelBrowserTab,_e=Ce?.updateRightPanelTerminalTab,Ie=w.useRef(Ce?.rightPanelTabs);Ie.current=Ce?.rightPanelTabs,w.useEffect(()=>{const Se=window.markusDesktop?.browser?.onPageEvent;if(!(!Se||!nt))return Se(Te=>{if(Te.type==="closed"){const Me=Ie.current?.find(at=>at.payload.kind==="url"&&at.payload.browserId===Te.browserId);Me&&et&&et(Me.id);return}if(Te.type==="navigated"){if(Te.url&&Nc(Te.url))return;Te.browserId&&xe&&xe(Te.browserId,{url:Te.url,title:Te.title||Te.url});return}if(Te.type==="opened"||Te.type==="selected"){if(!Te.url&&!Te.browserId||Te.browserId.startsWith("eb_")||sae(Te.browserId)||Te.url&&Nc(Te.url))return;nt({kind:"url",url:Te.url||"about:blank",title:Te.title||Te.url||"Browser",browserId:Te.browserId,pageId:Te.pageId})}})},[nt,et,xe]),w.useEffect(()=>{const Se=window.markusDesktop?.terminal?.onEvent;if(!(!Se||!nt))return Se(Te=>{if(Te.type==="closed"){const Me=Ie.current?.find(at=>at.payload.kind==="terminal"&&at.payload.terminalId===Te.id);Me&&et&&et(Me.id);return}if(Te.type==="cwd"){Te.cwd&&_e?.(Te.id,{cwd:Te.cwd});return}if(Te.type==="selected"){(Te.title||Te.cwd)&&_e?.(Te.id,{title:Te.title,cwd:Te.cwd});return}if(Te.type==="opened"){if(jb.has(Te.id)){(Te.title||Te.cwd)&&_e?.(Te.id,{title:Te.title,cwd:Te.cwd});return}Ds(Te.id),nt({kind:"terminal",terminalId:Te.id,title:Te.title||"Terminal",cwd:Te.cwd})}})},[nt,et,_e]);const re=Ce?.handleTerminalExit;w.useEffect(()=>{const Se=window.markusDesktop?.terminal?.onExit;if(!(!Se||!re))return Se(Te=>{re(Te.id)})},[re]),w.useLayoutEffect(()=>{const Se=t===se.TEAM&&Jt&&Ce?.rightPanelMode==="browser";jf(Se)},[t,Jt,Ce?.rightPanelMode]),w.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const $=w.useRef(!1);w.useEffect(()=>{if(!$.current){$.current=!0;return}y.setCollapsed(Ge)},[Ge,y.setCollapsed]),w.useEffect(()=>{if(u)return;const Se=navigator.platform.toUpperCase().includes("MAC"),Te=at=>{Se&&at.metaKey&&!at.ctrlKey&&at.key==="p"?(at.preventDefault(),q(yt=>!yt)):!Se&&at.ctrlKey&&!at.metaKey&&at.key==="p"&&(at.preventDefault(),q(yt=>!yt))},Me=()=>q(!0);return document.addEventListener("keydown",Te),window.addEventListener("markus:open-search",Me),()=>{document.removeEventListener("keydown",Te),window.removeEventListener("markus:open-search",Me)}},[u]);const ie=w.useCallback(()=>!Jt||!ce||!et?!1:(et(ce),!0),[Jt,ce,et]);w.useEffect(()=>{const Se=window.markusDesktop?.onAppShortcut?.(Te=>{if(Te.type==="close-tab"){ie();return}Te.type==="new-tab"&&wt?.()});return()=>{Se?.()}},[ie,wt]),w.useEffect(()=>{if(u||!Ve||!Nt)return;const Se=navigator.platform.toUpperCase().includes("MAC"),Te=Me=>{if(!(Se?Me.metaKey&&!Me.ctrlKey:Me.ctrlKey&&!Me.metaKey)||Me.altKey)return;if(!Me.shiftKey&&(Me.key==="/"||Me.code==="Slash")){Me.preventDefault(),L(pt=>!pt);return}if(Me.shiftKey&&(Me.key==="?"||Me.key==="/")){Me.preventDefault(),L(pt=>!pt);return}if(Me.shiftKey&&Jt&&ht){if(Me.key==="]"||Me.code==="BracketRight"){Me.preventDefault(),ht(1);return}if(Me.key==="["||Me.code==="BracketLeft"){Me.preventDefault(),ht(-1);return}}if(!Me.shiftKey&&Jt&&Lt){const pt=Me.key>="1"&&Me.key<="9"?Number(Me.key):0;if(pt>=1){Me.preventDefault(),Lt(pt-1);return}}if(Me.shiftKey)return;const yt=Me.key.toLowerCase();if(yt==="w"){Me.preventDefault(),Me.stopPropagation(),ie();return}if(yt==="t"){Me.preventDefault(),wt?.();return}if(yt==="b"){if(t===se.DELIVERABLES)return;Me.preventDefault(),Ve()}else if(t===se.TEAM&&yt==="l"){if(!Se&&r2(Me.target)||Se&&r2(Me.target)&&Me.ctrlKey)return;Me.preventDefault(),Nt()}else t===se.TEAM&&yt==="j"&&Ue&&(Me.preventDefault(),Ue())};return document.addEventListener("keydown",Te,!0),()=>document.removeEventListener("keydown",Te,!0)},[u,t,Ve,Nt,Ue,ht,Lt,Jt,ie,wt]);const ge=w.useCallback((Se,Te)=>{let Me=Cc(Se);u?Me=N4[Me]??Me:Me===se.NOTIFICATIONS&&(Me=se.HOME),Me!==se.TEAM&&jf(!1);const at=Ac(),yt=window.location.hash.slice(1);yt!==Ph(at)?Ku[at]=yt:delete Ku[at];const pt=Pt.current;if(Me===se.SETTINGS&&pt!==se.SETTINGS&&(fn.current=pt,st.setSettingsReturnPage(pt),mt?.("l1"),Dt?.(se.SETTINGS)),pt===se.SETTINGS&&Me!==se.SETTINGS&&(mt?.("l0"),Dt?.(Me)),Me===se.SETTINGS&&Te?.tab){const Z=`settings/${Te.tab}`;Ku[Me]=Z,history.pushState(null,"","#"+Z),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Me),T(je=>je.has(Me)?je:new Set([...je,Me]));return}const Rt=Me!==se.WORK?Ku[Me]:void 0;Rt&&Rt!==Ph(Me)?(history.pushState(null,"",Bs(Me)),history.pushState(null,"","#"+Rt)):history.pushState(null,"",Bs(Me)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Me),T(Z=>Z.has(Me)?Z:new Set([...Z,Me]))},[u,mt,Dt]);w.useEffect(()=>{st.setHandler((Se,Te)=>ge(Se,Te))},[ge]);const De=w.useCallback(Se=>{const Te=Pt.current,Me=mG(Te,dG(Te),Se);Me&&(Me.sub&&gG(Me.page,Me.sub),ge(Me.page))},[ge]);SG({enabled:u,activePage:()=>Pt.current,onStep:De}),w.useEffect(()=>{it==="l0"&&t!==se.SETTINGS&&Dt?.(t)},[it,t,Dt]),w.useEffect(()=>{if(u||!mt||!Dt)return;const Se=Te=>{if(Te.metaKey||Te.ctrlKey||Te.altKey||a2(Te.target))return;const Me=Te.key.length===1?Te.key.toLowerCase():Te.key;if(t===se.SETTINGS&&(Me==="h"||Me==="ArrowLeft")){Te.preventDefault(),Te.stopImmediatePropagation(),st.leaveSettings();return}if(it!=="l0"||t===se.SETTINGS)return;const at=Tt&&Mo.includes(Tt)?Tt:t,yt=Math.max(0,Mo.indexOf(at));if(Me==="j"||Me==="ArrowDown"){Te.preventDefault(),Te.stopImmediatePropagation();const pt=Mo[Math.min(Mo.length-1,yt+1)];Dt(pt),pt!==t&&ge(pt),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${pt}"]`)?.scrollIntoView({block:"nearest"})});return}if(Me==="k"||Me==="ArrowUp"){Te.preventDefault(),Te.stopImmediatePropagation();const pt=Mo[Math.max(0,yt-1)];Dt(pt),pt!==t&&ge(pt),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${pt}"]`)?.scrollIntoView({block:"nearest"})});return}if(Me==="l"||Me==="ArrowRight"||Me==="Enter"){const pt=Tt&&Mo.includes(Tt)?Tt:t;if(!eG.has(pt)){Te.preventDefault(),Te.stopImmediatePropagation();return}Te.preventDefault(),Te.stopImmediatePropagation(),pt!==t&&ge(pt),Qe?.(!1),mt("l1");return}(Me==="h"||Me==="ArrowLeft")&&(Te.preventDefault(),Te.stopImmediatePropagation())};return document.addEventListener("keydown",Se,!0),()=>document.removeEventListener("keydown",Se,!0)},[u,it,Tt,t,ge,mt,Dt,Qe]),w.useEffect(()=>{const Se=()=>_(!0);return window.addEventListener("markus:open-edit-profile",Se),()=>window.removeEventListener("markus:open-edit-profile",Se)},[]),w.useEffect(()=>{if(!window.markusDesktop)return;!u&&t!==se.SETTINGS&&!y.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[y.collapsed,t,u]),w.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Se=>{if(Se.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),Se.page){const Te=Cc(Se.page);Se.params&&Object.entries(Se.params).forEach(([Me,at])=>localStorage.setItem(`markus_nav_${Me}`,at)),ge(Te),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Te,params:Se.params}}))}})},[ge]);const Pe=w.useCallback(()=>{fetch("/api/settings/llm").then(Se=>Se.ok?Se.json():null).then(Se=>{if(Se?.providers){const Te=Object.values(Se.providers).some(Me=>Me.configured);V(Te)}}).catch(()=>{})},[]),pe=w.useCallback((Se,Te)=>{if(!Se)return;const at=Te&&{agent:"agents",team:"teams",skill:"skills"}[Te]||"agents";localStorage.setItem("markus_nav_installItem",Se),localStorage.setItem("markus_nav_storeTab",at);const yt=new URLSearchParams(window.location.search);yt.get("install")||(yt.set("install",Se),Te&&yt.set("type",Te));const pt=yt.toString();window.history.replaceState(null,"",`${window.location.pathname}?${pt}${Bs(se.STORE)}`);const Rt=()=>st.navigate(se.STORE,{storeTab:at,installItem:Se});Rt(),setTimeout(Rt,500),setTimeout(Rt,1500)},[]);w.useEffect(()=>{const Se=new URLSearchParams(window.location.search),Te=Se.get("install");Te&&pe(Te,Se.get("type"));const Me=window.markusDesktop;Me?.onDeepLinkInstall?.(({id:pt,type:Rt})=>pe(pt,Rt)),Me?.consumePendingDeepLinkInstall?.().then(pt=>{pt?.id&&pe(pt.id,pt.type)}),Ne.auth.me().then(({user:pt})=>{S(pt),z(!0),s(!1),pt.preferences?.guideHidden===!0&&!Gh(pt.id)&&Kh(pt.id),Noe(pt),kr.connect(pt.id),Pe(),Ne.health().then(Z=>{Z.updateAvailable&&Z.latestVersion&&X({latestVersion:Z.latestVersion,currentVersion:Z.version})}).catch(()=>{});const Rt=()=>{js(Ka.builderArtifacts,()=>Ne.builder.artifacts.list()),js(Ka.builderAgents,()=>Ne.agents.list()),js(Ka.builderHubMyItems,()=>ot.myItems()),js(Ka.builderInstalled,()=>Ne.builder.artifacts.installed()),js(Ka.hubAgents,()=>ot.search({type:"agent",limit:50})),js(Ka.hubTeams,()=>ot.search({type:"team",limit:50})),js(Ka.hubSkills,()=>ot.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Rt,{timeout:5e3}):setTimeout(Rt,3e3)}).catch(()=>{S(null),Ne.auth.status().then(({initialized:pt,hasOwner:Rt,hasMultipleUsers:Z})=>{z(pt),I({hasOwner:Rt,hasMultipleUsers:Z})}).catch(()=>z(!0))}),kr.connect();const at=kr.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),yt=()=>{const pt=FC(Ac());pt!==se.TEAM&&jf(!1),n(pt),T(Rt=>Rt.has(pt)?Rt:new Set([...Rt,pt]))};return window.addEventListener("hashchange",yt),window.addEventListener("popstate",yt),()=>{at(),kr.disconnect(),window.removeEventListener("hashchange",yt),window.removeEventListener("popstate",yt)}},[]),w.useEffect(()=>{const Se=C!=="loading"&&C!==null?C.id:void 0;if(!Se)return;const Te=navigator.platform.toUpperCase().includes("MAC"),Me=at=>{if(a2(at.target))return;const yt={key:at.key,code:at.code,metaKey:at.metaKey,ctrlKey:at.ctrlKey,altKey:at.altKey,shiftKey:at.shiftKey};oK(yt,Se,Te)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",Me,!0),()=>window.removeEventListener("keydown",Me,!0)},[C]);const fe=C!=="loading"&&C!==null?C:void 0,$e=w.useMemo(()=>u?{[se.HOME]:i.jsx(c2,{authUser:fe}),[se.TEAM]:i.jsx(r4,{authUser:fe}),[se.BUILDER]:i.jsx(noe,{authUser:fe}),[se.SETTINGS]:i.jsx(i4,{theme:v.mode,onThemeChange:v.setMode,authUser:fe,onLogout:()=>{Ne.auth.logout().catch(()=>{}),Ls(),S(null)},onUserUpdated:Se=>S(Se)}),[se.WORK]:i.jsx(s4,{authUser:fe}),[se.DELIVERABLES]:i.jsx(o4,{authUser:fe}),[se.NOTIFICATIONS]:i.jsx(Coe,{authUser:fe}),[se.SEARCH]:i.jsx(Aoe,{})}:{[se.HOME]:i.jsx(c2,{authUser:fe}),[se.TEAM]:i.jsx(r4,{authUser:fe}),[se.SETTINGS]:i.jsx(i4,{theme:v.mode,onThemeChange:v.setMode,authUser:fe,onLogout:()=>{Ne.auth.logout().catch(()=>{}),Ls(),S(null)},onUserUpdated:Se=>S(Se)}),[se.STORE]:i.jsx(woe,{authUser:fe}),[se.BUILDER]:i.jsx(Soe,{authUser:fe}),[se.WORK]:i.jsx(s4,{authUser:fe}),[se.DELIVERABLES]:i.jsx(o4,{authUser:fe})},[fe?.id,fe?.role,v.mode,u]);if(C==="loading"||C===null&&D===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 Je=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Je?i.jsx(soe,{token:Je[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),s(!0),W(!0),S("loading"),Ne.auth.me().then(Se=>{i2(Se.user.id),S(Se.user)}).catch(()=>S(null))}}):C===null?i.jsx(ioe,{hasOwner:M.hasOwner,hasMultipleUsers:M.hasMultipleUsers,onLogin:(Se,Te,Me)=>{S(Se),kr.connect(Se.id),Te?(i2(Se.id),s(!0),Me?.fromHub&&W(!0)):(s(!1),Gh(Se.id)?(Kh(Se.id),Ne.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),S({...Se,preferences:{...Se.preferences,guideHidden:!0}})):S(Se))}}):H?i.jsx(ooe,{onComplete:()=>Y(!1),isFirstTime:!0}):a?i.jsx(aoe,{theme:v.mode,onThemeChange:v.setMode,skipProfile:U,onProfileUpdated:Se=>{const Te={id:Se.id,name:Se.name,email:Se.email,role:Se.role,orgId:Se.orgId??"default",avatarUrl:Se.avatarUrl};S(Te)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),s(!1),W(!1),Ne.auth.me().then(Se=>S(Se.user)).catch(()=>{}),Pe(),ge(se.HOME)}}):i.jsxs("div",{className:`flex ${p?"min-h-dvh":"h-dvh overflow-x-hidden"} bg-surface-primary text-fg-primary ${u?"flex-col":""}`,children:[!u&&t!==se.SETTINGS&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"relative z-40 shrink-0",style:{width:y.width},children:i.jsx(nse,{currentPage:t,onNavigate:Se=>{ge(Se),c(!1),mt?.("l0"),Dt?.(Se)},authUser:C,collapsed:y.collapsed,onToggleCollapse:y.toggle,onLogout:()=>{Ne.auth.logout().catch(()=>{}),Ls(),S(null)},keyboardFocusPageId:Tt,keyboardPaneActive:it==="l0"})}),i.jsx("div",{className:`${y.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:y.collapsed?void 0:y.onResizeStart,children:!y.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 ${p?"":"overflow-hidden"} flex flex-col min-w-0 ${g?"pb-14":""}`,children:[ne===!1&&!F&&t!==se.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:u?"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:()=>J(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),P&&oe!==P.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:u?"text-xs":"",children:e("update.available",{latest:P.latestVersion,current:P.currentVersion})}),i.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[i.jsx("a",{href:"https://markus.global/#download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),i.jsx("button",{onClick:()=>{Ae(P.latestVersion),localStorage.setItem("markus_update_dismissed",P.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),i.jsx("main",{className:`flex-1 ${p?"":"overflow-hidden"} flex flex-col relative`,children:Object.keys($e).map(Se=>k.has(Se)?i.jsx(joe,{id:Se,activePage:t,docScroll:p,children:$e[Se]},Se):null)})]}),g&&i.jsx(pse,{currentPage:t,onNavigate:ge,userId:fe?.id}),u&&i.jsx(rK,{authUser:fe,onNavigate:ge,onLogout:()=>{Ne.auth.logout().catch(()=>{}),Ls(),S(null)}}),!u&&G&&i.jsx(hoe,{onClose:()=>q(!1),currentPage:t}),!u&&i.jsx(xoe,{open:le,onClose:()=>L(!1),page:t}),E&&fe&&i.jsx(koe,{authUser:fe,onClose:()=>_(!1),onUserUpdated:Se=>S(Se),onSaved:Se=>{_(!1),S(Se)}})]})}const c4="data-anim-paused",d4="data-anim-tick",u4=8,_oe=250;function Roe(){return document.visibilityState!=="visible"||document.hidden}let kc=null,Bo=0;function Doe(){kc===null&&(Bo=Bo%u4,document.documentElement.setAttribute(d4,String(Bo)),kc=window.setInterval(()=>{Bo=(Bo+1)%u4,document.documentElement.setAttribute(d4,String(Bo))},_oe))}function Ioe(){kc!==null&&(window.clearInterval(kc),kc=null)}function Rh(){const e=document.documentElement;Roe()?(e.setAttribute(c4,"true"),Ioe()):(e.removeAttribute(c4),Doe())}let m4=!1;function Loe(){m4||typeof document>"u"||(m4=!0,Rh(),document.addEventListener("visibilitychange",Rh,{passive:!0}),window.addEventListener("pageshow",Rh,{passive:!0}))}Loe();eT.createRoot(document.getElementById("root")).render(i.jsx(w.StrictMode,{children:i.jsx(mae,{children:i.jsx(Moe,{})})}));export{Ole as $,ns as A,WT as B,Jo as C,are as D,cG as E,bG as F,di as G,Bs as H,Qse as I,wa as J,OG as K,Yoe as L,G4 as M,Zie as N,ire as O,se as P,pie as Q,Poe as R,Wse as S,zse as T,mie as U,Qoe as V,_g as W,Db as X,tle as Y,ele as Z,Aa as _,Zo as a,vle as a$,Koe as a0,I4 as a1,Sr as a2,qoe as a3,Woe as a4,IG as a5,Voe as a6,Jx as a7,Foe as a8,_G as a9,gle as aA,ple as aB,mle as aC,ale as aD,ole as aE,SC as aF,lle as aG,ile as aH,yle as aI,Oie as aJ,Rle as aK,wC as aL,sle as aM,kC as aN,nle as aO,$oe as aP,$le as aQ,lse as aR,Ble as aS,Cle as aT,Ele as aU,rle as aV,Zoe as aW,ule as aX,Lb as aY,F4 as aZ,W4 as a_,Goe as aa,Uoe as ab,Vo as ac,Hle as ad,zoe as ae,Po as af,zle as ag,KT as ah,fle as ai,nG as aj,Boe as ak,Hoe as al,Ds as am,_u as an,gi as ao,xm as ap,Dle as aq,$ae as ar,nw as as,kie as at,Hs as au,sl as av,ble as aw,hle as ax,cle as ay,dle as az,JG as b,xle as b0,kle as b1,Mle as b2,kw as b3,zae as b4,Ple as b5,jle as b6,Ile as b7,Sle as b8,_le as b9,Iw as ba,Lw as bb,Yie as bc,Lle as bd,Ale as be,Nle as bf,dC as bg,r2 as bh,wle as bi,Tle as bj,Joe as bk,mC as bl,Uc as c,Zse as d,$se as e,Gse as f,Ps as g,ot as h,a2 as i,i as j,$r as k,Ne as l,loe as m,st as n,On as o,Cc as p,va as q,w as r,Yx as s,Rb as t,lt as u,Ua as v,kr as w,Ooe as x,Pc as y,Km as z};
|
|
883
|
+
${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:()=>{Nt(ce,{visibility:Ie?.visibility??"public"})},disabled:!!_e,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(_e==="share"?"common:sharing":"share.resubmit")]})]}):$?i.jsxs(i.Fragment,{children:[ie&&i.jsxs("button",{onClick:()=>{const Je=Ie?.visibility??"public";Nt(ce,{visibility:Je})},disabled:!!_e,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"})]}),_e==="share"?t("common:sharing"):t("share.updateVersion",{version:re})]}),i.jsxs("a",{href:ge()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Je=>{const Se=ge();Vo()&&Se&&(Je.preventDefault(),gi(Se))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ie?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ie?.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:[Ie?.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"})]}):Ie?.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"})]}),Ie?.visibility==="org"?t("visibility.sharedOrg"):Ie?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),i.jsxs("button",{onClick:()=>W({key:xe,name:nt}),disabled:!!_e,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 ot.ensureAuth(),Array.isArray(ce.meta.screenshots)&&ce.meta.screenshots.length>0?X(ce):V(ce)},disabled:!!_e,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(_e==="share"?"common:sharing":"common:share")]})]}),pe=i.jsx("button",{onClick:()=>S(ce),disabled:!!_e,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"})]})}),fe=ce.meta.icon,Xe=!!fe&&/\.(png|jpe?g|gif|webp|svg)$/i.test(fe)?fe.startsWith("http")||fe.startsWith("/")?fe:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(fe.split("/").pop()??"")}?v=${ce.updatedAt??""}`:fe;return i.jsx(Cr,{type:ce.type,name:nt,description:et,seed:xe,icon:Xe,version:re,footerLeft:i.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[i.jsx("button",{onClick:Je=>{Je.stopPropagation(),Ne.system.openPath(ce.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ce.path,children:jse(ce.path)}),i.jsx("span",{className:"shrink-0",children:"·"}),i.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:pe,actions:Pe,onClick:()=>Jt(ce)},xe)})})),E&&i.jsx(wa,{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),Pt(ce)},onCancel:()=>_(null)}),D&&i.jsx(wa,{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;z(null),fn(ce)},onCancel:()=>z(null)}),C&&i.jsx(wa,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:C.meta.displayName||C.meta.name||C.name}),confirmLabel:t("common:delete"),onConfirm:ht,onCancel:()=>S(null)}),U&&i.jsx(wa,{title:t("confirmUnshare"),message:t("removeFromHub",{name:U.name}),confirmLabel:t("unshare"),onConfirm:()=>{Ue()},onCancel:()=>W(null)}),H&&i.jsx(wa,{alertOnly:!0,variant:H.variant??"primary",title:H.title,message:H.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)}),ne&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>V(null),children:i.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),i.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("button",{onClick:()=>{const ce=ne;V(null),X(ce)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),i.jsx("button",{onClick:()=>{const ce=ne;V(null),Jt(ce)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&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(Ise,{isUpdate:M.has(`${F.type}/${F.name}`),onCancel:()=>J(null),onConfirm:(ce,nt)=>{const et=F;J(null),Nt(et,{priceCents:nt>0?nt:void 0})}})})}),P&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>X(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(Dse,{onCancel:()=>X(null),onConfirm:(ce,nt,et,xe)=>{const _e=P;X(null),Nt(_e,{visibility:ce,orgId:nt,priceCents:et,donationsEnabled:xe})}})})})]})})}function Dse({onCancel:e,onConfirm:t}){const{t:n}=lt(["builder","common"]),[a,s]=w.useState("public"),[l,c]=w.useState([]),[u,m]=w.useState(""),[p,h]=w.useState(!1),[g,v]=w.useState(0),[y,k]=w.useState(!1);w.useEffect(()=>{a==="org"&&l.length===0&&(h(!0),ot.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:u,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:HC.map(S=>i.jsx("button",{type:"button",onClick:()=>v(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=>k(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"?u:void 0,T&&g>0?g:void 0,T?y:void 0),disabled:a==="org"&&!u,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 HC=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Ise({isUpdate:e,onCancel:t,onConfirm:n}){const{t:a}=lt(["builder","common"]),[s,l]=w.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:HC.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 Lse=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:BC},Symbol.toStringTag,{value:"Module"}));async function $C(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 ot.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 Ose(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 Gm(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Fw(e,t){return e.i18n?.[t]?.description||e.description}const Pse={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function zse({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:a,i18n:s}=lt(["store","common"]),l=s.language,[c,u]=w.useState(""),[m,p]=w.useState([]),[h,g]=w.useState([]),[v,y]=w.useState(null),[k,T]=w.useState({}),[C,S]=w.useState(!1),[E,_]=w.useState(!0),[D,z]=w.useState(new Map),[M,I]=w.useState(new Set),[U,W]=w.useState(null),[H,Y]=w.useState(null),ne=w.useCallback(async()=>{try{const[J,P]=await Promise.all([Ne.builder.artifacts.list().catch(()=>({artifacts:[]})),Ne.builder.artifacts.installed().catch(()=>({installed:{}}))]),X=new Map;for(const oe of J.artifacts){if(oe.type!=="agent")continue;const Ae=!!P.installed[`agent/${oe.name}`];X.set(oe.name,{installed:Ae,localVersion:oe.meta.version||void 0,localUpdatedAt:oe.updatedAt})}z(X)}catch{}},[]),V=w.useCallback(async()=>{_(!0);try{const J=c?ot.search({type:"agent",q:c,limit:50}):Os(Ka.hubAgents)??ot.search({type:"agent",limit:50}),P=new URLSearchParams;c&&P.set("q",c);const X=fetch("/api/templates?"+P.toString()).then(q=>q.json()).catch(()=>({templates:[]})),[oe,Ae]=await Promise.all([J.catch(()=>({items:[],total:0})),X,ne(),ot.isAuthenticated()?ot.purchases.mine().then(q=>I(new Set(q.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),G=await $C(oe?.items??[],t);g(G.items),p(Array.isArray(Ae.templates)?Ae.templates:[]),G.missing&&n?.()}catch{p([]),g([])}finally{_(!1)}},[c,ne,t,n]);w.useEffect(()=>{V()},[V]),w.useEffect(()=>{if(!v){T({});return}fetch(`/api/templates/${encodeURIComponent(v.id)}/files`,{credentials:"include"}).then(J=>J.json()).then(J=>T(J.files??{})).catch(()=>T({}))},[v]);const F=async(J,P,X)=>{try{const oe=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:J,name:P,orgId:"default",teamId:X})});if(!oe.ok)throw new Error(`Failed: ${oe.status}`);S(!1),y(null)}catch(oe){Y({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${oe}`,variant:"danger"})}};if(U)return i.jsx(Us,{type:U.type,name:U.name,onBack:()=>W(null)});if(v){const J={type:"agent",name:v.id,displayName:Gm(v,l),version:v.version,description:Fw(v,l),author:v.author,category:v.category,tags:v.tags,icon:v.icon,files:k,agent:{roleName:v.roleId,agentRole:v.agentRole==="manager"?"manager":"worker"},dependencies:{skills:v.skills}},P=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:v.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 ${Pse[v.agentRole]??""}`,children:v.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:[v.skills.map(X=>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:X},X)),v.skills.length===0&&i.jsx("span",{className:"text-xs text-fg-tertiary italic",children:a("agentStore.noSkills")})]})]})]}),v.starterTasks&&v.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:v.starterTasks.map((X,oe)=>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 ${X.priority==="high"?"bg-red-400":X.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm text-fg-primary",children:X.title}),X.description&&i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:X.description})]})]},oe))})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(Us,{type:"agent",name:v.id,onBack:()=>y(null),readOnly:!0,initialManifest:J,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:P}),C&&i.jsx(Uw,{template:v,lang:l,onClose:()=>S(!1),onHire:F}),H&&i.jsx(wa,{alertOnly:!0,variant:H.variant??"danger",title:H.title,message:H.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:J=>u(J.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),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((J,P)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},P))}):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(Va,{columns:3,children:m.map(J=>i.jsx(Cr,{type:"agent",name:Gm(J,l),description:Fw(J,l),seed:J.id,icon:J.icon,version:J.version,category:J.category,tags:J.tags,authorLabel:J.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(J)},J.id))})]}),h.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:a("agentStore.markusHub")}),i.jsx(Va,{columns:3,children:h.map(J=>i.jsx(Bse,{item:J,localInfo:D.get(Gc(J)),purchased:bm(J,M),onStatusChange:ne,highlight:J.id===t,onHighlightDone:n,onViewDetail:P=>W({type:"agent",name:P})},J.id))})]})]})}),C&&v&&i.jsx(Uw,{template:v,lang:l,onClose:()=>S(!1),onHire:F}),H&&i.jsx(wa,{alertOnly:!0,variant:H.variant??"danger",title:H.title,message:H.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Gc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return xm(n||e.name,"hub-pkg")}function Ps(e){return(async()=>{const t=await ot.download(e.id),n=t.name||e.name,a=t.config??{},s=Gc(e,a),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},u=(t.version||e.version||(typeof a.version=="string"?a.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Ne.builder.artifacts.import(l,s,t.files,c,u);else{const m={...a,...u?{version:u}:{},name:s,displayName:a.displayName||n,description:e.description,source:c};await Ne.builder.artifacts.save(l,m)}return await Ne.builder.artifacts.install(l,s),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function zb(e,t){t("checking"),await ot.ensureAuth();const n=await ot.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Ps(e),"installed";try{if((await ot.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await ot.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Ps(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const a=Vo();let s=null;return a?gi(n.checkoutUrl):s=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const u=Date.now(),m=300*1e3,p=setInterval(async()=>{if(Date.now()-u>m){clearInterval(p),l("cancelled");return}const g=!a&&s?s.closed:!1;try{if((await ot.purchases.checkout(e.id)).alreadyOwned){clearInterval(p),t("installing");try{await Ps(e),l("installed")}catch(y){c(y)}return}}catch{}if(g){clearInterval(p);try{if((await ot.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Ps(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function Bse({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:s,onHighlightDone:l,onViewDetail:c}){const{t:u}=lt(["store"]),[m,p]=w.useState(!1),[h,g]=w.useState(""),v=w.useRef(null),[y,k]=w.useState(!1);w.useEffect(()=>{if(s&&v.current){v.current.scrollIntoView({behavior:"smooth",block:"center"}),k(!0);const U=setTimeout(()=>{k(!1)},4e3);return()=>clearTimeout(U)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&Ose(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async U=>{if(U.stopPropagation(),!m){p(!0),g("");try{await Ps(e),g(C?u("card.upgraded"):u("card.installed")+"!"),a()}catch(W){const H=W instanceof Error?W.message:"";H.includes("402")||H.includes("Purchase required")?g(u("card.purchaseRequired")):g(u("card.failed"))}finally{p(!1)}}},_=async U=>{if(U.stopPropagation(),!m){p(!0),g("");try{await zb(e,H=>{H==="checkout_opened"?g(u("card.waitingPurchase","Waiting for purchase...")):H==="installing"&&g(u("card.installing"))})==="installed"?(g(u("card.installed")+"!"),a()):g("")}catch(W){g(W instanceof Error?W.message:u("card.failed"))}finally{p(!1)}}},D=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,z=e.slug&&e.author?.username?`${ot.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,M=()=>{T&&c?c(Gc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:U=>{E(U)},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?u("card.upgrading"):u("card.upgrade",{version:e.version})}):T?i.jsxs("button",{onClick:U=>{E(U)},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:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?i.jsx("button",{onClick:U=>{_(U)},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||u("card.installing"):i.jsxs(i.Fragment,{children:[u("card.buy","Buy")," ",D]})}):i.jsx("button",{onClick:U=>{E(U)},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:u(m?"card.installing":"card.install")}),h&&!(S&&!n)&&i.jsx("span",{className:`text-[10px] ${h===u("card.failed")||h===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return i.jsx("div",{ref:v,className:y?"animate-pulse":"",children:i.jsx(Cr,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:ot.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 Uw({template:e,lang:t,onClose:n,onHire:a}){const{t:s}=lt(["store"]),[l,c]=w.useState(`${Gm(e,t)} Agent`),[u,m]=w.useState(""),[p,h]=w.useState([]),[g,v]=w.useState(!1);w.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(k=>k.json()).then(k=>h(k.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){v(!0);try{await a(e.id,l.trim(),u||void 0)}finally{v(!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:k=>k.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:Gm(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:k=>c(k.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:u,onChange:k=>m(k.target.value),className:"input-field",children:[i.jsx("option",{value:"",children:s("hireModal.noTeam")}),p.map(k=>i.jsx("option",{value:k.id,children:k.name},k.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 Nh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Gw(e,t){return e.i18n?.[t]?.description||e.description}function Kw(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function Hse(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 $se({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=lt(["store","common"]),s=a.language,[l,c]=w.useState(""),[u,m]=w.useState([]),[p,h]=w.useState([]),[g,v]=w.useState(null),[y,k]=w.useState({}),[T,C]=w.useState(!0),[S,E]=w.useState(!1),[_,D]=w.useState(null),[z,M]=w.useState(new Map),[I,U]=w.useState(new Set),[W,H]=w.useState(null),Y=w.useCallback(async()=>{try{const[F,J]=await Promise.all([Ne.builder.artifacts.list().catch(()=>({artifacts:[]})),Ne.builder.artifacts.installed().catch(()=>({installed:{}}))]),P=new Map;for(const X of F.artifacts){if(X.type!=="team")continue;const oe=!!J.installed[`team/${X.name}`];P.set(X.name,{installed:oe,localVersion:X.meta.version||void 0,localUpdatedAt:X.updatedAt})}M(P)}catch{}},[]),ne=w.useCallback(async()=>{C(!0);try{const F=l?ot.search({type:"team",q:l,limit:50}):Os(Ka.hubTeams)??ot.search({type:"team",limit:50}),[J,P]=await Promise.all([F.catch(()=>({items:[],total:0})),Ne.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),Y(),ot.isAuthenticated()?ot.purchases.mine().then(oe=>U(new Set(oe.purchases.map(Ae=>Ae.itemId)))).catch(()=>{}):Promise.resolve()]),X=await $C(J?.items??[],e);h(X.items),m(P?.templates??[]),X.missing&&t?.()}catch{m([]),h([])}finally{C(!1)}},[l,Y,e,t]);w.useEffect(()=>{ne()},[ne]),w.useEffect(()=>{if(!g){k({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>k(F.files??{})).catch(()=>k({}))},[g]);const V=async F=>{E(!0),D(null);try{const P=(await Ne.teams.create(F.name,F.description)).team.id;let X,oe=0;const Ae=[];for(const q of F.members){const le=q.count??1;for(let L=0;L<le;L++){const Ce=q.name??`${F.name} Agent ${L+1}`,Ge=le>1?`${Ce} ${L+1}`:Ce,Ve=q.roleName??q.templateId;try{const Qe=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Ge,...Ve?{roleName:Ve}:{},orgId:"default",teamId:P,agentRole:q.role??"worker",skills:q.skills??[]})});if(Qe.ok){oe++;const it=await Qe.json();q.role==="manager"&&!X&&(X=it.agent?.id)}else{const it=await Qe.json().catch(()=>({error:`HTTP ${Qe.status}`}));Ae.push(`${Ge}: ${it.error??Qe.statusText}`)}}catch(Qe){Ae.push(`${Ge}: ${String(Qe)}`)}}}X&&await Ne.teams.update(P,{managerId:X,managerType:"agent"}).catch(()=>{});const G=Ae.length>0?` (${Ae.length} failed: ${Ae[0]})`:"";D({ok:oe>0,message:`Team "${Nh(F,s)}" deployed with ${oe} agent(s)${G}`})}catch(J){D({ok:!1,message:`Failed: ${J}`})}finally{E(!1)}};if(W)return i.jsx(Us,{type:W.type,name:W.name,onBack:()=>H(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const J={type:"team",name:g.id,displayName:Nh(g,s),version:g.version,description:Gw(g,s),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(X=>({name:Kw(g,X.name??X.roleName??X.templateId??"Agent",s),role:X.role??"worker",roleName:X.roleName??X.templateId,count:X.count??1,skills:X.skills??[]}))}},P=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((X,oe)=>{const Ae=Kw(g,X.name??X.roleName??X.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 ${X.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:(Ae[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:Ae}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${X.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:X.role??"worker"}),(X.count??1)>1&&i.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",X.count]})]}),(X.roleName||X.templateId)&&i.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:X.roleName??X.templateId})]}),X.skills&&X.skills.length>0&&i.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[X.skills.slice(0,3).map(G=>i.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:G},G)),X.skills.length>3&&i.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",X.skills.length-3]})]})]},oe)})})]});return i.jsx(i.Fragment,{children:i.jsx(Us,{type:"team",name:g.id,onBack:()=>{v(null),D(null)},readOnly:!0,initialManifest:J,contentSlot:P,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:()=>{V(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:F=>c(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),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((F,J)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},J))}):u.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:[u.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:u.length})})]}),i.jsx(Va,{columns:2,children:u.map(F=>i.jsx(Cr,{type:"team",name:Nh(F,s),description:Gw(F,s),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>v(F)},F.id))})]}),p.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),i.jsx(Va,{columns:2,children:p.map(F=>i.jsx(qse,{item:F,localInfo:z.get(Gc(F)),purchased:bm(F,I),onStatusChange:Y,highlight:F.id===e,onHighlightDone:t,onViewDetail:J=>H({type:"team",name:J})},F.id))})]})]})})]})}function qse({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:s,onHighlightDone:l,onViewDetail:c}){const{t:u}=lt(["store"]),[m,p]=w.useState(!1),[h,g]=w.useState(""),v=w.useRef(null),[y,k]=w.useState(!1);w.useEffect(()=>{if(s&&v.current){v.current.scrollIntoView({behavior:"smooth",block:"center"}),k(!0);const U=setTimeout(()=>{k(!1)},4e3);return()=>clearTimeout(U)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&Hse(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async U=>{if(U.stopPropagation(),!m){p(!0),g("");try{await Ps(e),g(C?u("card.upgraded"):u("card.installed")+"!"),a()}catch(W){const H=W instanceof Error?W.message:"";H.includes("402")||H.includes("Purchase required")?g(u("card.purchaseRequired")):g(u("card.failed"))}finally{p(!1)}}},D=async U=>{if(U.stopPropagation(),!m){p(!0),g("");try{await zb(e,H=>{H==="checkout_opened"?g(u("card.waitingPurchase","Waiting for purchase...")):H==="installing"&&g(u("card.installing"))})==="installed"?(g(u("card.installed")+"!"),a()):g("")}catch(W){g(W instanceof Error?W.message:u("card.failed"))}finally{p(!1)}}},z=e.slug&&e.author?.username?`${ot.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,M=()=>{T&&c?c(Gc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:U=>{_(U)},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?u("card.upgrading"):u("card.upgrade",{version:e.version})}):T?i.jsxs("button",{onClick:U=>{_(U)},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:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?i.jsx("button",{onClick:U=>{D(U)},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||u("card.installing"):i.jsxs(i.Fragment,{children:[u("card.buy","Buy")," ",E]})}):i.jsx("button",{onClick:U=>{_(U)},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:u(m?"card.installing":"card.install")}),h&&i.jsx("span",{className:`text-[10px] ${h===u("card.failed")||h===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return i.jsx("div",{ref:v,className:y?"animate-pulse":"",children:i.jsx(Cr,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:ot.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 Eh(e,t){return e.i18n?.[t]?.displayName||e.name}function jh(e,t){return e.i18n?.[t]?.description||e.description||""}function qC(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 Fse={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 Use({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s}){const{t:l}=lt(["store"]),[c,u]=w.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&&qC(e.version,p.version),v=(e.priceCents??0)>0,[y,k]=w.useState(""),T=async()=>{if(!c){u(!0),k("");try{await Ps(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{u(!1)}}},C=async()=>{if(!c){u(!0),k("");try{await zb(e,E=>{E==="checkout_opened"?k(l("card.waitingPurchase","Waiting for purchase...")):E==="installing"&&k(l("card.installing"))})==="installed"&&(a(`Purchased & installed ${e.name}`,"success"),s()),k("")}catch(S){a(S instanceof Error?S.message:l("card.failed"),"error"),k("")}finally{u(!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(v&&!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 Vw({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s,highlight:l,onHighlightDone:c,type:u="skill"}){const m=w.useRef(null),[p,h]=w.useState(!1);w.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?`${ot.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,v=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return i.jsx("div",{ref:m,className:p?"animate-pulse":"",children:i.jsx(Cr,{type:u,showTypeBadge:u!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||lm(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:ot.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:v,actions:i.jsx(Use,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s})})})}function Gse({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=lt(["store","common"]),s=a.language,l=Zo(),[c,u]=w.useState("skills"),[m,p]=w.useState(null),[h,g]=w.useState(new Set),[v,y]=w.useState([]),[k,T]=w.useState(null),[C,S]=w.useState([]),[E,_]=w.useState(0),[D,z]=w.useState(1),[M,I]=w.useState([]),[U,W]=w.useState(""),[H,Y]=w.useState("score"),[ne,V]=w.useState(""),[F,J]=w.useState(!1),[P,X]=w.useState([]),[oe,Ae]=w.useState(!1),[G,q]=w.useState([]),[le,L]=w.useState(""),[Ce,Ge]=w.useState(!1),[Ve,Qe]=w.useState([]),[it,mt]=w.useState([]),[Tt,Dt]=w.useState(new Set),[Pt,fn]=w.useState(!1),[Nt,Ue]=w.useState(""),ht=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],Lt=($,ie="success")=>{p({text:$,type:ie}),setTimeout(()=>p(null),ie==="error"?1e4:4e3)},wt=w.useCallback(async()=>{try{const $=await Ne.skills.list();y($.skills)}catch{}},[]),Jt=w.useCallback(async()=>{Ae(!0);try{const $=await Ne.skills.builtin();X($.skills)}catch{}Ae(!1)},[]),ce=w.useCallback(async $=>{J(!0);try{const ie=await Ne.skills.registrySkillhub({q:$?.q,category:$?.category,page:$?.page??1,limit:24,sort:$?.sort??H});S(ie.skills),_(ie.total),ie.categories?.length&&I(ie.categories)}catch{}J(!1)},[H]),nt=w.useCallback(async $=>{Ge(!0);try{const ie=await Ne.skills.registrySkillssh($);q(ie.skills)}catch{}Ge(!1)},[]),et=w.useCallback(async $=>{fn(!0);try{const ie=$?ot.search({type:"skill",q:$,limit:50}):Os(Ka.hubSkills)??ot.search({type:"skill",limit:50}),ge=ot.search({subtype:"connector",q:$||void 0,limit:50}).catch(()=>({items:[]})),[De,Pe]=await Promise.all([ie,ge,ot.isAuthenticated()?ot.purchases.mine().then($e=>Dt(new Set($e.purchases.map(Xe=>Xe.itemId)))).catch(()=>{}):Promise.resolve()]);let pe=De?.items??[],fe=Pe?.items??[];if(e){const $e=pe.some(Je=>Je.id===e),Xe=fe.some(Je=>Je.id===e);if(!$e&&!Xe)try{const{item:Je}=await ot.getItem(e);Je?.subtype==="connector"?fe=[Je,...fe]:Je?pe=[Je,...pe]:t?.()}catch{t?.()}else $e&&(pe=[pe.find(Se=>Se.id===e),...pe.filter(Se=>Se.id!==e)]),Xe&&(fe=[fe.find(Se=>Se.id===e),...fe.filter(Se=>Se.id!==e)])}Qe(pe),mt(fe)}catch{}fn(!1)},[e,t]);w.useEffect(()=>{wt(),Jt(),ce(),nt()},[]),w.useEffect(()=>{c==="skills"&&et(Nt)},[c,Nt,et]);const xe=async $=>{g(ie=>new Set(ie).add($.name));try{const ie=await Ne.skills.install({name:$.name,source:"skillhub",slug:$.slug,sourceUrl:$.homepage,description:$.description_zh??$.description,category:"custom",version:$.version});await wt(),Lt(`"${$.name}" installed (${ie.method}) → ${ie.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Lt(`Download failed for "${$.name}". You can try manually from: ${$.homepage}`,"error")}g(ie=>{const ge=new Set(ie);return ge.delete($.name),ge})},_e=async $=>{g(ie=>new Set(ie).add($.name));try{const ie=await Ne.skills.install({name:$.name,source:"skillssh",sourceUrl:$.url,githubRepo:`${$.author}/${$.repo}`,githubSkillPath:$.name});await wt(),Lt(`"${$.name}" installed (${ie.method}) → ${ie.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Lt(`Download failed for "${$.name}". You can try manually from: ${$.url}`,"error")}g(ie=>{const ge=new Set(ie);return ge.delete($.name),ge})},Ie=async $=>{g(ie=>new Set(ie).add($.name));try{const ie=await Ne.skills.install({name:$.name,source:"builtin"});await wt(),await Jt(),Lt(`"${$.name}" installed (${ie.method}) → ${ie.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ie){Lt(`Install failed for "${$.name}": ${ie}`,"error")}g(ie=>{const ge=new Set(ie);return ge.delete($.name),ge})},re=G.filter($=>{if(!le)return!0;const ie=le.toLowerCase();return $.name.toLowerCase().includes(ie)||$.repo.toLowerCase().includes(ie)});if(k){const $=k,ie={};$.instructions&&(ie["SKILL.md"]=$.instructions);const ge={type:"skill",name:$.name,displayName:Eh($,s),version:$.version,description:jh($,s),author:$.author??"",category:$.category??"general",tags:$.tags,files:ie,skill:{skillFile:$.instructions?"SKILL.md":"",requiredPermissions:$.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},De=$.installed&&$.installedVersion&&qC($.version,$.installedVersion)?i.jsx("button",{onClick:()=>{Ie($)},disabled:h.has($.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($.name)?n("card.upgrading"):n("card.upgrade",{version:$.version})}):$.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"),$.installedVersion?` v${$.installedVersion}`:""]}):i.jsx("button",{onClick:()=>{Ie($)},disabled:h.has($.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($.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:[$.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 ${Fse[$.category]??"bg-gray-500/15 text-fg-secondary"}`,children:$.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:$.version})]}),$.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"})]}),$.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:"✓"})]})]})]}),($.requiredPermissions.length>0||$.tags.length>0)&&i.jsxs("div",{className:"space-y-4",children:[$.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:$.requiredPermissions.map(pe=>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:pe},pe))})]}),$.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:$.tags.map(pe=>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:pe},pe))})]})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(Us,{type:"skill",name:$.name,onBack:()=>T(null),readOnly:!0,initialManifest:ge,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:ht.map($=>i.jsx("button",{onClick:()=>u($.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===$.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n($.labelKey)},$.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 $=Nt.trim().toLowerCase(),ie=$?P.filter(Pe=>Eh(Pe,s).toLowerCase().includes($)||jh(Pe,s).toLowerCase().includes($)):P,ge=oe&&Pt,De=ie.length===0&&Ve.length===0&&it.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:Nt,onChange:Pe=>Ue(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"}`})}),ge&&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,pe)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},pe))}):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:[ie.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:ie.length})})]}),i.jsx(Va,{columns:3,children:ie.map(Pe=>i.jsx(Cr,{type:"skill",name:Eh(Pe,s),description:jh(Pe,s),seed:Pe.name,icon:lm(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))})]}),Ve.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),i.jsx(Va,{columns:3,children:Ve.map(Pe=>i.jsx(Vw,{item:Pe,installedSkills:v,purchased:bm(Pe,Tt),onMsg:Lt,onRefresh:()=>{wt(),et(Nt)},highlight:Pe.id===e,onHighlightDone:t},Pe.id))})]}),it.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(Va,{columns:3,children:it.map(Pe=>i.jsx(Vw,{item:Pe,type:"connector",installedSkills:v,purchased:bm(Pe,Tt),onMsg:Lt,onRefresh:()=>{wt(),et(Nt)},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:U,onChange:$=>{W($.target.value),z(1),ce({q:ne||void 0,category:$.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($=>i.jsx("option",{value:$,children:$},$))]}),i.jsxs("select",{value:H,onChange:$=>{Y($.target.value),z(1),ce({q:ne||void 0,category:U||void 0,page:1,sort:$.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[i.jsx("option",{value:"score",children:n("skillStore.sortScore")}),i.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),i.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),i.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&i.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:i.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),i.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[i.jsx("input",{value:ne,onChange:$=>V($.target.value),onKeyDown:$=>{$.key==="Enter"&&(z(1),ce({q:ne||void 0,category:U||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:()=>{z(1),ce({q:ne||void 0,category:U||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?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(Va,{columns:3,children:C.map($=>{const ie=v.some(ge=>ge.name===$.name||ge.name===$.slug);return i.jsx(Cr,{type:"skill",name:$.name,description:$.description_zh??$.description??"",seed:$.slug,icon:lm($.slug||$.name,$.tags?.[0]),version:$.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:$.tags,installed:ie,hideStats:!0,onClick:()=>window.open($.homepage,"_blank","noopener,noreferrer"),footerLeft:i.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[$.stars>0&&i.jsxs("span",{className:"text-amber-600",children:["★ ",$.stars.toLocaleString()]}),$.downloads>0&&i.jsxs("span",{children:[$.downloads>=1e4?`${($.downloads/1e4).toFixed(1)}万`:$.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ie?void 0:i.jsx("button",{onClick:()=>{xe($)},disabled:h.has($.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($.name)?"...":n("card.install")})},$.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 $=D-1;z($),ce({q:ne||void 0,category:U||void 0,page:$})},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 $=D+1;z($),ce({q:ne||void 0,category:U||void 0,page:$})},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:le,onChange:$=>L($.target.value),onKeyDown:$=>{$.key==="Enter"&&le.trim()&&nt(le)},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:()=>{le.trim()&&nt(le)},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")})})]}),Ce?i.jsx("div",{className:"text-center text-fg-tertiary py-20",children:i.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):re.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(Va,{columns:3,children:re.map($=>{const ie=v.some(ge=>ge.name===$.name);return i.jsx(Cr,{type:"skill",name:$.name,description:$.description||"",seed:`${$.author}-${$.name}`,icon:lm($.name),authorLabel:`${$.author}/${$.repo}`,showTypeBadge:!1,installed:ie,hideStats:!0,cornerLabel:ie?void 0:"skills.sh",onClick:()=>window.open($.url,"_blank","noopener,noreferrer"),footerLeft:$.installs?i.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[$.installs," installs"]}):void 0,actions:ie?void 0:i.jsx("button",{onClick:()=>{_e($)},disabled:h.has($.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($.name)?"...":n("card.install")})},`${$.author}-${$.name}`)})})]})]})}const Kse=["agent","team","skill","connector"];function Mh({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 Vse({item:e,onOpen:t}){const n=ol(e.subtype==="connector"?"connector":e.itemType),a=Pb(n,e.slug||e.name),s=$s[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(Um,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:ot.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),i.jsxs("span",{children:["↓ ",Fo(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 Ww({items:e,onOpen:t}){return i.jsx(Va,{columns:3,children:e.map(n=>i.jsx(Cr,{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:ot.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 Yw(){return i.jsx(Va,{columns:3,children:Array.from({length:6}).map((e,t)=>i.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function Wse({onOpenType:e}){const{t}=lt(["store","common"]),[n,a]=w.useState([]),[s,l]=w.useState(!0);w.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const v=await ot.search({limit:60,sort:"popular"});g||a(v.items??[])}catch{g||a([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=w.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),u=w.useMemo(()=>[...n].sort((g,v)=>(v.trendingScore??v.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=w.useMemo(()=>[...n].sort((g,v)=>(v.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),p=w.useMemo(()=>{const g=new Map;for(const v of n){const y=v.author?.username||v.author?.id;if(!y)continue;const k=g.get(y)??{author:v.author,downloads:0,count:0};k.downloads+=v.downloadCount||0,k.count+=1,g.set(y,k)}return[...g.values()].sort((v,y)=>y.downloads-v.downloads).slice(0,6)},[n]),h=g=>e(ol(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:Kse.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 ${$s[g].gradient} hover:opacity-90 transition-opacity`,children:[$s[g].labelZh,i.jsx("span",{className:"opacity-70",children:$s[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(Vse,{item:g,onOpen:()=>h(g)},g.id))}):null,i.jsxs("section",{children:[i.jsx(Mh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),s?i.jsx(Yw,{}):u.length>0?i.jsx(Ww,{items:u,onOpen:h}):i.jsx(Yse,{})]}),i.jsxs("section",{children:[i.jsx(Mh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),s?i.jsx(Yw,{}):m.length>0?i.jsx(Ww,{items:m,onOpen:h}):null]}),p.length>0&&i.jsxs("section",{children:[i.jsx(Mh,{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,v)=>i.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[i.jsxs("div",{className:"relative",children:[i.jsx(Um,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:ot.getUrl(),size:48,verified:v<3}),v<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:v+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," 作品 · ↓ ",Fo(g.downloads)]})]},g.author?.username||v))})]})]})}function Yse(){const{t:e}=lt(["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 Gu(e,t,n){return e.i18n?.[n]?.[t]}function Qse(){const{t:e,i18n:t}=lt(["store","common"]),n=Zo(),a=t.language,[s,l]=w.useState([]),[c,u]=w.useState({}),[m,p]=w.useState(new Set),[h,g]=w.useState(null),[v,y]=w.useState(!0),[k,T]=w.useState(""),[C,S]=w.useState("all"),[E,_]=w.useState(null),D=w.useCallback(async()=>{y(!0);try{const[I,U,W,H]=await Promise.all([Ne.builder.artifacts.list().catch(()=>({artifacts:[]})),Ne.builder.artifacts.installed().catch(()=>({installed:{}})),Ne.skills.updates().catch(()=>({updates:[],count:0})),Ne.skills.builtin().catch(()=>({skills:[]}))]),Y={};for(const F of W.updates)Y[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};u(Y);const ne=I.artifacts.filter(F=>{const J=`${F.type}/${F.name}`;return!!U.installed[J]}),V=new Set(ne.filter(F=>F.type==="skill").map(F=>F.name));for(const F of H.skills)!F.installed||V.has(F.name)||!(U.installed[`skill/${F.name}`]||Y[F.name])&&!F.updateAvailable||!U.installed[`skill/${F.name}`]&&!Y[F.name]||(ne.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[a]?.displayName||F.name,description:F.i18n?.[a]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),V.add(F.name));for(const[F,J]of Object.entries(Y))V.has(F)||(ne.push({type:"skill",name:F,meta:{displayName:J.displayName||F,description:J.description||"",version:J.installedVersion},path:"",updatedAt:""}),V.add(F));l(ne)}catch{}y(!1)},[a]);w.useEffect(()=>{D()},[D]),w.useEffect(()=>{const I=()=>{D()};return window.addEventListener("markus:data-changed",I),()=>window.removeEventListener("markus:data-changed",I)},[D]),w.useEffect(()=>{if(!h)return;const I=setTimeout(()=>g(null),3e3);return()=>clearTimeout(I)},[h]);const z=async(I,U)=>{if(!m.has(I)){p(W=>new Set(W).add(I));try{await Ne.skills.install({name:I,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:I,version:U}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await D()}catch{g({text:e("installedTab.updateFailed",{name:I}),type:"error"})}p(W=>{const H=new Set(W);return H.delete(I),H})}},M=s.filter(I=>{if(C!=="all"&&I.type!==C)return!1;if(!k)return!0;const U=k.toLowerCase(),W=(Gu(I.meta,"displayName",a)||I.meta.displayName||I.name).toLowerCase(),H=(Gu(I.meta,"description",a)||I.meta.description||"").toLowerCase();return W.includes(U)||H.includes(U)}).sort((I,U)=>{const W=I.type==="skill"&&c[I.name]?1:0;return(U.type==="skill"&&c[U.name]?1:0)-W});return E?i.jsx(Us,{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:k,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:v?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(Va,{columns:3,children:M.map(I=>{const U=Gu(I.meta,"displayName",a)||I.meta.displayName||I.name,W=Gu(I.meta,"description",a)||I.meta.description||"",H=I.meta.version||"",Y=I.meta.author||"",ne=I.meta.tags??[],V=I.meta.category||"",F=I.meta.icon,J=F&&/\.(png|jpe?g|gif|webp|svg)$/i.test(F)&&!F.startsWith("http")&&!F.startsWith("data:")&&!F.startsWith("/")?`/api/builder/artifacts/${I.type}s/${encodeURIComponent(I.name)}/${F}`:F,P=I.type==="skill"?c[I.name]:void 0;return i.jsx(Cr,{type:I.type,name:U,description:W,seed:I.name,icon:J,author:null,authorLabel:Y||void 0,version:P?P.installedVersion:H,category:V,tags:ne,installed:!P,hideStats:!0,cornerLabel:P?e("installedTab.updateAvailable"):void 0,onClick:()=>{I.path&&_({type:I.type,name:I.name})},actions:P?i.jsx("button",{type:"button",disabled:m.has(I.name),onClick:()=>{z(I.name,P.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:P.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 Xse=50,Jse=30;function Zse(e,t,n,a){const s=w.useRef(0),l=w.useRef(0),c=w.useCallback(m=>{s.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),u=w.useCallback(m=>{const p=m.changedTouches[0].clientX-s.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(p),v=Math.abs(h);if(g<Xse||Math.atan2(v,g)*(180/Math.PI)>Jse)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 k=e.findIndex(T=>T.id===t);p<0&&k<e.length-1?n(e[k+1].id):p>0&&k>0?n(e[k-1].id):p>0&&k===0&&a?.onSwipeOutLeft?a.onSwipeOutLeft():p<0&&k===e.length-1&&a?.onSwipeOutRight&&a.onSwipeOutRight()},[e,t,n,a]);return{onTouchStart:c,onTouchEnd:u}}const eoe=["builder","discover","agents","teams","skills","installed"],toe={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function zg(e){return!!e&&eoe.includes(e)}function Qw(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:zg(t)?t:"builder",installId:e}}function noe({authUser:e}){const{t}=lt(["nav","store","common"]),n=w.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]=w.useState(Qw),[s,l]=w.useState(a.tab),[c,u]=w.useState(a.installId),m=Zse(n,s,l);w.useEffect(()=>{const h=Qw();h.installId&&(u(h.installId),zg(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),w.useEffect(()=>{const h=g=>{const v=g.detail,y=v.params?.storeTab??localStorage.getItem("markus_nav_storeTab");zg(y)&&l(y);const k=v.params?.installItem??localStorage.getItem("markus_nav_installItem");k&&u(k),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&&u(g),l(toe[h]??"agents")};return i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[i.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[i.jsx(G4,{className:"ml-2"}),n.map(h=>i.jsx("button",{onClick:()=>l(h.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="builder"&&i.jsx(BC,{authUser:e}),s==="discover"&&i.jsx(Wse,{onOpenType:p}),s==="agents"&&i.jsx(zse,{authUser:e,highlightItemId:c,onHighlightDone:()=>u(null)}),s==="teams"&&i.jsx($se,{highlightItemId:c,onHighlightDone:()=>u(null)}),s==="skills"&&i.jsx(Gse,{highlightItemId:c,onHighlightDone:()=>u(null)}),s==="installed"&&i.jsx(Qse,{})]})]})}const Xw="usageType",_h="profile";function aoe({onComplete:e,theme:t,onThemeChange:n,skipProfile:a,onProfileUpdated:s}){const{t:l}=lt(["onboarding","common"]),[c,u]=w.useState(0),[m,p]=w.useState(""),[h,g]=w.useState(""),[v,y]=w.useState(""),[k,T]=w.useState(""),[C,S]=w.useState(!1),[E,_]=w.useState(""),[D,z]=w.useState(!1),[M,I]=w.useState(null);w.useEffect(()=>{Ne.auth.me().then(({user:Ue})=>{Ue.name&&p(Ue.name),Ue.email&&g(Ue.email),Ue.avatarUrl&&I(Ue.avatarUrl);const ht=Ue.name||Ue.email?.split("@")[0]||"";ht&&Y(Lt=>Lt||l("usageType.defaultOrgName",{name:ht}))}).catch(()=>{}),Ne.settings.getOrg().then(({org:Ue})=>{Ue?.name&&Ue.name!=="My Organization"&&Y(Ue.name)}).catch(()=>{}),On()&&Ne.hubOrgs.invitations().then(Ue=>{Ue.invitations?.length>0&&Ae(Ue.invitations)}).catch(()=>{})},[]);const[U,W]=w.useState(null),[H,Y]=w.useState(""),[ne,V]=w.useState(!1),[F,J]=w.useState(!1),[P,X]=w.useState(""),[oe,Ae]=w.useState([]),[G,q]=w.useState(null),[le,L]=w.useState(null),Ce=async()=>{const Ue=H.trim();if(Ue){V(!0),X("");try{if(await Ne.settings.updateOrg(Ue),On()){const ht=await Ne.hubOrgs.mine(),Lt=ht.orgs?.find(wt=>wt.role==="owner")??ht.orgs?.[0];Lt?.id?await Ne.hubOrgs.update(Lt.id,{name:Ue}):await Ne.hubOrgs.create(Ue)}J(!0)}catch{X(l("usageType.orgNameSaveFailed"))}finally{V(!1)}}},[Ge,Ve]=w.useState(!0),Qe=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(v&&v.length<6){_(l("profile.errors.passwordTooShort"));return}if(v&&v!==k){_(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:Ue}=await Ne.auth.updateProfile(m.trim(),h.trim());v&&await Ne.auth.changePassword("",v),s?.(Ue),z(!0)}catch{_(l("profile.errors.saveFailed"))}finally{S(!1)}},it=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],mt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:i.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:i.jsx(KT,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:i.jsx("strong",{className:"text-fg-primary"})}})})},{id:Xw,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:()=>{W("personal"),J(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${U==="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:()=>{W("organization"),J(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${U==="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."})})]})]})]}),U==="organization"&&i.jsxs("div",{className:"space-y-4 mt-4",children:[oe.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")}),oe.map(Ue=>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:Ue.orgName}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:Ue.invitedBy})})]}),i.jsx("button",{onClick:async()=>{q(Ue.orgId);try{await Ne.hubOrgs.acceptInvitation(Ue.orgId),L(Ue.orgId),J(!0)}catch{}finally{q(null)}},disabled:G===Ue.orgId||le===Ue.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:le===Ue.orgId?l("usageType.accepted"):G===Ue.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},Ue.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:H,onChange:Ue=>{Y(Ue.target.value),J(!1),X("")},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"})]}),P&&i.jsx("p",{className:"text-xs text-red-500",children:P}),i.jsx("button",{onClick:()=>{Ce()},disabled:ne||!H.trim()||F,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(ne?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:_h,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(F4,{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:Ue=>p(Ue.target.value),placeholder:l("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),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:Ue=>g(Ue.target.value),placeholder:l("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),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:v,onChange:Ue=>y(Ue.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),v&&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:k,onChange:Ue=>T(Ue.target.value),placeholder:l("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),E&&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:()=>{Qe()},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:it.map(Ue=>i.jsxs("button",{onClick:()=>n(Ue.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===Ue.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[i.jsx("span",{className:"text-2xl",children:Ue.icon}),i.jsx("span",{className:"text-sm font-medium text-fg-primary",children:Ue.label}),i.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:Ue.desc})]},Ue.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:Ge,onChange:Ue=>Ve(Ue.target.checked),className:"accent-brand-500 shrink-0"}),i.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],Tt=a?mt.filter(Ue=>Ue.id!==_h):mt,Dt=Tt.findIndex(Ue=>Ue.id===Xw),Pt=Tt.findIndex(Ue=>Ue.id===_h),fn=()=>{c===Dt&&Dt>=0&&!U||c===Dt&&U==="organization"&&!F||c===Pt&&Pt>=0&&!D||(c<Tt.length-1?u(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ge})}).catch(()=>{}),e()))},Nt=Tt[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:Tt.map((Ue,ht)=>i.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ht<=c?"bg-brand-500":"bg-surface-elevated"}`},ht))}),i.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:Nt.title}),i.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:Nt.subtitle}),Nt.content,i.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?i.jsx("button",{onClick:()=>u(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:fn,disabled:Pt>=0&&c===Pt&&!D||Dt>=0&&c===Dt&&(!U||U==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Pt>=0&&c===Pt&&!D||Dt>=0&&c===Dt&&(!U||U==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===Tt.length-1?l("getStarted"):l("common:next")})]})]})})})}const Jw="markus:legal-consent",roe="https://markus.global";function ioe({onLogin:e,hasOwner:t}){const{t:n,i18n:a}=lt("auth"),[s,l]=w.useState(null),[c,u]=w.useState(""),[m,p]=w.useState(!1),[h,g]=w.useState(""),[v,y]=w.useState(""),[k,T]=w.useState(!1),[C,S]=w.useState(!1),E=Y=>{const ne=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${roe}${Y}${ne}`},_=()=>{try{localStorage.setItem(Jw,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},D=()=>C?(_(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),z=async()=>{const Y=On(),ne=Sr();if(!Y||!ne){u(n("login.hubUnavailable"));return}const V=await Ne.auth.hubLogin(Y,ne);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),V.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",V.cloudAiError?n("login.cloudAiNotReady",{error:V.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(V.user,V.needsOnboarding??!1,{fromHub:!0})},M=async(Y,ne=!1)=>{if(!(!ne&&!D())){u(""),l(Y??"hub");try{if(ne&&On()&&Sr()){await z();return}await Ua({method:Y,force:!0}),await z()}catch(V){const F=V instanceof Error?V.message:"";if(!F.includes("cancelled")){if(!ne&&On())return M(Y,!0);u(F||n("login.hubUnavailable"))}}finally{l(null)}}},I=()=>{VG(),l(null),u("")};w.useEffect(()=>{const Y=window.markusDesktop;if(!Y?.peekPendingDeepLinkAuth&&!Y?.consumePendingDeepLinkAuth)return;let ne=!1;return(async()=>{const V=Y.peekPendingDeepLinkAuth?await Y.peekPendingDeepLinkAuth():null;if(ne||!V)return;let F=!1;try{F=!!localStorage.getItem(Jw)}catch{}if(!C&&!F){u(n("login.consentRequired"));return}F&&!C&&S(!0),_();const J=Y.consumePendingDeepLinkAuth?await Y.consumePendingDeepLinkAuth():V;if(!(ne||!J)){u(""),l("hub");try{if(!await KG(J)||!On()||!Sr()){u(n("login.hubUnavailable"));return}await z()}catch{u(n("login.hubUnavailable"))}finally{ne||l(null)}}})().catch(()=>{}),()=>{ne=!0}},[C]);const U=async Y=>{if(Y.preventDefault(),!(!h.trim()||!v)&&D()){u(""),l("local");try{const{user:ne,needsOnboarding:V}=await Ne.auth.login(h.trim(),v);e(ne,V??!1)}catch{u(n("login.invalidCredentials"))}finally{l(null)}}},W=n(t?"login.welcomeBack":"login.getStarted"),H="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:W})]}),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:U,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:v,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||!v,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),u("")},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:H,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:H,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:H,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),u("")},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 ${k?"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 soe({token:e,onComplete:t}){const{t:n}=lt("auth"),[a,s]=w.useState(null),[l,c]=w.useState(""),[u,m]=w.useState(""),[p,h]=w.useState(""),[g,v]=w.useState(!1),[y,k]=w.useState(!1),[T,C]=w.useState(!1);w.useEffect(()=>{Ne.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!==u){h(n("invite.passwordsDoNotMatch"));return}v(!0);try{await Ne.auth.setup(e,l),k(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{v(!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:u,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||!u,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 ooe({onComplete:e,isFirstTime:t}){const{t:n}=lt("auth"),[a,s]=w.useState(""),[l,c]=w.useState(""),[u,m]=w.useState(""),[p,h]=w.useState(""),[g,v]=w.useState(!1),y=async k=>{if(k.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==u){h(n("changePassword.passwordsDoNotMatch"));return}v(!0);try{await Ne.auth.changePassword(a,l),e()}catch{h(n("changePassword.failedToChange"))}finally{v(!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:k=>s(k.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:k=>c(k.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:u,onChange:k=>m(k.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||!u,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 loe({side:e,defaultWidth:t,minWidth:n,maxWidth:a,collapsedWidth:s=0,storageKey:l}){const[c,u]=w.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]=w.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=w.useRef(!1),g=w.useRef(n),v=w.useRef(a);g.current=n,v.current=a,w.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),w.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),w.useEffect(()=>{u(T=>Math.max(n,Math.min(a,T)))},[n,a]);const y=w.useCallback(T=>{T.preventDefault(),h.current=!0;const C=T.clientX,S=c,E=D=>{if(!h.current)return;const z=D.clientX-C;u(Math.max(g.current,Math.min(v.current,S+z)))},_=()=>{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]),k=w.useCallback(()=>p(T=>!T),[]);return{width:m?s:c,rawWidth:c,collapsed:m,toggle:k,setCollapsed:p,setWidth:u,onResizeStart:y}}const Hle=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Bg="markus-theme";function Zw(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 coe(){try{const e=localStorage.getItem(Bg);if(e==="midnight")return localStorage.setItem(Bg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function doe(){const[e,t]=w.useState(coe),n=w.useCallback(a=>{t(a);try{localStorage.setItem(Bg,a)}catch{}Zw(a)},[]);return w.useEffect(()=>{Zw(e)},[e]),{mode:e,setMode:n}}let Hg=!1;const $g=new Set;function $le(e){if(Hg!==e){Hg=e;for(const t of $g)t()}}function uoe(e){return $g.add(e),()=>{$g.delete(e)}}function moe(){return Hg}const dm={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},poe={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},foe=["agents","tasks","requirements","projects","deliverables","workflows"];let e4="",t4="all",n4=dm,a4=!1;function hoe({onClose:e,currentPage:t}){const{t:n}=lt(["common","home","work"]);Jo(!0);const[a,s]=w.useState(e4),[l,c]=w.useState(t4),[u,m]=w.useState(n4),[p,h]=w.useState(!1),[g,v]=w.useState(a4),[y,k]=w.useState(-1);w.useEffect(()=>{e4=a},[a]),w.useEffect(()=>{t4=l},[l]),w.useEffect(()=>{n4=u},[u]),w.useEffect(()=>{a4=g},[g]);const T=w.useRef(null),C=w.useRef(void 0),S=w.useRef(null),E=w.useRef(null);w.useEffect(()=>{setTimeout(()=>{T.current?.focus(),T.current?.select()},100)},[]);const _=w.useCallback(async V=>{if(!V.trim()){m(dm),v(!1),k(-1);return}h(!0),v(!0),k(-1);const F=V.toLowerCase();try{const[J,P,X,oe,Ae,G]=await Promise.allSettled([Ne.agents.list({lean:!0}),Ne.tasks.list({search:V,pageSize:20}),Ne.requirements.list(),Ne.projects.list(),Ne.deliverables.search({q:V,limit:20}),Ne.teams.list()]),q=J.status==="fulfilled"?J.value.agents.filter(Qe=>Qe.name?.toLowerCase().includes(F)||Qe.role?.toLowerCase().includes(F)):[],le=P.status==="fulfilled"?P.value.tasks:[],L=X.status==="fulfilled"?X.value.requirements.filter(Qe=>Qe.title?.toLowerCase().includes(F)||Qe.description?.toLowerCase().includes(F)):[],Ce=oe.status==="fulfilled"?oe.value.projects.filter(Qe=>Qe.name?.toLowerCase().includes(F)||Qe.description?.toLowerCase().includes(F)):[],Ge=Ae.status==="fulfilled"?Ae.value.results:[],Ve=[];if(G.status==="fulfilled"){const Qe=await Promise.allSettled(G.value.teams.map(it=>Ne.workflows.list(it.id)));for(const it of Qe)if(it.status==="fulfilled")for(const mt of it.value.workflows)(mt.name.toLowerCase().includes(F)||(mt.displayName||"").toLowerCase().includes(F)||mt.description?.toLowerCase().includes(F))&&Ve.push(mt)}m({agents:q,tasks:le,requirements:L,projects:Ce,deliverables:Ge,workflows:Ve})}catch{m(dm)}finally{h(!1)}},[]),D=V=>{s(V),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>_(V),400)},z=w.useCallback((V,F)=>{e(),st.navigate(V,F)},[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=w.useMemo(()=>poe[t||""]||foe,[t]),U=w.useMemo(()=>{const V=[],F=l==="all"?8:void 0,J=P=>{if(l!=="all"&&l!==P)return;const X=u[P].length;if(P==="workflows"){const oe=F?u.workflows.slice(0,F):u.workflows;for(const Ae of oe)V.push({id:Ae.name,type:"workflow",page:se.WORK,params:{boardType:"workflows"}})}else{const oe=u[P],Ae=F?oe.slice(0,F):oe;for(const G of Ae)switch(P){case"agents":V.push({id:G.id,type:"agent",page:se.TEAM,params:{agentId:G.id}});break;case"tasks":V.push({id:G.id,type:"task",page:se.WORK,params:{openTask:G.id}});break;case"requirements":V.push({id:G.id,type:"requirement",page:se.WORK,params:{openRequirement:G.id}});break;case"projects":V.push({id:G.id,type:"project",page:se.WORK,params:{projectId:G.id}});break;case"deliverables":V.push({id:G.id,type:"deliverable",page:se.DELIVERABLES,params:{openDeliverable:G.id}});break}}F&&X>F&&V.push({id:`more_${P}`,type:"showMore",page:"",expandCategory:P,totalCount:X})};for(const P of I)J(P);return V},[u,l,I]),W=w.useCallback(V=>{if(V.type==="showMore"&&V.expandCategory){c(V.expandCategory),k(-1);return}z(V.page,V.params)},[z]);w.useEffect(()=>{const V=E.current;if(!V||y<0)return;const F=V.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const H=w.useCallback(V=>{if(V.key==="Escape"){e();return}if(V.key==="Tab"){V.preventDefault();const P=M.map(Ae=>Ae.id),X=P.indexOf(l),oe=V.shiftKey?X<=0?P.length-1:X-1:X>=P.length-1?0:X+1;c(P[oe]),k(-1);return}const F=V.ctrlKey&&V.key==="n"||V.key==="ArrowDown",J=V.ctrlKey&&V.key==="p"||V.key==="ArrowUp";if(F||J){V.preventDefault(),k(P=>{const X=U.length-1;return X<0?-1:F?P>=X?0:P+1:P<=0?X:P-1});return}V.key==="Enter"&&(V.preventDefault(),y>=0&&y<U.length&&W(U[y]))},[e,U,y,W,M,l]);w.useEffect(()=>(document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)),[H]);const Y=U.length>0;let ne=0;return i.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:V=>{V.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:V=>D(V.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(dm),v(!1),k(-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(V=>i.jsx("button",{onClick:()=>{c(V.id),k(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===V.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:V.label},V.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(V=>{if(l!=="all"&&l!==V)return null;const F=l==="all"?8:void 0,J=P=>{const X=ne++,oe=P==="agents"?u.agents.length:P==="tasks"?u.tasks.length:P==="requirements"?u.requirements.length:P==="projects"?u.projects.length:P==="workflows"?u.workflows.length:u.deliverables.length;return i.jsxs("button",{"data-idx":X,onClick:()=>{c(P),k(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${X===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:"查看全部"})," (",oe,")"]})};return V==="agents"&&u.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:(F?u.agents.slice(0,F):u.agents).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.TEAM,{agentId:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx(ns,{name:P.name||"Agent",avatarUrl:P.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:P.name}),i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:P.role||P.status})]}),i.jsx(goe,{status:P.status})]},P.id)})}),F&&u.agents.length>F&&J("agents")]},"agents"):V==="tasks"&&u.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:(F?u.tasks.slice(0,F):u.tasks).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.WORK,{openTask:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx(boe,{status:P.status}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:P.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[P.status," · ",P.priority||""]})]})]},P.id)})}),F&&u.tasks.length>F&&J("tasks")]},"tasks"):V==="requirements"&&u.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:(F?u.requirements.slice(0,F):u.requirements).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.WORK,{openRequirement:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===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 ${P.status==="approved"?"text-green-500 bg-green-500/15":P.status==="pending"?"text-amber-500 bg-amber-500/15":P.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:P.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[P.status," · ",P.priority||""]})]})]},P.id)})}),F&&u.requirements.length>F&&J("requirements")]},"requirements"):V==="projects"&&u.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:(F?u.projects.slice(0,F):u.projects).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.WORK,{projectId:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===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:P.name}),P.description&&i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:P.description})]})]},P.id)})}),F&&u.projects.length>F&&J("projects")]},"projects"):V==="deliverables"&&u.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:(F?u.deliverables.slice(0,F):u.deliverables).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.DELIVERABLES,{openDeliverable:P.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===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:P.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[P.type," · ",P.status]})]})]},P.id)})}),F&&u.deliverables.length>F&&J("deliverables")]},"deliverables"):V==="workflows"&&u.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:(F?u.workflows.slice(0,F):u.workflows).map(P=>{const X=ne++;return i.jsxs("button",{"data-idx":X,onClick:()=>z(se.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${X===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:P.displayName||P.name}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[P.stepCount," steps · v",P.version]})]})]},P.name)})}),F&&u.workflows.length>F&&J("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 goe({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 boe({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 yoe=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function voe(e){return e===se.TEAM?"team":e===se.WORK?"work":e===se.DELIVERABLES?"deliverables":e===se.STORE?"store":"any"}function xoe({open:e,onClose:t,page:n}){const{t:a}=lt("common"),s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=voe(n);return w.useEffect(()=>{if(!e)return;const c=u=>{u.key==="Escape"&&(u.preventDefault(),u.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:yoe.map(c=>{const u=cK.filter(m=>{if(m.group!==c)return!1;const p=m.page??"any";return p==="any"?!0:p===l});return u.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:u.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 koe({authUser:e,onClose:t,onSaved:n,onUserUpdated:a}){const{t:s}=lt("common");Jo(!0);const[l,c]=w.useState(e.name||""),[u,m]=w.useState(e.email||""),[p,h]=w.useState(!1),[g,v]=w.useState(""),[y,k]=w.useState(()=>$4(e.avatarUrl,Sr()?.avatarUrl)),T=async C=>{if(C.preventDefault(),!l.trim()){v(s("profile.nameRequired"));return}if(u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u.trim())){v(s("profile.invalidEmail"));return}h(!0),v("");try{const{user:S}=await Ne.auth.updateProfile(l.trim(),u.trim());n({...S,avatarUrl:y??S.avatarUrl})}catch{v(s("profile.failedToSave"))}finally{h(!1)}};return i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:i.jsxs("form",{onSubmit:T,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:C=>C.stopPropagation(),children:[i.jsx("h3",{className:"text-base font-semibold mb-5",children:s("profile.editProfile")}),i.jsx("div",{className:"flex justify-center mb-5",children:i.jsx(F4,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:C=>{k(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:u,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 r4=w.lazy(()=>Aa(()=>import("./Team-Dcl-5Zvh.js"),__vite__mapDeps([2,3,4,5,6,7,8])).then(e=>({default:e.TeamPage}))),i4=w.lazy(()=>Aa(()=>import("./Settings-5tk3XjBZ.js"),__vite__mapDeps([9,3,7])).then(e=>({default:e.Settings}))),woe=w.lazy(()=>Aa(()=>import("./Store-CMxzEtXt.js"),[]).then(e=>({default:e.StorePage}))),Soe=w.lazy(()=>Aa(()=>Promise.resolve().then(()=>Lse),void 0).then(e=>({default:e.AgentBuilder}))),s4=w.lazy(()=>Aa(()=>import("./Work-Dj9tQYXg.js"),__vite__mapDeps([10,11,3,5,1,12,4,13])).then(e=>({default:e.WorkPage}))),o4=w.lazy(()=>Aa(()=>import("./Deliverables-DIeYy6k7.js"),__vite__mapDeps([14,5,6,11])).then(e=>({default:e.DeliverablesPage}))),Coe=w.lazy(()=>Aa(()=>import("./Notifications-BoPgYIh8.js"),[]).then(e=>({default:e.NotificationsPage}))),Aoe=w.lazy(()=>Aa(()=>import("./Search-Bc44e8vT.js"),__vite__mapDeps([15,3])).then(e=>({default:e.SearchPage}))),Toe={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function Noe(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,a=e.preferences??{};if(a.locale===t&&a.timezone===n)return;Ne.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function Eoe({docScroll:e}={}){return i.jsx("div",{className:`flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse ${e?"min-h-[50dvh]":""}`,children:"Loading..."})}const joe=w.memo(function({id:t,activePage:n,docScroll:a,children:s}){const l=t===n;return i.jsx("div",{"data-page-slot":!0,className:a?"block overflow-hidden":"flex-1 overflow-hidden flex flex-col",style:l?void 0:Toe,children:i.jsx(w.Suspense,{fallback:i.jsx(Eoe,{docScroll:a}),children:s})})},(e,t)=>{if(e.docScroll!==t.docScroll)return!1;const n=e.id===e.activePage,a=t.id===t.activePage;return n!==a?!1:a?e.children===t.children:!0}),Ku={};function FC(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?N4[e]??e:e}function l4(){return FC(Ac())}function Moe(){const{t:e}=lt("common"),[t,n]=w.useState(l4),[a,s]=w.useState(!1),[l,c]=w.useState(!0),u=Zo(),m=w.useSyncExternalStore(uoe,moe,()=>!1),p=u&&!(t===se.TEAM&&m),h=w.useSyncExternalStore(iG,R4,sG),g=u&&t!==se.SETTINGS&&t!==se.SEARCH&&_4(h,t);w.useEffect(()=>{const Se=document.documentElement;return Se.classList.toggle("mobile-doc-scroll",p),()=>{Se.classList.remove("mobile-doc-scroll")}},[p]),w.useLayoutEffect(()=>{p&&window.scrollTo(0,0)},[t,p]);const v=doe(),y=loe({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[k,T]=w.useState(()=>new Set([l4()])),[C,S]=w.useState("loading"),[E,_]=w.useState(!1),[D,z]=w.useState(null),[M,I]=w.useState({hasOwner:!1,hasMultipleUsers:!1}),[U,W]=w.useState(!1),[H,Y]=w.useState(!1),[ne,V]=w.useState(null),[F,J]=w.useState(!1),[P,X]=w.useState(null),[oe,Ae]=w.useState(()=>{const Se=localStorage.getItem("markus_update_dismissed");return Se||null}),[G,q]=w.useState(!1),[le,L]=w.useState(!1),Ce=Uc(),Ge=Ce?.leftCollapsed??!1,Ve=Ce?.toggleLeftCollapsed,Qe=Ce?.setLeftCollapsed,it=Ce?.keyboardPane??"l0",mt=Ce?.setKeyboardPane,Tt=Ce?.l0FocusPageId??null,Dt=Ce?.setL0FocusPageId,Pt=w.useRef(t);Pt.current=t;const fn=w.useRef(se.HOME),Nt=Ce?.toggleRightPanel,Ue=Ce?.toggleTerminalPanel,ht=Ce?.cycleRightPanelTab,Lt=Ce?.activateRightPanelTabAt,wt=Ce?.openNewRightPanelTab,Jt=Ce?.rightPanelOpen??!1,ce=Ce?.activeRightPanelTabId??null,nt=Ce?.openRightPanel,et=Ce?.closeRightPanelTab,xe=Ce?.updateRightPanelBrowserTab,_e=Ce?.updateRightPanelTerminalTab,Ie=w.useRef(Ce?.rightPanelTabs);Ie.current=Ce?.rightPanelTabs,w.useEffect(()=>{const Se=window.markusDesktop?.browser?.onPageEvent;if(!(!Se||!nt))return Se(Te=>{if(Te.type==="closed"){const Me=Ie.current?.find(at=>at.payload.kind==="url"&&at.payload.browserId===Te.browserId);Me&&et&&et(Me.id);return}if(Te.type==="navigated"){if(Te.url&&Nc(Te.url))return;Te.browserId&&xe&&xe(Te.browserId,{url:Te.url,title:Te.title||Te.url});return}if(Te.type==="opened"||Te.type==="selected"){if(!Te.url&&!Te.browserId||Te.browserId.startsWith("eb_")||sae(Te.browserId)||Te.url&&Nc(Te.url))return;nt({kind:"url",url:Te.url||"about:blank",title:Te.title||Te.url||"Browser",browserId:Te.browserId,pageId:Te.pageId})}})},[nt,et,xe]),w.useEffect(()=>{const Se=window.markusDesktop?.terminal?.onEvent;if(!(!Se||!nt))return Se(Te=>{if(Te.type==="closed"){const Me=Ie.current?.find(at=>at.payload.kind==="terminal"&&at.payload.terminalId===Te.id);Me&&et&&et(Me.id);return}if(Te.type==="cwd"){Te.cwd&&_e?.(Te.id,{cwd:Te.cwd});return}if(Te.type==="selected"){(Te.title||Te.cwd)&&_e?.(Te.id,{title:Te.title,cwd:Te.cwd});return}if(Te.type==="opened"){if(jb.has(Te.id)){(Te.title||Te.cwd)&&_e?.(Te.id,{title:Te.title,cwd:Te.cwd});return}Ds(Te.id),nt({kind:"terminal",terminalId:Te.id,title:Te.title||"Terminal",cwd:Te.cwd})}})},[nt,et,_e]);const re=Ce?.handleTerminalExit;w.useEffect(()=>{const Se=window.markusDesktop?.terminal?.onExit;if(!(!Se||!re))return Se(Te=>{re(Te.id)})},[re]),w.useLayoutEffect(()=>{const Se=t===se.TEAM&&Jt&&Ce?.rightPanelMode==="browser";jf(Se)},[t,Jt,Ce?.rightPanelMode]),w.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const $=w.useRef(!1);w.useEffect(()=>{if(!$.current){$.current=!0;return}y.setCollapsed(Ge)},[Ge,y.setCollapsed]),w.useEffect(()=>{if(u)return;const Se=navigator.platform.toUpperCase().includes("MAC"),Te=at=>{Se&&at.metaKey&&!at.ctrlKey&&at.key==="p"?(at.preventDefault(),q(yt=>!yt)):!Se&&at.ctrlKey&&!at.metaKey&&at.key==="p"&&(at.preventDefault(),q(yt=>!yt))},Me=()=>q(!0);return document.addEventListener("keydown",Te),window.addEventListener("markus:open-search",Me),()=>{document.removeEventListener("keydown",Te),window.removeEventListener("markus:open-search",Me)}},[u]);const ie=w.useCallback(()=>!Jt||!ce||!et?!1:(et(ce),!0),[Jt,ce,et]);w.useEffect(()=>{const Se=window.markusDesktop?.onAppShortcut?.(Te=>{if(Te.type==="close-tab"){ie();return}Te.type==="new-tab"&&wt?.()});return()=>{Se?.()}},[ie,wt]),w.useEffect(()=>{if(u||!Ve||!Nt)return;const Se=navigator.platform.toUpperCase().includes("MAC"),Te=Me=>{if(!(Se?Me.metaKey&&!Me.ctrlKey:Me.ctrlKey&&!Me.metaKey)||Me.altKey)return;if(!Me.shiftKey&&(Me.key==="/"||Me.code==="Slash")){Me.preventDefault(),L(pt=>!pt);return}if(Me.shiftKey&&(Me.key==="?"||Me.key==="/")){Me.preventDefault(),L(pt=>!pt);return}if(Me.shiftKey&&Jt&&ht){if(Me.key==="]"||Me.code==="BracketRight"){Me.preventDefault(),ht(1);return}if(Me.key==="["||Me.code==="BracketLeft"){Me.preventDefault(),ht(-1);return}}if(!Me.shiftKey&&Jt&&Lt){const pt=Me.key>="1"&&Me.key<="9"?Number(Me.key):0;if(pt>=1){Me.preventDefault(),Lt(pt-1);return}}if(Me.shiftKey)return;const yt=Me.key.toLowerCase();if(yt==="w"){Me.preventDefault(),Me.stopPropagation(),ie();return}if(yt==="t"){Me.preventDefault(),wt?.();return}if(yt==="b"){if(t===se.DELIVERABLES)return;Me.preventDefault(),Ve()}else if(t===se.TEAM&&yt==="l"){if(!Se&&r2(Me.target)||Se&&r2(Me.target)&&Me.ctrlKey)return;Me.preventDefault(),Nt()}else t===se.TEAM&&yt==="j"&&Ue&&(Me.preventDefault(),Ue())};return document.addEventListener("keydown",Te,!0),()=>document.removeEventListener("keydown",Te,!0)},[u,t,Ve,Nt,Ue,ht,Lt,Jt,ie,wt]);const ge=w.useCallback((Se,Te)=>{let Me=Cc(Se);u?Me=N4[Me]??Me:Me===se.NOTIFICATIONS&&(Me=se.HOME),Me!==se.TEAM&&jf(!1);const at=Ac(),yt=window.location.hash.slice(1);yt!==Ph(at)?Ku[at]=yt:delete Ku[at];const pt=Pt.current;if(Me===se.SETTINGS&&pt!==se.SETTINGS&&(fn.current=pt,st.setSettingsReturnPage(pt),mt?.("l1"),Dt?.(se.SETTINGS)),pt===se.SETTINGS&&Me!==se.SETTINGS&&(mt?.("l0"),Dt?.(Me)),Me===se.SETTINGS&&Te?.tab){const Z=`settings/${Te.tab}`;Ku[Me]=Z,history.pushState(null,"","#"+Z),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Me),T(je=>je.has(Me)?je:new Set([...je,Me]));return}const Rt=Me!==se.WORK?Ku[Me]:void 0;Rt&&Rt!==Ph(Me)?(history.pushState(null,"",Bs(Me)),history.pushState(null,"","#"+Rt)):history.pushState(null,"",Bs(Me)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Me),T(Z=>Z.has(Me)?Z:new Set([...Z,Me]))},[u,mt,Dt]);w.useEffect(()=>{st.setHandler((Se,Te)=>ge(Se,Te))},[ge]);const De=w.useCallback(Se=>{const Te=Pt.current,Me=mG(Te,dG(Te),Se);Me&&(Me.sub&&gG(Me.page,Me.sub),ge(Me.page))},[ge]);SG({enabled:u,activePage:()=>Pt.current,onStep:De}),w.useEffect(()=>{it==="l0"&&t!==se.SETTINGS&&Dt?.(t)},[it,t,Dt]),w.useEffect(()=>{if(u||!mt||!Dt)return;const Se=Te=>{if(Te.metaKey||Te.ctrlKey||Te.altKey||a2(Te.target))return;const Me=Te.key.length===1?Te.key.toLowerCase():Te.key;if(t===se.SETTINGS&&(Me==="h"||Me==="ArrowLeft")){Te.preventDefault(),Te.stopImmediatePropagation(),st.leaveSettings();return}if(it!=="l0"||t===se.SETTINGS)return;const at=Tt&&Mo.includes(Tt)?Tt:t,yt=Math.max(0,Mo.indexOf(at));if(Me==="j"||Me==="ArrowDown"){Te.preventDefault(),Te.stopImmediatePropagation();const pt=Mo[Math.min(Mo.length-1,yt+1)];Dt(pt),pt!==t&&ge(pt),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${pt}"]`)?.scrollIntoView({block:"nearest"})});return}if(Me==="k"||Me==="ArrowUp"){Te.preventDefault(),Te.stopImmediatePropagation();const pt=Mo[Math.max(0,yt-1)];Dt(pt),pt!==t&&ge(pt),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${pt}"]`)?.scrollIntoView({block:"nearest"})});return}if(Me==="l"||Me==="ArrowRight"||Me==="Enter"){const pt=Tt&&Mo.includes(Tt)?Tt:t;if(!eG.has(pt)){Te.preventDefault(),Te.stopImmediatePropagation();return}Te.preventDefault(),Te.stopImmediatePropagation(),pt!==t&&ge(pt),Qe?.(!1),mt("l1");return}(Me==="h"||Me==="ArrowLeft")&&(Te.preventDefault(),Te.stopImmediatePropagation())};return document.addEventListener("keydown",Se,!0),()=>document.removeEventListener("keydown",Se,!0)},[u,it,Tt,t,ge,mt,Dt,Qe]),w.useEffect(()=>{const Se=()=>_(!0);return window.addEventListener("markus:open-edit-profile",Se),()=>window.removeEventListener("markus:open-edit-profile",Se)},[]),w.useEffect(()=>{if(!window.markusDesktop)return;!u&&t!==se.SETTINGS&&!y.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[y.collapsed,t,u]),w.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Se=>{if(Se.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),Se.page){const Te=Cc(Se.page);Se.params&&Object.entries(Se.params).forEach(([Me,at])=>localStorage.setItem(`markus_nav_${Me}`,at)),ge(Te),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Te,params:Se.params}}))}})},[ge]);const Pe=w.useCallback(()=>{fetch("/api/settings/llm").then(Se=>Se.ok?Se.json():null).then(Se=>{if(Se?.providers){const Te=Object.values(Se.providers).some(Me=>Me.configured);V(Te)}}).catch(()=>{})},[]),pe=w.useCallback((Se,Te)=>{if(!Se)return;const at=Te&&{agent:"agents",team:"teams",skill:"skills"}[Te]||"agents";localStorage.setItem("markus_nav_installItem",Se),localStorage.setItem("markus_nav_storeTab",at);const yt=new URLSearchParams(window.location.search);yt.get("install")||(yt.set("install",Se),Te&&yt.set("type",Te));const pt=yt.toString();window.history.replaceState(null,"",`${window.location.pathname}?${pt}${Bs(se.STORE)}`);const Rt=()=>st.navigate(se.STORE,{storeTab:at,installItem:Se});Rt(),setTimeout(Rt,500),setTimeout(Rt,1500)},[]);w.useEffect(()=>{const Se=new URLSearchParams(window.location.search),Te=Se.get("install");Te&&pe(Te,Se.get("type"));const Me=window.markusDesktop;Me?.onDeepLinkInstall?.(({id:pt,type:Rt})=>pe(pt,Rt)),Me?.consumePendingDeepLinkInstall?.().then(pt=>{pt?.id&&pe(pt.id,pt.type)}),Ne.auth.me().then(({user:pt})=>{S(pt),z(!0),s(!1),pt.preferences?.guideHidden===!0&&!Gh(pt.id)&&Kh(pt.id),Noe(pt),kr.connect(pt.id),Pe(),Ne.health().then(Z=>{Z.updateAvailable&&Z.latestVersion&&X({latestVersion:Z.latestVersion,currentVersion:Z.version})}).catch(()=>{});const Rt=()=>{js(Ka.builderArtifacts,()=>Ne.builder.artifacts.list()),js(Ka.builderAgents,()=>Ne.agents.list()),js(Ka.builderHubMyItems,()=>ot.myItems()),js(Ka.builderInstalled,()=>Ne.builder.artifacts.installed()),js(Ka.hubAgents,()=>ot.search({type:"agent",limit:50})),js(Ka.hubTeams,()=>ot.search({type:"team",limit:50})),js(Ka.hubSkills,()=>ot.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Rt,{timeout:5e3}):setTimeout(Rt,3e3)}).catch(()=>{S(null),Ne.auth.status().then(({initialized:pt,hasOwner:Rt,hasMultipleUsers:Z})=>{z(pt),I({hasOwner:Rt,hasMultipleUsers:Z})}).catch(()=>z(!0))}),kr.connect();const at=kr.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),yt=()=>{const pt=FC(Ac());pt!==se.TEAM&&jf(!1),n(pt),T(Rt=>Rt.has(pt)?Rt:new Set([...Rt,pt]))};return window.addEventListener("hashchange",yt),window.addEventListener("popstate",yt),()=>{at(),kr.disconnect(),window.removeEventListener("hashchange",yt),window.removeEventListener("popstate",yt)}},[]),w.useEffect(()=>{const Se=C!=="loading"&&C!==null?C.id:void 0;if(!Se)return;const Te=navigator.platform.toUpperCase().includes("MAC"),Me=at=>{if(a2(at.target))return;const yt={key:at.key,code:at.code,metaKey:at.metaKey,ctrlKey:at.ctrlKey,altKey:at.altKey,shiftKey:at.shiftKey};oK(yt,Se,Te)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",Me,!0),()=>window.removeEventListener("keydown",Me,!0)},[C]);const fe=C!=="loading"&&C!==null?C:void 0,$e=w.useMemo(()=>u?{[se.HOME]:i.jsx(c2,{authUser:fe}),[se.TEAM]:i.jsx(r4,{authUser:fe}),[se.BUILDER]:i.jsx(noe,{authUser:fe}),[se.SETTINGS]:i.jsx(i4,{theme:v.mode,onThemeChange:v.setMode,authUser:fe,onLogout:()=>{Ne.auth.logout().catch(()=>{}),Ls(),S(null)},onUserUpdated:Se=>S(Se)}),[se.WORK]:i.jsx(s4,{authUser:fe}),[se.DELIVERABLES]:i.jsx(o4,{authUser:fe}),[se.NOTIFICATIONS]:i.jsx(Coe,{authUser:fe}),[se.SEARCH]:i.jsx(Aoe,{})}:{[se.HOME]:i.jsx(c2,{authUser:fe}),[se.TEAM]:i.jsx(r4,{authUser:fe}),[se.SETTINGS]:i.jsx(i4,{theme:v.mode,onThemeChange:v.setMode,authUser:fe,onLogout:()=>{Ne.auth.logout().catch(()=>{}),Ls(),S(null)},onUserUpdated:Se=>S(Se)}),[se.STORE]:i.jsx(woe,{authUser:fe}),[se.BUILDER]:i.jsx(Soe,{authUser:fe}),[se.WORK]:i.jsx(s4,{authUser:fe}),[se.DELIVERABLES]:i.jsx(o4,{authUser:fe})},[fe?.id,fe?.role,v.mode,u]);if(C==="loading"||C===null&&D===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 Je=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Je?i.jsx(soe,{token:Je[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),s(!0),W(!0),S("loading"),Ne.auth.me().then(Se=>{i2(Se.user.id),S(Se.user)}).catch(()=>S(null))}}):C===null?i.jsx(ioe,{hasOwner:M.hasOwner,hasMultipleUsers:M.hasMultipleUsers,onLogin:(Se,Te,Me)=>{S(Se),kr.connect(Se.id),Te?(i2(Se.id),s(!0),Me?.fromHub&&W(!0)):(s(!1),Gh(Se.id)?(Kh(Se.id),Ne.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),S({...Se,preferences:{...Se.preferences,guideHidden:!0}})):S(Se))}}):H?i.jsx(ooe,{onComplete:()=>Y(!1),isFirstTime:!0}):a?i.jsx(aoe,{theme:v.mode,onThemeChange:v.setMode,skipProfile:U,onProfileUpdated:Se=>{const Te={id:Se.id,name:Se.name,email:Se.email,role:Se.role,orgId:Se.orgId??"default",avatarUrl:Se.avatarUrl};S(Te)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),s(!1),W(!1),Ne.auth.me().then(Se=>S(Se.user)).catch(()=>{}),Pe(),ge(se.HOME)}}):i.jsxs("div",{className:`flex ${p?"min-h-dvh":"h-dvh overflow-x-hidden"} bg-surface-primary text-fg-primary ${u?"flex-col":""}`,children:[!u&&t!==se.SETTINGS&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"relative z-40 shrink-0",style:{width:y.width},children:i.jsx(nse,{currentPage:t,onNavigate:Se=>{ge(Se),c(!1),mt?.("l0"),Dt?.(Se)},authUser:C,collapsed:y.collapsed,onToggleCollapse:y.toggle,onLogout:()=>{Ne.auth.logout().catch(()=>{}),Ls(),S(null)},keyboardFocusPageId:Tt,keyboardPaneActive:it==="l0"})}),i.jsx("div",{className:`${y.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:y.collapsed?void 0:y.onResizeStart,children:!y.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 ${p?"":"overflow-hidden"} flex flex-col min-w-0 ${g?"pb-14":""}`,children:[ne===!1&&!F&&t!==se.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:u?"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:()=>J(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),P&&oe!==P.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:u?"text-xs":"",children:e("update.available",{latest:P.latestVersion,current:P.currentVersion})}),i.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[i.jsx("a",{href:"https://markus.global/#download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),i.jsx("button",{onClick:()=>{Ae(P.latestVersion),localStorage.setItem("markus_update_dismissed",P.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),i.jsx("main",{className:`flex-1 ${p?"":"overflow-hidden"} flex flex-col relative`,children:Object.keys($e).map(Se=>k.has(Se)?i.jsx(joe,{id:Se,activePage:t,docScroll:p,children:$e[Se]},Se):null)})]}),g&&i.jsx(pse,{currentPage:t,onNavigate:ge,userId:fe?.id}),u&&i.jsx(rK,{authUser:fe,onNavigate:ge,onLogout:()=>{Ne.auth.logout().catch(()=>{}),Ls(),S(null)}}),!u&&G&&i.jsx(hoe,{onClose:()=>q(!1),currentPage:t}),!u&&i.jsx(xoe,{open:le,onClose:()=>L(!1),page:t}),E&&fe&&i.jsx(koe,{authUser:fe,onClose:()=>_(!1),onUserUpdated:Se=>S(Se),onSaved:Se=>{_(!1),S(Se)}})]})}const c4="data-anim-paused",d4="data-anim-tick",u4=8,_oe=250;function Roe(){return document.visibilityState!=="visible"||document.hidden}let kc=null,Bo=0;function Doe(){kc===null&&(Bo=Bo%u4,document.documentElement.setAttribute(d4,String(Bo)),kc=window.setInterval(()=>{Bo=(Bo+1)%u4,document.documentElement.setAttribute(d4,String(Bo))},_oe))}function Ioe(){kc!==null&&(window.clearInterval(kc),kc=null)}function Rh(){const e=document.documentElement;Roe()?(e.setAttribute(c4,"true"),Ioe()):(e.removeAttribute(c4),Doe())}let m4=!1;function Loe(){m4||typeof document>"u"||(m4=!0,Rh(),document.addEventListener("visibilitychange",Rh,{passive:!0}),window.addEventListener("pageshow",Rh,{passive:!0}))}Loe();eT.createRoot(document.getElementById("root")).render(i.jsx(w.StrictMode,{children:i.jsx(mae,{children:i.jsx(Moe,{})})}));export{Ole as $,ns as A,WT as B,Jo as C,are as D,cG as E,bG as F,di as G,Bs as H,Qse as I,wa as J,OG as K,Yoe as L,G4 as M,Zie as N,ire as O,se as P,pie as Q,Poe as R,Wse as S,zse as T,mie as U,Qoe as V,_g as W,Db as X,tle as Y,ele as Z,Aa as _,Zo as a,vle as a$,Koe as a0,I4 as a1,Sr as a2,qoe as a3,Woe as a4,IG as a5,Voe as a6,Jx as a7,Foe as a8,_G as a9,gle as aA,ple as aB,mle as aC,ale as aD,ole as aE,SC as aF,lle as aG,ile as aH,yle as aI,Oie as aJ,Rle as aK,wC as aL,sle as aM,kC as aN,nle as aO,$oe as aP,$le as aQ,lse as aR,Ble as aS,Cle as aT,Ele as aU,rle as aV,Zoe as aW,ule as aX,Lb as aY,F4 as aZ,W4 as a_,Goe as aa,Uoe as ab,Vo as ac,Hle as ad,zoe as ae,Po as af,zle as ag,KT as ah,fle as ai,nG as aj,Boe as ak,Hoe as al,Ds as am,_u as an,gi as ao,xm as ap,Dle as aq,$ae as ar,nw as as,kie as at,Hs as au,sl as av,ble as aw,hle as ax,cle as ay,dle as az,JG as b,xle as b0,kle as b1,Mle as b2,kw as b3,zae as b4,Ple as b5,jle as b6,Ile as b7,Sle as b8,_le as b9,Iw as ba,Lw as bb,Yie as bc,Lle as bd,Ale as be,Nle as bf,dC as bg,r2 as bh,wle as bi,Tle as bj,Joe as bk,mC as bl,Uc as c,Zse as d,$se as e,Gse as f,Ps as g,ot as h,a2 as i,i as j,$r as k,Ne as l,loe as m,st as n,On as o,Cc as p,va as q,w as r,Yx as s,Rb as t,lt as u,Ua as v,kr as w,Ooe as x,Pc as y,Km as z};
|