@markus-global/cli 0.9.5 → 0.9.6-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 +2 -2
- package/dist/web-ui/assets/{CommentInput-K1-kq6ho.js → CommentInput-CgAj8T7-.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-DgRLJ_sK.js → ContentRenderer-CVnHxqVj.js} +2 -2
- package/dist/web-ui/assets/{Deliverables-DsAhIzy4.js → Deliverables-taaUZEbu.js} +1 -1
- package/dist/web-ui/assets/{Notifications-DUsdhlI8.js → Notifications-C3tsNNUx.js} +1 -1
- package/dist/web-ui/assets/{Search-BJtkRIyn.js → Search-Bye2uSm-.js} +1 -1
- package/dist/web-ui/assets/{Settings-0bN9LNlr.js → Settings-DPoSSAgs.js} +1 -1
- package/dist/web-ui/assets/{Store-CGSeZJqn.js → Store-CLmn7GZP.js} +1 -1
- package/dist/web-ui/assets/{Team-zOWObrjC.js → Team-gO8trCNU.js} +4 -4
- package/dist/web-ui/assets/{Work-D1BC-rJN.js → Work-DZrsJS4u.js} +1 -1
- package/dist/web-ui/assets/{arc-De7J8ftK.js → arc-BJfex9Bc.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-BhqFXwVG.js → architectureDiagram-3BPJPVTR-CdxQMu7v.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-B2cm8nqb.js → blockDiagram-GPEHLZMM-Bt7Q5m3V.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-Cvu0i-1x.js → c4Diagram-AAUBKEIU-Bdj761dO.js} +1 -1
- package/dist/web-ui/assets/channel-ZkBqfCc6.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-DBfaBIyS.js → chunk-2J33WTMH-CdET0kHk.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-BBaHrwAj.js → chunk-4BX2VUAB-DUr1UOVm.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-zcV2Y13D.js → chunk-55IACEB6--uhlmjf4.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-BBHa0iAB.js → chunk-727SXJPM-B35nhhcv.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-C3lHDfp8.js → chunk-AQP2D5EJ-DKfNlodw.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-TujVpLAH.js → chunk-FMBD7UC4-DLrapbKI.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-CcrzijGa.js → chunk-ND2GUHAM-DIhERt5l.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-B-LMarez.js → chunk-QZHKN3VN-ChKgZnL5.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CqItVnx6.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CqItVnx6.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-C0LEHvuP.js → cose-bilkent-S5V4N54A-MvGuvN3H.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-BTBuQOUc.js → dagre-BM42HDAG-DJ2ytfov.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-C56kLPIh.js → diagram-2AECGRRQ-D8Racvwp.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-Dx0YVtfP.js → diagram-5GNKFQAL-CSF4ne-j.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-BRPFCmne.js → diagram-KO2AKTUF-CNKD_lhX.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-CNuIiOHo.js → diagram-LMA3HP47-D2y4o6gC.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-BwviFJz4.js → diagram-OG6HWLK6-B7_9RfCU.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-Dl0PPlss.js → erDiagram-TEJ5UH35-BXD6RRQQ.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BJqLMNxV.js → flowDiagram-I6XJVG4X-zNMRNC9Y.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-yjY0wGjd.js → ganttDiagram-6RSMTGT7-CujOgFSS.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DzPQQvbM.js → gitGraphDiagram-PVQCEYII-DnzfHFn7.js} +1 -1
- package/dist/web-ui/assets/{index-BvQfZ8gL.js → index-DMVnwNLi.js} +4 -4
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-C54MywrZ.js → infoDiagram-5YYISTIA-CLoylCmO.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Kn-uy7RN.js → ishikawaDiagram-YF4QCWOH-BJ4GZ9KA.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-BIzRFbcv.js → journeyDiagram-JHISSGLW-B41r3J63.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-3yDXXmvB.js → kanban-definition-UN3LZRKU-C6JKeESA.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-ldKpNPpw.js → mermaid.core-b733zJmi.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-DoO7zKsW.js → mindmap-definition-RKZ34NQL-Pm1HkKOL.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CECVsVlJ.js → pieDiagram-4H26LBE5-4-vnM26v.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-DnztoAiu.js → quadrantDiagram-W4KKPZXB-DkB22D9V.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-ZYyLtPtO.js → requirementDiagram-4Y6WPE33-CEt14Oew.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-ZrSJq_r1.js → sankeyDiagram-5OEKKPKP-Di3L1P8v.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-BnqOxBEw.js → sequenceDiagram-3UESZ5HK-DgU-dNfs.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-DjLP576M.js → stateDiagram-AJRCARHV-B3pROBDB.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BbfDz_rK.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-Cn0J0w9_.js → timeline-definition-PNZ67QCA-B3qYSixU.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-MoHmK1SI.js → vennDiagram-CIIHVFJN-CwVU9FLF.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-zGFhbSj6.js → wardley-L42UT6IY-C_cMkzJj.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-yA9YynQY.js → wardleyDiagram-YWT4CUSO-BMZGCjLT.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-CFFBWxGh.js → xychartDiagram-2RQKCTM6-BeETG7wt.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-BhYWDMUn.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DScJ100R.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DScJ100R.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DpLKSgC7.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-b733zJmi.js","assets/transform-CpIVI4vC.js","assets/Team-gO8trCNU.js","assets/CommentInput-CgAj8T7-.js","assets/ContentRenderer-CVnHxqVj.js","assets/Team-DFuMZ0ql.css","assets/Work-DZrsJS4u.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-taaUZEbu.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function Tc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zf={exports:{}},ql={};var Ey;function m7(){if(Ey)return ql;Ey=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,l){var c=null;if(l!==void 0&&(c=""+l),o.key!==void 0&&(c=""+o.key),"key"in o){l={};for(var d in o)d!=="key"&&(l[d]=o[d])}else l=o;return o=l.ref,{$$typeof:e,type:r,key:c,ref:o!==void 0?o:null,props:l}}return ql.Fragment=t,ql.jsx=n,ql.jsxs=n,ql}var _y;function f7(){return _y||(_y=1,Zf.exports=m7()),Zf.exports}var s=f7(),Jf={exports:{}},Dt={};var jy;function p7(){if(jy)return Dt;jy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.iterator;function y(W){return W===null||typeof W!="object"?null:(W=x&&W[x]||W["@@iterator"],typeof W=="function"?W:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,T={};function S(W,fe,I){this.props=W,this.context=fe,this.refs=T,this.updater=I||w}S.prototype.isReactComponent={},S.prototype.setState=function(W,fe){if(typeof W!="object"&&typeof W!="function"&&W!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,W,fe,"setState")},S.prototype.forceUpdate=function(W){this.updater.enqueueForceUpdate(this,W,"forceUpdate")};function _(){}_.prototype=S.prototype;function j(W,fe,I){this.props=W,this.context=fe,this.refs=T,this.updater=I||w}var O=j.prototype=new _;O.constructor=j,C(O,S.prototype),O.isPureReactComponent=!0;var P=Array.isArray;function L(){}var F={H:null,A:null,T:null,S:null},V=Object.prototype.hasOwnProperty;function X(W,fe,I){var Re=I.ref;return{$$typeof:e,type:W,key:fe,ref:Re!==void 0?Re:null,props:I}}function z(W,fe){return X(W.type,fe,W.props)}function G(W){return typeof W=="object"&&W!==null&&W.$$typeof===e}function ae(W){var fe={"=":"=0",":":"=2"};return"$"+W.replace(/[=:]/g,function(I){return fe[I]})}var Z=/\/+/g;function q(W,fe){return typeof W=="object"&&W!==null&&W.key!=null?ae(""+W.key):fe.toString(36)}function te(W){switch(W.status){case"fulfilled":return W.value;case"rejected":throw W.reason;default:switch(typeof W.status=="string"?W.then(L,L):(W.status="pending",W.then(function(fe){W.status==="pending"&&(W.status="fulfilled",W.value=fe)},function(fe){W.status==="pending"&&(W.status="rejected",W.reason=fe)})),W.status){case"fulfilled":return W.value;case"rejected":throw W.reason}}throw W}function U(W,fe,I,Re,Be){var Pe=typeof W;(Pe==="undefined"||Pe==="boolean")&&(W=null);var Fe=!1;if(W===null)Fe=!0;else switch(Pe){case"bigint":case"string":case"number":Fe=!0;break;case"object":switch(W.$$typeof){case e:case t:Fe=!0;break;case h:return Fe=W._init,U(Fe(W._payload),fe,I,Re,Be)}}if(Fe)return Be=Be(W),Fe=Re===""?"."+q(W,0):Re,P(Be)?(I="",Fe!=null&&(I=Fe.replace(Z,"$&/")+"/"),U(Be,fe,I,"",function(Nt){return Nt})):Be!=null&&(G(Be)&&(Be=z(Be,I+(Be.key==null||W&&W.key===Be.key?"":(""+Be.key).replace(Z,"$&/")+"/")+Fe)),fe.push(Be)),1;Fe=0;var dt=Re===""?".":Re+":";if(P(W))for(var mt=0;mt<W.length;mt++)Re=W[mt],Pe=dt+q(Re,mt),Fe+=U(Re,fe,I,Pe,Be);else if(mt=y(W),typeof mt=="function")for(W=mt.call(W),mt=0;!(Re=W.next()).done;)Re=Re.value,Pe=dt+q(Re,mt++),Fe+=U(Re,fe,I,Pe,Be);else if(Pe==="object"){if(typeof W.then=="function")return U(te(W),fe,I,Re,Be);throw fe=String(W),Error("Objects are not valid as a React child (found: "+(fe==="[object Object]"?"object with keys {"+Object.keys(W).join(", ")+"}":fe)+"). If you meant to render a collection of children, use an array instead.")}return Fe}function Q(W,fe,I){if(W==null)return W;var Re=[],Be=0;return U(W,Re,"","",function(Pe){return fe.call(I,Pe,Be++)}),Re}function me(W){if(W._status===-1){var fe=W._result;fe=fe(),fe.then(function(I){(W._status===0||W._status===-1)&&(W._status=1,W._result=I)},function(I){(W._status===0||W._status===-1)&&(W._status=2,W._result=I)}),W._status===-1&&(W._status=0,W._result=fe)}if(W._status===1)return W._result.default;throw W._result}var Ce=typeof reportError=="function"?reportError:function(W){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var fe=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof W=="object"&&W!==null&&typeof W.message=="string"?String(W.message):String(W),error:W});if(!window.dispatchEvent(fe))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",W);return}console.error(W)},H={map:Q,forEach:function(W,fe,I){Q(W,function(){fe.apply(this,arguments)},I)},count:function(W){var fe=0;return Q(W,function(){fe++}),fe},toArray:function(W){return Q(W,function(fe){return fe})||[]},only:function(W){if(!G(W))throw Error("React.Children.only expected to receive a single React element child.");return W}};return Dt.Activity=g,Dt.Children=H,Dt.Component=S,Dt.Fragment=n,Dt.Profiler=o,Dt.PureComponent=j,Dt.StrictMode=r,Dt.Suspense=m,Dt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=F,Dt.__COMPILER_RUNTIME={__proto__:null,c:function(W){return F.H.useMemoCache(W)}},Dt.cache=function(W){return function(){return W.apply(null,arguments)}},Dt.cacheSignal=function(){return null},Dt.cloneElement=function(W,fe,I){if(W==null)throw Error("The argument must be a React element, but you passed "+W+".");var Re=C({},W.props),Be=W.key;if(fe!=null)for(Pe in fe.key!==void 0&&(Be=""+fe.key),fe)!V.call(fe,Pe)||Pe==="key"||Pe==="__self"||Pe==="__source"||Pe==="ref"&&fe.ref===void 0||(Re[Pe]=fe[Pe]);var Pe=arguments.length-2;if(Pe===1)Re.children=I;else if(1<Pe){for(var Fe=Array(Pe),dt=0;dt<Pe;dt++)Fe[dt]=arguments[dt+2];Re.children=Fe}return X(W.type,Be,Re)},Dt.createContext=function(W){return W={$$typeof:c,_currentValue:W,_currentValue2:W,_threadCount:0,Provider:null,Consumer:null},W.Provider=W,W.Consumer={$$typeof:l,_context:W},W},Dt.createElement=function(W,fe,I){var Re,Be={},Pe=null;if(fe!=null)for(Re in fe.key!==void 0&&(Pe=""+fe.key),fe)V.call(fe,Re)&&Re!=="key"&&Re!=="__self"&&Re!=="__source"&&(Be[Re]=fe[Re]);var Fe=arguments.length-2;if(Fe===1)Be.children=I;else if(1<Fe){for(var dt=Array(Fe),mt=0;mt<Fe;mt++)dt[mt]=arguments[mt+2];Be.children=dt}if(W&&W.defaultProps)for(Re in Fe=W.defaultProps,Fe)Be[Re]===void 0&&(Be[Re]=Fe[Re]);return X(W,Pe,Be)},Dt.createRef=function(){return{current:null}},Dt.forwardRef=function(W){return{$$typeof:d,render:W}},Dt.isValidElement=G,Dt.lazy=function(W){return{$$typeof:h,_payload:{_status:-1,_result:W},_init:me}},Dt.memo=function(W,fe){return{$$typeof:p,type:W,compare:fe===void 0?null:fe}},Dt.startTransition=function(W){var fe=F.T,I={};F.T=I;try{var Re=W(),Be=F.S;Be!==null&&Be(I,Re),typeof Re=="object"&&Re!==null&&typeof Re.then=="function"&&Re.then(L,Ce)}catch(Pe){Ce(Pe)}finally{fe!==null&&I.types!==null&&(fe.types=I.types),F.T=fe}},Dt.unstable_useCacheRefresh=function(){return F.H.useCacheRefresh()},Dt.use=function(W){return F.H.use(W)},Dt.useActionState=function(W,fe,I){return F.H.useActionState(W,fe,I)},Dt.useCallback=function(W,fe){return F.H.useCallback(W,fe)},Dt.useContext=function(W){return F.H.useContext(W)},Dt.useDebugValue=function(){},Dt.useDeferredValue=function(W,fe){return F.H.useDeferredValue(W,fe)},Dt.useEffect=function(W,fe){return F.H.useEffect(W,fe)},Dt.useEffectEvent=function(W){return F.H.useEffectEvent(W)},Dt.useId=function(){return F.H.useId()},Dt.useImperativeHandle=function(W,fe,I){return F.H.useImperativeHandle(W,fe,I)},Dt.useInsertionEffect=function(W,fe){return F.H.useInsertionEffect(W,fe)},Dt.useLayoutEffect=function(W,fe){return F.H.useLayoutEffect(W,fe)},Dt.useMemo=function(W,fe){return F.H.useMemo(W,fe)},Dt.useOptimistic=function(W,fe){return F.H.useOptimistic(W,fe)},Dt.useReducer=function(W,fe,I){return F.H.useReducer(W,fe,I)},Dt.useRef=function(W){return F.H.useRef(W)},Dt.useState=function(W){return F.H.useState(W)},Dt.useSyncExternalStore=function(W,fe,I){return F.H.useSyncExternalStore(W,fe,I)},Dt.useTransition=function(){return F.H.useTransition()},Dt.version="19.2.4",Dt}var My;function A0(){return My||(My=1,Jf.exports=p7()),Jf.exports}var k=A0();const DY=Tc(k);var ep={exports:{}},Gl={},tp={exports:{}},np={};var Ry;function h7(){return Ry||(Ry=1,(function(e){function t(U,Q){var me=U.length;U.push(Q);e:for(;0<me;){var Ce=me-1>>>1,H=U[Ce];if(0<o(H,Q))U[Ce]=Q,U[me]=H,me=Ce;else break e}}function n(U){return U.length===0?null:U[0]}function r(U){if(U.length===0)return null;var Q=U[0],me=U.pop();if(me!==Q){U[0]=me;e:for(var Ce=0,H=U.length,W=H>>>1;Ce<W;){var fe=2*(Ce+1)-1,I=U[fe],Re=fe+1,Be=U[Re];if(0>o(I,me))Re<H&&0>o(Be,I)?(U[Ce]=Be,U[Re]=me,Ce=Re):(U[Ce]=I,U[fe]=me,Ce=fe);else if(Re<H&&0>o(Be,me))U[Ce]=Be,U[Re]=me,Ce=Re;else break e}}return Q}function o(U,Q){var me=U.sortIndex-Q.sortIndex;return me!==0?me:U.id-Q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var m=[],p=[],h=1,g=null,x=3,y=!1,w=!1,C=!1,T=!1,S=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function O(U){for(var Q=n(p);Q!==null;){if(Q.callback===null)r(p);else if(Q.startTime<=U)r(p),Q.sortIndex=Q.expirationTime,t(m,Q);else break;Q=n(p)}}function P(U){if(C=!1,O(U),!w)if(n(m)!==null)w=!0,L||(L=!0,ae());else{var Q=n(p);Q!==null&&te(P,Q.startTime-U)}}var L=!1,F=-1,V=5,X=-1;function z(){return T?!0:!(e.unstable_now()-X<V)}function G(){if(T=!1,L){var U=e.unstable_now();X=U;var Q=!0;try{e:{w=!1,C&&(C=!1,_(F),F=-1),y=!0;var me=x;try{t:{for(O(U),g=n(m);g!==null&&!(g.expirationTime>U&&z());){var Ce=g.callback;if(typeof Ce=="function"){g.callback=null,x=g.priorityLevel;var H=Ce(g.expirationTime<=U);if(U=e.unstable_now(),typeof H=="function"){g.callback=H,O(U),Q=!0;break t}g===n(m)&&r(m),O(U)}else r(m);g=n(m)}if(g!==null)Q=!0;else{var W=n(p);W!==null&&te(P,W.startTime-U),Q=!1}}break e}finally{g=null,x=me,y=!1}Q=void 0}}finally{Q?ae():L=!1}}}var ae;if(typeof j=="function")ae=function(){j(G)};else if(typeof MessageChannel<"u"){var Z=new MessageChannel,q=Z.port2;Z.port1.onmessage=G,ae=function(){q.postMessage(null)}}else ae=function(){S(G,0)};function te(U,Q){F=S(function(){U(e.unstable_now())},Q)}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(U){U.callback=null},e.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<U?Math.floor(1e3/U):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(U){switch(x){case 1:case 2:case 3:var Q=3;break;default:Q=x}var me=x;x=Q;try{return U()}finally{x=me}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(U,Q){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var me=x;x=U;try{return Q()}finally{x=me}},e.unstable_scheduleCallback=function(U,Q,me){var Ce=e.unstable_now();switch(typeof me=="object"&&me!==null?(me=me.delay,me=typeof me=="number"&&0<me?Ce+me:Ce):me=Ce,U){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=me+H,U={id:h++,callback:Q,priorityLevel:U,startTime:me,expirationTime:H,sortIndex:-1},me>Ce?(U.sortIndex=me,t(p,U),n(m)===null&&U===n(p)&&(C?(_(F),F=-1):C=!0,te(P,me-Ce))):(U.sortIndex=H,t(m,U),w||y||(w=!0,L||(L=!0,ae()))),U},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(U){var Q=x;return function(){var me=x;x=Q;try{return U.apply(this,arguments)}finally{x=me}}}})(np)),np}var Oy;function g7(){return Oy||(Oy=1,tp.exports=h7()),tp.exports}var rp={exports:{}},nr={};var Ly;function b7(){if(Ly)return nr;Ly=1;var e=A0();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 r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function l(m,p,h){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:p,implementation:h}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(m,p){if(m==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return nr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,nr.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)},nr.flushSync=function(m){var p=c.T,h=r.p;try{if(c.T=null,r.p=2,m)return m()}finally{c.T=p,r.p=h,r.d.f()}},nr.preconnect=function(m,p){typeof m=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(m,p))},nr.prefetchDNS=function(m){typeof m=="string"&&r.d.D(m)},nr.preinit=function(m,p){if(typeof m=="string"&&p&&typeof p.as=="string"){var h=p.as,g=d(h,p.crossOrigin),x=typeof p.integrity=="string"?p.integrity:void 0,y=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;h==="style"?r.d.S(m,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:g,integrity:x,fetchPriority:y}):h==="script"&&r.d.X(m,{crossOrigin:g,integrity:x,fetchPriority:y,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},nr.preinitModule=function(m,p){if(typeof m=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var h=d(p.as,p.crossOrigin);r.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&&r.d.M(m)},nr.preload=function(m,p){if(typeof m=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var h=p.as,g=d(h,p.crossOrigin);r.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})}},nr.preloadModule=function(m,p){if(typeof m=="string")if(p){var h=d(p.as,p.crossOrigin);r.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 r.d.m(m)},nr.requestFormReset=function(m){r.d.r(m)},nr.unstable_batchedUpdates=function(m,p){return m(p)},nr.useFormState=function(m,p,h){return c.H.useFormState(m,p,h)},nr.useFormStatus=function(){return c.H.useHostTransitionStatus()},nr.version="19.2.4",nr}var Dy;function sw(){if(Dy)return rp.exports;Dy=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),rp.exports=b7(),rp.exports}var Iy;function x7(){if(Iy)return Gl;Iy=1;var e=g7(),t=A0(),n=sw();function r(a){var i="https://react.dev/errors/"+a;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)i+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+a+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function l(a){var i=a,u=a;if(a.alternate)for(;i.return;)i=i.return;else{a=i;do i=a,(i.flags&4098)!==0&&(u=i.return),a=i.return;while(a)}return i.tag===3?u:null}function c(a){if(a.tag===13){var i=a.memoizedState;if(i===null&&(a=a.alternate,a!==null&&(i=a.memoizedState)),i!==null)return i.dehydrated}return null}function d(a){if(a.tag===31){var i=a.memoizedState;if(i===null&&(a=a.alternate,a!==null&&(i=a.memoizedState)),i!==null)return i.dehydrated}return null}function m(a){if(l(a)!==a)throw Error(r(188))}function p(a){var i=a.alternate;if(!i){if(i=l(a),i===null)throw Error(r(188));return i!==a?null:a}for(var u=a,f=i;;){var b=u.return;if(b===null)break;var v=b.alternate;if(v===null){if(f=b.return,f!==null){u=f;continue}break}if(b.child===v.child){for(v=b.child;v;){if(v===u)return m(b),a;if(v===f)return m(b),i;v=v.sibling}throw Error(r(188))}if(u.return!==f.return)u=b,f=v;else{for(var E=!1,D=b.child;D;){if(D===u){E=!0,u=b,f=v;break}if(D===f){E=!0,f=b,u=v;break}D=D.sibling}if(!E){for(D=v.child;D;){if(D===u){E=!0,u=v,f=b;break}if(D===f){E=!0,f=v,u=b;break}D=D.sibling}if(!E)throw Error(r(189))}}if(u.alternate!==f)throw Error(r(190))}if(u.tag!==3)throw Error(r(188));return u.stateNode.current===u?a:i}function h(a){var i=a.tag;if(i===5||i===26||i===27||i===6)return a;for(a=a.child;a!==null;){if(i=h(a),i!==null)return i;a=a.sibling}return null}var g=Object.assign,x=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),j=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),z=Symbol.for("react.memo_cache_sentinel"),G=Symbol.iterator;function ae(a){return a===null||typeof a!="object"?null:(a=G&&a[G]||a["@@iterator"],typeof a=="function"?a:null)}var Z=Symbol.for("react.client.reference");function q(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===Z?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case C:return"Fragment";case S:return"Profiler";case T:return"StrictMode";case P:return"Suspense";case L:return"SuspenseList";case X:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case w:return"Portal";case j:return a.displayName||"Context";case _:return(a._context.displayName||"Context")+".Consumer";case O:var i=a.render;return a=a.displayName,a||(a=i.displayName||i.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case F:return i=a.displayName||null,i!==null?i:q(a.type)||"Memo";case V:i=a._payload,a=a._init;try{return q(a(i))}catch{}}return null}var te=Array.isArray,U=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,me={pending:!1,data:null,method:null,action:null},Ce=[],H=-1;function W(a){return{current:a}}function fe(a){0>H||(a.current=Ce[H],Ce[H]=null,H--)}function I(a,i){H++,Ce[H]=a.current,a.current=i}var Re=W(null),Be=W(null),Pe=W(null),Fe=W(null);function dt(a,i){switch(I(Pe,i),I(Be,a),I(Re,null),i.nodeType){case 9:case 11:a=(a=i.documentElement)&&(a=a.namespaceURI)?Qx(a):0;break;default:if(a=i.tagName,i=i.namespaceURI)i=Qx(i),a=Zx(i,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}fe(Re),I(Re,a)}function mt(){fe(Re),fe(Be),fe(Pe)}function Nt(a){a.memoizedState!==null&&I(Fe,a);var i=Re.current,u=Zx(i,a.type);i!==u&&(I(Be,a),I(Re,u))}function Ot(a){Be.current===a&&(fe(Re),fe(Be)),Fe.current===a&&(fe(Fe),$l._currentValue=me)}var At,qt;function jt(a){if(At===void 0)try{throw Error()}catch(u){var i=u.stack.trim().match(/\n( *(at )?)/);At=i&&i[1]||"",qt=-1<u.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+At+a+qt}var $e=!1;function ut(a,i){if(!a||$e)return"";$e=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var f={DetermineComponentFrameRoot:function(){try{if(i){var Ie=function(){throw Error()};if(Object.defineProperty(Ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ie,[])}catch(Ae){var Ne=Ae}Reflect.construct(a,[],Ie)}else{try{Ie.call()}catch(Ae){Ne=Ae}a.call(Ie.prototype)}}else{try{throw Error()}catch(Ae){Ne=Ae}(Ie=a())&&typeof Ie.catch=="function"&&Ie.catch(function(){})}}catch(Ae){if(Ae&&Ne&&typeof Ae.stack=="string")return[Ae.stack,Ne.stack]}return[null,null]}};f.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(f.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(f.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var v=f.DetermineComponentFrameRoot(),E=v[0],D=v[1];if(E&&D){var se=E.split(`
|
|
@@ -645,7 +645,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
645
645
|
`},p]}}const Xq=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Qq=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Zq=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],Jq=[...Qq,...Zq],eG=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),s3=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),i3=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),tG=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),nG=s3.concat(i3).sort().reverse();function rG(e){const t=Xq(e),n=nG,r="and or not only",o="[\\w-]+",l="("+o+"|@\\{"+o+"\\})",c=[],d=[],m=function(j){return{className:"string",begin:"~?"+j+".*?"+j}},p=function(j,O,P){return{className:j,begin:O,relevance:P}},h={$pattern:/[a-z-]+/,keyword:r,attribute:eG.join(" ")},g={begin:"\\(",end:"\\)",contains:d,keywords:h,relevance:0};d.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,m("'"),m('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,g,p("variable","@@?"+o,10),p("variable","@\\{"+o+"\\}"),p("built_in","~?`[^`]*?`"),{className:"attribute",begin:o+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const x=d.concat({begin:/\{/,end:/\}/,contains:c}),y={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(d)},w={begin:l+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+tG.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:d}}]},C={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:h,returnEnd:!0,contains:d,relevance:0}},T={className:"variable",variants:[{begin:"@"+o+"\\s*:",relevance:15},{begin:"@"+o}],starts:{end:"[;}]",returnEnd:!0,contains:x}},S={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:l,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,y,p("keyword","all\\b"),p("variable","@\\{"+o+"\\}"),{begin:"\\b("+Jq.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,p("selector-tag",l,0),p("selector-id","#"+l),p("selector-class","\\."+l,0),p("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+s3.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+i3.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:x},{begin:"!important"},t.FUNCTION_DISPATCH]},_={begin:o+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[S]};return c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,C,T,_,w,S,y,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:c}}function aG(e){const t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},o=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:o.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:o}].concat(o)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}}function sG(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},o={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},l={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},c={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,r,o,l,c]}}function iG(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},o={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},l={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},d=/[A-Za-z][A-Za-z0-9+.-]*/,m={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,d,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},p={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(p,{contains:[]}),x=e.inherit(h,{contains:[]});p.contains.push(x),h.contains.push(g);let y=[n,m];return[p,h,g,x].forEach(S=>{S.contains=S.contains.concat(y)}),y=y.concat(p,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,l,p,h,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},o,r,m,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function oG(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,d={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},m={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:d,illegal:"</",contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+m.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:m,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function lG(e){const t=e.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,o={$pattern:/[\w.]+/,keyword:n.join(" ")},l={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:o},c={begin:/->\{/,end:/\}/},d={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},m={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[d]},p={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},h=[e.BACKSLASH_ESCAPE,l,m],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],x=(C,T,S="\\1")=>{const _=S==="\\1"?S:t.concat(S,T);return t.concat(t.concat("(?:",C,")"),T,/(?:\\.|[^\\\/])*?/,_,/(?:\\.|[^\\\/])*?/,S,r)},y=(C,T,S)=>t.concat(t.concat("(?:",C,")"),T,/(?:\\.|[^\\\/])*?/,S,r),w=[m,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),c,{className:"string",contains:h,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},p,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:x("s|tr|y",t.either(...g,{capture:!0}))},{begin:x("s|tr|y","\\(","\\)")},{begin:x("s|tr|y","\\[","\\]")},{begin:x("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:y("(?:m|qr)?",/\//,/\//)},{begin:y("m|qr",t.either(...g,{capture:!0}),/\1/)},{begin:y("m|qr",/\(/,/\)/)},{begin:y("m|qr",/\[/,/\]/)},{begin:y("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,d]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,d,p]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return l.contains=w,c.contains=w,{name:"Perl",aliases:["pl","pm"],keywords:o,contains:w}}function cG(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),o=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),l=t.concat(/[A-Z]+/,n),c={scope:"variable",match:"\\$+"+r},d={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},m={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},p=e.inherit(e.APOS_STRING_MODE,{illegal:null}),h=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(m)}),g={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(m),"on:begin":(q,te)=>{te.data._beginMatch=q[1]||q[2]},"on:end":(q,te)=>{te.data._beginMatch!==q[1]&&te.ignoreMatch()}},x=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),y=`[
|
|
646
646
|
]`,w={scope:"string",variants:[h,p,g,x]},C={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},T=["false","null","true"],S=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],_=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],O={keyword:S,literal:(q=>{const te=[];return q.forEach(U=>{te.push(U),U.toLowerCase()===U?te.push(U.toUpperCase()):te.push(U.toLowerCase())}),te})(T),built_in:_},P=q=>q.map(te=>te.replace(/\|\d+$/,"")),L={variants:[{match:[/new/,t.concat(y,"+"),t.concat("(?!",P(_).join("\\b|"),"\\b)"),o],scope:{1:"keyword",4:"title.class"}}]},F=t.concat(r,"\\b(?!\\()"),V={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),F],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[o,t.concat(/::/,t.lookahead(/(?!class\b)/)),F],scope:{1:"title.class",3:"variable.constant"}},{match:[o,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[o,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},X={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},z={relevance:0,begin:/\(/,end:/\)/,keywords:O,contains:[X,c,V,e.C_BLOCK_COMMENT_MODE,w,C,L]},G={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",P(S).join("\\b|"),"|",P(_).join("\\b|"),"\\b)"),r,t.concat(y,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[z]};z.contains.push(G);const ae=[X,V,e.C_BLOCK_COMMENT_MODE,w,C,L],Z={begin:t.concat(/#\[\s*\\?/,t.either(o,l)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:T,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:T,keyword:["new","array"]},contains:["self",...ae]},...ae,{scope:"meta",variants:[{match:o},{match:l}]}]};return{case_insensitive:!1,keywords:O,contains:[Z,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},d,{scope:"variable.language",match:/\$this\b/},c,G,V,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},L,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:O,contains:["self",Z,c,V,e.C_BLOCK_COMMENT_MODE,w,C]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},w,C]}}function uG(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function dG(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function mG(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],d={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},m={className:"meta",begin:/^(>>>|\.\.\.) /},p={className:"subst",begin:/\{/,end:/\}/,keywords:d,illegal:/#/},h={begin:/\{\{/,relevance:0},g={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,m],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,m,h,p]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m,h,p]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,h,p]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,p]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},x="[0-9](_?[0-9])*",y=`(\\b(${x}))?\\.(${x})|\\b(${x})\\.`,w=`\\b|${r.join("|")}`,C={className:"number",relevance:0,variants:[{begin:`(\\b(${x})|(${y}))[eE][+-]?(${x})[jJ]?(?=${w})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${w})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${w})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${w})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${w})`},{begin:`\\b(${x})[jJ](?=${w})`}]},T={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:d,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},S={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:["self",m,C,g,e.HASH_COMMENT_MODE]}]};return p.contains=[g,C,m],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:d,illegal:/(<\/|\?)|=>/,contains:[m,C,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,T,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[S]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[C,S,g]}]}}function fG(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function pG(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),o=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,l=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[o,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[l,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:o},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:l},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function hG(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),o=t.concat(r,/(::\w+)*/),c={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},d={className:"doctag",begin:"@[A-Za-z]+"},m={begin:"#<",end:">"},p=[e.COMMENT("#","$",{contains:[d]}),e.COMMENT("^=begin","^=end",{contains:[d],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:c},g={className:"string",contains:[e.BACKSLASH_ESCAPE,h],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,h]})]}]},x="[1-9](_?[0-9])*|0",y="[0-9](_?[0-9])*",w={className:"number",relevance:0,variants:[{begin:`\\b(${x})(\\.(${y}))?([eE][+-]?(${y})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},C={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:c}]},L=[g,{variants:[{match:[/class\s+/,o,/\s+<\s+/,o]},{match:[/\b(class|module)\s+/,o]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:c},{match:[/(include|extend)\s+/,o],scope:{2:"title.class"},keywords:c},{relevance:0,match:[o,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[C]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[g,{begin:n}],relevance:0},w,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:c},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,h],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(m,p),relevance:0}].concat(m,p);h.contains=L,C.contains=L;const z=[{begin:/^\s*=>/,starts:{end:"$",contains:L}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:c,contains:L}}];return p.unshift(m),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:c,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(z).concat(p).concat(L)}}function gG(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),l={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,o,t.lookahead(/\s*\(/))},c="([ui](8|16|32|64|128|size)|f(32|64))?",d=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],m=["true","false","Some","None","Ok","Err"],p=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:h,keyword:d,literal:m,built_in:p},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:p,type:h}},{className:"punctuation",begin:"->"},l]}}const bG=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),xG=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],yG=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],vG=[...xG,...yG],wG=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),kG=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),SG=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),NG=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function CG(e){const t=bG(e),n=SG,r=kG,o="@[a-z-]+",l="and or not only",d={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+vG.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},d,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+NG.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,d,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:o,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:l,attribute:wG.join(" ")},contains:[{begin:o,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},d,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function TG(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function AG(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},o={begin:/"/,end:/"/,contains:[{match:/""/}]},l=["true","false","unknown"],c=["double precision","large object","with timezone","without timezone"],d=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],m=["add","asc","collation","desc","final","first","last","view"],p=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],h=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],g=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],x=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],y=h,w=[...p,...m].filter(P=>!h.includes(P)),C={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},T={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},S={match:t.concat(/\b/,t.either(...y),/\s*\(/),relevance:0,keywords:{built_in:y}};function _(P){return t.concat(/\b/,t.either(...P.map(L=>L.replace(/\s+/,"\\s+"))),/\b/)}const j={scope:"keyword",match:_(x),relevance:0};function O(P,{exceptions:L,when:F}={}){const V=F;return L=L||[],P.map(X=>X.match(/\|\d+$/)||L.includes(X)?X:V(X)?`${X}|0`:X)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:O(w,{when:P=>P.length<3}),literal:l,type:d,built_in:g},contains:[{scope:"type",match:_(c)},j,S,C,r,o,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,T]}}function o3(e){return e?typeof e=="string"?e:e.source:null}function Ql(e){return dn("(?=",e,")")}function dn(...e){return e.map(n=>o3(n)).join("")}function EG(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function cr(...e){return"("+(EG(e).capture?"":"?:")+e.map(r=>o3(r)).join("|")+")"}const Gg=e=>dn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),_G=["Protocol","Type"].map(Gg),W2=["init","self"].map(Gg),jG=["Any","Self"],Wp=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],Y2=["false","nil","true"],MG=["assignment","associativity","higherThan","left","lowerThan","none","right"],RG=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],X2=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],l3=cr(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),c3=cr(l3,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Yp=dn(l3,c3,"*"),u3=cr(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),h0=cr(u3,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),ba=dn(u3,h0,"*"),vd=dn(/[A-Z]/,h0,"*"),OG=["attached","autoclosure",dn(/convention\(/,cr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",dn(/objc\(/,ba,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],LG=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function DG(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],o={match:[/\./,cr(..._G,...W2)],className:{2:"keyword"}},l={match:dn(/\./,cr(...Wp)),relevance:0},c=Wp.filter(ut=>typeof ut=="string").concat(["_|0"]),d=Wp.filter(ut=>typeof ut!="string").concat(jG).map(Gg),m={variants:[{className:"keyword",match:cr(...d,...W2)}]},p={$pattern:cr(/\b\w+/,/#\w+/),keyword:c.concat(RG),literal:Y2},h=[o,l,m],g={match:dn(/\./,cr(...X2)),relevance:0},x={className:"built_in",match:dn(/\b/,cr(...X2),/(?=\()/)},y=[g,x],w={match:/->/,relevance:0},C={className:"operator",relevance:0,variants:[{match:Yp},{match:`\\.(\\.|${c3})+`}]},T=[w,C],S="([0-9]_*)+",_="([0-9a-fA-F]_*)+",j={className:"number",relevance:0,variants:[{match:`\\b(${S})(\\.(${S}))?([eE][+-]?(${S}))?\\b`},{match:`\\b0x(${_})(\\.(${_}))?([pP][+-]?(${S}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},O=(ut="")=>({className:"subst",variants:[{match:dn(/\\/,ut,/[0\\tnr"']/)},{match:dn(/\\/,ut,/u\{[0-9a-fA-F]{1,8}\}/)}]}),P=(ut="")=>({className:"subst",match:dn(/\\/,ut,/[\t ]*(?:[\r\n]|\r\n)/)}),L=(ut="")=>({className:"subst",label:"interpol",begin:dn(/\\/,ut,/\(/),end:/\)/}),F=(ut="")=>({begin:dn(ut,/"""/),end:dn(/"""/,ut),contains:[O(ut),P(ut),L(ut)]}),V=(ut="")=>({begin:dn(ut,/"/),end:dn(/"/,ut),contains:[O(ut),L(ut)]}),X={className:"string",variants:[F(),F("#"),F("##"),F("###"),V(),V("#"),V("##"),V("###")]},z=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],G={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:z},ae=ut=>{const kt=dn(ut,/\//),xt=dn(/\//,ut);return{begin:kt,end:xt,contains:[...z,{scope:"comment",begin:`#(?!.*${xt})`,end:/$/}]}},Z={scope:"regexp",variants:[ae("###"),ae("##"),ae("#"),G]},q={match:dn(/`/,ba,/`/)},te={className:"variable",match:/\$\d+/},U={className:"variable",match:`\\$${h0}+`},Q=[q,te,U],me={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:LG,contains:[...T,j,X]}]}},Ce={scope:"keyword",match:dn(/@/,cr(...OG),Ql(cr(/\(/,/\s+/)))},H={scope:"meta",match:dn(/@/,ba)},W=[me,Ce,H],fe={match:Ql(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:dn(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,h0,"+")},{className:"type",match:vd,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:dn(/\s+&\s+/,Ql(vd)),relevance:0}]},I={begin:/</,end:/>/,keywords:p,contains:[...r,...h,...W,w,fe]};fe.contains.push(I);const Re={match:dn(ba,/\s*:/),keywords:"_|0",relevance:0},Be={begin:/\(/,end:/\)/,relevance:0,keywords:p,contains:["self",Re,...r,Z,...h,...y,...T,j,X,...Q,...W,fe]},Pe={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,fe]},Fe={begin:cr(Ql(dn(ba,/\s*:/)),Ql(dn(ba,/\s+/,ba,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:ba}]},dt={begin:/\(/,end:/\)/,keywords:p,contains:[Fe,...r,...h,...T,j,X,...W,fe,Be],endsParent:!0,illegal:/["']/},mt={match:[/(func|macro)/,/\s+/,cr(q.match,ba,Yp)],className:{1:"keyword",3:"title.function"},contains:[Pe,dt,t],illegal:[/\[/,/%/]},Nt={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Pe,dt,t],illegal:/\[|%/},Ot={match:[/operator/,/\s+/,Yp],className:{1:"keyword",3:"title"}},At={begin:[/precedencegroup/,/\s+/,vd],className:{1:"keyword",3:"title"},contains:[fe],keywords:[...MG,...Y2],end:/}/},qt={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},jt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},$e={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,ba,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:p,contains:[Pe,...h,{begin:/:/,end:/\{/,keywords:p,contains:[{scope:"title.class.inherited",match:vd},...h],relevance:0}]};for(const ut of X.variants){const kt=ut.contains.find(Ct=>Ct.label==="interpol");kt.keywords=p;const xt=[...h,...y,...T,j,X,...Q];kt.contains=[...xt,{begin:/\(/,end:/\)/,contains:["self",...xt]}]}return{name:"Swift",keywords:p,contains:[...r,mt,Nt,qt,jt,$e,Ot,At,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},Z,...h,...y,...T,j,X,...Q,...W,fe,Be]}}const g0="[A-Za-z$_][0-9A-Za-z$_]*",d3=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],m3=["true","false","null","undefined","NaN","Infinity"],f3=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],p3=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],h3=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],g3=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],b3=[].concat(h3,f3,p3);function IG(e){const t=e.regex,n=(me,{after:Ce})=>{const H="</"+me[0].slice(1);return me.input.indexOf(H,Ce)!==-1},r=g0,o={begin:"<>",end:"</>"},l=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(me,Ce)=>{const H=me[0].length+me.index,W=me.input[H];if(W==="<"||W===","){Ce.ignoreMatch();return}W===">"&&(n(me,{after:H})||Ce.ignoreMatch());let fe;const I=me.input.substring(H);if(fe=I.match(/^\s*=/)){Ce.ignoreMatch();return}if((fe=I.match(/^\s+extends\s+/))&&fe.index===0){Ce.ignoreMatch();return}}},d={$pattern:g0,keyword:d3,literal:m3,built_in:b3,"variable.language":g3},m="[0-9](_?[0-9])*",p=`\\.(${m})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${h})((${p})|\\.)?|(${p}))[eE][+-]?(${m})\\b`},{begin:`\\b(${h})\\b((${p})\\b|\\.)?|(${p})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},x={className:"subst",begin:"\\$\\{",end:"\\}",keywords:d,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"css"}},C={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"graphql"}},T={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,x]},_={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},j=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,C,T,{match:/\$\d+/},g];x.contains=j.concat({begin:/\{/,end:/\}/,keywords:d,contains:["self"].concat(j)});const O=[].concat(_,x.contains),P=O.concat([{begin:/(\s*)\(/,end:/\)/,keywords:d,contains:["self"].concat(O)}]),L={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:P},F={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},V={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...f3,...p3]}},X={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[L],illegal:/%/},G={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function ae(me){return t.concat("(?!",me.join("|"),")")}const Z={match:t.concat(/\b/,ae([...h3,"super","import"].map(me=>`${me}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},q={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},te={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},L]},U="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Q={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(U)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[L]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:d,exports:{PARAMS_CONTAINS:P,CLASS_REFERENCE:V},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),X,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,C,T,_,{match:/\$\d+/},g,V,{scope:"attr",match:r+t.lookahead(":"),relevance:0},Q,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,e.REGEXP_MODE,{className:"function",begin:U,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:P}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:l},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[L,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},q,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[L]},Z,G,F,te,{match:/\$[(.]/}]}}function PG(e){const t=e.regex,n=IG(e),r=g0,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],l={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},d={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},m=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],p={$pattern:g0,keyword:d3.concat(m),literal:m3,built_in:b3.concat(o),"variable.language":g3},h={className:"meta",begin:"@"+r},g=(C,T,S)=>{const _=C.contains.findIndex(j=>j.label===T);if(_===-1)throw new Error("can not find mode to replace");C.contains.splice(_,1,S)};Object.assign(n.keywords,p),n.exports.PARAMS_CONTAINS.push(h);const x=n.contains.find(C=>C.scope==="attr"),y=Object.assign({},x,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,x,y]),n.contains=n.contains.concat([h,l,c,y]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",d);const w=n.contains.find(C=>C.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function zG(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},o=/\d{1,2}\/\d{1,2}\/\d{4}/,l=/\d{4}-\d{1,2}-\d{1,2}/,c=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,d=/\d{1,2}(:\d{1,2}){1,2}/,m={className:"literal",variants:[{begin:t.concat(/# */,t.either(l,o),/ *#/)},{begin:t.concat(/# */,d,/ *#/)},{begin:t.concat(/# */,c,/ *#/)},{begin:t.concat(/# */,t.either(l,o),/ +/,t.either(c,d),/ *#/)}]},p={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},h={className:"label",begin:/^\w+:/},g=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),x=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,m,p,h,g,x,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[x]}]}}function BG(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],o={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},l={className:"variable",begin:/\$[\w_]+/},c={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},d={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},m={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},p={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},l,c,o,e.QUOTE_STRING_MODE,m,p,d]}}function $G(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,o={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},l={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},c=e.inherit(l,{begin:/\(/,end:/\)/}),d=e.inherit(e.APOS_STRING_MODE,{className:"string"}),m=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),p={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[l,m,d,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[l,c,m,d]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[m]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[p],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[p],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:p}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function HG(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},l={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},d=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),x={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},w={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},C={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},T=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},x,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,C,l,c],S=[...T];return S.pop(),S.push(d),y.contains=S,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:T}}const UG={arduino:Sq,bash:Nq,c:Cq,cpp:Tq,csharp:Aq,css:Iq,diff:Pq,go:zq,graphql:Bq,ini:$q,java:Hq,javascript:Kq,json:Vq,kotlin:Yq,less:rG,lua:aG,makefile:sG,markdown:iG,objectivec:oG,perl:lG,php:cG,"php-template":uG,plaintext:dG,python:mG,"python-repl":fG,r:pG,ruby:hG,rust:gG,scss:CG,shell:TG,sql:AG,swift:DG,typescript:PG,vbnet:zG,wasm:BG,xml:$G,yaml:HG};var Xp,Q2;function FG(){if(Q2)return Xp;Q2=1;function e(K){return K instanceof Map?K.clear=K.delete=K.set=function(){throw new Error("map is read-only")}:K instanceof Set&&(K.add=K.clear=K.delete=function(){throw new Error("set is read-only")}),Object.freeze(K),Object.getOwnPropertyNames(K).forEach(le=>{const je=K[le],Ue=typeof je;(Ue==="object"||Ue==="function")&&!Object.isFrozen(je)&&e(je)}),K}class t{constructor(le){le.data===void 0&&(le.data={}),this.data=le.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(K){return K.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(K,...le){const je=Object.create(null);for(const Ue in K)je[Ue]=K[Ue];return le.forEach(function(Ue){for(const tt in Ue)je[tt]=Ue[tt]}),je}const o="</span>",l=K=>!!K.scope,c=(K,{prefix:le})=>{if(K.startsWith("language:"))return K.replace("language:","language-");if(K.includes(".")){const je=K.split(".");return[`${le}${je.shift()}`,...je.map((Ue,tt)=>`${Ue}${"_".repeat(tt+1)}`)].join(" ")}return`${le}${K}`};class d{constructor(le,je){this.buffer="",this.classPrefix=je.classPrefix,le.walk(this)}addText(le){this.buffer+=n(le)}openNode(le){if(!l(le))return;const je=c(le.scope,{prefix:this.classPrefix});this.span(je)}closeNode(le){l(le)&&(this.buffer+=o)}value(){return this.buffer}span(le){this.buffer+=`<span class="${le}">`}}const m=(K={})=>{const le={children:[]};return Object.assign(le,K),le};class p{constructor(){this.rootNode=m(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(le){this.top.children.push(le)}openNode(le){const je=m({scope:le});this.add(je),this.stack.push(je)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(le){return this.constructor._walk(le,this.rootNode)}static _walk(le,je){return typeof je=="string"?le.addText(je):je.children&&(le.openNode(je),je.children.forEach(Ue=>this._walk(le,Ue)),le.closeNode(je)),le}static _collapse(le){typeof le!="string"&&le.children&&(le.children.every(je=>typeof je=="string")?le.children=[le.children.join("")]:le.children.forEach(je=>{p._collapse(je)}))}}class h extends p{constructor(le){super(),this.options=le}addText(le){le!==""&&this.add(le)}startScope(le){this.openNode(le)}endScope(){this.closeNode()}__addSublanguage(le,je){const Ue=le.root;je&&(Ue.scope=`language:${je}`),this.add(Ue)}toHTML(){return new d(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(K){return K?typeof K=="string"?K:K.source:null}function x(K){return C("(?=",K,")")}function y(K){return C("(?:",K,")*")}function w(K){return C("(?:",K,")?")}function C(...K){return K.map(je=>g(je)).join("")}function T(K){const le=K[K.length-1];return typeof le=="object"&&le.constructor===Object?(K.splice(K.length-1,1),le):{}}function S(...K){return"("+(T(K).capture?"":"?:")+K.map(Ue=>g(Ue)).join("|")+")"}function _(K){return new RegExp(K.toString()+"|").exec("").length-1}function j(K,le){const je=K&&K.exec(le);return je&&je.index===0}const O=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function P(K,{joinWith:le}){let je=0;return K.map(Ue=>{je+=1;const tt=je;let yt=g(Ue),qe="";for(;yt.length>0;){const nt=O.exec(yt);if(!nt){qe+=yt;break}qe+=yt.substring(0,nt.index),yt=yt.substring(nt.index+nt[0].length),nt[0][0]==="\\"&&nt[1]?qe+="\\"+String(Number(nt[1])+tt):(qe+=nt[0],nt[0]==="("&&je++)}return qe}).map(Ue=>`(${Ue})`).join(le)}const L=/\b\B/,F="[a-zA-Z]\\w*",V="[a-zA-Z_]\\w*",X="\\b\\d+(\\.\\d+)?",z="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",G="\\b(0b[01]+)",ae="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Z=(K={})=>{const le=/^#![ ]*\//;return K.binary&&(K.begin=C(le,/.*\b/,K.binary,/\b.*/)),r({scope:"meta",begin:le,end:/$/,relevance:0,"on:begin":(je,Ue)=>{je.index!==0&&Ue.ignoreMatch()}},K)},q={begin:"\\\\[\\s\\S]",relevance:0},te={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[q]},U={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[q]},Q={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},me=function(K,le,je={}){const Ue=r({scope:"comment",begin:K,end:le,contains:[]},je);Ue.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const tt=S("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return Ue.contains.push({begin:C(/[ ]+/,"(",tt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ue},Ce=me("//","$"),H=me("/\\*","\\*/"),W=me("#","$"),fe={scope:"number",begin:X,relevance:0},I={scope:"number",begin:z,relevance:0},Re={scope:"number",begin:G,relevance:0},Be={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[q,{begin:/\[/,end:/\]/,relevance:0,contains:[q]}]},Pe={scope:"title",begin:F,relevance:0},Fe={scope:"title",begin:V,relevance:0},dt={begin:"\\.\\s*"+V,relevance:0};var Nt=Object.freeze({__proto__:null,APOS_STRING_MODE:te,BACKSLASH_ESCAPE:q,BINARY_NUMBER_MODE:Re,BINARY_NUMBER_RE:G,COMMENT:me,C_BLOCK_COMMENT_MODE:H,C_LINE_COMMENT_MODE:Ce,C_NUMBER_MODE:I,C_NUMBER_RE:z,END_SAME_AS_BEGIN:function(K){return Object.assign(K,{"on:begin":(le,je)=>{je.data._beginMatch=le[1]},"on:end":(le,je)=>{je.data._beginMatch!==le[1]&&je.ignoreMatch()}})},HASH_COMMENT_MODE:W,IDENT_RE:F,MATCH_NOTHING_RE:L,METHOD_GUARD:dt,NUMBER_MODE:fe,NUMBER_RE:X,PHRASAL_WORDS_MODE:Q,QUOTE_STRING_MODE:U,REGEXP_MODE:Be,RE_STARTERS_RE:ae,SHEBANG:Z,TITLE_MODE:Pe,UNDERSCORE_IDENT_RE:V,UNDERSCORE_TITLE_MODE:Fe});function Ot(K,le){K.input[K.index-1]==="."&&le.ignoreMatch()}function At(K,le){K.className!==void 0&&(K.scope=K.className,delete K.className)}function qt(K,le){le&&K.beginKeywords&&(K.begin="\\b("+K.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",K.__beforeBegin=Ot,K.keywords=K.keywords||K.beginKeywords,delete K.beginKeywords,K.relevance===void 0&&(K.relevance=0))}function jt(K,le){Array.isArray(K.illegal)&&(K.illegal=S(...K.illegal))}function $e(K,le){if(K.match){if(K.begin||K.end)throw new Error("begin & end are not supported with match");K.begin=K.match,delete K.match}}function ut(K,le){K.relevance===void 0&&(K.relevance=1)}const kt=(K,le)=>{if(!K.beforeMatch)return;if(K.starts)throw new Error("beforeMatch cannot be used with starts");const je=Object.assign({},K);Object.keys(K).forEach(Ue=>{delete K[Ue]}),K.keywords=je.keywords,K.begin=C(je.beforeMatch,x(je.begin)),K.starts={relevance:0,contains:[Object.assign(je,{endsParent:!0})]},K.relevance=0,delete je.beforeMatch},xt=["of","and","for","in","not","or","if","then","parent","list","value"],Ct="keyword";function ce(K,le,je=Ct){const Ue=Object.create(null);return typeof K=="string"?tt(je,K.split(" ")):Array.isArray(K)?tt(je,K):Object.keys(K).forEach(function(yt){Object.assign(Ue,ce(K[yt],le,yt))}),Ue;function tt(yt,qe){le&&(qe=qe.map(nt=>nt.toLowerCase())),qe.forEach(function(nt){const St=nt.split("|");Ue[St[0]]=[yt,rt(St[0],St[1])]})}}function rt(K,le){return le?Number(le):at(K)?0:1}function at(K){return xt.includes(K.toLowerCase())}const ve={},_e=K=>{console.error(K)},Ee=(K,...le)=>{console.log(`WARN: ${K}`,...le)},oe=(K,le)=>{ve[`${K}/${le}`]||(console.log(`Deprecated as of ${K}. ${le}`),ve[`${K}/${le}`]=!0)},$=new Error;function J(K,le,{key:je}){let Ue=0;const tt=K[je],yt={},qe={};for(let nt=1;nt<=le.length;nt++)qe[nt+Ue]=tt[nt],yt[nt+Ue]=!0,Ue+=_(le[nt-1]);K[je]=qe,K[je]._emit=yt,K[je]._multi=!0}function Te(K){if(Array.isArray(K.begin)){if(K.skip||K.excludeBegin||K.returnBegin)throw _e("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),$;if(typeof K.beginScope!="object"||K.beginScope===null)throw _e("beginScope must be object"),$;J(K,K.begin,{key:"beginScope"}),K.begin=P(K.begin,{joinWith:""})}}function ne(K){if(Array.isArray(K.end)){if(K.skip||K.excludeEnd||K.returnEnd)throw _e("skip, excludeEnd, returnEnd not compatible with endScope: {}"),$;if(typeof K.endScope!="object"||K.endScope===null)throw _e("endScope must be object"),$;J(K,K.end,{key:"endScope"}),K.end=P(K.end,{joinWith:""})}}function he(K){K.scope&&typeof K.scope=="object"&&K.scope!==null&&(K.beginScope=K.scope,delete K.scope)}function be(K){he(K),typeof K.beginScope=="string"&&(K.beginScope={_wrap:K.beginScope}),typeof K.endScope=="string"&&(K.endScope={_wrap:K.endScope}),Te(K),ne(K)}function ge(K){function le(qe,nt){return new RegExp(g(qe),"m"+(K.case_insensitive?"i":"")+(K.unicodeRegex?"u":"")+(nt?"g":""))}class je{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(nt,St){St.position=this.position++,this.matchIndexes[this.matchAt]=St,this.regexes.push([St,nt]),this.matchAt+=_(nt)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const nt=this.regexes.map(St=>St[1]);this.matcherRe=le(P(nt,{joinWith:"|"}),!0),this.lastIndex=0}exec(nt){this.matcherRe.lastIndex=this.lastIndex;const St=this.matcherRe.exec(nt);if(!St)return null;const jn=St.findIndex((Ea,Di)=>Di>0&&Ea!==void 0),vn=this.matchIndexes[jn];return St.splice(0,jn),Object.assign(St,vn)}}class Ue{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(nt){if(this.multiRegexes[nt])return this.multiRegexes[nt];const St=new je;return this.rules.slice(nt).forEach(([jn,vn])=>St.addRule(jn,vn)),St.compile(),this.multiRegexes[nt]=St,St}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(nt,St){this.rules.push([nt,St]),St.type==="begin"&&this.count++}exec(nt){const St=this.getMatcher(this.regexIndex);St.lastIndex=this.lastIndex;let jn=St.exec(nt);if(this.resumingScanAtSamePosition()&&!(jn&&jn.index===this.lastIndex)){const vn=this.getMatcher(0);vn.lastIndex=this.lastIndex+1,jn=vn.exec(nt)}return jn&&(this.regexIndex+=jn.position+1,this.regexIndex===this.count&&this.considerAll()),jn}}function tt(qe){const nt=new Ue;return qe.contains.forEach(St=>nt.addRule(St.begin,{rule:St,type:"begin"})),qe.terminatorEnd&&nt.addRule(qe.terminatorEnd,{type:"end"}),qe.illegal&&nt.addRule(qe.illegal,{type:"illegal"}),nt}function yt(qe,nt){const St=qe;if(qe.isCompiled)return St;[At,$e,be,kt].forEach(vn=>vn(qe,nt)),K.compilerExtensions.forEach(vn=>vn(qe,nt)),qe.__beforeBegin=null,[qt,jt,ut].forEach(vn=>vn(qe,nt)),qe.isCompiled=!0;let jn=null;return typeof qe.keywords=="object"&&qe.keywords.$pattern&&(qe.keywords=Object.assign({},qe.keywords),jn=qe.keywords.$pattern,delete qe.keywords.$pattern),jn=jn||/\w+/,qe.keywords&&(qe.keywords=ce(qe.keywords,K.case_insensitive)),St.keywordPatternRe=le(jn,!0),nt&&(qe.begin||(qe.begin=/\B|\b/),St.beginRe=le(St.begin),!qe.end&&!qe.endsWithParent&&(qe.end=/\B|\b/),qe.end&&(St.endRe=le(St.end)),St.terminatorEnd=g(St.end)||"",qe.endsWithParent&&nt.terminatorEnd&&(St.terminatorEnd+=(qe.end?"|":"")+nt.terminatorEnd)),qe.illegal&&(St.illegalRe=le(qe.illegal)),qe.contains||(qe.contains=[]),qe.contains=[].concat(...qe.contains.map(function(vn){return st(vn==="self"?qe:vn)})),qe.contains.forEach(function(vn){yt(vn,St)}),qe.starts&&yt(qe.starts,nt),St.matcher=tt(St),St}if(K.compilerExtensions||(K.compilerExtensions=[]),K.contains&&K.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return K.classNameAliases=r(K.classNameAliases||{}),yt(K)}function Se(K){return K?K.endsWithParent||Se(K.starts):!1}function st(K){return K.variants&&!K.cachedVariants&&(K.cachedVariants=K.variants.map(function(le){return r(K,{variants:null},le)})),K.cachedVariants?K.cachedVariants:Se(K)?r(K,{starts:K.starts?r(K.starts):null}):Object.isFrozen(K)?r(K):K}var Ve="11.11.1";class Je extends Error{constructor(le,je){super(le),this.name="HTMLInjectionError",this.html=je}}const R=n,ie=r,Le=Symbol("nomatch"),xe=7,Ge=function(K){const le=Object.create(null),je=Object.create(null),Ue=[];let tt=!0;const yt="Could not find the language '{}', did you forget to load/include a language module?",qe={disableAutodetect:!0,name:"Plain text",contains:[]};let nt={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function St(Ke){return nt.noHighlightRe.test(Ke)}function jn(Ke){let vt=Ke.className+" ";vt+=Ke.parentNode?Ke.parentNode.className:"";const Ht=nt.languageDetectRe.exec(vt);if(Ht){const rn=ir(Ht[1]);return rn||(Ee(yt.replace("{}",Ht[1])),Ee("Falling back to no-highlight mode for this block.",Ke)),rn?Ht[1]:"no-highlight"}return vt.split(/\s+/).find(rn=>St(rn)||ir(rn))}function vn(Ke,vt,Ht){let rn="",Rn="";typeof vt=="object"?(rn=Ke,Ht=vt.ignoreIllegals,Rn=vt.language):(oe("10.7.0","highlight(lang, code, ...args) has been deprecated."),oe("10.7.0",`Please use highlight(code, options) instead.
|
|
647
647
|
https://github.com/highlightjs/highlight.js/issues/2277`),Rn=Ke,rn=vt),Ht===void 0&&(Ht=!0);const tr={code:rn,language:Rn};Ys("before:highlight",tr);const Mr=tr.result?tr.result:Ea(tr.language,tr.code,Ht);return Mr.code=tr.code,Ys("after:highlight",Mr),Mr}function Ea(Ke,vt,Ht,rn){const Rn=Object.create(null);function tr(et,ht){return et.keywords[ht]}function Mr(){if(!_t.keywords){In.addText(an);return}let et=0;_t.keywordPatternRe.lastIndex=0;let ht=_t.keywordPatternRe.exec(an),It="";for(;ht;){It+=an.substring(et,ht.index);const Wt=Yn.case_insensitive?ht[0].toLowerCase():ht[0],Nn=tr(_t,Wt);if(Nn){const[Vr,nl]=Nn;if(In.addText(It),It="",Rn[Wt]=(Rn[Wt]||0)+1,Rn[Wt]<=xe&&(ls+=nl),Vr.startsWith("_"))It+=ht[0];else{const Hc=Yn.classNameAliases[Vr]||Vr;Rr(ht[0],Hc)}}else It+=ht[0];et=_t.keywordPatternRe.lastIndex,ht=_t.keywordPatternRe.exec(an)}It+=an.substring(et),In.addText(It)}function gr(){if(an==="")return;let et=null;if(typeof _t.subLanguage=="string"){if(!le[_t.subLanguage]){In.addText(an);return}et=Ea(_t.subLanguage,an,!0,$c[_t.subLanguage]),$c[_t.subLanguage]=et._top}else et=Ii(an,_t.subLanguage.length?_t.subLanguage:null);_t.relevance>0&&(ls+=et.relevance),In.__addSublanguage(et._emitter,et.language)}function hn(){_t.subLanguage!=null?gr():Mr(),an=""}function Rr(et,ht){et!==""&&(In.startScope(ht),In.addText(et),In.endScope())}function zc(et,ht){let It=1;const Wt=ht.length-1;for(;It<=Wt;){if(!et._emit[It]){It++;continue}const Nn=Yn.classNameAliases[et[It]]||et[It],Vr=ht[It];Nn?Rr(Vr,Nn):(an=Vr,Mr(),an=""),It++}}function zi(et,ht){return et.scope&&typeof et.scope=="string"&&In.openNode(Yn.classNameAliases[et.scope]||et.scope),et.beginScope&&(et.beginScope._wrap?(Rr(an,Yn.classNameAliases[et.beginScope._wrap]||et.beginScope._wrap),an=""):et.beginScope._multi&&(zc(et.beginScope,ht),an="")),_t=Object.create(et,{parent:{value:_t}}),_t}function Jo(et,ht,It){let Wt=j(et.endRe,It);if(Wt){if(et["on:end"]){const Nn=new t(et);et["on:end"](ht,Nn),Nn.isMatchIgnored&&(Wt=!1)}if(Wt){for(;et.endsParent&&et.parent;)et=et.parent;return et}}if(et.endsWithParent)return Jo(et.parent,ht,It)}function Bi(et){return _t.matcher.regexIndex===0?(an+=et[0],1):(cs=!0,0)}function X0(et){const ht=et[0],It=et.rule,Wt=new t(It),Nn=[It.__beforeBegin,It["on:begin"]];for(const Vr of Nn)if(Vr&&(Vr(et,Wt),Wt.isMatchIgnored))return Bi(ht);return It.skip?an+=ht:(It.excludeBegin&&(an+=ht),hn(),!It.returnBegin&&!It.excludeBegin&&(an=ht)),zi(It,et),It.returnBegin?0:ht.length}function br(et){const ht=et[0],It=vt.substring(et.index),Wt=Jo(_t,et,It);if(!Wt)return Le;const Nn=_t;_t.endScope&&_t.endScope._wrap?(hn(),Rr(ht,_t.endScope._wrap)):_t.endScope&&_t.endScope._multi?(hn(),zc(_t.endScope,et)):Nn.skip?an+=ht:(Nn.returnEnd||Nn.excludeEnd||(an+=ht),hn(),Nn.excludeEnd&&(an=ht));do _t.scope&&In.closeNode(),!_t.skip&&!_t.subLanguage&&(ls+=_t.relevance),_t=_t.parent;while(_t!==Wt.parent);return Wt.starts&&zi(Wt.starts,et),Nn.returnEnd?0:ht.length}function el(){const et=[];for(let ht=_t;ht!==Yn;ht=ht.parent)ht.scope&&et.unshift(ht.scope);et.forEach(ht=>In.openNode(ht))}let Xs={};function $i(et,ht){const It=ht&&ht[0];if(an+=et,It==null)return hn(),0;if(Xs.type==="begin"&&ht.type==="end"&&Xs.index===ht.index&&It===""){if(an+=vt.slice(ht.index,ht.index+1),!tt){const Wt=new Error(`0 width match regex (${Ke})`);throw Wt.languageName=Ke,Wt.badRule=Xs.rule,Wt}return 1}if(Xs=ht,ht.type==="begin")return X0(ht);if(ht.type==="illegal"&&!Ht){const Wt=new Error('Illegal lexeme "'+It+'" for mode "'+(_t.scope||"<unnamed>")+'"');throw Wt.mode=_t,Wt}else if(ht.type==="end"){const Wt=br(ht);if(Wt!==Le)return Wt}if(ht.type==="illegal"&&It==="")return an+=`
|
|
648
|
-
`,1;if(tl>1e5&&tl>ht.index*3)throw new Error("potential infinite loop, way more iterations than matches");return an+=It,It.length}const Yn=ir(Ke);if(!Yn)throw _e(yt.replace("{}",Ke)),new Error('Unknown language: "'+Ke+'"');const Bc=ge(Yn);let Hi="",_t=rn||Bc;const $c={},In=new nt.__emitter(nt);el();let an="",ls=0,Ma=0,tl=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(vt,In);else{for(_t.matcher.considerAll();;){tl++,cs?cs=!1:_t.matcher.considerAll(),_t.matcher.lastIndex=Ma;const et=_t.matcher.exec(vt);if(!et)break;const ht=vt.substring(Ma,et.index),It=$i(ht,et);Ma=et.index+It}$i(vt.substring(Ma))}return In.finalize(),Hi=In.toHTML(),{language:Ke,value:Hi,relevance:ls,illegal:!1,_emitter:In,_top:_t}}catch(et){if(et.message&&et.message.includes("Illegal"))return{language:Ke,value:R(vt),illegal:!0,relevance:0,_illegalBy:{message:et.message,index:Ma,context:vt.slice(Ma-100,Ma+100),mode:et.mode,resultSoFar:Hi},_emitter:In};if(tt)return{language:Ke,value:R(vt),illegal:!1,relevance:0,errorRaised:et,_emitter:In,_top:_t};throw et}}function Di(Ke){const vt={value:R(Ke),illegal:!1,relevance:0,_top:qe,_emitter:new nt.__emitter(nt)};return vt._emitter.addText(Ke),vt}function Ii(Ke,vt){vt=vt||nt.languages||Object.keys(le);const Ht=Di(Ke),rn=vt.filter(ir).filter(is).map(hn=>Ea(hn,Ke,!1));rn.unshift(Ht);const Rn=rn.sort((hn,Rr)=>{if(hn.relevance!==Rr.relevance)return Rr.relevance-hn.relevance;if(hn.language&&Rr.language){if(ir(hn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===hn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(Ke,vt,Ht){const rn=vt&&je[vt]||Ht;Ke.classList.add("hljs"),Ke.classList.add(`language-${rn}`)}function Mn(Ke){let vt=null;const Ht=jn(Ke);if(St(Ht))return;if(Ys("before:highlightElement",{el:Ke,language:Ht}),Ke.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ke);return}if(Ke.children.length>0&&(nt.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Ke)),nt.throwUnescapedHTML))throw new Je("One of your code blocks includes unescaped HTML.",Ke.innerHTML);vt=Ke;const rn=vt.textContent,Rn=Ht?vn(rn,{language:Ht,ignoreIllegals:!0}):Ii(rn);Ke.innerHTML=Rn.value,Ke.dataset.highlighted="yes",ma(Ke,Ht,Rn.language),Ke.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(Ke.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ys("after:highlightElement",{el:Ke,result:Rn,text:rn})}function er(Ke){nt=ie(nt,Ke)}const ss=()=>{Pi(),oe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Qo(){Pi(),oe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Dc=!1;function Pi(){function Ke(){Pi()}if(document.readyState==="loading"){Dc||window.addEventListener("DOMContentLoaded",Ke,!1),Dc=!0;return}document.querySelectorAll(nt.cssSelector).forEach(Mn)}function Ic(Ke,vt){let Ht=null;try{Ht=vt(K)}catch(rn){if(_e("Language definition for '{}' could not be registered.".replace("{}",Ke)),tt)_e(rn);else throw rn;Ht=qe}Ht.name||(Ht.name=Ke),le[Ke]=Ht,Ht.rawDefinition=vt.bind(null,K),Ht.aliases&&_a(Ht.aliases,{languageName:Ke})}function Ws(Ke){delete le[Ke];for(const vt of Object.keys(je))je[vt]===Ke&&delete je[vt]}function Zo(){return Object.keys(le)}function ir(Ke){return Ke=(Ke||"").toLowerCase(),le[Ke]||le[je[Ke]]}function _a(Ke,{languageName:vt}){typeof Ke=="string"&&(Ke=[Ke]),Ke.forEach(Ht=>{je[Ht.toLowerCase()]=vt})}function is(Ke){const vt=ir(Ke);return vt&&!vt.disableAutodetect}function os(Ke){Ke["before:highlightBlock"]&&!Ke["before:highlightElement"]&&(Ke["before:highlightElement"]=vt=>{Ke["before:highlightBlock"](Object.assign({block:vt.el},vt))}),Ke["after:highlightBlock"]&&!Ke["after:highlightElement"]&&(Ke["after:highlightElement"]=vt=>{Ke["after:highlightBlock"](Object.assign({block:vt.el},vt))})}function Dn(Ke){os(Ke),Ue.push(Ke)}function Pc(Ke){const vt=Ue.indexOf(Ke);vt!==-1&&Ue.splice(vt,1)}function Ys(Ke,vt){const Ht=Ke;Ue.forEach(function(rn){rn[Ht]&&rn[Ht](vt)})}function ja(Ke){return oe("10.7.0","highlightBlock will be removed entirely in v12.0"),oe("10.7.0","Please use highlightElement now."),Mn(Ke)}Object.assign(K,{highlight:vn,highlightAuto:Ii,highlightAll:Pi,highlightElement:Mn,highlightBlock:ja,configure:er,initHighlighting:ss,initHighlightingOnLoad:Qo,registerLanguage:Ic,unregisterLanguage:Ws,listLanguages:Zo,getLanguage:ir,registerAliases:_a,autoDetection:is,inherit:ie,addPlugin:Dn,removePlugin:Pc}),K.debugMode=function(){tt=!1},K.safeMode=function(){tt=!0},K.versionString=Ve,K.regex={concat:C,lookahead:x,either:S,optional:w,anyNumberOfTimes:y};for(const Ke in Nt)typeof Nt[Ke]=="object"&&e(Nt[Ke]);return Object.assign(K,Nt),K},Qe=Ge({});return Qe.newInstance=()=>Ge({}),Xp=Qe,Qe.HighlightJS=Qe,Qe.default=Qe,Xp}var qG=FG();const GG=Tc(qG),Z2={},KG="hljs-";function VG(e){const t=GG.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:c,registered:d};function n(m,p,h){const g=h||Z2,x=typeof g.prefix=="string"?g.prefix:KG;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:WG,classPrefix:x});const y=t.highlight(p,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,C=w.data;return C.language=y.language,C.relevance=y.relevance,w}function r(m,p){const g=(p||Z2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const C=g[x];if(!t.getLanguage(C))continue;const T=n(C,m,p);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function l(m,p){if(typeof m=="string")t.registerLanguage(m,p);else{let h;for(h in m)Object.hasOwn(m,h)&&t.registerLanguage(h,m[h])}}function c(m,p){if(typeof m=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:m});else{let h;for(h in m)if(Object.hasOwn(m,h)){const g=m[h];t.registerAliases(typeof g=="string"?g:[...g],{languageName:h})}}}function d(m){return!!t.getLanguage(m)}}class WG{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(c,d){return d?c+"_".repeat(d):n.options.classPrefix+c}),o=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const YG={};function x3(e){const t=e||YG,n=t.aliases,r=t.detect||!1,o=t.languages||UG,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const p=VG(o);if(n&&p.registerAlias(n),c){const h=c.indexOf("-");m=h===-1?c:c.slice(0,h)}return function(h,g){D0(h,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const C=XG(x);if(C===!1||!C&&!r||C&&l&&l.includes(C))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=Qk(x,{whitespace:"pre"});let S;try{S=C?p.highlight(C,T,{prefix:c}):p.highlightAuto(T,{prefix:c,subset:d})}catch(_){const j=_;if(C&&/Unknown language/.test(j.message)){g.message("Cannot highlight as `"+C+"`, it’s not registered",{ancestors:[w,x],cause:j,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw j}!C&&S.data&&S.data.language&&x.properties.className.push("language-"+S.data.language),S.children.length>0&&(x.children=S.children)})}}function XG(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const o=String(t[n]);if(o==="no-highlight"||o==="nohighlight")return!1;!r&&o.slice(0,5)==="lang-"&&(r=o.slice(5)),!r&&o.slice(0,9)==="language-"&&(r=o.slice(9))}return r}const Kg=new Set;function wi(e){e&&Kg.add(e)}function Kh(e){e&&Kg.delete(e)}const y3="markus_right_panel_v1",QG=10,Vh=new Map;function ZG(e,t=3e3){Vh.set(e,Date.now()+t)}function JG(e){const t=Vh.get(e);return t==null?!1:Date.now()>t?(Vh.delete(e),!1):!0}function eK(e){return e.kind==="terminal"}function Zl(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;if(e.kind==="terminal")return`terminal:${e.terminalId}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function J2(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.kind==="terminal"?e.title||"Terminal":e.title||e.path.split(/[/\\]/).pop()||e.path}function Is(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function wd(e){let t=e;for(;t.length>QG;){let n=-1;for(let o=t.length-1;o>=0;o--)if(!t[o].pinned){n=o;break}if(n<0)break;const r=t[n];r&&(Wh(r.payload),Yh(r.payload)),t=t.filter((o,l)=>l!==n)}return t}function Wh(e){e?.kind==="url"&&e.browserId&&(ZG(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function Yh(e){e?.kind==="terminal"&&e.terminalId&&(Kh(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function tK(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?gc(t.url||"")||gc(t.title||"")?null:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"url",url:t.url||"about:blank",title:t.title||e.title}}:t.kind==="file"?{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"file",path:t.path,title:t.title}}:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"deliverable",deliverable:t.deliverable}}}function nK(e,t=0){if(e.payload.kind==="url"){const n=`eb_${Date.now().toString(36)}_${t.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return{...e,payload:{kind:"url",url:e.payload.url||"about:blank",title:e.payload.title||e.title,browserId:n}}}return e}function rK(){try{const e=localStorage.getItem(y3);if(!e)return null;const t=JSON.parse(e);return!t||t.mode!=="browser"&&t.mode!=="terminal"||!Array.isArray(t.browserTabs)?null:t}catch{return null}}function aK(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=rK();if(!t)return e;const n=t.browserTabs.map((y,w)=>{try{return nK(y,w)}catch{return null}}).filter(y=>!(!y||y.payload.kind==="terminal"||y.payload.kind==="url"&&gc(y.payload.url||""))),r=n.some(y=>y.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,o=(t.terminalTabs||[]).map((y,w)=>{const C=`term_${Date.now().toString(36)}_${w.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return wi(C),{id:y.id||Is(),title:y.title||"Terminal",payload:{kind:"terminal",terminalId:C,title:y.title||"Terminal",cwd:y.cwd}}}),l=o.some(y=>y.id===t.terminalActiveId)?t.terminalActiveId:o[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,d=!!t.terminalCollapsed&&o.length>0,m=c?[]:n,p=c?null:r,h=d?[]:o,g=d?null:l;let x=t.mode;return x==="terminal"&&h.length===0&&!d&&(x="browser"),x==="browser"&&m.length===0&&h.length>0&&(x="terminal"),{mode:x,browserTabs:m,browserActiveId:p,terminalTabs:h,terminalActiveId:g,stashedBrowserTabs:n,stashedBrowserActiveId:r,stashedTerminalTabs:o,stashedTerminalActiveId:l}}const v3=k.createContext(null);function sK({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),r=k.useMemo(()=>aK(),[]),[o,l]=k.useState(r.mode),[c,d]=k.useState(r.browserTabs),[m,p]=k.useState(r.terminalTabs),[h,g]=k.useState(r.browserActiveId),[x,y]=k.useState(r.terminalActiveId),[w,C]=k.useState(!1),[T,S]=k.useState(!1),[_,j]=k.useState("l0"),[O,P]=k.useState(null),L=k.useCallback(ve=>j(ve),[]),F=k.useCallback(ve=>P(ve),[]);k.useEffect(()=>{const ve=Ee=>{if(!(Ee instanceof HTMLElement))return!1;const oe=Ee.tagName;return oe==="INPUT"||oe==="TEXTAREA"||oe==="SELECT"?!0:Ee.isContentEditable},_e=Ee=>{if(!(Ee.target instanceof Element))return;const oe=document.activeElement;if(ve(oe)){const Te=oe===Ee.target||oe.contains(Ee.target),ne=!!Ee.target.closest("[data-keep-edit-focus]"),he=ve(Ee.target)||!!Ee.target.closest('input, textarea, select, [contenteditable="true"]'),be=!!Ee.target.closest(".xterm");!Te&&!ne&&!he&&!be&&oe.blur()}const $=Ee.target.closest("[data-keyboard-pane]");if(!$)return;const J=$.getAttribute("data-keyboard-pane");if(!(J!=="l0"&&J!=="l1"&&J!=="l2"&&J!=="content")&&(j(J),J==="l0")){const ne=Ee.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");ne&&P(ne)}};return document.addEventListener("pointerdown",_e,!0),()=>document.removeEventListener("pointerdown",_e,!0)},[]);const V=k.useRef(r.stashedBrowserTabs.length>0?r.stashedBrowserTabs:r.browserTabs),X=k.useRef(r.stashedBrowserActiveId??r.browserActiveId),z=k.useRef(r.stashedTerminalTabs.length>0?r.stashedTerminalTabs:r.terminalTabs),G=k.useRef(r.stashedTerminalActiveId??r.terminalActiveId),ae=k.useRef(r.browserActiveId),Z=k.useRef(r.terminalActiveId),q=k.useRef(r.browserTabs),te=k.useRef(r.terminalTabs),U=k.useRef(r.mode);ae.current=h,Z.current=x,q.current=c,te.current=m,U.current=o,k.useEffect(()=>{(r.mode==="terminal"||r.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),k.useEffect(()=>{const ve=c.length===0&&V.current.length>0,_e=m.length===0&&z.current.length>0,Ee=ve?V.current:c,oe=_e?z.current:m,$=Ee.map(tK).filter(ne=>!!ne),J=oe.filter(ne=>ne.payload.kind==="terminal").map(ne=>({id:ne.id,title:ne.title,cwd:ne.payload.kind==="terminal"?ne.payload.cwd:void 0})),Te={mode:o,browserTabs:$,browserActiveId:ve?X.current:h,terminalTabs:J,terminalActiveId:_e?G.current:x,browserCollapsed:ve,terminalCollapsed:_e};try{localStorage.setItem(y3,JSON.stringify(Te))}catch{}},[o,c,h,m,x]);const Q=k.useCallback(ve=>n(ve),[]),me=k.useCallback(()=>n(ve=>!ve),[]),Ce=k.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),H=k.useCallback(ve=>{l(_e=>_e===ve?_e:(ve==="terminal"&&Ce(),ve))},[Ce]),W=k.useCallback(ve=>{if(ve==="terminal"){if(Ce(),l("terminal"),n(!0),m.length>0)return;if(z.current.length>0){const ne=z.current,he=G.current&&ne.some(be=>be.id===G.current)?G.current:ne[0].id;p(ne),y(he),G.current=he;return}const $=Is(),J=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(J);const Te={id:$,title:"Terminal",payload:{kind:"terminal",terminalId:J,title:"Terminal"}};z.current=[Te],p([Te]),y(Te.id),G.current=Te.id;return}if(l("browser"),n(!0),c.length>0)return;if(V.current.length>0){const $=V.current,J=X.current&&$.some(Te=>Te.id===X.current)?X.current:$[0].id;d($),g(J),X.current=J;return}const _e=Is(),Ee=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,oe={id:_e,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ee}};V.current=[oe],d([oe]),g(oe.id),X.current=oe.id},[c.length,m.length,Ce]),fe=k.useCallback(ve=>{const _e=Zl(ve),Ee=Is();if(eK(ve)){ve.kind==="terminal"&&wi(ve.terminalId),l("terminal"),Ce();const $=te.current,J=$.find(he=>Zl(he.payload)===_e)??z.current.find(he=>Zl(he.payload)===_e);let Te,ne;if(J)ne=J.id,Te=$.some(he=>he.id===J.id)?$:wd([J,...$]);else{const he={id:Ee,title:J2(ve),payload:ve};Te=wd([he,...$]),ne=Ee}z.current=Te,te.current=Te,p(Te),y(ne),G.current=ne,Z.current=ne}else{l("browser");const $=q.current,J=$.find(he=>Zl(he.payload)===_e)??V.current.find(he=>Zl(he.payload)===_e);let Te,ne;if(J)ne=J.id,Te=$.some(he=>he.id===J.id)?$:wd([J,...$]);else{const he={id:Ee,title:J2(ve),payload:ve};Te=wd([he,...$]),ne=Ee}V.current=Te,q.current=Te,d(Te),g(ne),X.current=ne,ae.current=ne}n(!0)},[Ce]),I=k.useCallback(ve=>{const _e=q.current,Ee=_e.findIndex(ge=>ge.id===ve);if(Ee>=0){const ge=_e[Ee]?.payload,Se=_e.filter(R=>R.id!==ve),st=ae.current,Je=(_e.some(R=>R.id===st)?st:_e[0]?.id??null)===ve||Se.length===0?Se[Math.min(Ee,Se.length-1)]?.id??null:void 0;V.current=Se,q.current=Se,d(Se),Se.length===0&&U.current==="browser"&&C(!1),Je!==void 0&&(g(Je),X.current=Je,ae.current=Je),Wh(ge);return}const oe=te.current,$=oe.findIndex(ge=>ge.id===ve);if($<0)return;const J=oe[$]?.payload,Te=oe.filter(ge=>ge.id!==ve),ne=Z.current,be=(oe.some(ge=>ge.id===ne)?ne:oe[0]?.id??null)===ve||Te.length===0?Te[Math.min($,Te.length-1)]?.id??null:void 0;z.current=Te,te.current=Te,p(Te),Te.length===0&&U.current==="terminal"&&C(!1),be!==void 0&&(y(be),G.current=be,Z.current=be),Yh(J)},[]),Re=k.useCallback(()=>{const ve=q.current.map(Ee=>Ee.payload),_e=te.current.map(Ee=>Ee.payload);q.current=[],te.current=[],V.current=[],X.current=null,z.current=[],G.current=null,ae.current=null,Z.current=null,d([]),p([]),g(null),y(null),C(!1);for(const Ee of ve)Wh(Ee);for(const Ee of _e)Yh(Ee)},[]),Be=k.useCallback(ve=>{U.current==="terminal"?(y(ve),G.current=ve):(g(ve),X.current=ve)},[]),Pe=k.useCallback((ve,_e)=>{d(Ee=>{let oe=!1;const $=Ee.map(J=>{if(J.payload.kind!=="url"||J.payload.browserId!==ve)return J;const Te=_e.url??J.payload.url,ne=_e.title||J.payload.title||Te,he=_e.pageId??J.payload.pageId;return Te===J.payload.url&&ne===(J.payload.title||J.title)&&he===J.payload.pageId&&ne===J.title?J:(oe=!0,{...J,title:ne,payload:{...J.payload,url:Te,title:ne,...he!=null?{pageId:he}:{}}})});return oe&&(V.current=$),oe?$:Ee})},[]),Fe=k.useCallback((ve,_e)=>{p(Ee=>{let oe=!1;const $=Ee.map(J=>{if(J.payload.kind!=="terminal"||J.payload.terminalId!==ve)return J;const Te=_e.title||J.payload.title||J.title,ne=_e.cwd??J.payload.cwd;return Te===J.title&&ne===J.payload.cwd&&Te===(J.payload.title||J.title)?J:(oe=!0,{...J,title:Te,payload:{...J.payload,title:Te,...ne!=null?{cwd:ne}:{}}})});return oe&&(z.current=$),oe?$:Ee})},[]),dt=k.useCallback(()=>{U.current==="terminal"?(p(ve=>ve.length===0?ve:(z.current=ve,Z.current&&(G.current=Z.current),[])),y(null)):(d(ve=>ve.length===0?ve:(V.current=ve,ae.current&&(X.current=ae.current),[])),g(null),Ce()),C(!1)},[Ce]),mt=k.useCallback(()=>{if(U.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(V.current.length>0){const he=V.current,be=X.current&&he.some(ge=>ge.id===X.current)?X.current:he[0].id;d(he),g(be),X.current=be,n(!0);return}const J=Is(),Te=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,ne={id:J,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Te}};V.current=[ne],d([ne]),g(ne.id),X.current=ne.id,n(!0);return}const ve=Is(),_e=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Ee,oe=!1,$=!1;l("browser"),d(J=>{if(J.length>0)return V.current=J,ae.current&&(X.current=ae.current),$=!0,Ee=null,[];if(V.current.length>0){oe=!0;const ne=V.current;return Ee=X.current&&ne.some(be=>be.id===X.current)?X.current:ne[0].id,ne}oe=!0;const Te={id:ve,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:_e}};return V.current=[Te],Ee=Te.id,[Te]}),oe&&n(!0),$?(g(null),C(!1),Ce()):Ee!=null&&(g(Ee),X.current=Ee)},[c.length,m.length,Ce]),Nt=k.useCallback(()=>{if(U.current==="browser"&&c.length>0){if(l("terminal"),Ce(),m.length>0){n(!0);return}if(z.current.length>0){const he=z.current,be=G.current&&he.some(ge=>ge.id===G.current)?G.current:he[0].id;p(he),y(be),G.current=be,n(!0);return}const J=Is(),Te=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(Te);const ne={id:J,title:"Terminal",payload:{kind:"terminal",terminalId:Te,title:"Terminal"}};z.current=[ne],p([ne]),y(ne.id),G.current=ne.id,n(!0);return}const ve=Is(),_e=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(_e);let Ee,oe=!1,$=!1;l("terminal"),Ce(),p(J=>{if(J.length>0)return z.current=J,Z.current&&(G.current=Z.current),$=!0,Ee=null,[];if(z.current.length>0){oe=!0;const ne=z.current;return Ee=G.current&&ne.some(be=>be.id===G.current)?G.current:ne[0].id,ne}oe=!0;const Te={id:ve,title:"Terminal",payload:{kind:"terminal",terminalId:_e,title:"Terminal"}};return z.current=[Te],Ee=Te.id,[Te]}),oe&&n(!0),$?(y(null),C(!1)):Ee!=null&&(y(Ee),G.current=Ee)},[c.length,m.length,Ce]),Ot=k.useCallback(ve=>{const _e=U.current==="terminal"?m:c;if(_e.length<2)return;const Ee=U.current==="terminal"?Z.current:ae.current,$=(Math.max(0,_e.findIndex(Te=>Te.id===Ee))+ve+_e.length)%_e.length,J=_e[$].id;U.current==="terminal"?(y(J),G.current=J):(g(J),X.current=J)},[c,m]),At=k.useCallback(ve=>{const Ee=(U.current==="terminal"?m:c)[ve];Ee&&(U.current==="terminal"?(y(Ee.id),G.current=Ee.id):(g(Ee.id),X.current=Ee.id))},[c,m]),qt=k.useCallback(()=>{if(U.current==="terminal"){const _e=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;fe({kind:"terminal",terminalId:_e,title:"Terminal"});return}const ve=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;fe({kind:"url",url:"about:blank",title:"New Tab",browserId:ve})},[fe]),jt=k.useCallback(ve=>{const _e=te.current,Ee=_e.findIndex(he=>he.payload.kind==="terminal"&&he.payload.terminalId===ve);if(Ee<0){Kh(ve),window.markusDesktop?.terminal?.destroy(ve);return}const oe=_e[Ee];if(_e.length>1){I(oe.id);return}Kh(ve),window.markusDesktop?.terminal?.destroy(ve);const $=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi($);const J=oe.payload.kind==="terminal"&&(oe.payload.title||oe.title)||"Terminal",Te=oe.payload.kind==="terminal"?oe.payload.cwd:void 0,ne={id:oe.id,title:J,payload:{kind:"terminal",terminalId:$,title:J,cwd:Te}};z.current=[ne],p([ne]),y(ne.id),G.current=ne.id,U.current!=="terminal"&&l("terminal")},[I]),$e=k.useCallback(ve=>C(ve),[]),ut=k.useCallback(()=>C(ve=>!ve),[]),kt=o==="terminal"?m:c,xt=o==="terminal"?x:h,Ct=kt.find(ve=>ve.id===xt)??kt[0]??null,ce=Ct?.payload??null,rt=kt.length>0,at=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:Q,toggleLeftCollapsed:me,keyboardPane:_,setKeyboardPane:L,l0FocusPageId:O,setL0FocusPageId:F,rightPanelMode:o,setRightPanelMode:H,switchRightPanelMode:W,rightPanel:ce,rightPanelOpen:rt,rightPanelTabs:kt,activeRightPanelTabId:Ct?.id??null,openRightPanel:fe,closeRightPanel:Re,closeRightPanelTab:I,setActiveRightPanelTab:Be,updateRightPanelBrowserTab:Pe,updateRightPanelTerminalTab:Fe,toggleRightPanel:mt,toggleTerminalPanel:Nt,collapseRightPanelOnly:dt,cycleRightPanelTab:Ot,activateRightPanelTabAt:At,openNewRightPanelTab:qt,handleTerminalExit:jt,rightPanelFullscreen:w,setRightPanelFullscreen:$e,toggleRightPanelFullscreen:ut,hostAvailable:T,setHostAvailable:S}),[t,Q,me,_,L,O,F,o,H,W,ce,rt,kt,Ct,fe,Re,I,Be,Pe,Fe,mt,Nt,dt,Ot,At,qt,jt,w,$e,ut,T]);return s.jsx(v3.Provider,{value:at,children:e})}function Oc(){return k.useContext(v3)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>H3),void 0).then(e=>({default:e.MarkdownMessage})));const iK=k.lazy(()=>qr(()=>import("./ContentRenderer-DgRLJ_sK.js"),[]).then(e=>({default:e.ContentRenderer})));let No=[],e4=60;function oK(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++e4);return k.useEffect(()=>{const r=()=>t.current();No.push(r);const o=l=>{l.key==="Escape"&&No[No.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),No=No.filter(l=>l!==r),No.length===0&&(e4=60)}},[]),n}const t4=500,$s=new Map,b0=new Set,qd=new Map;let Gd=null;function lK(){if($s.size<=t4)return;const e=$s.size-t4,t=$s.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;$s.delete(r)}}function n4(e,t){$s.delete(e),$s.set(e,t),lK()}function r4(e){const t=qd.get(e);if(t)for(const n of t)n()}function cK(){Gd=null;const e=[...b0];b0.clear(),e.length!==0&&Me.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))n4(n,r),r4(n)}).catch(()=>{for(const t of e)n4(t,{exists:!1,isFile:!1,type:"unknown"}),r4(t)})}function uK(e){$s.has(e)||b0.has(e)||(b0.add(e),Gd&&clearTimeout(Gd),Gd=setTimeout(cK,30))}function dK(e,t){let n=qd.get(e);return n||(n=new Set,qd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&qd.delete(e)}}function mK(e){const t=k.useCallback(o=>dK(e,o),[e]),n=k.useCallback(()=>$s.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{uK(e)},[e]),r}const fK=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function pK(e){return e.length<2||e.length>500?!1:fK.test(e)}function hK({filePath:e,onClose:t}){const n=oK(t),[r,o]=k.useState(!0),[l,c]=k.useState(null),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[C,T]=k.useState("");k.useEffect(()=>{o(!0),c(null),Me.files.preview(e).then(_=>{m(typeof _.content=="string"?_.content:""),h(_.type),x(_.name),w(_.mimeType||""),T(_.streamUrl||(_.path?Me.files.streamUrl(_.path):"")||(_.type==="audio"||_.type==="video"?Me.files.streamUrl(e):""))}).catch(_=>{c(String(_?.message||_))}).finally(()=>{o(!1)})},[e]);const S=g||e.split(/[/\\]/).pop()||e;return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:_=>_.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:S}),s.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Me.files.reveal(e),title:"Reveal in file explorer",children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{d:"M4.5 17a2.5 2.5 0 01-2.5-2.5v-9A2.5 2.5 0 014.5 3h3.672a1.5 1.5 0 011.06.44L10.56 4.77a.5.5 0 00.354.147H15.5A2.5 2.5 0 0118 7.417v7.083A2.5 2.5 0 0115.5 17h-11z"})})}),s.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[r&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),l&&s.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[s.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:l})]}),!r&&!l&&p==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${y||"image/png"};base64,${d}`,alt:S,className:"max-w-full rounded"})}),!r&&!l&&p==="audio"&&C&&s.jsx("audio",{controls:!0,preload:"metadata",src:C,className:"w-full"}),!r&&!l&&p==="video"&&C&&s.jsx("video",{controls:!0,preload:"metadata",src:C,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(p==="binary"||!d&&p!=="image"&&p!=="audio"&&p!=="video")&&s.jsxs("div",{className:"text-center py-8 space-y-3",children:[s.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),s.jsx("button",{className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",onClick:()=>{Me.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&p!=="image"&&p!=="audio"&&p!=="video"&&p!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(iK,{content:d,format:p==="text"?"text":p,className:"text-sm"})})]})]})}),document.body)}function gK({path:e}){const t=mK(e),[n,r]=k.useState(null),o=Oc(),l=t?.exists??!1,c=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Me.files.reveal(e)},[l,c,e,o]),m="inline w-3 h-3 align-[-0.125em]",p=c?s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}):s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})});return t?l?s.jsxs(s.Fragment,{children:[s.jsxs("code",{className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:d,title:c?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[p,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(hK,{filePath:n,onClose:()=>r(null)})]}):s.jsx("code",{className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:"File not found",children:e}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let Qp=null;function bK(){return Qp||(Qp=qr(()=>import("./mermaid.core-ldKpNPpw.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Qp}function xK(){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 yK(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 vK(){return xK()}function wK(){return k.useSyncExternalStore(yK,vK)}function w3({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),c=k.useId(),d=k.useRef(0),m=k.useRef(null),p=wK();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===p)return;let h=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await bK();if(h)return;g.default.initialize({startOnLoad:!1,theme:p?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const x=`mermaid-${c.replace(/:/g,"")}-${d.current}`,{svg:y}=await g.default.render(x,e.trim());if(h)return;t.current&&(t.current.innerHTML=y,m.current={code:e,dark:p})}catch(g){h||r(g instanceof Error?g.message:String(g))}finally{h||l(!1)}})(),()=>{h=!0}},[e,c,p]),n?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[o&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),s.jsx("div",{ref:t,className:`flex justify-center [&>svg]:max-w-full${o?" hidden":""}`})]})}const kK="/assets/viz-global-C_AyN6D9.js";let kd=!1,Zp=null;function SK(){return kd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(kd=!0,e()):(n.addEventListener("load",()=>{kd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const r=document.createElement("script");r.setAttribute("data-plantuml-viz",""),r.src=kK,r.onload=()=>{kd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function NK(){return Zp||(Zp=SK().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),Zp}let a4=Promise.resolve();function CK(e,t){const n=a4.then(()=>new Promise((r,o)=>{NK().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,r,o,{dark:t})}).catch(o)}));return a4=n.then(()=>{},()=>{}),n}function TK(){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 AK(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 EK(){return k.useSyncExternalStore(AK,()=>TK())}function k3({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,c]=k.useState(!0),d=k.useRef(null),m=EK();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let p=!1;return c(!0),o(null),CK(e.trim(),m).then(h=>{p||(n(h),d.current={code:e,dark:m})}).catch(h=>{p||o(h instanceof Error?h.message:String(h))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[e,m]),r?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t&&s.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`,dangerouslySetInnerHTML:{__html:t}})]})}function _K(e,t,n){const r=e.cloneNode(!0),o=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",c=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},d=t==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},m={p:`margin:0 0 10px;color:${d.text};line-height:1.7;`,h1:`font-size:${c.h1}em;font-weight:700;color:${d.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${d.border};padding-bottom:6px;`,h2:`font-size:${c.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.h4}em;font-weight:600;color:${d.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${d.strong};`,em:"font-style:italic;",a:`color:${d.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${d.text};`,blockquote:`border-left:3px solid ${d.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${d.blockquoteText};`,hr:`border:none;border-top:1px solid ${d.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${d.tableHeaderBg};`,th:`border:1px solid ${d.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${d.tableHeaderText};`,td:`border:1px solid ${d.tableBorder};padding:8px 12px;color:${d.text};`,img:"max-width:100%;height:auto;"};function p(h){h.removeAttribute("class");const g=h.tagName.toLowerCase();if(g==="pre"){h.setAttribute("style",`background:${d.preBg};color:${d.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${d.preBorder};`);const x=h.querySelector("code");x&&(x.removeAttribute("class"),x.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}g==="code"?h.setAttribute("style",`background:${d.codeBg};color:${d.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[g]&&h.setAttribute("style",m[g]),Array.from(h.children).forEach(p)}return r.removeAttribute("class"),Array.from(r.children).forEach(h=>p(h)),`<div style="background:${d.bg};color:${d.text};padding:20px 24px;font-family:${o};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function Vg(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}async function jK(e,t,n,r){const o=_K(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Vg(n),method:"text"}}}function Xh({code:e,language:t,children:n}){const{t:r}=ft("common"),[o,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await Vg(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return s.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),r("markdown.viewRendered")]})}),s.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),r("markdown.viewSource")]})})]})]}),o==="rendered"?s.jsx("div",{children:n}):s.jsxs("div",{className:"relative group/source",children:[s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary bg-surface-secondary leading-relaxed whitespace-pre-wrap break-words",children:e}),s.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:r("markdown.copyContent"),children:c?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}function Jl(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,o="";for(const l of e.matchAll(n))o+=t(e.slice(r,l.index)),o+=l[0],r=l.index+l[0].length;return o+=t(e.slice(r)),o}function MK(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const Sd="#mention:";function RK(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,d)=>{const m=c??d;return`[@${m}](${Sd}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.length-l.length);let r="",o=0;for(;o<e.length;){const l=e.indexOf("@",o);if(l<0){r+=e.slice(o);break}if(r+=e.slice(o,l),e[l+1]==="["){const h=e.indexOf("]",l+2);if(h>l+2){const g=e.slice(l+2,h);r+=`[@${g}](${Sd}${encodeURIComponent(g)})`,o=h+1;continue}}const c=e.slice(l+1),d=c.toLowerCase(),m=n.find(h=>d.startsWith(h.toLowerCase()));if(m){const h=c.slice(0,m.length);r+=`[@${h}](${Sd}${encodeURIComponent(h)})`,o=l+1+m.length;continue}const p=c.match(/^([\w\p{L}\p{N}]+)/u);if(p){const h=p[1];r+=`[@${h}](${Sd}${encodeURIComponent(h)})`,o=l+1+h.length;continue}r+="@",o=l+1}return r}const S3="#entity:",OK=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),LK=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function DK(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function IK(e){return e.replace(LK,(t,n,r)=>`[${n}](${S3}${r})`)}function PK(e){return e.replace(OK,(t,n,r)=>DK(e,r)?t:`[${t}](${S3}${t})`)}function zK(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const BK=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function $K(e){return BK.test(e.trim())}const HK={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",tsx:"TSX",jsx:"JSX",py:"Python",python:"Python",rb:"Ruby",ruby:"Ruby",rs:"Rust",rust:"Rust",go:"Go",java:"Java",kotlin:"Kotlin",swift:"Swift",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",sql:"SQL",sh:"Shell",bash:"Bash",zsh:"Zsh",shell:"Shell",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",toml:"TOML",ini:"INI",md:"Markdown",markdown:"Markdown",dockerfile:"Dockerfile",docker:"Dockerfile",graphql:"GraphQL",gql:"GraphQL",lua:"Lua",perl:"Perl",r:"R",scala:"Scala",elixir:"Elixir",erlang:"Erlang",haskell:"Haskell",clojure:"Clojure",dart:"Dart",zig:"Zig",nim:"Nim",powershell:"PowerShell",ps1:"PowerShell",vue:"Vue",svelte:"Svelte",plaintext:"Text",text:"Text",txt:"Text"};function UK(e){return HK[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function FK(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const qK=[w3,k3];function GK(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return FK(n)}return null}function lc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(lc).join("");if(k.isValidElement(e)){const t=e.props;return lc(t.children)}return""}function KK({children:e}){const{t}=ft("common"),n=GK(e),r=k.useRef(null),[o,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=lc(e):h=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(h),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(k.Children.toArray(e).some(h=>k.isValidElement(h)&&qK.includes(h.type))){const h=lc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Xh,{code:h,language:g,children:e})}return n==="mermaid"||n==="plantuml"?s.jsx(s.Fragment,{children:e}):s.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:UK(n)}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>d("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),s.jsx("button",{onClick:()=>d("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),s.jsxs("div",{className:"relative",children:[c==="rendered"?s.jsx("pre",{ref:r,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,h=>k.isValidElement(h)?k.cloneElement(h,{style:{background:"transparent",padding:0}}):h)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:lc(e)}),s.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:t("markdown.copyContent"),children:o?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const N3=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,C3=/^\.{1,2}\//,VK=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,T3=/^[A-Za-z]:[\\/]/,A3=/^\\\\[^\\]/;function E3(e){const t=e.trim();return t?!!(/^file:/i.test(t)||T3.test(t)||A3.test(t)||t.startsWith("~/")||t.startsWith("/")||C3.test(t)):!1}function Wg(e){let t=e.trim();if(/^file:/i.test(t)){try{t=decodeURIComponent(t.replace(/^file:\/\//i,""))}catch{t=t.replace(/^file:\/\//i,"")}/^\/[A-Za-z]:\//.test(t)&&(t=t.slice(1))}return t=t.replace(/\\+/g,"/"),t}function WK(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,r,o)=>`${n}${r.replace(/\\+/g,"/")}${o}`)}function _3(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Nd(e,t){if(!e)return e;if(N3.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const r=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,o=r.split("/"),l=[];for(const d of o)!d||d==="."||(d===".."?l.pop():l.push(d));const c=l.join("/");return r.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function s4(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function i4(e,t){if(!e)return{kind:"passthrough"};const n=e.trim();if(!n||n==="#")return{kind:"passthrough"};if(n.startsWith("#")&&!n.startsWith("#mention:")&&!n.startsWith("#entity:"))return{kind:"fragment",id:decodeURIComponent(n.slice(1))};if(T3.test(n)||A3.test(n)){const{path:l,fragment:c}=s4(n);return{kind:"file",path:Nd(l,t),fragment:c}}if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n))return/^https?:\/\//i.test(n)||/^mailto:/i.test(n)?{kind:"external",url:n}:/^file:\/\//i.test(n)?{kind:"file",path:Wg(n)}:{kind:"passthrough"};const{path:r,fragment:o}=s4(n);return N3.test(r)?{kind:"file",path:Nd(r,t),fragment:o}:C3.test(r)?{kind:"file",path:Nd(r,t),fragment:o}:r&&VK.test(r)&&!r.includes("://")?{kind:"file",path:Nd(r,t),fragment:o}:{kind:"passthrough"}}function YK(e,t){if(!e||!t)return!1;let n=null;try{n=e.querySelector(`#${CSS.escape(t)}`)}catch{n=null}if(n||(n=e.querySelector(`[id="${t.replace(/"/g,'\\"')}"]`)),!n){const r=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const o of r)if(_3(o.textContent||"")===t||o.id===t){n=o;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function j3(e){return e.type==="text"?e.value??"":(e.children??[]).map(j3).join("")}function XK(){return e=>{const t=new Map,n=r=>{if(r.type==="element"&&r.tagName&&/^h[1-6]$/.test(r.tagName)){const o=j3(r).trim();let l=_3(o);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),r.properties={...r.properties??{},id:l}}}for(const o of r.children??[])n(o)};n(e)}}const M3="markus-copy-typography",o4={fontFamily:"default",fontSize:15,headingScale:"standard"};function R3(){try{const e=localStorage.getItem(M3);if(e)return{...o4,...JSON.parse(e)}}catch{}return o4}function QK(e){localStorage.setItem(M3,JSON.stringify(e))}function ZK(e){const t={default:"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif",serif:"Georgia, 'Times New Roman', Times, serif","sans-serif":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif",mono:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"},n={compact:{h1:1.3,h2:1.15,h3:1.05,h4:1},standard:{h1:1.6,h2:1.35,h3:1.15,h4:1},large:{h1:2,h2:1.6,h3:1.3,h4:1.1}};return{fontFamily:t[e.fontFamily]??t.default,fontSize:`${e.fontSize}px`,headingScales:n[e.headingScale]??n.standard}}function JK({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(R3);k.useEffect(()=>{QK(n)},[n]);const o=k.useCallback((l,c)=>{r(d=>({...d,[l]:c}))},[]);return s.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:t("markdown.typographySettings")}),s.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("markdown.typographyDesc")}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.fontFamily")}),s.jsxs("select",{value:n.fontFamily,onChange:l=>o("fontFamily",l.target.value),className:"w-full px-2 py-1 text-xs rounded bg-surface-primary border border-border-subtle text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50",children:[s.jsx("option",{value:"default",children:t("markdown.fontDefault")}),s.jsx("option",{value:"serif",children:t("markdown.fontSerif")}),s.jsx("option",{value:"sans-serif",children:t("markdown.fontSansSerif")}),s.jsx("option",{value:"mono",children:t("markdown.fontMono")})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[t("markdown.fontSize"),": ",n.fontSize,"px"]}),s.jsx("input",{type:"range",min:10,max:24,step:1,value:n.fontSize,onChange:l=>o("fontSize",Number(l.target.value)),className:"w-full h-1 rounded-full appearance-none bg-border-subtle [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-brand-500"}),s.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[s.jsx("span",{children:"10px"}),s.jsx("span",{children:"24px"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.headingScale")}),s.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(l=>s.jsx("button",{onClick:()=>o("headingScale",l),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${n.headingScale===l?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:t(`markdown.scale${l.charAt(0).toUpperCase()+l.slice(1)}`)},l))})]})]})}const eV=k.lazy(()=>qr(()=>Promise.resolve().then(()=>H3),void 0).then(e=>({default:e.MarkdownMessage}))),tV={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},l4={active:{color:"text-green-600 bg-green-500/10"},verified:{color:"text-blue-600 bg-blue-500/10"},outdated:{color:"text-fg-tertiary bg-surface-elevated/50"}};function nV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=tV[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=l4[e.status]??l4.active,c=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),s.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-start gap-3 rounded-t-2xl z-10",children:[s.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${o.color}`,children:o.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),s.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.summary")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(k.Suspense,{fallback:s.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:s.jsx(eV,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.reference")}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),c?s.jsx("button",{onClick:()=>window.open(e.reference,"_blank","noopener,noreferrer"),className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")}):s.jsx("button",{onClick:()=>{Me.files.reveal(e.reference).catch(()=>{})},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")})]})]}),e.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),s.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),s.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),s.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&s.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&s.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>s.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),s.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[s.jsxs("span",{children:[r("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),s.jsxs("span",{children:[r("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&s.jsx("span",{children:r("agent:deliverables.accessed",{count:e.accessCount})})]})]}),s.jsxs("div",{className:"sticky bottom-0 bg-surface-primary/95 backdrop-blur-sm border-t border-border-default px-5 py-3 flex items-center justify-end gap-2 rounded-b-2xl",children:[s.jsxs("button",{onClick:()=>n(e.id),className:"px-3 py-1.5 text-xs font-medium text-brand-500 hover:bg-brand-500/10 rounded-lg transition-colors flex items-center gap-1.5",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),r("agent:deliverables.openInPage")]}),s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs font-medium text-fg-secondary bg-surface-elevated hover:bg-surface-overlay rounded-lg transition-colors",children:r("common:close")})]})]})]});return typeof document<"u"?Sa.createPortal(d,document.body):d}const rV={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function O3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const L3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},D3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},aV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function x0(e){return aV.test(e.trim())}function sV(e){const t=e.split("_")[0]?.toLowerCase();return t?rV[t]:void 0}function I3(e){e.startsWith("tsk_")?it.navigate(ue.WORK,{openTask:e}):e.startsWith("req_")?it.navigate(ue.WORK,{openRequirement:e}):e.startsWith("proj_")?it.navigate(ue.WORK,{projectId:e}):e.startsWith("dlv_")?it.navigate(ue.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?it.navigate(ue.TEAM,{agentId:e}):e.startsWith("team_")&&it.navigate(ue.TEAM,{selectTeam:e})}const Jp=new Map,Cd=new Map;async function iV(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Me.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Me.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Me.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Me.deliverables.get(e);return{...n,title:r.deliverable.title,status:r.deliverable.status,summary:r.deliverable.summary,deliverable:r.deliverable}}case"agent":{const r=await Me.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Me.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function P3(e,t){const n=t??sV(e),[r,o]=k.useState(()=>Jp.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){o({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Jp.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let c=!0,d=Cd.get(e);return d||(d=iV(e,n),Cd.set(e,d)),d.then(m=>{Jp.set(e,m),Cd.delete(e),c&&o(m)}).catch(()=>{Cd.delete(e),c&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{c=!1}},[e,n]),r}function z3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function cc({id:e,type:t,label:n}){const r=P3(e,t),o=Oc(),l=L3[r.type]??"🔗",c=n??(r.loading||r.notFound?z3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&o?.hostAvailable){o.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}I3(e)};return s.jsxs("span",{"data-entity-link":e,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors align-baseline",onClick:d,title:`${D3[r.type]}: ${r.notFound?e:r.title} (${e})`,children:[s.jsx("span",{className:"text-[10px]",children:l}),s.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:c})]})}function oV({id:e,type:t,label:n}){const r=P3(e,t),[o,l]=k.useState(!1),c=Oc(),d=L3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(c?.hostAvailable){c.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}I3(e)},p=r.loading?z3(e):n||(r.notFound?e:r.title);return s.jsxs("span",{className:"not-prose block my-2",children:[s.jsxs("button",{type:"button",onClick:m,className:"w-full max-w-md text-left rounded-xl border border-border-default bg-surface-elevated/30 hover:border-brand-500/40 hover:bg-surface-elevated/50 transition-colors px-3 py-2.5 flex items-start gap-2.5",children:[s.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:d}),s.jsxs("span",{className:"flex-1 min-w-0 block",children:[s.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:D3[r.type]}),r.status&&s.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded font-medium bg-brand-500/10 text-brand-500",children:r.status})]}),s.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${r.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:p}),r.summary&&r.summary.trim()!==r.title.trim()&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:r.summary})]}),s.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),o&&r.deliverable&&s.jsx(nV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),it.navigate(ue.DELIVERABLES,{openDeliverable:h})}})]})}class lV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!cV(t.resetKeys,this.props.resetKeys)&&this.setState({error:null})}componentDidCatch(t,n){this.props.onError?.(t,n),console.error("[ErrorBoundary] caught render error:",t,n.componentStack)}reset=()=>this.setState({error:null});render(){const{error:t}=this.state;if(t){const{fallback:n}=this.props;return typeof n=="function"?n(t,this.reset):n??null}return this.props.children}}function cV(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 uV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function c4(e){return uV.test(e)||E3(e)?e:x5(e)}const u4=[q5,UF,Kk],d4=[XK,[wq,{strict:"ignore"}],[x3,{detect:!0,ignoreMissing:!0}]],Qh="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer",dV=/<think>([\s\S]*?)(<\/think>|$)/g;function mV(e){const t=[];let n=e.replace(dV,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:t,rest:n.trim()}}const m4="#mention:",y0="#entity:",fV=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,B3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Zh(e){return e.type==="text"?e.value??"":(e.children??[]).map(Zh).join("")}function pV(e){return e.type==="text"&&(e.value??"").trim()===""}function hV(e){if(!e?.children)return null;const t=e.children.filter(r=>!pV(r));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const r=n.properties?.href;if(!r)return null;const o=Zh(n);if(r.startsWith(y0))return{id:r.slice(y0.length)};const l=r.match(B3);return l&&l[1]!=="workflow"?{id:l[2],type:O3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Zh(n).trim();if(x0(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(x0(r))return{id:r}}return null}const gV={p:({children:e})=>s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>s.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>s.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>s.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>s.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>s.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>s.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>s.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>s.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>s.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),r=n.trim();if(t?.includes("language-plantuml")||zK(r))return s.jsx(Xh,{code:r,language:"plantuml",children:s.jsx(k3,{code:r})});if(t?.includes("language-mermaid")||!t&&$K(r))return s.jsx(Xh,{code:r,language:"mermaid",children:s.jsx(w3,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(x0(n))return s.jsx(cc,{id:n.trim()});const o=n.match(fV);return o?s.jsx(cc,{id:o[2],label:o[1]}):pK(n)?s.jsx(gK,{path:n}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e})},pre:({children:e})=>s.jsx(KK,{children:e}),strong:({children:e})=>s.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>s.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>s.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>s.jsx("a",{href:e,className:Qh,children:t}),hr:()=>s.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>s.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>s.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>s.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>s.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold text-fg-primary border border-border-default",children:e}),td:({children:e})=>s.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},bV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function xV(e){const t=Wg(e);return E3(e)&&bV.test(t.split("?")[0]??t)}function yV(e,t){const n=Wg(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const o=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of o)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function vV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const Co=new Map;function wV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>xV(e)?vV(yV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),c=Co.get(o),[d,m]=k.useState(c??(l?null:o)),[p,h]=k.useState(!!c),[g,x]=k.useState(!1),[y,w]=k.useState(null),[C,T]=k.useState(0),S=k.useRef(0),_=k.useCallback(()=>{Co.delete(o),x(!1),w(null),h(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(j=>j+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const j=Co.get(o);if(j){m(j),h(!0),x(!1),w(null);return}const O=++S.current;x(!1),w(null),h(!1),m(null),(async()=>{try{const P=await fetch(o,{credentials:"same-origin"});if(O!==S.current)return;if(!P.ok){let V=`HTTP ${P.status}`;try{const X=await P.json();X.error&&(V=X.error)}catch{}throw new Error(V)}const L=await P.blob();if(O!==S.current)return;if(L.size===0)throw new Error("Empty image response");if(L.type&&!L.type.startsWith("image/")&&!L.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${L.type}`);const F=URL.createObjectURL(L);Co.set(o,F),m(F),h(!0),x(!1),w(null)}catch(P){if(O!==S.current)return;const L=P instanceof Error?P.message:String(P);console.warn("[MarkdownImage] failed to load local image",o,P),w(L),x(!0),h(!1)}})()},[l,o,C]),k.useEffect(()=>{l||(m(o),h(!!Co.get(o)),x(!1),w(null))},[o,l,C]),g?s.jsxs("button",{type:"button",onClick:_,title:y??"Click to retry",className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[s.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",y?` (${y})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!p&&s.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),d?s.jsx("img",{src:d,alt:t??"",onLoad:()=>{l||Co.set(o,o),h(!0)},onError:()=>{w("Image decode failed"),x(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${p?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function f4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function kV(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const r=n.getContext("2d");if(!r)throw new Error("Canvas unavailable");return r.drawImage(t,0,0),t.close(),new Promise((o,l)=>{n.toBlob(c=>c?o(c):l(new Error("PNG encode failed")),"image/png")})}function SV(e,t){try{const o=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(o&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(o))return decodeURIComponent(o)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function $3({src:e,onClose:t}){const{t:n}=ft("common"),[r,o]=k.useState(null),[l,c]=k.useState(null);Ho(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{o(g),window.setTimeout(()=>o(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const x=await f4(e),y=await kV(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{c(null)}}},[l,d,e,n]),p=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const x=await f4(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=SV(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{c(null)}}},[l,d,e,n]),h="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/10 hover:bg-white/20 text-white text-sm transition-colors disabled:opacity-50";return Sa.createPortal(s.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[s.jsxs("button",{type:"button",className:h,onClick:m,disabled:!!l,title:n("copyImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),s.jsxs("button",{type:"button",className:h,onClick:p,disabled:!!l,title:n("downloadImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),s.jsx("button",{type:"button",onClick:t,className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",title:n("close"),children:s.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r&&s.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:r}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function NV(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),o=l=>n(l.matches);return r.addEventListener("change",o),n(r.matches),()=>r.removeEventListener("change",o)},[e]),t}function CV({content:e,contentRef:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[p,h]=k.useState(null),g=k.useRef(null),x=NV();k.useEffect(()=>{if(!r)return;const T=S=>{g.current&&!g.current.contains(S.target)&&(o(!1),c(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const y=k.useCallback(T=>{h(T),setTimeout(()=>h(null),1500)},[]),w=async()=>{const T=await Vg(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},C=async T=>{const S=t.current?.firstElementChild;if(!S)return;const _=R3(),j=ZK(_),O=await jK(S,T,e,{fontFamily:j.fontFamily,fontSize:j.fontSize,headingScales:j.headingScales}),P=n(T==="light"?"markdown.themeLight":"markdown.themeDark");y(O.ok?O.method==="html"?n("markdown.htmlCopied",{theme:P}):n("markdown.textCopied"):n("markdown.failed")),o(!1)};return s.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[p&&s.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 px-2 py-0.5 rounded bg-surface-elevated border border-border-default text-[10px] text-fg-secondary whitespace-nowrap shadow-lg",children:p}),s.jsx("button",{onClick:()=>o(T=>!T),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:n("markdown.copyContent"),children:s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),r&&s.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:d?s.jsx(JK,{onClose:()=>m(!1)}):l?s.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),s.jsx("button",{onClick:()=>c(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),s.jsx("button",{onClick:()=>c(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),s.jsxs("button",{onClick:w,className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.jsxs("button",{onClick:()=>C("light"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.jsxs("button",{onClick:()=>C("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Er=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:c,rest:d}=mV(t),m=k.useRef(null),[p,h]=k.useState(null),g=Oc(),x=k.useCallback(T=>{let S=Jl(T,MK);return S=Jl(S,WK),S=Jl(S,IK),S=Jl(S,PK),S=Jl(S,_=>RK(_,o)),S},[o]),y=k.useMemo(()=>x(d),[d,x]),w=k.useCallback((T,S)=>{const _=i4(S,l);if(_.kind!=="passthrough"){if(T.preventDefault(),T.stopPropagation(),_.kind==="fragment"){YK(m.current,_.id);return}if(_.kind==="file"){g?.hostAvailable?g.openRightPanel({kind:"file",path:_.path,title:_.path.split(/[/\\]/).pop()}):Me.files.reveal(_.path).catch(()=>{});return}if(_.kind==="external"){if(g?.hostAvailable&&/^https?:\/\//i.test(_.url)){g.openRightPanel({kind:"url",url:_.url,title:_.url});return}_i(_.url)}}},[l,g]),C=k.useMemo(()=>({...gV,img:({src:T,alt:S})=>s.jsx(wV,{src:T??"",alt:S,onPreview:h,basePath:l},T??""),p:({children:T,node:S})=>{const _=hV(S);return _?s.jsx(oV,{id:_.id,type:_.type,label:_.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:T})},a:({href:T,children:S})=>{if(T?.startsWith(m4)){const j=decodeURIComponent(T.slice(m4.length));return s.jsx("span",{className:`text-brand-500 font-medium${r?" cursor-pointer hover:underline":""}`,onClick:r?O=>{O.preventDefault(),O.stopPropagation(),r(j,O)}:void 0,title:j,children:S})}if(T?.startsWith(y0))return s.jsx(cc,{id:T.slice(y0.length)});{const j=T?.match(B3);if(j){const[,O,P]=j;if(O==="workflow")return s.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:F=>{F.preventDefault(),F.stopPropagation(),it.navigate(ue.WORK,{boardType:"workflows"})},title:`workflow: ${P}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:S})]});const L=O3(O);if(L)return s.jsx(cc,{id:P,type:L,label:S})}}if(T&&x0(T))return s.jsx(cc,{id:T.trim(),label:S});const _=i4(T,l);return _.kind==="fragment"||_.kind==="file"||_.kind==="external"?s.jsx("a",{href:T,className:Qh,onClick:j=>w(j,T),title:_.kind==="fragment"?`#${_.id}`:_.kind==="file"?_.path:_.url,children:S}):s.jsx("a",{href:T,className:Qh,onClick:j=>{yc()&&T&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(T)&&j.preventDefault()},children:S})}}),[r,l,w]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(CV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(lV,{resetKeys:[y],fallback:s.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:s.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${n}`,children:[c.length>0&&(()=>{const T=c.join(`
|
|
648
|
+
`,1;if(tl>1e5&&tl>ht.index*3)throw new Error("potential infinite loop, way more iterations than matches");return an+=It,It.length}const Yn=ir(Ke);if(!Yn)throw _e(yt.replace("{}",Ke)),new Error('Unknown language: "'+Ke+'"');const Bc=ge(Yn);let Hi="",_t=rn||Bc;const $c={},In=new nt.__emitter(nt);el();let an="",ls=0,Ma=0,tl=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(vt,In);else{for(_t.matcher.considerAll();;){tl++,cs?cs=!1:_t.matcher.considerAll(),_t.matcher.lastIndex=Ma;const et=_t.matcher.exec(vt);if(!et)break;const ht=vt.substring(Ma,et.index),It=$i(ht,et);Ma=et.index+It}$i(vt.substring(Ma))}return In.finalize(),Hi=In.toHTML(),{language:Ke,value:Hi,relevance:ls,illegal:!1,_emitter:In,_top:_t}}catch(et){if(et.message&&et.message.includes("Illegal"))return{language:Ke,value:R(vt),illegal:!0,relevance:0,_illegalBy:{message:et.message,index:Ma,context:vt.slice(Ma-100,Ma+100),mode:et.mode,resultSoFar:Hi},_emitter:In};if(tt)return{language:Ke,value:R(vt),illegal:!1,relevance:0,errorRaised:et,_emitter:In,_top:_t};throw et}}function Di(Ke){const vt={value:R(Ke),illegal:!1,relevance:0,_top:qe,_emitter:new nt.__emitter(nt)};return vt._emitter.addText(Ke),vt}function Ii(Ke,vt){vt=vt||nt.languages||Object.keys(le);const Ht=Di(Ke),rn=vt.filter(ir).filter(is).map(hn=>Ea(hn,Ke,!1));rn.unshift(Ht);const Rn=rn.sort((hn,Rr)=>{if(hn.relevance!==Rr.relevance)return Rr.relevance-hn.relevance;if(hn.language&&Rr.language){if(ir(hn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===hn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(Ke,vt,Ht){const rn=vt&&je[vt]||Ht;Ke.classList.add("hljs"),Ke.classList.add(`language-${rn}`)}function Mn(Ke){let vt=null;const Ht=jn(Ke);if(St(Ht))return;if(Ys("before:highlightElement",{el:Ke,language:Ht}),Ke.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ke);return}if(Ke.children.length>0&&(nt.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Ke)),nt.throwUnescapedHTML))throw new Je("One of your code blocks includes unescaped HTML.",Ke.innerHTML);vt=Ke;const rn=vt.textContent,Rn=Ht?vn(rn,{language:Ht,ignoreIllegals:!0}):Ii(rn);Ke.innerHTML=Rn.value,Ke.dataset.highlighted="yes",ma(Ke,Ht,Rn.language),Ke.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(Ke.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ys("after:highlightElement",{el:Ke,result:Rn,text:rn})}function er(Ke){nt=ie(nt,Ke)}const ss=()=>{Pi(),oe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Qo(){Pi(),oe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Dc=!1;function Pi(){function Ke(){Pi()}if(document.readyState==="loading"){Dc||window.addEventListener("DOMContentLoaded",Ke,!1),Dc=!0;return}document.querySelectorAll(nt.cssSelector).forEach(Mn)}function Ic(Ke,vt){let Ht=null;try{Ht=vt(K)}catch(rn){if(_e("Language definition for '{}' could not be registered.".replace("{}",Ke)),tt)_e(rn);else throw rn;Ht=qe}Ht.name||(Ht.name=Ke),le[Ke]=Ht,Ht.rawDefinition=vt.bind(null,K),Ht.aliases&&_a(Ht.aliases,{languageName:Ke})}function Ws(Ke){delete le[Ke];for(const vt of Object.keys(je))je[vt]===Ke&&delete je[vt]}function Zo(){return Object.keys(le)}function ir(Ke){return Ke=(Ke||"").toLowerCase(),le[Ke]||le[je[Ke]]}function _a(Ke,{languageName:vt}){typeof Ke=="string"&&(Ke=[Ke]),Ke.forEach(Ht=>{je[Ht.toLowerCase()]=vt})}function is(Ke){const vt=ir(Ke);return vt&&!vt.disableAutodetect}function os(Ke){Ke["before:highlightBlock"]&&!Ke["before:highlightElement"]&&(Ke["before:highlightElement"]=vt=>{Ke["before:highlightBlock"](Object.assign({block:vt.el},vt))}),Ke["after:highlightBlock"]&&!Ke["after:highlightElement"]&&(Ke["after:highlightElement"]=vt=>{Ke["after:highlightBlock"](Object.assign({block:vt.el},vt))})}function Dn(Ke){os(Ke),Ue.push(Ke)}function Pc(Ke){const vt=Ue.indexOf(Ke);vt!==-1&&Ue.splice(vt,1)}function Ys(Ke,vt){const Ht=Ke;Ue.forEach(function(rn){rn[Ht]&&rn[Ht](vt)})}function ja(Ke){return oe("10.7.0","highlightBlock will be removed entirely in v12.0"),oe("10.7.0","Please use highlightElement now."),Mn(Ke)}Object.assign(K,{highlight:vn,highlightAuto:Ii,highlightAll:Pi,highlightElement:Mn,highlightBlock:ja,configure:er,initHighlighting:ss,initHighlightingOnLoad:Qo,registerLanguage:Ic,unregisterLanguage:Ws,listLanguages:Zo,getLanguage:ir,registerAliases:_a,autoDetection:is,inherit:ie,addPlugin:Dn,removePlugin:Pc}),K.debugMode=function(){tt=!1},K.safeMode=function(){tt=!0},K.versionString=Ve,K.regex={concat:C,lookahead:x,either:S,optional:w,anyNumberOfTimes:y};for(const Ke in Nt)typeof Nt[Ke]=="object"&&e(Nt[Ke]);return Object.assign(K,Nt),K},Qe=Ge({});return Qe.newInstance=()=>Ge({}),Xp=Qe,Qe.HighlightJS=Qe,Qe.default=Qe,Xp}var qG=FG();const GG=Tc(qG),Z2={},KG="hljs-";function VG(e){const t=GG.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:c,registered:d};function n(m,p,h){const g=h||Z2,x=typeof g.prefix=="string"?g.prefix:KG;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:WG,classPrefix:x});const y=t.highlight(p,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,C=w.data;return C.language=y.language,C.relevance=y.relevance,w}function r(m,p){const g=(p||Z2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const C=g[x];if(!t.getLanguage(C))continue;const T=n(C,m,p);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function l(m,p){if(typeof m=="string")t.registerLanguage(m,p);else{let h;for(h in m)Object.hasOwn(m,h)&&t.registerLanguage(h,m[h])}}function c(m,p){if(typeof m=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:m});else{let h;for(h in m)if(Object.hasOwn(m,h)){const g=m[h];t.registerAliases(typeof g=="string"?g:[...g],{languageName:h})}}}function d(m){return!!t.getLanguage(m)}}class WG{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(c,d){return d?c+"_".repeat(d):n.options.classPrefix+c}),o=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const YG={};function x3(e){const t=e||YG,n=t.aliases,r=t.detect||!1,o=t.languages||UG,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const p=VG(o);if(n&&p.registerAlias(n),c){const h=c.indexOf("-");m=h===-1?c:c.slice(0,h)}return function(h,g){D0(h,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const C=XG(x);if(C===!1||!C&&!r||C&&l&&l.includes(C))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=Qk(x,{whitespace:"pre"});let S;try{S=C?p.highlight(C,T,{prefix:c}):p.highlightAuto(T,{prefix:c,subset:d})}catch(_){const j=_;if(C&&/Unknown language/.test(j.message)){g.message("Cannot highlight as `"+C+"`, it’s not registered",{ancestors:[w,x],cause:j,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw j}!C&&S.data&&S.data.language&&x.properties.className.push("language-"+S.data.language),S.children.length>0&&(x.children=S.children)})}}function XG(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const o=String(t[n]);if(o==="no-highlight"||o==="nohighlight")return!1;!r&&o.slice(0,5)==="lang-"&&(r=o.slice(5)),!r&&o.slice(0,9)==="language-"&&(r=o.slice(9))}return r}const Kg=new Set;function wi(e){e&&Kg.add(e)}function Kh(e){e&&Kg.delete(e)}const y3="markus_right_panel_v1",QG=10,Vh=new Map;function ZG(e,t=3e3){Vh.set(e,Date.now()+t)}function JG(e){const t=Vh.get(e);return t==null?!1:Date.now()>t?(Vh.delete(e),!1):!0}function eK(e){return e.kind==="terminal"}function Zl(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;if(e.kind==="terminal")return`terminal:${e.terminalId}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function J2(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.kind==="terminal"?e.title||"Terminal":e.title||e.path.split(/[/\\]/).pop()||e.path}function Is(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function wd(e){let t=e;for(;t.length>QG;){let n=-1;for(let o=t.length-1;o>=0;o--)if(!t[o].pinned){n=o;break}if(n<0)break;const r=t[n];r&&(Wh(r.payload),Yh(r.payload)),t=t.filter((o,l)=>l!==n)}return t}function Wh(e){e?.kind==="url"&&e.browserId&&(ZG(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function Yh(e){e?.kind==="terminal"&&e.terminalId&&(Kh(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function tK(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?gc(t.url||"")||gc(t.title||"")?null:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"url",url:t.url||"about:blank",title:t.title||e.title}}:t.kind==="file"?{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"file",path:t.path,title:t.title}}:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"deliverable",deliverable:t.deliverable}}}function nK(e,t=0){if(e.payload.kind==="url"){const n=`eb_${Date.now().toString(36)}_${t.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return{...e,payload:{kind:"url",url:e.payload.url||"about:blank",title:e.payload.title||e.title,browserId:n}}}return e}function rK(){try{const e=localStorage.getItem(y3);if(!e)return null;const t=JSON.parse(e);return!t||t.mode!=="browser"&&t.mode!=="terminal"||!Array.isArray(t.browserTabs)?null:t}catch{return null}}function aK(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=rK();if(!t)return e;const n=t.browserTabs.map((y,w)=>{try{return nK(y,w)}catch{return null}}).filter(y=>!(!y||y.payload.kind==="terminal"||y.payload.kind==="url"&&gc(y.payload.url||""))),r=n.some(y=>y.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,o=(t.terminalTabs||[]).map((y,w)=>{const C=`term_${Date.now().toString(36)}_${w.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return wi(C),{id:y.id||Is(),title:y.title||"Terminal",payload:{kind:"terminal",terminalId:C,title:y.title||"Terminal",cwd:y.cwd}}}),l=o.some(y=>y.id===t.terminalActiveId)?t.terminalActiveId:o[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,d=!!t.terminalCollapsed&&o.length>0,m=c?[]:n,p=c?null:r,h=d?[]:o,g=d?null:l;let x=t.mode;return x==="terminal"&&h.length===0&&!d&&(x="browser"),x==="browser"&&m.length===0&&h.length>0&&(x="terminal"),{mode:x,browserTabs:m,browserActiveId:p,terminalTabs:h,terminalActiveId:g,stashedBrowserTabs:n,stashedBrowserActiveId:r,stashedTerminalTabs:o,stashedTerminalActiveId:l}}const v3=k.createContext(null);function sK({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),r=k.useMemo(()=>aK(),[]),[o,l]=k.useState(r.mode),[c,d]=k.useState(r.browserTabs),[m,p]=k.useState(r.terminalTabs),[h,g]=k.useState(r.browserActiveId),[x,y]=k.useState(r.terminalActiveId),[w,C]=k.useState(!1),[T,S]=k.useState(!1),[_,j]=k.useState("l0"),[O,P]=k.useState(null),L=k.useCallback(ve=>j(ve),[]),F=k.useCallback(ve=>P(ve),[]);k.useEffect(()=>{const ve=Ee=>{if(!(Ee instanceof HTMLElement))return!1;const oe=Ee.tagName;return oe==="INPUT"||oe==="TEXTAREA"||oe==="SELECT"?!0:Ee.isContentEditable},_e=Ee=>{if(!(Ee.target instanceof Element))return;const oe=document.activeElement;if(ve(oe)){const Te=oe===Ee.target||oe.contains(Ee.target),ne=!!Ee.target.closest("[data-keep-edit-focus]"),he=ve(Ee.target)||!!Ee.target.closest('input, textarea, select, [contenteditable="true"]'),be=!!Ee.target.closest(".xterm");!Te&&!ne&&!he&&!be&&oe.blur()}const $=Ee.target.closest("[data-keyboard-pane]");if(!$)return;const J=$.getAttribute("data-keyboard-pane");if(!(J!=="l0"&&J!=="l1"&&J!=="l2"&&J!=="content")&&(j(J),J==="l0")){const ne=Ee.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");ne&&P(ne)}};return document.addEventListener("pointerdown",_e,!0),()=>document.removeEventListener("pointerdown",_e,!0)},[]);const V=k.useRef(r.stashedBrowserTabs.length>0?r.stashedBrowserTabs:r.browserTabs),X=k.useRef(r.stashedBrowserActiveId??r.browserActiveId),z=k.useRef(r.stashedTerminalTabs.length>0?r.stashedTerminalTabs:r.terminalTabs),G=k.useRef(r.stashedTerminalActiveId??r.terminalActiveId),ae=k.useRef(r.browserActiveId),Z=k.useRef(r.terminalActiveId),q=k.useRef(r.browserTabs),te=k.useRef(r.terminalTabs),U=k.useRef(r.mode);ae.current=h,Z.current=x,q.current=c,te.current=m,U.current=o,k.useEffect(()=>{(r.mode==="terminal"||r.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),k.useEffect(()=>{const ve=c.length===0&&V.current.length>0,_e=m.length===0&&z.current.length>0,Ee=ve?V.current:c,oe=_e?z.current:m,$=Ee.map(tK).filter(ne=>!!ne),J=oe.filter(ne=>ne.payload.kind==="terminal").map(ne=>({id:ne.id,title:ne.title,cwd:ne.payload.kind==="terminal"?ne.payload.cwd:void 0})),Te={mode:o,browserTabs:$,browserActiveId:ve?X.current:h,terminalTabs:J,terminalActiveId:_e?G.current:x,browserCollapsed:ve,terminalCollapsed:_e};try{localStorage.setItem(y3,JSON.stringify(Te))}catch{}},[o,c,h,m,x]);const Q=k.useCallback(ve=>n(ve),[]),me=k.useCallback(()=>n(ve=>!ve),[]),Ce=k.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),H=k.useCallback(ve=>{l(_e=>_e===ve?_e:(ve==="terminal"&&Ce(),ve))},[Ce]),W=k.useCallback(ve=>{if(ve==="terminal"){if(Ce(),l("terminal"),n(!0),m.length>0)return;if(z.current.length>0){const ne=z.current,he=G.current&&ne.some(be=>be.id===G.current)?G.current:ne[0].id;p(ne),y(he),G.current=he;return}const $=Is(),J=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(J);const Te={id:$,title:"Terminal",payload:{kind:"terminal",terminalId:J,title:"Terminal"}};z.current=[Te],p([Te]),y(Te.id),G.current=Te.id;return}if(l("browser"),n(!0),c.length>0)return;if(V.current.length>0){const $=V.current,J=X.current&&$.some(Te=>Te.id===X.current)?X.current:$[0].id;d($),g(J),X.current=J;return}const _e=Is(),Ee=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,oe={id:_e,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ee}};V.current=[oe],d([oe]),g(oe.id),X.current=oe.id},[c.length,m.length,Ce]),fe=k.useCallback(ve=>{const _e=Zl(ve),Ee=Is();if(eK(ve)){ve.kind==="terminal"&&wi(ve.terminalId),l("terminal"),Ce();const $=te.current,J=$.find(he=>Zl(he.payload)===_e)??z.current.find(he=>Zl(he.payload)===_e);let Te,ne;if(J)ne=J.id,Te=$.some(he=>he.id===J.id)?$:wd([J,...$]);else{const he={id:Ee,title:J2(ve),payload:ve};Te=wd([he,...$]),ne=Ee}z.current=Te,te.current=Te,p(Te),y(ne),G.current=ne,Z.current=ne}else{l("browser");const $=q.current,J=$.find(he=>Zl(he.payload)===_e)??V.current.find(he=>Zl(he.payload)===_e);let Te,ne;if(J)ne=J.id,Te=$.some(he=>he.id===J.id)?$:wd([J,...$]);else{const he={id:Ee,title:J2(ve),payload:ve};Te=wd([he,...$]),ne=Ee}V.current=Te,q.current=Te,d(Te),g(ne),X.current=ne,ae.current=ne}n(!0)},[Ce]),I=k.useCallback(ve=>{const _e=q.current,Ee=_e.findIndex(ge=>ge.id===ve);if(Ee>=0){const ge=_e[Ee]?.payload,Se=_e.filter(R=>R.id!==ve),st=ae.current,Je=(_e.some(R=>R.id===st)?st:_e[0]?.id??null)===ve||Se.length===0?Se[Math.min(Ee,Se.length-1)]?.id??null:void 0;V.current=Se,q.current=Se,d(Se),Se.length===0&&U.current==="browser"&&C(!1),Je!==void 0&&(g(Je),X.current=Je,ae.current=Je),Wh(ge);return}const oe=te.current,$=oe.findIndex(ge=>ge.id===ve);if($<0)return;const J=oe[$]?.payload,Te=oe.filter(ge=>ge.id!==ve),ne=Z.current,be=(oe.some(ge=>ge.id===ne)?ne:oe[0]?.id??null)===ve||Te.length===0?Te[Math.min($,Te.length-1)]?.id??null:void 0;z.current=Te,te.current=Te,p(Te),Te.length===0&&U.current==="terminal"&&C(!1),be!==void 0&&(y(be),G.current=be,Z.current=be),Yh(J)},[]),Re=k.useCallback(()=>{const ve=q.current.map(Ee=>Ee.payload),_e=te.current.map(Ee=>Ee.payload);q.current=[],te.current=[],V.current=[],X.current=null,z.current=[],G.current=null,ae.current=null,Z.current=null,d([]),p([]),g(null),y(null),C(!1);for(const Ee of ve)Wh(Ee);for(const Ee of _e)Yh(Ee)},[]),Be=k.useCallback(ve=>{U.current==="terminal"?(y(ve),G.current=ve):(g(ve),X.current=ve)},[]),Pe=k.useCallback((ve,_e)=>{d(Ee=>{let oe=!1;const $=Ee.map(J=>{if(J.payload.kind!=="url"||J.payload.browserId!==ve)return J;const Te=_e.url??J.payload.url,ne=_e.title||J.payload.title||Te,he=_e.pageId??J.payload.pageId;return Te===J.payload.url&&ne===(J.payload.title||J.title)&&he===J.payload.pageId&&ne===J.title?J:(oe=!0,{...J,title:ne,payload:{...J.payload,url:Te,title:ne,...he!=null?{pageId:he}:{}}})});return oe&&(V.current=$),oe?$:Ee})},[]),Fe=k.useCallback((ve,_e)=>{p(Ee=>{let oe=!1;const $=Ee.map(J=>{if(J.payload.kind!=="terminal"||J.payload.terminalId!==ve)return J;const Te=_e.title||J.payload.title||J.title,ne=_e.cwd??J.payload.cwd;return Te===J.title&&ne===J.payload.cwd&&Te===(J.payload.title||J.title)?J:(oe=!0,{...J,title:Te,payload:{...J.payload,title:Te,...ne!=null?{cwd:ne}:{}}})});return oe&&(z.current=$),oe?$:Ee})},[]),dt=k.useCallback(()=>{U.current==="terminal"?(p(ve=>ve.length===0?ve:(z.current=ve,Z.current&&(G.current=Z.current),[])),y(null)):(d(ve=>ve.length===0?ve:(V.current=ve,ae.current&&(X.current=ae.current),[])),g(null),Ce()),C(!1)},[Ce]),mt=k.useCallback(()=>{if(U.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(V.current.length>0){const he=V.current,be=X.current&&he.some(ge=>ge.id===X.current)?X.current:he[0].id;d(he),g(be),X.current=be,n(!0);return}const J=Is(),Te=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,ne={id:J,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Te}};V.current=[ne],d([ne]),g(ne.id),X.current=ne.id,n(!0);return}const ve=Is(),_e=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Ee,oe=!1,$=!1;l("browser"),d(J=>{if(J.length>0)return V.current=J,ae.current&&(X.current=ae.current),$=!0,Ee=null,[];if(V.current.length>0){oe=!0;const ne=V.current;return Ee=X.current&&ne.some(be=>be.id===X.current)?X.current:ne[0].id,ne}oe=!0;const Te={id:ve,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:_e}};return V.current=[Te],Ee=Te.id,[Te]}),oe&&n(!0),$?(g(null),C(!1),Ce()):Ee!=null&&(g(Ee),X.current=Ee)},[c.length,m.length,Ce]),Nt=k.useCallback(()=>{if(U.current==="browser"&&c.length>0){if(l("terminal"),Ce(),m.length>0){n(!0);return}if(z.current.length>0){const he=z.current,be=G.current&&he.some(ge=>ge.id===G.current)?G.current:he[0].id;p(he),y(be),G.current=be,n(!0);return}const J=Is(),Te=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(Te);const ne={id:J,title:"Terminal",payload:{kind:"terminal",terminalId:Te,title:"Terminal"}};z.current=[ne],p([ne]),y(ne.id),G.current=ne.id,n(!0);return}const ve=Is(),_e=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(_e);let Ee,oe=!1,$=!1;l("terminal"),Ce(),p(J=>{if(J.length>0)return z.current=J,Z.current&&(G.current=Z.current),$=!0,Ee=null,[];if(z.current.length>0){oe=!0;const ne=z.current;return Ee=G.current&&ne.some(be=>be.id===G.current)?G.current:ne[0].id,ne}oe=!0;const Te={id:ve,title:"Terminal",payload:{kind:"terminal",terminalId:_e,title:"Terminal"}};return z.current=[Te],Ee=Te.id,[Te]}),oe&&n(!0),$?(y(null),C(!1)):Ee!=null&&(y(Ee),G.current=Ee)},[c.length,m.length,Ce]),Ot=k.useCallback(ve=>{const _e=U.current==="terminal"?m:c;if(_e.length<2)return;const Ee=U.current==="terminal"?Z.current:ae.current,$=(Math.max(0,_e.findIndex(Te=>Te.id===Ee))+ve+_e.length)%_e.length,J=_e[$].id;U.current==="terminal"?(y(J),G.current=J):(g(J),X.current=J)},[c,m]),At=k.useCallback(ve=>{const Ee=(U.current==="terminal"?m:c)[ve];Ee&&(U.current==="terminal"?(y(Ee.id),G.current=Ee.id):(g(Ee.id),X.current=Ee.id))},[c,m]),qt=k.useCallback(()=>{if(U.current==="terminal"){const _e=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;fe({kind:"terminal",terminalId:_e,title:"Terminal"});return}const ve=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;fe({kind:"url",url:"about:blank",title:"New Tab",browserId:ve})},[fe]),jt=k.useCallback(ve=>{const _e=te.current,Ee=_e.findIndex(he=>he.payload.kind==="terminal"&&he.payload.terminalId===ve);if(Ee<0){Kh(ve),window.markusDesktop?.terminal?.destroy(ve);return}const oe=_e[Ee];if(_e.length>1){I(oe.id);return}Kh(ve),window.markusDesktop?.terminal?.destroy(ve);const $=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi($);const J=oe.payload.kind==="terminal"&&(oe.payload.title||oe.title)||"Terminal",Te=oe.payload.kind==="terminal"?oe.payload.cwd:void 0,ne={id:oe.id,title:J,payload:{kind:"terminal",terminalId:$,title:J,cwd:Te}};z.current=[ne],p([ne]),y(ne.id),G.current=ne.id,U.current!=="terminal"&&l("terminal")},[I]),$e=k.useCallback(ve=>C(ve),[]),ut=k.useCallback(()=>C(ve=>!ve),[]),kt=o==="terminal"?m:c,xt=o==="terminal"?x:h,Ct=kt.find(ve=>ve.id===xt)??kt[0]??null,ce=Ct?.payload??null,rt=kt.length>0,at=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:Q,toggleLeftCollapsed:me,keyboardPane:_,setKeyboardPane:L,l0FocusPageId:O,setL0FocusPageId:F,rightPanelMode:o,setRightPanelMode:H,switchRightPanelMode:W,rightPanel:ce,rightPanelOpen:rt,rightPanelTabs:kt,activeRightPanelTabId:Ct?.id??null,openRightPanel:fe,closeRightPanel:Re,closeRightPanelTab:I,setActiveRightPanelTab:Be,updateRightPanelBrowserTab:Pe,updateRightPanelTerminalTab:Fe,toggleRightPanel:mt,toggleTerminalPanel:Nt,collapseRightPanelOnly:dt,cycleRightPanelTab:Ot,activateRightPanelTabAt:At,openNewRightPanelTab:qt,handleTerminalExit:jt,rightPanelFullscreen:w,setRightPanelFullscreen:$e,toggleRightPanelFullscreen:ut,hostAvailable:T,setHostAvailable:S}),[t,Q,me,_,L,O,F,o,H,W,ce,rt,kt,Ct,fe,Re,I,Be,Pe,Fe,mt,Nt,dt,Ot,At,qt,jt,w,$e,ut,T]);return s.jsx(v3.Provider,{value:at,children:e})}function Oc(){return k.useContext(v3)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>H3),void 0).then(e=>({default:e.MarkdownMessage})));const iK=k.lazy(()=>qr(()=>import("./ContentRenderer-CVnHxqVj.js"),[]).then(e=>({default:e.ContentRenderer})));let No=[],e4=60;function oK(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++e4);return k.useEffect(()=>{const r=()=>t.current();No.push(r);const o=l=>{l.key==="Escape"&&No[No.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),No=No.filter(l=>l!==r),No.length===0&&(e4=60)}},[]),n}const t4=500,$s=new Map,b0=new Set,qd=new Map;let Gd=null;function lK(){if($s.size<=t4)return;const e=$s.size-t4,t=$s.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;$s.delete(r)}}function n4(e,t){$s.delete(e),$s.set(e,t),lK()}function r4(e){const t=qd.get(e);if(t)for(const n of t)n()}function cK(){Gd=null;const e=[...b0];b0.clear(),e.length!==0&&Me.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))n4(n,r),r4(n)}).catch(()=>{for(const t of e)n4(t,{exists:!1,isFile:!1,type:"unknown"}),r4(t)})}function uK(e){$s.has(e)||b0.has(e)||(b0.add(e),Gd&&clearTimeout(Gd),Gd=setTimeout(cK,30))}function dK(e,t){let n=qd.get(e);return n||(n=new Set,qd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&qd.delete(e)}}function mK(e){const t=k.useCallback(o=>dK(e,o),[e]),n=k.useCallback(()=>$s.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{uK(e)},[e]),r}const fK=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function pK(e){return e.length<2||e.length>500?!1:fK.test(e)}function hK({filePath:e,onClose:t}){const n=oK(t),[r,o]=k.useState(!0),[l,c]=k.useState(null),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[C,T]=k.useState("");k.useEffect(()=>{o(!0),c(null),Me.files.preview(e).then(_=>{m(typeof _.content=="string"?_.content:""),h(_.type),x(_.name),w(_.mimeType||""),T(_.streamUrl||(_.path?Me.files.streamUrl(_.path):"")||(_.type==="audio"||_.type==="video"?Me.files.streamUrl(e):""))}).catch(_=>{c(String(_?.message||_))}).finally(()=>{o(!1)})},[e]);const S=g||e.split(/[/\\]/).pop()||e;return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:_=>_.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:S}),s.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Me.files.reveal(e),title:"Reveal in file explorer",children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{d:"M4.5 17a2.5 2.5 0 01-2.5-2.5v-9A2.5 2.5 0 014.5 3h3.672a1.5 1.5 0 011.06.44L10.56 4.77a.5.5 0 00.354.147H15.5A2.5 2.5 0 0118 7.417v7.083A2.5 2.5 0 0115.5 17h-11z"})})}),s.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[r&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),l&&s.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[s.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:l})]}),!r&&!l&&p==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${y||"image/png"};base64,${d}`,alt:S,className:"max-w-full rounded"})}),!r&&!l&&p==="audio"&&C&&s.jsx("audio",{controls:!0,preload:"metadata",src:C,className:"w-full"}),!r&&!l&&p==="video"&&C&&s.jsx("video",{controls:!0,preload:"metadata",src:C,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(p==="binary"||!d&&p!=="image"&&p!=="audio"&&p!=="video")&&s.jsxs("div",{className:"text-center py-8 space-y-3",children:[s.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),s.jsx("button",{className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",onClick:()=>{Me.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&p!=="image"&&p!=="audio"&&p!=="video"&&p!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(iK,{content:d,format:p==="text"?"text":p,className:"text-sm"})})]})]})}),document.body)}function gK({path:e}){const t=mK(e),[n,r]=k.useState(null),o=Oc(),l=t?.exists??!1,c=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Me.files.reveal(e)},[l,c,e,o]),m="inline w-3 h-3 align-[-0.125em]",p=c?s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}):s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})});return t?l?s.jsxs(s.Fragment,{children:[s.jsxs("code",{className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:d,title:c?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[p,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(hK,{filePath:n,onClose:()=>r(null)})]}):s.jsx("code",{className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:"File not found",children:e}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let Qp=null;function bK(){return Qp||(Qp=qr(()=>import("./mermaid.core-b733zJmi.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Qp}function xK(){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 yK(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 vK(){return xK()}function wK(){return k.useSyncExternalStore(yK,vK)}function w3({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),c=k.useId(),d=k.useRef(0),m=k.useRef(null),p=wK();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===p)return;let h=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await bK();if(h)return;g.default.initialize({startOnLoad:!1,theme:p?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const x=`mermaid-${c.replace(/:/g,"")}-${d.current}`,{svg:y}=await g.default.render(x,e.trim());if(h)return;t.current&&(t.current.innerHTML=y,m.current={code:e,dark:p})}catch(g){h||r(g instanceof Error?g.message:String(g))}finally{h||l(!1)}})(),()=>{h=!0}},[e,c,p]),n?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[o&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),s.jsx("div",{ref:t,className:`flex justify-center [&>svg]:max-w-full${o?" hidden":""}`})]})}const kK="/assets/viz-global-C_AyN6D9.js";let kd=!1,Zp=null;function SK(){return kd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(kd=!0,e()):(n.addEventListener("load",()=>{kd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const r=document.createElement("script");r.setAttribute("data-plantuml-viz",""),r.src=kK,r.onload=()=>{kd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function NK(){return Zp||(Zp=SK().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),Zp}let a4=Promise.resolve();function CK(e,t){const n=a4.then(()=>new Promise((r,o)=>{NK().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,r,o,{dark:t})}).catch(o)}));return a4=n.then(()=>{},()=>{}),n}function TK(){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 AK(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 EK(){return k.useSyncExternalStore(AK,()=>TK())}function k3({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,c]=k.useState(!0),d=k.useRef(null),m=EK();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let p=!1;return c(!0),o(null),CK(e.trim(),m).then(h=>{p||(n(h),d.current={code:e,dark:m})}).catch(h=>{p||o(h instanceof Error?h.message:String(h))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[e,m]),r?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t&&s.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`,dangerouslySetInnerHTML:{__html:t}})]})}function _K(e,t,n){const r=e.cloneNode(!0),o=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",c=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},d=t==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},m={p:`margin:0 0 10px;color:${d.text};line-height:1.7;`,h1:`font-size:${c.h1}em;font-weight:700;color:${d.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${d.border};padding-bottom:6px;`,h2:`font-size:${c.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.h4}em;font-weight:600;color:${d.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${d.strong};`,em:"font-style:italic;",a:`color:${d.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${d.text};`,blockquote:`border-left:3px solid ${d.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${d.blockquoteText};`,hr:`border:none;border-top:1px solid ${d.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${d.tableHeaderBg};`,th:`border:1px solid ${d.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${d.tableHeaderText};`,td:`border:1px solid ${d.tableBorder};padding:8px 12px;color:${d.text};`,img:"max-width:100%;height:auto;"};function p(h){h.removeAttribute("class");const g=h.tagName.toLowerCase();if(g==="pre"){h.setAttribute("style",`background:${d.preBg};color:${d.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${d.preBorder};`);const x=h.querySelector("code");x&&(x.removeAttribute("class"),x.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}g==="code"?h.setAttribute("style",`background:${d.codeBg};color:${d.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[g]&&h.setAttribute("style",m[g]),Array.from(h.children).forEach(p)}return r.removeAttribute("class"),Array.from(r.children).forEach(h=>p(h)),`<div style="background:${d.bg};color:${d.text};padding:20px 24px;font-family:${o};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function Vg(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}async function jK(e,t,n,r){const o=_K(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Vg(n),method:"text"}}}function Xh({code:e,language:t,children:n}){const{t:r}=ft("common"),[o,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await Vg(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return s.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),r("markdown.viewRendered")]})}),s.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),r("markdown.viewSource")]})})]})]}),o==="rendered"?s.jsx("div",{children:n}):s.jsxs("div",{className:"relative group/source",children:[s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary bg-surface-secondary leading-relaxed whitespace-pre-wrap break-words",children:e}),s.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:r("markdown.copyContent"),children:c?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}function Jl(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,o="";for(const l of e.matchAll(n))o+=t(e.slice(r,l.index)),o+=l[0],r=l.index+l[0].length;return o+=t(e.slice(r)),o}function MK(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const Sd="#mention:";function RK(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,d)=>{const m=c??d;return`[@${m}](${Sd}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.length-l.length);let r="",o=0;for(;o<e.length;){const l=e.indexOf("@",o);if(l<0){r+=e.slice(o);break}if(r+=e.slice(o,l),e[l+1]==="["){const h=e.indexOf("]",l+2);if(h>l+2){const g=e.slice(l+2,h);r+=`[@${g}](${Sd}${encodeURIComponent(g)})`,o=h+1;continue}}const c=e.slice(l+1),d=c.toLowerCase(),m=n.find(h=>d.startsWith(h.toLowerCase()));if(m){const h=c.slice(0,m.length);r+=`[@${h}](${Sd}${encodeURIComponent(h)})`,o=l+1+m.length;continue}const p=c.match(/^([\w\p{L}\p{N}]+)/u);if(p){const h=p[1];r+=`[@${h}](${Sd}${encodeURIComponent(h)})`,o=l+1+h.length;continue}r+="@",o=l+1}return r}const S3="#entity:",OK=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),LK=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function DK(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function IK(e){return e.replace(LK,(t,n,r)=>`[${n}](${S3}${r})`)}function PK(e){return e.replace(OK,(t,n,r)=>DK(e,r)?t:`[${t}](${S3}${t})`)}function zK(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const BK=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function $K(e){return BK.test(e.trim())}const HK={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",tsx:"TSX",jsx:"JSX",py:"Python",python:"Python",rb:"Ruby",ruby:"Ruby",rs:"Rust",rust:"Rust",go:"Go",java:"Java",kotlin:"Kotlin",swift:"Swift",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",sql:"SQL",sh:"Shell",bash:"Bash",zsh:"Zsh",shell:"Shell",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",toml:"TOML",ini:"INI",md:"Markdown",markdown:"Markdown",dockerfile:"Dockerfile",docker:"Dockerfile",graphql:"GraphQL",gql:"GraphQL",lua:"Lua",perl:"Perl",r:"R",scala:"Scala",elixir:"Elixir",erlang:"Erlang",haskell:"Haskell",clojure:"Clojure",dart:"Dart",zig:"Zig",nim:"Nim",powershell:"PowerShell",ps1:"PowerShell",vue:"Vue",svelte:"Svelte",plaintext:"Text",text:"Text",txt:"Text"};function UK(e){return HK[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function FK(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const qK=[w3,k3];function GK(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return FK(n)}return null}function lc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(lc).join("");if(k.isValidElement(e)){const t=e.props;return lc(t.children)}return""}function KK({children:e}){const{t}=ft("common"),n=GK(e),r=k.useRef(null),[o,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=lc(e):h=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(h),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(k.Children.toArray(e).some(h=>k.isValidElement(h)&&qK.includes(h.type))){const h=lc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Xh,{code:h,language:g,children:e})}return n==="mermaid"||n==="plantuml"?s.jsx(s.Fragment,{children:e}):s.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:UK(n)}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>d("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),s.jsx("button",{onClick:()=>d("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),s.jsxs("div",{className:"relative",children:[c==="rendered"?s.jsx("pre",{ref:r,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,h=>k.isValidElement(h)?k.cloneElement(h,{style:{background:"transparent",padding:0}}):h)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:lc(e)}),s.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:t("markdown.copyContent"),children:o?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const N3=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,C3=/^\.{1,2}\//,VK=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,T3=/^[A-Za-z]:[\\/]/,A3=/^\\\\[^\\]/;function E3(e){const t=e.trim();return t?!!(/^file:/i.test(t)||T3.test(t)||A3.test(t)||t.startsWith("~/")||t.startsWith("/")||C3.test(t)):!1}function Wg(e){let t=e.trim();if(/^file:/i.test(t)){try{t=decodeURIComponent(t.replace(/^file:\/\//i,""))}catch{t=t.replace(/^file:\/\//i,"")}/^\/[A-Za-z]:\//.test(t)&&(t=t.slice(1))}return t=t.replace(/\\+/g,"/"),t}function WK(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,r,o)=>`${n}${r.replace(/\\+/g,"/")}${o}`)}function _3(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Nd(e,t){if(!e)return e;if(N3.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const r=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,o=r.split("/"),l=[];for(const d of o)!d||d==="."||(d===".."?l.pop():l.push(d));const c=l.join("/");return r.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function s4(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function i4(e,t){if(!e)return{kind:"passthrough"};const n=e.trim();if(!n||n==="#")return{kind:"passthrough"};if(n.startsWith("#")&&!n.startsWith("#mention:")&&!n.startsWith("#entity:"))return{kind:"fragment",id:decodeURIComponent(n.slice(1))};if(T3.test(n)||A3.test(n)){const{path:l,fragment:c}=s4(n);return{kind:"file",path:Nd(l,t),fragment:c}}if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n))return/^https?:\/\//i.test(n)||/^mailto:/i.test(n)?{kind:"external",url:n}:/^file:\/\//i.test(n)?{kind:"file",path:Wg(n)}:{kind:"passthrough"};const{path:r,fragment:o}=s4(n);return N3.test(r)?{kind:"file",path:Nd(r,t),fragment:o}:C3.test(r)?{kind:"file",path:Nd(r,t),fragment:o}:r&&VK.test(r)&&!r.includes("://")?{kind:"file",path:Nd(r,t),fragment:o}:{kind:"passthrough"}}function YK(e,t){if(!e||!t)return!1;let n=null;try{n=e.querySelector(`#${CSS.escape(t)}`)}catch{n=null}if(n||(n=e.querySelector(`[id="${t.replace(/"/g,'\\"')}"]`)),!n){const r=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const o of r)if(_3(o.textContent||"")===t||o.id===t){n=o;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function j3(e){return e.type==="text"?e.value??"":(e.children??[]).map(j3).join("")}function XK(){return e=>{const t=new Map,n=r=>{if(r.type==="element"&&r.tagName&&/^h[1-6]$/.test(r.tagName)){const o=j3(r).trim();let l=_3(o);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),r.properties={...r.properties??{},id:l}}}for(const o of r.children??[])n(o)};n(e)}}const M3="markus-copy-typography",o4={fontFamily:"default",fontSize:15,headingScale:"standard"};function R3(){try{const e=localStorage.getItem(M3);if(e)return{...o4,...JSON.parse(e)}}catch{}return o4}function QK(e){localStorage.setItem(M3,JSON.stringify(e))}function ZK(e){const t={default:"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif",serif:"Georgia, 'Times New Roman', Times, serif","sans-serif":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif",mono:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"},n={compact:{h1:1.3,h2:1.15,h3:1.05,h4:1},standard:{h1:1.6,h2:1.35,h3:1.15,h4:1},large:{h1:2,h2:1.6,h3:1.3,h4:1.1}};return{fontFamily:t[e.fontFamily]??t.default,fontSize:`${e.fontSize}px`,headingScales:n[e.headingScale]??n.standard}}function JK({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(R3);k.useEffect(()=>{QK(n)},[n]);const o=k.useCallback((l,c)=>{r(d=>({...d,[l]:c}))},[]);return s.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:t("markdown.typographySettings")}),s.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("markdown.typographyDesc")}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.fontFamily")}),s.jsxs("select",{value:n.fontFamily,onChange:l=>o("fontFamily",l.target.value),className:"w-full px-2 py-1 text-xs rounded bg-surface-primary border border-border-subtle text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50",children:[s.jsx("option",{value:"default",children:t("markdown.fontDefault")}),s.jsx("option",{value:"serif",children:t("markdown.fontSerif")}),s.jsx("option",{value:"sans-serif",children:t("markdown.fontSansSerif")}),s.jsx("option",{value:"mono",children:t("markdown.fontMono")})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[t("markdown.fontSize"),": ",n.fontSize,"px"]}),s.jsx("input",{type:"range",min:10,max:24,step:1,value:n.fontSize,onChange:l=>o("fontSize",Number(l.target.value)),className:"w-full h-1 rounded-full appearance-none bg-border-subtle [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-brand-500"}),s.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[s.jsx("span",{children:"10px"}),s.jsx("span",{children:"24px"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.headingScale")}),s.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(l=>s.jsx("button",{onClick:()=>o("headingScale",l),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${n.headingScale===l?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:t(`markdown.scale${l.charAt(0).toUpperCase()+l.slice(1)}`)},l))})]})]})}const eV=k.lazy(()=>qr(()=>Promise.resolve().then(()=>H3),void 0).then(e=>({default:e.MarkdownMessage}))),tV={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},l4={active:{color:"text-green-600 bg-green-500/10"},verified:{color:"text-blue-600 bg-blue-500/10"},outdated:{color:"text-fg-tertiary bg-surface-elevated/50"}};function nV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=tV[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=l4[e.status]??l4.active,c=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),s.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-start gap-3 rounded-t-2xl z-10",children:[s.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${o.color}`,children:o.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),s.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.summary")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(k.Suspense,{fallback:s.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:s.jsx(eV,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.reference")}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),c?s.jsx("button",{onClick:()=>window.open(e.reference,"_blank","noopener,noreferrer"),className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")}):s.jsx("button",{onClick:()=>{Me.files.reveal(e.reference).catch(()=>{})},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")})]})]}),e.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),s.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),s.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),s.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&s.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&s.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>s.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),s.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[s.jsxs("span",{children:[r("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),s.jsxs("span",{children:[r("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&s.jsx("span",{children:r("agent:deliverables.accessed",{count:e.accessCount})})]})]}),s.jsxs("div",{className:"sticky bottom-0 bg-surface-primary/95 backdrop-blur-sm border-t border-border-default px-5 py-3 flex items-center justify-end gap-2 rounded-b-2xl",children:[s.jsxs("button",{onClick:()=>n(e.id),className:"px-3 py-1.5 text-xs font-medium text-brand-500 hover:bg-brand-500/10 rounded-lg transition-colors flex items-center gap-1.5",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),r("agent:deliverables.openInPage")]}),s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs font-medium text-fg-secondary bg-surface-elevated hover:bg-surface-overlay rounded-lg transition-colors",children:r("common:close")})]})]})]});return typeof document<"u"?Sa.createPortal(d,document.body):d}const rV={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function O3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const L3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},D3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},aV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function x0(e){return aV.test(e.trim())}function sV(e){const t=e.split("_")[0]?.toLowerCase();return t?rV[t]:void 0}function I3(e){e.startsWith("tsk_")?it.navigate(ue.WORK,{openTask:e}):e.startsWith("req_")?it.navigate(ue.WORK,{openRequirement:e}):e.startsWith("proj_")?it.navigate(ue.WORK,{projectId:e}):e.startsWith("dlv_")?it.navigate(ue.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?it.navigate(ue.TEAM,{agentId:e}):e.startsWith("team_")&&it.navigate(ue.TEAM,{selectTeam:e})}const Jp=new Map,Cd=new Map;async function iV(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Me.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Me.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Me.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Me.deliverables.get(e);return{...n,title:r.deliverable.title,status:r.deliverable.status,summary:r.deliverable.summary,deliverable:r.deliverable}}case"agent":{const r=await Me.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Me.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function P3(e,t){const n=t??sV(e),[r,o]=k.useState(()=>Jp.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){o({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Jp.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let c=!0,d=Cd.get(e);return d||(d=iV(e,n),Cd.set(e,d)),d.then(m=>{Jp.set(e,m),Cd.delete(e),c&&o(m)}).catch(()=>{Cd.delete(e),c&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{c=!1}},[e,n]),r}function z3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function cc({id:e,type:t,label:n}){const r=P3(e,t),o=Oc(),l=L3[r.type]??"🔗",c=n??(r.loading||r.notFound?z3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&o?.hostAvailable){o.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}I3(e)};return s.jsxs("span",{"data-entity-link":e,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors align-baseline",onClick:d,title:`${D3[r.type]}: ${r.notFound?e:r.title} (${e})`,children:[s.jsx("span",{className:"text-[10px]",children:l}),s.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:c})]})}function oV({id:e,type:t,label:n}){const r=P3(e,t),[o,l]=k.useState(!1),c=Oc(),d=L3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(c?.hostAvailable){c.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}I3(e)},p=r.loading?z3(e):n||(r.notFound?e:r.title);return s.jsxs("span",{className:"not-prose block my-2",children:[s.jsxs("button",{type:"button",onClick:m,className:"w-full max-w-md text-left rounded-xl border border-border-default bg-surface-elevated/30 hover:border-brand-500/40 hover:bg-surface-elevated/50 transition-colors px-3 py-2.5 flex items-start gap-2.5",children:[s.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:d}),s.jsxs("span",{className:"flex-1 min-w-0 block",children:[s.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:D3[r.type]}),r.status&&s.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded font-medium bg-brand-500/10 text-brand-500",children:r.status})]}),s.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${r.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:p}),r.summary&&r.summary.trim()!==r.title.trim()&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:r.summary})]}),s.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),o&&r.deliverable&&s.jsx(nV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),it.navigate(ue.DELIVERABLES,{openDeliverable:h})}})]})}class lV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!cV(t.resetKeys,this.props.resetKeys)&&this.setState({error:null})}componentDidCatch(t,n){this.props.onError?.(t,n),console.error("[ErrorBoundary] caught render error:",t,n.componentStack)}reset=()=>this.setState({error:null});render(){const{error:t}=this.state;if(t){const{fallback:n}=this.props;return typeof n=="function"?n(t,this.reset):n??null}return this.props.children}}function cV(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 uV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function c4(e){return uV.test(e)||E3(e)?e:x5(e)}const u4=[q5,UF,Kk],d4=[XK,[wq,{strict:"ignore"}],[x3,{detect:!0,ignoreMissing:!0}]],Qh="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer",dV=/<think>([\s\S]*?)(<\/think>|$)/g;function mV(e){const t=[];let n=e.replace(dV,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:t,rest:n.trim()}}const m4="#mention:",y0="#entity:",fV=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,B3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Zh(e){return e.type==="text"?e.value??"":(e.children??[]).map(Zh).join("")}function pV(e){return e.type==="text"&&(e.value??"").trim()===""}function hV(e){if(!e?.children)return null;const t=e.children.filter(r=>!pV(r));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const r=n.properties?.href;if(!r)return null;const o=Zh(n);if(r.startsWith(y0))return{id:r.slice(y0.length)};const l=r.match(B3);return l&&l[1]!=="workflow"?{id:l[2],type:O3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Zh(n).trim();if(x0(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(x0(r))return{id:r}}return null}const gV={p:({children:e})=>s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>s.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>s.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>s.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>s.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>s.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>s.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>s.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>s.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>s.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),r=n.trim();if(t?.includes("language-plantuml")||zK(r))return s.jsx(Xh,{code:r,language:"plantuml",children:s.jsx(k3,{code:r})});if(t?.includes("language-mermaid")||!t&&$K(r))return s.jsx(Xh,{code:r,language:"mermaid",children:s.jsx(w3,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(x0(n))return s.jsx(cc,{id:n.trim()});const o=n.match(fV);return o?s.jsx(cc,{id:o[2],label:o[1]}):pK(n)?s.jsx(gK,{path:n}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e})},pre:({children:e})=>s.jsx(KK,{children:e}),strong:({children:e})=>s.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>s.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>s.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>s.jsx("a",{href:e,className:Qh,children:t}),hr:()=>s.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>s.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>s.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>s.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>s.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold text-fg-primary border border-border-default",children:e}),td:({children:e})=>s.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},bV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function xV(e){const t=Wg(e);return E3(e)&&bV.test(t.split("?")[0]??t)}function yV(e,t){const n=Wg(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const o=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of o)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function vV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const Co=new Map;function wV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>xV(e)?vV(yV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),c=Co.get(o),[d,m]=k.useState(c??(l?null:o)),[p,h]=k.useState(!!c),[g,x]=k.useState(!1),[y,w]=k.useState(null),[C,T]=k.useState(0),S=k.useRef(0),_=k.useCallback(()=>{Co.delete(o),x(!1),w(null),h(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(j=>j+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const j=Co.get(o);if(j){m(j),h(!0),x(!1),w(null);return}const O=++S.current;x(!1),w(null),h(!1),m(null),(async()=>{try{const P=await fetch(o,{credentials:"same-origin"});if(O!==S.current)return;if(!P.ok){let V=`HTTP ${P.status}`;try{const X=await P.json();X.error&&(V=X.error)}catch{}throw new Error(V)}const L=await P.blob();if(O!==S.current)return;if(L.size===0)throw new Error("Empty image response");if(L.type&&!L.type.startsWith("image/")&&!L.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${L.type}`);const F=URL.createObjectURL(L);Co.set(o,F),m(F),h(!0),x(!1),w(null)}catch(P){if(O!==S.current)return;const L=P instanceof Error?P.message:String(P);console.warn("[MarkdownImage] failed to load local image",o,P),w(L),x(!0),h(!1)}})()},[l,o,C]),k.useEffect(()=>{l||(m(o),h(!!Co.get(o)),x(!1),w(null))},[o,l,C]),g?s.jsxs("button",{type:"button",onClick:_,title:y??"Click to retry",className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[s.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",y?` (${y})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!p&&s.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),d?s.jsx("img",{src:d,alt:t??"",onLoad:()=>{l||Co.set(o,o),h(!0)},onError:()=>{w("Image decode failed"),x(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${p?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function f4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function kV(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const r=n.getContext("2d");if(!r)throw new Error("Canvas unavailable");return r.drawImage(t,0,0),t.close(),new Promise((o,l)=>{n.toBlob(c=>c?o(c):l(new Error("PNG encode failed")),"image/png")})}function SV(e,t){try{const o=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(o&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(o))return decodeURIComponent(o)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function $3({src:e,onClose:t}){const{t:n}=ft("common"),[r,o]=k.useState(null),[l,c]=k.useState(null);Ho(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{o(g),window.setTimeout(()=>o(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const x=await f4(e),y=await kV(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{c(null)}}},[l,d,e,n]),p=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const x=await f4(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=SV(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{c(null)}}},[l,d,e,n]),h="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/10 hover:bg-white/20 text-white text-sm transition-colors disabled:opacity-50";return Sa.createPortal(s.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[s.jsxs("button",{type:"button",className:h,onClick:m,disabled:!!l,title:n("copyImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),s.jsxs("button",{type:"button",className:h,onClick:p,disabled:!!l,title:n("downloadImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),s.jsx("button",{type:"button",onClick:t,className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",title:n("close"),children:s.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r&&s.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:r}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function NV(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),o=l=>n(l.matches);return r.addEventListener("change",o),n(r.matches),()=>r.removeEventListener("change",o)},[e]),t}function CV({content:e,contentRef:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[p,h]=k.useState(null),g=k.useRef(null),x=NV();k.useEffect(()=>{if(!r)return;const T=S=>{g.current&&!g.current.contains(S.target)&&(o(!1),c(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const y=k.useCallback(T=>{h(T),setTimeout(()=>h(null),1500)},[]),w=async()=>{const T=await Vg(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},C=async T=>{const S=t.current?.firstElementChild;if(!S)return;const _=R3(),j=ZK(_),O=await jK(S,T,e,{fontFamily:j.fontFamily,fontSize:j.fontSize,headingScales:j.headingScales}),P=n(T==="light"?"markdown.themeLight":"markdown.themeDark");y(O.ok?O.method==="html"?n("markdown.htmlCopied",{theme:P}):n("markdown.textCopied"):n("markdown.failed")),o(!1)};return s.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[p&&s.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 px-2 py-0.5 rounded bg-surface-elevated border border-border-default text-[10px] text-fg-secondary whitespace-nowrap shadow-lg",children:p}),s.jsx("button",{onClick:()=>o(T=>!T),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:n("markdown.copyContent"),children:s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),r&&s.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:d?s.jsx(JK,{onClose:()=>m(!1)}):l?s.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),s.jsx("button",{onClick:()=>c(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),s.jsx("button",{onClick:()=>c(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),s.jsxs("button",{onClick:w,className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.jsxs("button",{onClick:()=>C("light"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.jsxs("button",{onClick:()=>C("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Er=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:c,rest:d}=mV(t),m=k.useRef(null),[p,h]=k.useState(null),g=Oc(),x=k.useCallback(T=>{let S=Jl(T,MK);return S=Jl(S,WK),S=Jl(S,IK),S=Jl(S,PK),S=Jl(S,_=>RK(_,o)),S},[o]),y=k.useMemo(()=>x(d),[d,x]),w=k.useCallback((T,S)=>{const _=i4(S,l);if(_.kind!=="passthrough"){if(T.preventDefault(),T.stopPropagation(),_.kind==="fragment"){YK(m.current,_.id);return}if(_.kind==="file"){g?.hostAvailable?g.openRightPanel({kind:"file",path:_.path,title:_.path.split(/[/\\]/).pop()}):Me.files.reveal(_.path).catch(()=>{});return}if(_.kind==="external"){if(g?.hostAvailable&&/^https?:\/\//i.test(_.url)){g.openRightPanel({kind:"url",url:_.url,title:_.url});return}_i(_.url)}}},[l,g]),C=k.useMemo(()=>({...gV,img:({src:T,alt:S})=>s.jsx(wV,{src:T??"",alt:S,onPreview:h,basePath:l},T??""),p:({children:T,node:S})=>{const _=hV(S);return _?s.jsx(oV,{id:_.id,type:_.type,label:_.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:T})},a:({href:T,children:S})=>{if(T?.startsWith(m4)){const j=decodeURIComponent(T.slice(m4.length));return s.jsx("span",{className:`text-brand-500 font-medium${r?" cursor-pointer hover:underline":""}`,onClick:r?O=>{O.preventDefault(),O.stopPropagation(),r(j,O)}:void 0,title:j,children:S})}if(T?.startsWith(y0))return s.jsx(cc,{id:T.slice(y0.length)});{const j=T?.match(B3);if(j){const[,O,P]=j;if(O==="workflow")return s.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:F=>{F.preventDefault(),F.stopPropagation(),it.navigate(ue.WORK,{boardType:"workflows"})},title:`workflow: ${P}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:S})]});const L=O3(O);if(L)return s.jsx(cc,{id:P,type:L,label:S})}}if(T&&x0(T))return s.jsx(cc,{id:T.trim(),label:S});const _=i4(T,l);return _.kind==="fragment"||_.kind==="file"||_.kind==="external"?s.jsx("a",{href:T,className:Qh,onClick:j=>w(j,T),title:_.kind==="fragment"?`#${_.id}`:_.kind==="file"?_.path:_.url,children:S}):s.jsx("a",{href:T,className:Qh,onClick:j=>{yc()&&T&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(T)&&j.preventDefault()},children:S})}}),[r,l,w]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(CV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(lV,{resetKeys:[y],fallback:s.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:s.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${n}`,children:[c.length>0&&(()=>{const T=c.join(`
|
|
649
649
|
|
|
650
650
|
`),S=T.split(`
|
|
651
651
|
`)[0]??"",_=S.length>80?S.slice(0,80)+"…":S;return s.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[s.jsxs("summary",{className:"cursor-pointer select-none px-3 py-2 text-xs text-fg-secondary hover:text-fg-secondary transition-colors flex items-center gap-1.5 min-w-0",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),s.jsx("span",{className:"shrink-0",children:"Thinking"}),s.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:_})]}),s.jsx("div",{className:"px-3 pb-3 border-t border-border-default/50",children:s.jsx("div",{className:"mt-2 pl-3 border-l-2 border-brand-500/40 text-xs text-fg-secondary leading-relaxed",children:s.jsx(Eh,{remarkPlugins:u4,rehypePlugins:d4,components:C,urlTransform:c4,children:x(T)})})})]})})(),s.jsx(Eh,{remarkPlugins:u4,rehypePlugins:d4,components:C,urlTransform:c4,children:y})]})})}),p&&s.jsx($3,{src:p,onClose:()=>h(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&TV(e.knownNames,t.knownNames));function TV(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 H3=Object.freeze(Object.defineProperty({__proto__:null,ImagePreviewModal:$3,MarkdownMessage:Er},Symbol.toStringTag,{value:"Module"})),Jh={suppressAdjustUntil:0};function Cc(e=2500){const t=typeof performance<"u"?performance.now():Date.now();Jh.suppressAdjustUntil=Math.max(Jh.suppressAdjustUntil,t+e)}function FY(){return(typeof performance<"u"?performance.now():Date.now())<Jh.suppressAdjustUntil}const p4={shell_execute:{label:"Running command",icon:"⌨"},list_terminals:{label:"Listing terminals",icon:"⌨"},new_terminal:{label:"Opening terminal",icon:"⌨"},select_terminal:{label:"Selecting terminal",icon:"⌨"},close_terminal:{label:"Closing terminal",icon:"⌨"},read_terminal:{label:"Reading terminal",icon:"⌨"},write_terminal:{label:"Writing terminal",icon:"⌨"},exec_terminal:{label:"Running in terminal",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},apply_patch:{label:"Applying patch",icon:"🔀"},list_directory:{label:"Listing directory",icon:"📂"},glob_find:{label:"Finding files",icon:"🔍"},grep_search:{label:"Searching code",icon:"🔍"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},task_get:{label:"Getting task",icon:"📋"},task_note:{label:"Adding note",icon:"📝"},task_assign:{label:"Assigning task",icon:"👥"},task_submit_review:{label:"Submitting for review",icon:"✅"},task_comment:{label:"Commenting task",icon:"💬"},subtask_create:{label:"Adding subtask",icon:"📌"},subtask_complete:{label:"Completing subtask",icon:"✅"},subtask_cancel:{label:"Cancelling subtask",icon:"🚫"},subtask_list:{label:"Listing subtasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},requirement_get:{label:"Getting requirement",icon:"📋"},requirement_update:{label:"Updating requirement",icon:"📋"},requirement_update_status:{label:"Updating req status",icon:"✅"},requirement_resubmit:{label:"Resubmitting requirement",icon:"📋"},requirement_comment:{label:"Commenting requirement",icon:"💬"},list_projects:{label:"Listing projects",icon:"🗂"},get_project:{label:"Getting project",icon:"🗂"},create_project:{label:"Creating project",icon:"🗂"},update_project:{label:"Updating project",icon:"🗂"},deliverable_create:{label:"Creating deliverable",icon:"📦"},deliverable_search:{label:"Searching deliverables",icon:"🔍"},deliverable_list:{label:"Listing deliverables",icon:"📦"},deliverable_update:{label:"Updating deliverable",icon:"📦"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list_colleagues:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},memory_list:{label:"Listing memory",icon:"💾"},memory_update:{label:"Updating memory",icon:"💾"},recall_activity:{label:"Recalling activity",icon:"📜"},update_working_memory:{label:"Updating notes",icon:"📝"},notify_user:{label:"Notifying user",icon:"🔔"},request_user_input:{label:"Requesting input",icon:"❓"},request_user_approval:{label:"Requesting approval",icon:"❓"},schedule_wakeup:{label:"Scheduling wakeup",icon:"⏰"},cancel_wakeup:{label:"Cancelling wakeup",icon:"⏰"},set_heartbeat_interval:{label:"Setting heartbeat",icon:"⏱"},discover_tools:{label:"Discovering tools",icon:"🧰"},check_mailbox:{label:"Checking mailbox",icon:"📥"},goal_create:{label:"Creating goal",icon:"🎯"},goal_update:{label:"Updating goal",icon:"🎯"},goal_status:{label:"Goal status",icon:"🎯"},background_exec:{label:"Background command",icon:"⌨"},process:{label:"Managing process",icon:"⚙"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"},invoke_coding_tool:{label:"Invoke Coding Tool",icon:"🛠"},coding_tool_apply:{label:"Apply Coding Result",icon:"🔀"},generate_image:{label:"Generating image",icon:"🖼"},text_to_speech:{label:"Generating speech",icon:"🔊"},speech_to_text:{label:"Transcribing audio",icon:"🎙"},generate_video:{label:"Generating video",icon:"🎬"},llm_list_providers:{label:"Listing providers",icon:"⚙"},llm_switch_model:{label:"Switching model",icon:"⚙"},llm_switch_default_provider:{label:"Switching provider",icon:"⚙"},llm_add_provider:{label:"Adding provider",icon:"⚙"},llm_edit_provider:{label:"Editing provider",icon:"⚙"},llm_add_model:{label:"Adding model",icon:"⚙"},llm_get_capability_routing:{label:"Checking capability routing",icon:"⚙"},llm_set_capability_routing:{label:"Setting capability routing",icon:"⚙"},team_list:{label:"Listing teams",icon:"👥"},team_status:{label:"Team status",icon:"👥"},team_start:{label:"Starting team",icon:"👥"},team_stop:{label:"Stopping team",icon:"👥"},team_update:{label:"Updating team",icon:"👥"},agent_start:{label:"Starting agent",icon:"◎"},agent_stop:{label:"Stopping agent",icon:"◎"},agent_update:{label:"Updating agent",icon:"◎"},agent_delegate_task:{label:"Delegating task",icon:"📌"},agent_broadcast_status:{label:"Broadcasting status",icon:"📣"},agent_create_group_chat:{label:"Creating group chat",icon:"💬"},agent_list_group_chats:{label:"Listing group chats",icon:"💬"},agent_send_group_message:{label:"Sending group message",icon:"💬"},delete_project:{label:"Deleting project",icon:"🗂"},project_stats:{label:"Project stats",icon:"📊"},hub_search:{label:"Searching Hub",icon:"🔍"},hub_install:{label:"Installing from Hub",icon:"📦"},package_list:{label:"Listing packages",icon:"📦"},package_install:{label:"Installing package",icon:"📦"},memory_delete:{label:"Deleting memory",icon:"💾"},memory_update_longterm:{label:"Updating long-term memory",icon:"💾"},clear_working_memory:{label:"Clearing notes",icon:"📝"},clear_notebook:{label:"Clearing notebook",icon:"📝"},update_notebook:{label:"Updating notebook",icon:"📝"},recall_context:{label:"Recalling context",icon:"📜"},defer_mailbox_item:{label:"Deferring mailbox item",icon:"📥"},drop_mailbox_item:{label:"Dropping mailbox item",icon:"📥"},prioritize_mailbox_item:{label:"Prioritizing mailbox",icon:"📥"},delegate_message:{label:"Delegating message",icon:"💬"},task_board_health:{label:"Checking task board",icon:"📋"},task_check_duplicates:{label:"Checking duplicates",icon:"📋"},task_cleanup_duplicates:{label:"Cleaning duplicates",icon:"📋"},workflow_list:{label:"Listing workflows",icon:"🔄"},workflow_create:{label:"Creating workflow",icon:"🔄"},workflow_update:{label:"Updating workflow",icon:"🔄"},workflow_delete:{label:"Deleting workflow",icon:"🔄"},workflow_run:{label:"Running workflow",icon:"🔄"},workflow_status:{label:"Workflow status",icon:"🔄"},workflow_cancel:{label:"Cancelling workflow",icon:"🔄"},open_page:{label:"Opening page",icon:"🌐"},resize_page:{label:"Resizing page",icon:"🌐"},drag:{label:"Dragging element",icon:"👆"},upload_file:{label:"Uploading file",icon:"📎"},emulate:{label:"Emulating device",icon:"📱"},handle_dialog:{label:"Handling dialog",icon:"💬"},get_console_message:{label:"Console message",icon:"🔍"},get_network_request:{label:"Network request",icon:"🔍"}},h4={shell_execute:"square-terminal",background_exec:"square-terminal",process:"settings",list_terminals:"square-terminal",new_terminal:"square-terminal",select_terminal:"square-terminal",close_terminal:"square-terminal",read_terminal:"square-terminal",write_terminal:"square-terminal",exec_terminal:"square-terminal",file_read:"file-text",file_write:"edit",file_edit:"edit",apply_patch:"git-branch",list_directory:"folder",glob_find:"search",grep_search:"search",web_fetch:"globe",web_search:"search",web_extract:"file-text",create_task:"clipboard",task_create:"clipboard",create_subtask:"clipboard",update_task:"check-circle",task_update:"check-circle",add_task_note:"edit",task_add_note:"edit",task_note:"edit",task_list:"clipboard",task_get:"clipboard",task_assign:"users",task_submit_review:"check-circle",task_comment:"message-square",subtask_create:"clipboard",subtask_complete:"check-circle",subtask_cancel:"alert-circle",subtask_list:"clipboard",requirement_propose:"clipboard",requirement_list:"clipboard",requirement_get:"clipboard",requirement_update:"clipboard",requirement_update_status:"check-circle",requirement_resubmit:"clipboard",requirement_comment:"message-square",list_projects:"layers",get_project:"layers",create_project:"layers",update_project:"layers",deliverable_create:"package",deliverable_search:"search",deliverable_list:"package",deliverable_update:"edit",git_status:"git-branch",git_diff:"git-branch",git_log:"book-open",git_branch:"git-branch",git_add:"git-branch",git_commit:"save",project_structure:"layers",code_stats:"bar-chart",navigate_page:"globe",new_page:"globe",close_page:"globe",select_page:"globe",list_pages:"globe",click:"target",hover:"target",fill:"terminal",fill_form:"terminal",type_text:"terminal",press_key:"terminal",take_screenshot:"camera",take_snapshot:"camera",evaluate_script:"code",wait_for:"clock",list_console_messages:"terminal",list_network_requests:"globe",lighthouse_audit:"bar-chart",agent_send_message:"message-square",agent_list_colleagues:"users",memory_save:"database",memory_search:"search",memory_list:"database",memory_update:"database",recall_activity:"book-open",update_working_memory:"edit",notify_user:"megaphone",request_user_input:"message-square",request_user_approval:"check-circle",schedule_wakeup:"clock",cancel_wakeup:"clock",set_heartbeat_interval:"clock",discover_tools:"wrench",check_mailbox:"message-square",goal_create:"target",goal_update:"target",goal_status:"target",feishu_send_message:"message-square",feishu_search_docs:"search",spawn_subagent:"bot",spawn_subagents:"bot",invoke_coding_tool:"wrench",coding_tool_apply:"git-branch",generate_image:"camera",text_to_speech:"headphones",speech_to_text:"headphones",generate_video:"camera",llm_list_providers:"settings",llm_switch_model:"settings",llm_switch_default_provider:"settings",llm_add_provider:"settings",llm_edit_provider:"settings",llm_add_model:"settings",llm_get_capability_routing:"settings",llm_set_capability_routing:"settings",team_list:"users",team_status:"users",team_start:"users",team_stop:"users",team_update:"users",agent_start:"bot",agent_stop:"bot",agent_update:"bot",agent_delegate_task:"clipboard",agent_broadcast_status:"megaphone",agent_create_group_chat:"message-square",agent_list_group_chats:"message-square",agent_send_group_message:"message-square",delete_project:"layers",project_stats:"bar-chart",hub_search:"search",hub_install:"package",package_list:"package",package_install:"package",memory_delete:"database",memory_update_longterm:"database",clear_working_memory:"edit",clear_notebook:"edit",update_notebook:"edit",recall_context:"book-open",defer_mailbox_item:"message-square",drop_mailbox_item:"message-square",prioritize_mailbox_item:"message-square",delegate_message:"message-square",task_board_health:"clipboard",task_check_duplicates:"clipboard",task_cleanup_duplicates:"clipboard",workflow_list:"git-branch",workflow_create:"git-branch",workflow_update:"git-branch",workflow_delete:"git-branch",workflow_run:"git-branch",workflow_status:"git-branch",workflow_cancel:"git-branch",open_page:"globe",resize_page:"globe",drag:"target",upload_file:"file-text",emulate:"settings",handle_dialog:"message-square",get_console_message:"terminal",get_network_request:"globe"};function Ai(e){const t=e.includes("__")?e.split("__").pop():e,n=p4[t]??p4[e],r=h4[t]??h4[e]??"settings";return n?{...n,iconName:r,key:t}:{label:t.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase()),icon:"⚙",iconName:r,key:t}}function $o(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function AV(e){const t=new Date(e);if(isNaN(t.getTime()))return e;const n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),c=String(t.getSeconds()).padStart(2,"0");return`${n}-${r} ${o}:${l}:${c}`}function eg(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function g4(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function U3(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,n])=>n!=null).map(([n,r])=>({key:n,value:typeof r=="string"?r:JSON.stringify(r,null,2)}))}function EV(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 qY(e,t){const n=new Map;let r=null;for(const o of e)if(o.type==="tool_start"&&(o.content==="spawn_subagent"||o.content==="spawn_subagents"))r=o.seq,n.set(o.seq,[]);else if(o.type==="tool_end"&&(o.content==="spawn_subagent"||o.content==="spawn_subagents")){if(r!==null){const l=n.get(r);l&&n.set(o.seq,l)}r=null}else if(r!==null&&o.type.startsWith("subagent_")){const l=o.type.replace("subagent_",""),c=o.metadata;n.get(r)?.push({eventType:l,content:o.content,metadata:c})}return t.map(o=>{if(o.type!=="tool")return o;const l=o.key;if(!l)return o;const c=l.replace(/^(?:t[se]_|e[se]_)/,""),d=parseInt(c,10);if(isNaN(d))return o;const m=n.get(d);return!m||m.length===0?o:{...o,info:{...o.info,subagentLogs:m}}})}function b4(e){const t=new Set;for(let n=0;n<e.length;n++){const r=e[n];if(r.type==="tool"&&(r.info.status==="done"||r.info.status==="error"))for(let o=n-1;o>=0;o--){const l=e[o];if(l.type==="tool"&&l.info.status==="running"&&l.info.tool===r.info.tool&&!t.has(o)){t.add(o);break}}}return e.filter((n,r)=>!t.has(r))}function F3(e){const t=AV(e.createdAt),n=e.createdAt,r=e.metadata;switch(e.type){case"text":return r?.isThinking?{type:"thinking",content:e.content,time:t,timestamp:n}:{type:"text",content:e.content,time:t,timestamp:n};case"status":{const o=r?.action;return o&&["chat","chat_stream","task_execution","respond_in_session"].includes(o)?null:{type:"status",content:e.content,time:t,timestamp:n}}case"error":return{type:"error",content:e.content,time:t,timestamp:n};case"tool_start":return{type:"tool",time:t,timestamp:n,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:r?.arguments,subagentLogs:r?.subagentLogs}};case"tool_end":return{type:"tool",time:t,timestamp:n,key:`ee_${e.seq}`,info:{tool:e.content,status:r?.success===!1?"error":"done",args:r?.arguments,result:r?.result,error:r?.error,durationMs:r?.durationMs,subagentLogs:r?.subagentLogs}};default:return null}}function q3(e,t){if(e!=="task_create"&&e!=="create_task"||!t)return null;try{const n=JSON.parse(t);if(!n.task)return null;const r=n.task;return{taskId:r.id,title:r.title,description:r.description,assignedAgentId:r.assignedAgentId,priority:r.priority}}catch{return null}}function G3(e,t){if(e!=="requirement_propose"||!t)return null;try{const n=JSON.parse(t);if(n.status!=="success"||!n.requirement)return null;const r=n.requirement;return r.status!=="pending"?null:{requirementId:r.id,title:r.title,description:r.description,priority:r.priority}}catch{return null}}const K3={code:s.jsxs(s.Fragment,{children:[s.jsx("polyline",{points:"16 18 22 12 16 6"}),s.jsx("polyline",{points:"8 6 2 12 8 18"})]}),search:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]}),clipboard:s.jsxs(s.Fragment,{children:[s.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),s.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"})]}),"check-circle":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"m9 12 2 2 4-4"})]}),server:s.jsxs(s.Fragment,{children:[s.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),s.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),"file-text":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),s.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),s.jsx("path",{d:"M10 9H8"}),s.jsx("path",{d:"M16 13H8"}),s.jsx("path",{d:"M16 17H8"})]}),"book-open":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 7v14"}),s.jsx("path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"})]}),users:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"9",cy:"7",r:"4"}),s.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),s.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"dollar-sign":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"}),s.jsx("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]}),megaphone:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m3 11 18-5v12L3 14v-3z"}),s.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]}),edit:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),headphones:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5a9 9 0 0 1 18 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"})}),settings:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),target:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("circle",{cx:"12",cy:"12",r:"6"}),s.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),zap:s.jsx(s.Fragment,{children:s.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),terminal:s.jsxs(s.Fragment,{children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]}),sparkles:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .962 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.962 0z"}),s.jsx("path",{d:"M20 3v4"}),s.jsx("path",{d:"M22 5h-4"})]}),wrench:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),globe:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),s.jsx("path",{d:"M2 12h20"})]}),link:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),bot:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 8V4H8"}),s.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),s.jsx("path",{d:"M2 14h2"}),s.jsx("path",{d:"M20 14h2"}),s.jsx("path",{d:"M15 13v2"}),s.jsx("path",{d:"M9 13v2"})]}),"message-square":s.jsx(s.Fragment,{children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),newspaper:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"}),s.jsx("path",{d:"M18 14h-8"}),s.jsx("path",{d:"M15 18h-5"}),s.jsx("path",{d:"M10 6h8v4h-8V6Z"})]}),layers:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"}),s.jsx("path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}),s.jsx("path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"})]}),"bar-chart":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),s.jsx("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),s.jsx("line",{x1:"6",x2:"6",y1:"20",y2:"16"})]}),folder:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}),"git-branch":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"18",r:"3"}),s.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),save:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),s.jsx("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),s.jsx("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]}),camera:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"}),s.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),clock:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),database:s.jsxs(s.Fragment,{children:[s.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),s.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),s.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]}),lightbulb:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}),s.jsx("path",{d:"M9 18h6"}),s.jsx("path",{d:"M10 22h4"})]}),"alert-circle":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),s.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),"square-terminal":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m7 11 2-2-2-2"}),s.jsx("path",{d:"M11 13h4"}),s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]}),package:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m7.5 4.27 9 5.15"}),s.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),s.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),s.jsx("path",{d:"M12 22V12"})]})};function _V(e){return!!e&&e in K3}function Yo({name:e,size:t=24,className:n=""}){const r=K3[e];return r?s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":!0,children:r}):null}const x4={"coding-tools":"terminal",markitdown:"file-text","markus-admin-cli":"terminal",codex:"code","team-building":"users","claude-code":"code","skill-building":"wrench","workflow-building":"layers","chrome-devtools":"globe","markus-hub-connector":"link","cursor-agent":"bot","agent-building":"bot","feishu-interaction":"message-square","content-publishing":"edit","research-report":"book-open","daily-digest":"newspaper"},y4={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Kd(e,t){const n=(e||"").toLowerCase();return x4[n]?x4[n]:t&&y4[t]?y4[t]:"layers"}function jV(e){const t=[];for(const n of e)if(n.phase!=="output"){if(n.phase==="start"){const r=`${n.tool}_${n.ts}`;t.push({key:r,tool:n.tool,status:"running"})}else for(let r=t.length-1;r>=0;r--)if(t[r].tool===n.tool&&t[r].status==="running"){t[r]={...t[r],status:n.success===!1?"error":"done"};break}}return t}function V3(){return s.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function MV(){return s.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>s.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function v4({item:e}){const{t}=ft("common"),n=Ai(e.tool);return s.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[s.jsx(Yo,{name:n.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),s.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[t(`execution.tools.${n.key}`,{defaultValue:n.label}),e.status==="running"?"…":""]}),e.status==="running"&&s.jsx(V3,{})]})}function RV({activities:e,isActive:t,persistent:n}){const{t:r}=ft("common"),o=jV(e),[l,c]=k.useState(!1),d=o.length>0,m=d&&o.every(w=>w.status!=="running");if(n&&m){const w=o.filter(T=>T.status==="error").length,C=o.filter(T=>T.status==="done").length;return s.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[s.jsxs("button",{onClick:()=>c(T=>!T),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[s.jsx("span",{className:`transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),s.jsx("span",{className:"font-medium",children:r("activity.step",{count:C})}),w>0&&s.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",r("activity.failed",{count:w})]}),!l&&s.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[o.slice(0,5).map(T=>{const S=Ai(T.tool);return s.jsx(Yo,{name:S.iconName,size:13,className:`shrink-0 ${T.status==="error"?"text-red-500":"text-green-500"}`},T.key)}),o.length>5&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",o.length-5]})]})]}),l&&s.jsx("div",{className:"mt-2 space-y-0.5",children:o.map((T,S)=>s.jsx(v4,{item:T,idx:S,total:o.length},T.key))})]})}if(!d)return s.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[s.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:r("activity.thinking")}),s.jsx(MV,{})]});const p=o.filter(w=>w.status==="error").length;let h=null;for(let w=o.length-1;w>=0;w--)if(o[w].status==="running"){h=o[w];break}const g=o[o.length-1];let x;if(h){const w=Ai(h.tool);x=`${r(`execution.tools.${w.key}`,{defaultValue:w.label})}…`}else if(t&&m)x=r("activity.writingResponse");else{const w=Ai(g.tool);x=r(`execution.tools.${w.key}`,{defaultValue:w.label})}const y=!!h||t&&m;return s.jsxs("div",{className:"mb-1",children:[s.jsxs("button",{onClick:w=>{w.stopPropagation(),c(C=>!C)},className:"flex items-center gap-1.5 text-xs w-full min-w-0 select-none text-fg-tertiary hover:text-fg-secondary transition-colors",children:[s.jsx("span",{className:`shrink-0 transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),s.jsx("span",{className:`truncate font-medium ${y?"activity-text-shimmer":"text-fg-secondary"}`,children:x}),s.jsxs("span",{className:"shrink-0",children:["· ",r("activity.step",{count:o.length})]}),p>0&&s.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",r("activity.failed",{count:p})]}),y&&s.jsx(V3,{})]}),l&&s.jsx("div",{className:"mt-1 space-y-0.5",children:o.map((w,C)=>s.jsx(v4,{item:w,idx:C,total:o.length},w.key))})]})}const OV={"claude-code":{label:"Claude Code",icon:"🤖",badgeClass:"bg-orange-500/15 text-orange-500"},codex:{label:"Codex",icon:"⬡",badgeClass:"bg-emerald-500/15 text-emerald-500"},"cursor-agent":{label:"Cursor",icon:"▶",badgeClass:"bg-blue-500/15 text-blue-500"}},Do=["created","context_injected","running"],LV=new Set(["completed","failed","cancelled","timeout"]),w4={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function DV(e){return OV[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function IV(e,t){if(e.cost?.durationMs!=null)return e.cost.durationMs;const n=e.startedAt??e.createdAt,r=new Date(n).getTime();if(!Number.isNaN(r)){if(e.completedAt){const o=new Date(e.completedAt).getTime();return Number.isNaN(o)?void 0:Math.max(0,o-r)}if(e.status==="running"||e.status==="context_injected")return Math.max(0,t-r)}}function PV(e){if(e==="completed"||LV.has(e))return Do.length;const t=Do.indexOf(e);return t>=0?t:0}function zV({session:e,className:t}){const n=DV(e.tool),[r,o]=k.useState(!1),[l,c]=k.useState(()=>Date.now()),d=e.status==="running"||e.status==="context_injected"||e.status==="created",m=e.status==="failed"||e.status==="timeout"||e.result?.success===!1,p=e.status==="completed"||e.result?.success===!0;k.useEffect(()=>{if(!d)return;const w=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(w)},[d]);const h=k.useMemo(()=>IV(e,l),[e,l]),g=PV(e.status),x=e.result?.rawOutput??(p||m?e.result?.summary:void 0),y=d?"border-brand-500/40 bg-brand-500/5":m?"border-red-500/30 bg-red-500/5":p?"border-green-500/30 bg-green-500/5":"border-border-default bg-surface-secondary/30";return s.jsxs("div",{className:`my-2 rounded-lg border ${y} p-3 max-w-2xl transition-colors ${t??""}`,children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-sm mt-0.5",children:n.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${n.badgeClass}`,children:n.label}),s.jsx("span",{className:`text-[10px] font-medium ${d?"text-brand-500":m?"text-red-500":p?"text-green-500":"text-fg-tertiary"}`,children:w4[e.status]??e.status}),h!=null&&s.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:$o(h)}),e.cost?.estimatedCostUsd!=null&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:["$",e.cost.estimatedCostUsd.toFixed(4)]})]}),s.jsx("div",{className:"text-xs text-fg-secondary mt-1 line-clamp-2",children:e.prompt})]}),d&&s.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0 mt-0.5",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),s.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-6",children:[Do.map((w,C)=>{const T=g>C||g===C&&!d&&p,S=g===C&&d,_=m&&C===Do.length-1&&e.status!=="completed";return s.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${_?"bg-red-500":T?"bg-green-500":S?"bg-brand-500 animate-pulse":"bg-gray-600"}`,title:w4[w]}),C<Do.length-1&&s.jsx("div",{className:`h-px flex-1 ${T?"bg-green-500/50":"bg-border-default/60"}`})]},w)}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${m?"bg-red-500":p?"bg-green-500":"bg-gray-600"}`,title:m?"Failed":"Done"})]}),(e.progressMessage||e.progressPercent!=null)&&d&&s.jsxs("div",{className:"mt-2 ml-6 space-y-1",children:[e.progressPercent!=null&&s.jsx("div",{className:"h-1 bg-surface-elevated rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-brand-500 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progressPercent))}%`}})}),e.progressMessage&&s.jsx("div",{className:"text-[11px] text-fg-tertiary font-mono truncate",children:e.progressMessage})]}),e.result&&!d&&s.jsxs("div",{className:"mt-2 ml-6 space-y-1.5",children:[e.result.summary&&s.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[s.jsxs("span",{className:"text-fg-tertiary",children:[e.result.diffStats.filesChanged," files"]}),s.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["−",e.result.diffStats.deletions]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null)&&s.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[e.cost.inputTokens!=null&&s.jsxs("span",{children:[e.cost.inputTokens.toLocaleString()," in"]}),e.cost.inputTokens!=null&&e.cost.outputTokens!=null&&s.jsx("span",{className:"mx-1",children:"·"}),e.cost.outputTokens!=null&&s.jsxs("span",{children:[e.cost.outputTokens.toLocaleString()," out"]})]})]}),x&&s.jsxs("div",{className:"mt-2 ml-6 border-t border-border-default/30 pt-2",children:[s.jsxs("button",{type:"button",onClick:()=>o(!r),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[s.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),s.jsx("span",{className:"font-medium uppercase tracking-wider",children:"Raw output"})]}),r&&s.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-48 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:x})]})]})}function BV({label:e}){const{t}=ft("common");return s.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[s.jsx("span",{className:"activity-text-shimmer",children:e??t("execution.thinking")}),s.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(n=>s.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${n}ms`,animationDuration:"1s"}},n))})]})}const k4=150;function $V({content:e,className:t}){const[n,r]=k.useState(e),o=k.useRef(0),l=k.useRef(null);k.useEffect(()=>{const d=Date.now(),m=d-o.current;return m>=k4?(o.current=d,r(e)):l.current||(l.current=setTimeout(()=>{o.current=Date.now(),l.current=null,r(e)},k4-m)),()=>{l.current&&(clearTimeout(l.current),l.current=null)}},[e]);const c=k.useMemo(()=>n,[n]);return s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[s.jsx(Er,{content:c,className:t??"text-sm text-fg-secondary break-words"}),s.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}const v0=8e3,Td=120;function eh({text:e,className:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),l=e.length>v0,c=!l||r?e:`${e.slice(0,v0)}
|
|
@@ -658,7 +658,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=Ke,rn=vt),Ht===void
|
|
|
658
658
|
`;return e.startsWith(r)?e.slice(r.length):e}function XY(e,t=12e4){if(e.length<2)return e;const n=[];for(const r of e){const o=n[n.length-1];if(r.sender==="user"&&o?.sender==="user"&&o.text===r.text&&o.text.length>0&&o.text.length<=500){const l=o.rawCreatedAt?Date.parse(o.rawCreatedAt):NaN,c=r.rawCreatedAt?Date.parse(r.rawCreatedAt):NaN;if(!Number.isFinite(l)||!Number.isFinite(c)||Math.abs(c-l)<=t)continue}n.push(r)}return n}function QY(e,t){const n=e.senderType==="system"||e.senderType==="agent"&&e.text.startsWith("⚠"),r=e.senderType==="human"&&(!t||e.senderId===t);let o=e.text;r&&e.replyToId&&e.replyToSender&&e.replyToText&&(o=Q3(o,e.replyToSender,e.replyToText));const l={id:e.id,sender:r?"user":"agent",text:o,time:new Date(e.createdAt).toLocaleTimeString(),rawCreatedAt:e.createdAt,agentName:r?void 0:e.senderName,agentId:r?void 0:e.senderId,isError:n,replyToId:e.replyToId,replyToSender:e.replyToSender,replyToText:e.replyToText},c=e.metadata;if(c?.images?.length&&(l.images=c.images),c&&e.senderType==="agent"){const d=[];if(c.thinking?.length&&d.push({type:"text",content:"",thinking:c.thinking.join(`
|
|
659
659
|
|
|
660
660
|
`)}),c.toolCalls?.length)for(let m=0;m<c.toolCalls.length;m++){const p=c.toolCalls[m];d.push({type:"tool",key:`${p.tool}_${m}`,tool:p.tool,status:p.status==="error"?"error":"done",args:p.arguments,result:p.result,durationMs:p.durationMs})}d.length>0&&(d.push({type:"text",content:e.text}),l.segments=d)}return l}function ZY(e,t,n){const r=t?new Date(t):new Date;if(isNaN(r.getTime()))return e;const o=new Date,l=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),c=r.getTime(),d=r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});return c>=l?d:c>=l-864e5?`${n?.yesterday??"Yesterday"} ${d}`:r.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+d}function JY(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function eX(e,t){const n=new Date(e);if(isNaN(n.getTime()))return"";const r=new Date,o=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),l=n.getTime();return l>=o?t?.today??"Today":l>=o-864e5?t?.yesterday??"Yesterday":n.toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function tX(e,t){let n=0,r=null;return((...o)=>{const l=Date.now(),c=t-(l-n);if(c<=0)return r&&(clearTimeout(r),r=null),n=l,e(...o);r||(r=setTimeout(()=>{n=Date.now(),r=null,e(...o)},c))})}function nX({priority:e}){const t=e==="high"||e==="critical";return s.jsxs("div",{className:`inline-flex items-center gap-1 mt-1.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${t?"bg-amber-500/10 text-amber-500 border border-amber-500/20":"bg-brand-500/10 text-brand-400 border border-brand-500/20"}`,children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),s.jsxs("span",{children:["Notification",e&&e!=="normal"?` · ${e}`:""]})]})}function rX({name:e,agentId:t,agents:n,onViewProfile:r}){const{t:o}=ft(["team","common"]),[l,c]=k.useState(!1),d=k.useRef(null),m=t?n.find(p=>p.id===t):n.find(p=>p.name===e);return k.useEffect(()=>{if(!l)return;const p=h=>{d.current&&!d.current.contains(h.target)&&c(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[l]),m?s.jsxs("span",{ref:d,className:"relative inline-block",children:[s.jsx("button",{onClick:()=>c(!l),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),l&&s.jsxs("div",{className:"absolute left-0 top-full mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-40 w-56 p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hs,{name:m.name,avatarUrl:m.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-600"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:m.name}),s.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[m.role," · ",m.agentRole??o("page.workerRole")]})]}),s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${m.status==="working"?"bg-blue-400 animate-pulse":m.status==="error"?"bg-red-400":"bg-green-400"}`})]}),s.jsx("button",{onClick:()=>{c(!1),r?.(m.id)},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:o("page.viewProfileArrow")})]})]}):s.jsx("span",{children:e})}function aX({agent:e,anchorRect:t,onClose:n,onViewProfile:r}){const{t:o}=ft(["common","team"]),l=k.useRef(null);k.useEffect(()=>{const p=h=>{l.current&&!l.current.contains(h.target)&&n()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[n]);const c=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",d=e.status==="idle"?o("common:status.online"):e.status==="working"?o("common:status.working"):e.status==="error"?o("common:status.error"):o("common:status.offline"),m=k.useCallback(p=>{if(!p)return;l.current=p;const h=p.getBoundingClientRect(),g=window.innerWidth,x=window.innerHeight,y=8;h.right>g-y&&(p.style.left=`${Math.max(y,g-h.width-y)}px`),h.left<y&&(p.style.left=`${y}px`),h.bottom>x-y&&(p.style.top=`${Math.max(y,x-h.height-y)}px`)},[]);return s.jsxs("div",{ref:m,className:"fixed z-50 w-64 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:t.top+40,left:t.left},children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Hs,{name:e.name,avatarUrl:e.avatarUrl,size:40,bgClass:"bg-brand-500/15 text-brand-600"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c}`}),s.jsx("span",{className:"text-[10px] text-fg-secondary",children:d}),e.agentRole&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),s.jsx("button",{onClick:()=>{n(),r(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:o("team:page.viewProfileArrow")})]})}function rW(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const Z3="markus:credit-notif-muted";let E4=0;function sX(){try{if(localStorage.getItem(Z3))return}catch{}const e=Date.now();e-E4<5*6e4||(E4=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function aW(){try{localStorage.setItem(Z3,"1")}catch{}}function iX(e,t){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let r="";const o=n.match(/\{[\s\S]*\}/);if(o)try{const d=JSON.parse(o[0]);r=d.error?.message??d.message??""}catch{}if(!r){const d=n.lastIndexOf(": ");d>=0&&(r=n.slice(d+2).trim())}const l=(d,m)=>t(`team:errors.${d}`,m);if(n.includes("MARKUS_UPSTREAM_ERROR"))return l("aiUpstreamBillingMismatch",{detail:r||l("defaultUpstreamBillingMismatch")});if(rW(n)||n.includes("CU_EXCEEDED"))return l("markusCuExceeded");if(n.includes("CU_WINDOW_EXCEEDED"))return l("markusWindowExceeded");if(n.includes("MARKUS_RATE_LIMITED"))return l("markusRateLimited");if(/not available in your region/i.test(n))return l("aiRegionBlocked",{model:(n.match(/\[(?:markus|openrouter):([^\]]+)\]/i)?.[1]||"").trim()||"—"});if(n.includes("401")||/unauthorized|invalid.?api.?key/i.test(n))return l("ai401",{detail:r||l("defaultInvalidApiKey")});if(n.includes("429")||/rate.?limit/i.test(n))return l("ai429",{detail:r||l("defaultTooManyRequests")});if(/\b409\b/.test(n)||/conflict/i.test(n))return l("ai409",{detail:r||l("defaultConflict")});if(n.includes("502")||/bad.?gateway/i.test(n))return l("ai502",{detail:r||l("defaultUpstreamDown")});if(n.includes("503")||/service.?unavailable/i.test(n))return l("ai503",{detail:r||l("defaultServiceDown")});const c=(r||n).replace(/https?:\/\/[^\s]*openrouter\.ai[^\s]*/gi,"").trim();return l("aiGeneric",{detail:(c||n).slice(0,120)})}function oX({msg:e,onCopy:t,onRetry:n,onResume:r,onReply:o,onRemember:l,isCopied:c,isLastAgentMsg:d,showRemember:m}){const{t:p}=ft(["team","common"]),h=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),g=e.isStopped,x=!!e.emptyReply||e.sender==="agent"&&!e.text?.trim()&&!e.segments?.some(C=>C.type==="text"&&(C.content||C.thinking)||C.type==="tool"),y=d!==!1,w=QV(m,e.sender)&&!!l;return s.jsxs("div",{className:"flex items-center flex-wrap gap-0.5 mt-1",children:[s.jsxs("button",{onClick:()=>t(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:p("common:copy"),children:[c?s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}):s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),p(c?"common:copied":"common:copy")]}),y&&r&&s.jsxs("button",{onClick:()=>r(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-green-500 hover:text-green-400 hover:bg-green-500/10 transition-colors",title:p("page.messageActions.resumeTitle"),children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),p("page.messageActions.resumeTitle")]}),y&&g&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-brand-500 hover:text-brand-500 hover:bg-brand-500/10 transition-colors",title:p("page.messageActions.reaskTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),p("page.messageActions.reaskTitle")]}),y&&(h||x)&&!g&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-amber-600 hover:text-amber-600 hover:bg-amber-500/10 transition-colors",title:p("page.messageActions.retryTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),p("page.messageActions.retryTitle")]}),y&&!h&&!x&&!g&&e.sender==="agent"&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:p("page.messageActions.retryTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),p("page.messageActions.retryTitle")]}),o&&s.jsxs("button",{onClick:()=>o(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:p("page.messageActions.replyTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"9 17 4 12 9 7"}),s.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),p("page.messageActions.replyTitle")]}),w&&s.jsxs("button",{type:"button",onClick:()=>l(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:p("page.messageActions.rememberTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a7 7 0 00-4 12.7V19a1 1 0 001 1h6a1 1 0 001-1v-4.3A7 7 0 0012 2z"}),s.jsx("path",{d:"M9 22h6"})]}),p("page.messageActions.rememberTitle")]}),e.sender==="agent"&&s.jsx("span",{className:"ml-1 px-1 text-[10px] leading-none text-fg-tertiary/70 select-none whitespace-nowrap",children:p("page.messageActions.aiGeneratedDisclaimer")})]})}function lX({busy:e,onConfirm:t,onCancel:n}){const{t:r}=ft(["team","common"]),[o,l]=k.useState("");return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:c=>c.stopPropagation(),children:[s.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:r("page.messageActions.rememberModalTitle")}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",children:r("page.messageActions.rememberModalHint")}),s.jsx("textarea",{value:o,onChange:c=>l(c.target.value),placeholder:r("page.messageActions.rememberModalPlaceholder"),rows:3,disabled:e,className:"mt-3 w-full px-3 py-2 text-sm bg-surface-primary border border-border-default rounded-lg outline-none focus:border-brand-500/50 resize-y min-h-[72px]"}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.jsx("button",{type:"button",onClick:n,disabled:e,className:"px-4 py-1.5 text-sm text-fg-secondary hover:text-fg-primary rounded-lg transition-colors",children:r("page.messageActions.rememberCancel")}),s.jsx("button",{type:"button",onClick:()=>t(o),disabled:e,className:"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-60 text-white rounded-lg transition-colors",children:e?r("common:loading",{defaultValue:"…"}):r("page.messageActions.rememberConfirm")})]})]})}),document.body)}function _4(e,t,n){if(!e)return[];const r=[];let o=0;const l=t??"";let d=n?new Date(n).getTime():Date.now();const m=e.some(j=>j.createdAt),p=j=>{if(j.createdAt)return j.createdAt;if(m)return new Date(d).toISOString();const O=new Date(d).toISOString();return j.type==="tool"&&j.durationMs?d+=j.durationMs:d+=1e3,O};let h=!1,g="",x="",y="";const w=()=>{const j=g.trim();j&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:j,createdAt:y,metadata:{isThinking:!0}}),g=""},C=()=>{const j=x.trim();j&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:j,createdAt:y}),x=""},T="<think>",S="</think>",_=j=>{let O=0;for(;O<j.length;)if(h){const P=j.indexOf(S,O);P===-1?(g+=j.slice(O),O=j.length):(g+=j.slice(O,P),h=!1,w(),O=P+S.length)}else{const P=j.indexOf(T,O);P===-1?(x+=j.slice(O),O=j.length):(x+=j.slice(O,P),C(),h=!0,O=P+T.length)}};for(const j of e)if(y=p(j),j.type==="tool"){h||C();const O=j.createdAt&&j.durationMs?new Date(new Date(j.createdAt).getTime()-j.durationMs).toISOString():y;r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_start",content:j.tool,metadata:{arguments:j.args,...j.status==="running"&&j.subagentLogs?.length?{subagentLogs:j.subagentLogs}:{}},createdAt:O}),j.status!=="running"&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_end",content:j.tool,metadata:{arguments:j.args,result:j.result,error:j.error,durationMs:j.durationMs,success:j.status!=="error",...j.subagentLogs?.length?{subagentLogs:j.subagentLogs}:{}},createdAt:y})}else j.thinking&&(h||C(),g+=j.thinking,w()),_(Yg(j.content).cleaned);return h?w():C(),r}const cX=k.memo(function({msg:t,isStreaming:n,liveActivities:r,onMentionClick:o,knownNames:l}){const{t:c}=ft(["team","common"]),d=t.segments,m=t.isStopped,p=j=>j.type==="text"?j.content.length+(j.thinking?.length??0):(j.result?.length??0)+(j.subagentLogs?.length??0)*1e3+(j.liveOutput?.length??0),h=d?d.length+":"+(d.length>0?p(d[d.length-1]):0):"",g=d?d.reduce((j,O)=>j+(O.type==="tool"?O.subagentLogs?.length??0:0),0):0,x=k.useMemo(()=>d&&d.length>0?_4(d,t.agentId,t.rawCreatedAt):[],[h,g,t.agentId,t.rawCreatedAt]),y=t.committedSegments,w=y?y.length+":"+(y.length>0?p(y[y.length-1]):0):"",C=y?y.reduce((j,O)=>j+(O.type==="tool"?O.subagentLogs?.length??0:0),0):0,T=k.useMemo(()=>n?x:y&&y.length>0?_4(y,t.agentId,t.rawCreatedAt):x,[n,w,C,t.agentId,t.rawCreatedAt,x]);if(d!==void 0&&d.length>0){const j=d.some(z=>z.type==="tool"),O=d.filter(z=>z.type==="text"),P=n?null:O.map(z=>z.content).join(""),L=z=>z.replace(/\n*<!--\s*notify_context:\s*[\s\S]*?-->/g,"").replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim()||null,V=(P?L(P):null)||(!n&&t.text?L(t.text):null),X=[];for(const z of d){if(z.type!=="tool")continue;const G=q3(z.tool,z.result);if(G){X.push({key:`task-${G.taskId}`,kind:"task",info:G});continue}const ae=G3(z.tool,z.result);ae&&X.push({key:`req-${ae.requirementId}`,kind:"req",info:ae})}return s.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[j||n?s.jsx(XV,{entries:T,isActive:n,embedded:!0,hideApprovalCards:!0}):V&&s.jsx(Er,{content:V,onMentionClick:o,knownNames:l}),X.map(z=>z.kind==="task"?s.jsx(Y3,{info:z.info},z.key):s.jsx(X3,{info:z.info},z.key)),!n&&!V&&!j&&X.length===0&&!m&&(t.emptyReply||!t.isError)&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:c("page.emptyReply")})}),!n&&(t.isError||t.text.startsWith("⚠"))&&t.text&&!d?.some(z=>z.type==="text"&&z.content&&(z.content===t.text||z.content.startsWith("⚠")))&&s.jsx("p",{className:"mt-1.5 text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:t.text.replace(/^⚠\s*/,"")}),m&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),s.jsx("span",{children:c("page.stopped")})]})]})}const S=(t.activities?.length??0)>0,_=t.text?t.text.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim():"";return s.jsxs(s.Fragment,{children:[(n||S)&&s.jsx(RV,{activities:n?r:t.activities??[],isActive:n,persistent:!n&&S}),_?t.isError||_.startsWith("⚠")?s.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:_.replace(/^⚠\s*/,"")}):s.jsx(Er,{content:_,onMentionClick:o,knownNames:l}):null,!n&&!_&&!S&&!m&&t.sender==="agent"&&(t.emptyReply||!t.isError)&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:c("page.emptyReply")})}),m&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),s.jsx("span",{children:c("page.stopped")})]})]})});function sW(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 iW({approval:e,submitting:t,readOnly:n,onClose:r,onSubmit:o}){const{t:l}=ft(["team","common"]);Ho(!0);const c=k.useMemo(()=>sW(e),[e]),[d,m]=k.useState(0),[p,h]=k.useState(()=>{if(n&&e.answers&&e.answers.length>0){const P={};for(const L of e.answers)P[L.questionId]={selectedOptionIds:L.selectedOptionIds??[],text:L.text??""};return P}return{}}),g=c[d],x=d===c.length-1,y=c.length>1,w=P=>p[P]??{selectedOptionIds:[],text:""},C=(P,L)=>{h(F=>({...F,[P]:{...w(P),...L}}))},T=(P,L)=>{const F=w(P.id);if(P.allowMultiple){const V=F.selectedOptionIds.includes(L);C(P.id,{selectedOptionIds:V?F.selectedOptionIds.filter(X=>X!==L):[...F.selectedOptionIds,L],text:V?F.text:""})}else{const V=F.selectedOptionIds.includes(L);C(P.id,{selectedOptionIds:V?[]:[L],text:V?F.text:""})}},S=P=>{const L=w(P.id);return P.inputType==="choice"?L.selectedOptionIds.length>0?!0:!!(P.allowFreeform&&L.text.trim()):L.text.trim().length>0},_=c.every(S),j=()=>c.map(P=>{const L=w(P.id),F={questionId:P.id};return L.selectedOptionIds.length>0&&(F.selectedOptionIds=L.selectedOptionIds),L.text.trim()&&(F.text=L.text.trim()),F}),O=()=>{const P=j();let L=!0,F;if(!e.questions?.length&&e.options?.length){const X=P[0];F=X?.selectedOptionIds?.[0]??(X?.text?"custom":void 0),L=F!=="reject"&&F!=="request_changes"}const V=P.map(X=>X.text).filter(Boolean).join(`
|
|
661
|
-
`)||void 0;o({approved:L,comment:V,selectedOption:F,answers:P})};return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:P=>{P.target===P.currentTarget&&r()},children:s.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[s.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),s.jsx("path",{d:"M12 8v4"}),s.jsx("path",{d:"M12 16h.01"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),s.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:l("common:close"),children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&s.jsx("div",{className:"flex items-center gap-2",children:c.map((P,L)=>s.jsx("button",{onClick:()=>m(L),className:`h-1.5 flex-1 rounded-full transition-colors ${L===d?"bg-brand-500":S(P)?"bg-green-500/60":"bg-border-default"}`,title:`${L+1}. ${P.prompt.slice(0,40)}`},P.id))}),y&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:c.length,defaultValue:`Question ${d+1} of ${c.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Er,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((P,L)=>{const F=w(g.id).selectedOptionIds.includes(P.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,P.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${F?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!F?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${F?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:F?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+L)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Er,{content:P.label}),P.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Er,{content:P.description})})]})]},P.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&s.jsx("textarea",{rows:g.inputType==="text"?4:2,readOnly:n,placeholder:g.inputType==="text"?l("team:userInput.textPlaceholder",{defaultValue:"Type your answer…"}):l("team:userInput.freeformPlaceholder",{defaultValue:"Or write your own answer…"}),value:w(g.id).text,onChange:P=>{const L=P.target.value;C(g.id,{text:L,selectedOptionIds:L.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:y&&d>0&&s.jsx("button",{onClick:()=>m(P=>Math.max(0,P-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("team:userInput.previous",{defaultValue:"Previous"})})}),s.jsx("div",{className:"flex items-center gap-2",children:y&&!x?s.jsx("button",{disabled:!n&&!S(g),onClick:()=>m(P=>Math.min(c.length-1,P+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:l("team:userInput.next",{defaultValue:"Next"})}):n?s.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("common:close",{defaultValue:"Close"})}):s.jsxs("button",{disabled:t||!_,onClick:O,className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[t&&s.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l("team:userInput.submit",{defaultValue:"Submit"})]})})]})]})}),document.body)}function Ad(e){return Array.isArray(e.questions)&&e.questions.length>0}const Ed={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},To={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},j4={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function Ao(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}const M4="markus:template-updates-ack";let th=!1,_d=null;function oW(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function R4(e,t){if(e.type!=="system"||!e.metadata?.templateUpdates)return!1;if(!t)return!0;const n=e.metadata.templateUpdatesFingerprint;return!n||n===t}function jd(e,t){const n=e.actionType;if(n==="open_chat")return t("team:notifications.actionHints.openChat");if(n==="navigate")return t("team:notifications.actionHints.viewDetails");const r=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return r.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return r.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return r.agentId?t("team:notifications.actionHints.viewAgent"):null;case"direct_message":return t("team:notifications.actionHints.openChat");case"group_message":return t("team:notifications.actionHints.openChat");case"approval_request":return t("team:notifications.actionHints.viewApproval");case"system":return r.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return r.taskId?t("team:notifications.actionHints.viewTask"):r.requirementId?t("team:notifications.actionHints.viewRequirement"):r.agentId?t("team:notifications.actionHints.viewAgent"):null}}function nh(){try{const e=new AudioContext,t=e.currentTime,n=e.createGain();n.connect(e.destination),n.gain.setValueAtTime(.15,t),n.gain.exponentialRampToValueAtTime(.01,t+.6);const r=e.createOscillator();r.type="sine",r.frequency.setValueAtTime(880,t),r.frequency.setValueAtTime(1174.66,t+.15),r.connect(n),r.start(t),r.stop(t+.6),r.onended=()=>e.close()}catch{}}function lW({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:c,iconPath:d}){const{t:m}=ft(["team","common"]),[p,h]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[C,T]=k.useState([]),[S,_]=k.useState(null),[j,O]=k.useState(null),[P,L]=k.useState(null),[F,V]=k.useState({}),[X,z]=k.useState(0),G=k.useRef(null),ae=k.useRef(null),[Z,q]=k.useState({top:0,left:0,width:448,maxHeight:576}),te=k.useRef(null),U=k.useRef(!1),[Q,me]=k.useState(!0),[Ce,H]=k.useState(!1),W=k.useRef(null),fe=k.useRef("approvals"),[I,Re]=k.useState(!1),Be=30,Pe=k.useCallback(async()=>{try{Ya("/approvals"),Ya("/notifications");const[R,ie]=await Promise.all([Me.notifications.list(t,!1,{limit:Be,offset:0}),Me.approvals.list()]);w(R.notifications);const Le=R.unreadCount??R.notifications.filter(xe=>!xe.read).length;if(z(Le),me(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=Be),T(ie.approvals),!U.current){const xe=ie.approvals.filter(Ge=>Ge.status==="pending").length;te.current=xe,U.current=!0}}catch{}},[t]),Fe=k.useCallback(async()=>{if(!(Ce||!Q)){H(!0);try{const R=await Me.notifications.list(t,!1,{limit:Be,offset:y.length});R.notifications.length>0&&w(ie=>[...ie,...R.notifications.filter(Le=>!ie.some(xe=>xe.id===Le.id))]),me(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=Be)}catch{}H(!1)}},[t,y.length,Ce,Q]),dt=k.useCallback(R=>{const ie=R.detail;if(!ie)return;const{taskId:Le,requirementId:xe}=ie;!Le&&!xe||w(Ge=>{const Qe=Ge.filter(K=>!K.read&&(Le&&K.metadata?.taskId===Le||xe&&K.metadata?.requirementId===xe));if(Qe.length===0)return Ge;for(const K of Qe)Me.notifications.markRead(K.id).catch(()=>{});return z(K=>Math.max(0,K-Qe.length)),Ge.map(K=>Qe.some(le=>le.id===K.id)?{...K,read:!0}:K)})},[]),mt=k.useRef(y);mt.current=y;const Nt=k.useCallback(async()=>{if(!mt.current.some(ie=>!ie.read&&ie.type==="system"&&ie.metadata?.creditExhausted))try{await Me.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),Pe(),nh()}catch{}},[Pe,m]),Ot=k.useCallback(async()=>{if(!th){th=!0;try{const{updates:R}=await Me.skills.updates();if(!R.length)return;const ie=oW(R);try{if(localStorage.getItem(M4)===ie)return}catch{}if(_d===ie||mt.current.some(xe=>!xe.read&&R4(xe,ie)))return;try{const Ge=(await Me.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(Qe=>R4(Qe,ie)).sort((Qe,K)=>new Date(K.createdAt).getTime()-new Date(Qe.createdAt).getTime());if(Ge.length>0){for(const Qe of Ge.slice(1))Me.notifications.markRead(Qe.id).catch(()=>{});Ge.length>1&&Pe(),_d=ie;return}}catch{}_d=ie,await Me.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:R.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:ie,count:R.length,skills:R.map(xe=>xe.name)}}),Pe(),nh()}catch{_d=null}finally{th=!1}}},[Pe,m,t]);k.useEffect(()=>{Pe();const R=setInterval(Pe,6e4);let ie=null;const Le=()=>{ie||(ie=setTimeout(()=>{ie=null,Pe()},400))},xe=()=>Le(),Ge=()=>{h(!0),Pe()};window.addEventListener("markus:notifications-changed",xe),window.addEventListener("markus:mark-read-by-ref",dt),window.addEventListener("markus:open-notifications",Ge),window.addEventListener("markus:credit-exhausted",Nt);const Qe=va.on("notification",Le),K=va.on("approval:requested",Le);return()=>{clearInterval(R),ie&&clearTimeout(ie),window.removeEventListener("markus:notifications-changed",xe),window.removeEventListener("markus:mark-read-by-ref",dt),window.removeEventListener("markus:open-notifications",Ge),window.removeEventListener("markus:credit-exhausted",Nt),Qe(),K()}},[Pe,dt,Nt]),k.useEffect(()=>{Ot();const R=setInterval(()=>{Ot()},5*6e4),ie=()=>{Ot()};return window.addEventListener("markus:data-changed",ie),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",ie)}},[t]);const At=k.useCallback(()=>{if(!G.current)return;const R=G.current.getBoundingClientRect(),ie=window.innerWidth,Le=window.innerHeight,xe=Math.min(448,ie-16),Ge=Math.min(576,Le-16);let Qe=R.right+8,K=R.top;Qe+xe>ie-8&&(Qe=Math.max(8,ie-xe-8)),K+Ge>Le-8&&(K=Math.max(8,Le-Ge-8)),q({top:K,left:Qe,width:xe,maxHeight:Ge})},[]);k.useLayoutEffect(()=>{p&&At()},[p,At]),k.useEffect(()=>{if(p)return window.addEventListener("resize",At),()=>window.removeEventListener("resize",At)},[p,At]),k.useEffect(()=>{if(!p)return;const R=ie=>{G.current?.contains(ie.target)||ae.current?.contains(ie.target)||h(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[p]),k.useEffect(()=>{if(!p)return;const R=C.some(Le=>Le.status==="pending"),ie=y.some(Le=>!Le.read);x(R&&!ie?"approvals":!R&&ie?"notifications":fe.current)},[p]);const qt=new Set(C.filter(R=>R.status==="pending").map(R=>R.id)),jt=new Set(C.map(R=>R.id)),$e=y.filter(R=>!(R.type==="approval_request"&&R.metadata?.approvalId&&jt.has(R.metadata.approvalId))),ut=y.filter(R=>R.type==="approval_request"&&!R.read&&R.metadata?.approvalId&&qt.has(R.metadata.approvalId)).length,kt=Math.max(0,X-ut),xt=qt.size,Ct=kt+xt;k.useEffect(()=>{te.current!==null&&xt>te.current&&nh(),te.current=xt},[xt]);const ce=async R=>{await Me.notifications.markRead(R),w(ie=>ie.map(Le=>Le.id===R?{...Le,read:!0}:Le)),z(ie=>Math.max(0,ie-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},rt=R=>{const ie=R.metadata??{},Le=R.actionType,xe=R.actionTarget;if(Le==="open_chat"&&xe)try{const Ge=typeof xe=="string"?JSON.parse(xe):xe;if(Ge.agentId){const Qe={agentId:Ge.agentId};Ge.sessionId&&(Qe.sessionId=Ge.sessionId),it.navigate(ue.TEAM,Qe);return}}catch{}if(Le==="navigate"&&xe)try{const Ge=typeof xe=="string"?JSON.parse(xe):xe;if(Ge.path){if(Ge.path.startsWith("/team")){const Qe={},K=new URLSearchParams(Ge.path.split("?")[1]||"");for(const[le,je]of K.entries())Qe[le]=je;it.navigate(ue.TEAM,Qe);return}if(Ge.path.startsWith("/work")){const Qe={},K=new URLSearchParams(Ge.path.split("?")[1]||"");for(const[le,je]of K.entries())Qe[le]=je;it.navigate(ue.WORK,Qe);return}}}catch{}switch(R.type){case"approval_request":{const Ge=ie.approvalId,Qe=Ge?C.find(Ue=>Ue.id===Ge):void 0;if(Qe&&Ad(Qe)){O(Qe);break}const K=Qe?.details?.taskId??ie.taskId,le=Qe?.details?.requirementId??ie.requirementId,je=Qe?.details?.agentId??Qe?.agentId;K?it.navigate(ue.WORK,{openTask:K}):le?it.navigate(ue.WORK,{openRequirement:le}):je?it.navigate(ue.TEAM,{agentId:je}):it.navigate(ue.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":ie.taskId?it.navigate(ue.WORK,{openTask:ie.taskId}):it.navigate(ue.WORK);break;case"requirement_created":case"requirement_decision":ie.requirementId?it.navigate(ue.WORK,{openRequirement:ie.requirementId}):it.navigate(ue.WORK);break;case"agent_report":case"system":{if(ie.creditExhausted){Re(!0);return}if(ie.templateUpdates){const Ge=ie.templateUpdatesFingerprint;if(Ge)try{localStorage.setItem(M4,Ge)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),it.navigate(ue.STORE);return}if(ie.agentId){const Ge={agentId:ie.agentId};ie.sessionId&&(Ge.sessionId=ie.sessionId),it.navigate(ue.TEAM,Ge)}else it.navigate(ue.TEAM);break}case"direct_message":{const Ge=ie.senderId;Ge?it.navigate(ue.TEAM,{dm:Ge}):it.navigate(ue.TEAM);break}case"group_message":{const Ge=ie.channel;Ge?it.navigate(ue.TEAM,{channel:Ge}):it.navigate(ue.TEAM);break}default:ie.taskId?it.navigate(ue.WORK,{openTask:ie.taskId}):ie.requirementId?it.navigate(ue.WORK,{openRequirement:ie.requirementId}):ie.projectId?it.navigate(ue.WORK,{projectId:ie.projectId}):ie.agentId&&it.navigate(ue.TEAM,{agentId:ie.agentId});break}},at=async R=>{const ie=R.metadata??{},Le=R.actionType,xe=R.type==="agent_report"&&!ie.creditExhausted&&!ie.templateUpdates&&(Le==="open_chat"||!!ie.agentId&&Le!=="navigate");!R.read&&!xe&&ce(R.id);const Ge=ie.taskId,Qe=ie.requirementId;if(!xe&&(Ge||Qe)){const K=y.filter(le=>le.id!==R.id&&!le.read&&(Ge&&le.metadata?.taskId===Ge||Qe&&le.metadata?.requirementId===Qe));for(const le of K)ce(le.id)}rt(R)},ve=async(R,ie,Le,xe,Ge)=>{_(R);try{const{approval:Qe}=await Me.approvals.respond(R,ie,t,Le,xe,Ge);T(Ue=>Ue.map(tt=>tt.id===R?Qe:tt)),O(null),L(null),V(Ue=>{const tt={...Ue};return delete tt[R],tt});const K=Qe.details?.taskId,le=Qe.details?.requirementId,je=y.filter(Ue=>!Ue.read&&(Ue.type==="approval_request"&&Ue.metadata?.approvalId===R||K&&Ue.metadata?.taskId===K||le&&Ue.metadata?.requirementId===le));if(je.length>0){for(const tt of je)Me.notifications.markRead(tt.id).catch(()=>{});const Ue=new Set(je.map(tt=>tt.id));w(tt=>tt.map(yt=>Ue.has(yt.id)?{...yt,read:!0}:yt)),z(tt=>Math.max(0,tt-je.length))}Ya("/approvals"),Ya("/notifications"),Ya("/tasks"),Ya("/taskboard"),Ya("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Pe(),800)}catch{}_(null)},_e=async()=>{try{if(!t)return;await Me.notifications.markAllRead(t),w(R=>R.map(ie=>({...ie,read:!0}))),z(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const R=$e.filter(ie=>!ie.read);await Promise.all(R.map(ie=>Me.notifications.markRead(ie.id))),w(ie=>ie.map(Le=>({...Le,read:!0}))),z(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ee=R=>{const ie=R.details?.subType;return ie==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):ie==="requirement"||R.details?.requirementId?m("team:notifications.approvalType.requirement"):ie==="task_review"?m("team:notifications.approvalType.taskReview"):ie==="task"||R.details?.taskId?m("team:notifications.approvalType.task"):R.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},oe=R=>{const ie=[];ie.push(R.agentName);const Le=R.details?.taskTitle,xe=R.details?.taskId;Le?ie.push(Le):xe&&ie.push(`Task ${xe.slice(0,8)}`);const Ge=R.details?.requirementId;return Ge&&!xe&&ie.push(`Req ${Ge.slice(0,8)}`),ie.join(" · ")},$=[...C].sort((R,ie)=>new Date(ie.requestedAt).getTime()-new Date(R.requestedAt).getTime()),J=$.filter(R=>R.status==="pending"),Te=$.filter(R=>R.status!=="pending"),ne=R=>{const ie=R.details?.taskId,Le=R.details?.requirementId,xe=R.details?.agentId??R.agentId;ie?it.navigate(ue.WORK,{openTask:ie}):Le?it.navigate(ue.WORK,{openRequirement:Le}):xe?it.navigate(ue.TEAM,{agentId:xe}):it.navigate(ue.WORK)},he=()=>{h(!1),r?.()},be=R=>s.jsxs("button",{disabled:S===R.id,onClick:()=>O(R),className:"w-full px-3 py-2 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center justify-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),m("team:userInput.respond",{defaultValue:"Respond"}),R.questions&&R.questions.length>1?` (${R.questions.length})`:""]}),ge=j?s.jsx(iW,{approval:j,submitting:S===j.id,readOnly:j.status!=="pending",onClose:()=>O(null),onSubmit:R=>ve(j.id,R.approved,R.comment,R.selectedOption,R.answers)}):null,Se=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{x("approvals"),fe.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"),xt>0?` (${xt})`:""]}),s.jsxs("button",{onClick:()=>{x("notifications"),fe.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),kt>0?` (${kt})`:""]}),s.jsx("button",{onClick:he,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&X>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:_e,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:W,className:"flex-1 overflow-y-auto",onScroll:R=>{if(g!=="notifications"||!Q||Ce)return;const ie=R.currentTarget;ie.scrollTop+ie.clientHeight>=ie.scrollHeight-80&&Fe()},children:[g==="approvals"&&(C.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[J.map(R=>{const ie=R.details?.command,Le=ie?R.description.replace(/\s*Command:.*$/,""):R.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>ne(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:To.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ee(R)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ee(R)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ao(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Le,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),ie&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:ie})]}),(()=>{if(Ad(R))return be(R);const xe=R.details?.subType,Ge=xe==="task"||xe==="requirement"||xe==="requirement_resubmit",Qe=R.options&&R.options.length>0,K=(F[R.id]??"").trim();return Qe?s.jsxs("div",{className:"space-y-1.5",children:[R.options.map((le,je)=>s.jsxs("button",{disabled:S===R.id,onClick:()=>ve(R.id,le.id!=="reject",K||void 0,le.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${le.id==="reject"||le.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:le.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+je)}),le.label]},le.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:F[R.id]??"",onChange:le=>V(je=>({...je,[R.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&(F[R.id]??"").trim()&&ve(R.id,!0,(F[R.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===R.id||!(F[R.id]??"").trim(),onClick:()=>ve(R.id,!0,(F[R.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")})]})]}):Ge?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===R.id,onClick:()=>ve(R.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:S===R.id,onClick:()=>ve(R.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==R.id&&s.jsxs("button",{disabled:S===R.id,onClick:()=>L(R.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),P===R.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:F[R.id]??"",onChange:le=>V(je=>({...je,[R.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&(F[R.id]??"").trim()&&ve(R.id,!1,(F[R.id]??"").trim(),"needs_adjustment"),le.key==="Escape"&&L(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===R.id||!(F[R.id]??"").trim(),onClick:()=>ve(R.id,!1,(F[R.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>L(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:F[R.id]??"",onChange:le=>V(je=>({...je,[R.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&ve(R.id,!0,K||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===R.id,onClick:()=>ve(R.id,!0,K||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:S===R.id,onClick:()=>ve(R.id,!1,K||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},R.id)}),Te.length>0&&s.jsxs(s.Fragment,{children:[J.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Te.slice(0,50).map(R=>s.jsxs("button",{onClick:()=>Ad(R)?O(R):ne(R),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${R.status==="approved"?"bg-green-500":R.status==="cancelled"||R.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ee(R)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ee(R)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:R.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${R.status==="approved"?"text-green-500":R.status==="cancelled"||R.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${R.status}`,{defaultValue:R.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:oe(R)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ao(R.respondedAt??R.requestedAt,m)})]}),R.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",R.responseComment,"”"]})]},R.id))]})]})),g==="notifications"&&($e.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[$e.map(R=>{const ie=j4[R.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>at(R),onKeyDown:Le=>{(Le.key==="Enter"||Le.key===" ")&&(Le.preventDefault(),at(R))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${R.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:ie,children:s.jsx("path",{d:To[R.type]??To.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!R.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[R.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:Ao(R.createdAt,m)}),jd(R,m)&&s.jsx("span",{className:`text-[10px] font-medium ${ie}`,children:jd(R,m)})]})]})]},R.id)}),Ce&&s.jsx("div",{className:"py-3 text-center",children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),st=k.useCallback(R=>{R?.mute&&aW()},[]),Ve=k.useCallback(R=>{st(R),Re(!1)},[st]),Je=I?s.jsx(dr,{title:m("credits.dialogTitle",{ns:"common"}),message:m("credits.dialogDesc",{ns:"common"}),variant:"primary",cancelLabel:m("credits.configureModels",{ns:"common"}),confirmLabel:m("credits.topUp",{ns:"common"}),checkboxes:[{id:"mute",label:m("credits.dontRemind",{ns:"common"})}],onCancel:()=>Re(!1),onCancelClick:R=>{Ve(R),it.navigate(ue.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:R=>{const ie=`${lt.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Ve(R),_i(ie)}}):null;if(n){const R=["approvals","notifications"],ie=R.indexOf(g),Le=(()=>{let xe=0,Ge=0;return{onTouchStart:Qe=>{xe=Qe.touches[0].clientX,Ge=Qe.touches[0].clientY},onTouchEnd:Qe=>{const K=Qe.changedTouches[0].clientX-xe,le=Qe.changedTouches[0].clientY-Ge;Math.abs(K)>60&&Math.abs(K)>Math.abs(le)*1.5&&(K<0&&ie<R.length-1&&x(R[ie+1]),K>0&&ie>0&&x(R[ie-1]))}}})();return s.jsxs(s.Fragment,{children:[Je,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[ge,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:R.map(xe=>s.jsx("button",{onClick:()=>x(xe),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===xe?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:xe==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),xt>0?` (${xt})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),kt>0?` (${kt})`:""]})},xe))}),g==="notifications"&&X>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:_e,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsx("div",{className:"flex-1 overflow-hidden relative",...Le,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${ie*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:C.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[J.map(xe=>{const Ge=xe.details?.command,Qe=Ge?xe.description.replace(/\s*Command:.*$/,""):xe.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>ne(xe),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:To.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ee(xe)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ee(xe)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ao(xe.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:xe.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),Ge&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:Ge})]}),(()=>{if(Ad(xe))return be(xe);const K=xe.details?.subType,le=K==="task"||K==="requirement"||K==="requirement_resubmit",je=xe.options&&xe.options.length>0,Ue=(F[xe.id]??"").trim();return je?s.jsxs("div",{className:"space-y-1.5",children:[xe.options.map((tt,yt)=>s.jsxs("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,tt.id!=="reject",Ue||void 0,tt.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${tt.id==="reject"||tt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:tt.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+yt)}),tt.label]},tt.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:F[xe.id]??"",onChange:tt=>V(yt=>({...yt,[xe.id]:tt.target.value})),onKeyDown:tt=>{tt.key==="Enter"&&(F[xe.id]??"").trim()&&ve(xe.id,!0,(F[xe.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===xe.id||!(F[xe.id]??"").trim(),onClick:()=>ve(xe.id,!0,(F[xe.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):le?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==xe.id&&s.jsxs("button",{disabled:S===xe.id,onClick:()=>L(xe.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),P===xe.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:F[xe.id]??"",onChange:tt=>V(yt=>({...yt,[xe.id]:tt.target.value})),onKeyDown:tt=>{tt.key==="Enter"&&(F[xe.id]??"").trim()&&ve(xe.id,!1,(F[xe.id]??"").trim(),"needs_adjustment"),tt.key==="Escape"&&L(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===xe.id||!(F[xe.id]??"").trim(),onClick:()=>ve(xe.id,!1,(F[xe.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>L(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:F[xe.id]??"",onChange:tt=>V(yt=>({...yt,[xe.id]:tt.target.value})),onKeyDown:tt=>{tt.key==="Enter"&&ve(xe.id,!0,Ue||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,!0,Ue||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,!1,Ue||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},xe.id)}),Te.length>0&&s.jsxs(s.Fragment,{children:[J.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Te.slice(0,50).map(xe=>s.jsxs("button",{onClick:()=>ne(xe),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${xe.status==="approved"?"bg-green-500":xe.status==="cancelled"||xe.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:xe.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${xe.status==="approved"?"text-green-500":xe.status==="cancelled"||xe.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${xe.status}`,{defaultValue:xe.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:oe(xe)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ao(xe.respondedAt??xe.requestedAt,m)})]})]},xe.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:$e.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsx("div",{className:"divide-y divide-border-default/50",children:$e.slice(0,50).map(xe=>{const Ge=j4[xe.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>at(xe),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${xe.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:Ge,children:s.jsx("path",{d:To[xe.type]??To.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!xe.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[xe.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:xe.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:Ao(xe.createdAt,m)}),jd(xe,m)&&s.jsx("span",{className:`text-[10px] font-medium ${Ge}`,children:jd(xe,m)})]})]})]},xe.id)})})})]})})]})]})}if(o){const R=d||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return s.jsxs(s.Fragment,{children:[ge,s.jsxs("button",{ref:G,onClick:()=>{h(!p),p||Pe()},title:e?c||m("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors relative text-fg-primary ${p||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:R})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):s.jsx("span",{className:"truncate",children:c}),Ct>0&&s.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:Ct>99?m("common:badgeOverLimit"):Ct})]}),p&&Sa.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:Z.top,left:Z.left,width:Z.width,maxHeight:Z.maxHeight},children:Se}),document.body),Je]})}return s.jsxs(s.Fragment,{children:[ge,s.jsxs("button",{ref:G,onClick:()=>{h(!p),p||Pe()},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:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),Ct>0&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:Ct>99?m("common:badgeOverLimit"):Ct})]}),p&&Sa.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:Z.top,left:Z.left,width:Z.width,maxHeight:Z.maxHeight},children:Se}),document.body),Je]})}function Md({d:e,size:t=14}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}const rh=200;function cW({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:c}=ft(["nav","common"]),[d,m]=k.useState(!1),[p,h]=k.useState(!1),[g,x]=k.useState(()=>lt.isAuthenticated()),[y,w]=k.useState(()=>sa()),[C,T]=k.useState({top:0,left:0}),S=k.useRef(null),_=k.useRef(null),j=k.useCallback(Z=>{if(w(sa()),!lt.isAuthenticated()){x(!1);return}if(!Z?.validate){x(!0);return}Cw().then(q=>{x(q),w(sa())})},[]);k.useEffect(()=>{j({validate:!0});const Z=()=>j(),q=()=>j({validate:!0});return window.addEventListener("markus:hub-auth",Z),window.addEventListener("focus",q),()=>{window.removeEventListener("markus:hub-auth",Z),window.removeEventListener("focus",q)}},[j]);const O=k.useCallback(()=>{if(!S.current)return;const Z=S.current.getBoundingClientRect(),q=window.innerWidth,te=window.innerHeight,U=_.current?.offsetHeight??220;let Q=Z.right+8;Q+rh>q-8&&(Q=Math.max(8,Z.left-rh-8));let me=Z.top-U-8;me<8&&(me=Math.min(Z.bottom+8,te-U-8)),T({top:Math.max(8,me),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const Z=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(Z)},[d,O,o]),k.useEffect(()=>{if(!d)return;const Z=te=>{const U=te.target;S.current?.contains(U)||_.current?.contains(U)||m(!1)},q=()=>O();return document.addEventListener("mousedown",Z),window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{document.removeEventListener("mousedown",Z),window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[d,O]);const P=e?.name||y?.displayName||y?.username||c("common:userPlaceholder"),L=e?.email||y?.email||"",F=Ew(e?.avatarUrl,y?.avatarUrl),V=g?"bg-emerald-500":"bg-fg-muted",X=g?y?.username?c("sidebar.hubConnectedAs",{username:y.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),z=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),G=()=>{m(!1),j({validate:!0}),it.navigate(ue.SETTINGS,{tab:"account"})},ae=d&&Sa.createPortal(s.jsxs("div",{ref:_,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:C.top,left:C.left,width:rh},children:[s.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:P}),L&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:L})]}),n&&s.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:c("common:profile.editProfile"),className:"shrink-0 mt-0.5 p-1.5 rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:s.jsx(Md,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),s.jsxs("button",{type:"button",onClick:G,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${V}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:X}),z&&y?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:y.username})})]}),s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-muted shrink-0",children:s.jsx("path",{d:"m9 18 6-6-6-6"})})]}),s.jsxs("div",{className:"py-1",children:[r&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),it.navigate(ue.SETTINGS)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(Md,{d:hc[ue.SETTINGS]}),c("settings")]}),window.markusDesktop&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),window.markusDesktop?.openInBrowser()},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(Md,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3"}),c("common:openInBrowser")]}),t&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),h(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(Md,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),c("common:signOut")]})]})]}),document.body);return s.jsxs("div",{className:`relative ${o?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:S,type:"button",onClick:()=>m(Z=>!Z),title:P,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Hs,{name:P,avatarUrl:F,size:o?28:32,fallback:"icon"}),s.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${V}`,title:X})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.5"]}),ae,p&&t&&s.jsx(dr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function uW({d:e,size:t=18}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}function dW({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:d}){const{t:m}=ft(["nav","common"]);return s.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{"data-no-drag":!0,onClick:o,title:m(r?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!r&&s.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),s.jsx("nav",{className:`${r?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:FL.map((p,h)=>{const g=vw.filter(y=>y.section===p.key);if(g.length===0)return null;const x=m(`sections.${p.key}`);return s.jsx("div",{children:s.jsxs("div",{className:h>0?"mt-3":"",children:[!r&&x&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:x}),r&&h>0&&s.jsx("div",{className:"my-3"}),g.map(y=>{if(y.id===ue.NOTIFICATIONS)return s.jsx(lW,{sidebarMode:!0,collapsed:r,userId:n?.id,label:m(y.id),iconPath:hc[y.id],isActive:e===y.id},y.id);const w=e===y.id,C=d&&c===y.id;return s.jsxs("button",{"data-l0-page-id":y.id,onClick:()=>t(y.id),title:r?m(y.id):void 0,className:`w-full flex items-center ${r?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${C?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":w?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(uW,{d:hc[y.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(y.id)}):s.jsx("span",{className:"truncate",children:m(y.id)})]},y.id)})]})},p.key)})}),s.jsx("div",{className:`shrink-0 border-t border-border-subtle ${r?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:s.jsx(cW,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const mW=6e4;let zs={},xi={};const tg=new Set,ng=new Set;let J3=0,uc=null,Rd=0,Vd=null;function w0(){for(const e of tg)e()}async function rg(){try{const e=await Me.unread.getCounts();zs=e.counts??{},xi=e.sessionAgentMap??{},w0()}catch{}}function fW(){uc||(rg(),uc=setInterval(rg,mW),Vd=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!ng.has(t)&&Date.now()>J3&&(zs[t]=(zs[t]??0)+1,w0())}))}function pW(){uc&&(clearInterval(uc),uc=null),Vd&&(Vd(),Vd=null)}function hW(e){const t=e?.enabled??!0,[n,r]=k.useState(zs),[o,l]=k.useState(xi),c=k.useCallback(async()=>{await rg()},[]),d=k.useCallback(async w=>{const C=new Date().toISOString();delete zs[w],w0();try{await Me.unread.markRead(w,C)}catch{}},[]),m=k.useCallback(async()=>{zs={},w0();try{await Me.unread.markAllRead()}catch{}},[]),p=k.useCallback(w=>{ng.add(w)},[]),h=k.useCallback(w=>{ng.delete(w),J3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;Rd++,fW();let w=xi;const C=()=>{r({...zs}),w!==xi&&(w=xi,l({...xi}))};return tg.add(C),r({...zs}),l({...xi}),()=>{tg.delete(C),Rd--,Rd<=0&&(Rd=0,pW())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,C)=>w+C,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:c,setActiveKey:p,clearActiveKey:h}}function uX(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,o]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+o)}return n},[e,t])}function gW({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:c}=hW({enabled:!0}),d=k.useMemo(()=>{let p=0;for(const h of Object.values(c))p+=h;return p},[c]),m=k.useCallback(async()=>{try{const p=await Me.notifications.list(n,!1);l(p.unreadCount??p.notifications.filter(h=>!h.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const p=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),h=()=>m();return window.addEventListener("markus:notifications-changed",h),()=>{clearInterval(p),window.removeEventListener("markus:notifications-changed",h)}},[m]),s.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:GL.map(p=>{const h=p.group.includes(e),g=p.id===ue.NOTIFICATIONS,x=p.id===ue.TEAM;return s.jsxs("button",{onClick:()=>t(p.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${h?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[s.jsxs("div",{className:"relative",children:[s.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:h?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:hc[p.id]})}),g&&o>0&&s.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:o>99?"99+":o}),x&&d>0&&s.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:d>99?"99+":d})]}),s.jsx("span",{className:`text-[10px] leading-tight ${h?"font-semibold":""}`,children:r(p.id)})]},p.id)})})}const k0=new Map;function gi(e,t){k0.has(e)||k0.set(e,t().catch(()=>{}))}function Si(e){const t=k0.get(e);return k0.delete(e),t}const Tr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Ei={agent:{label:"Agent",labelZh:"智能体",gradient:"from-violet-500 to-indigo-600",accent:"#8b5cf6",covers:[["#7c3aed","#4f46e5"],["#8b5cf6","#6366f1"],["#a855f7","#4338ca"],["#6d28d9","#2563eb"]]},team:{label:"Team",labelZh:"AI 小队",gradient:"from-cyan-500 to-blue-600",accent:"#06b6d4",covers:[["#0891b2","#2563eb"],["#06b6d4","#3b82f6"],["#0e7490","#1d4ed8"],["#22d3ee","#4f46e5"]]},skill:{label:"Skill",labelZh:"技能",gradient:"from-amber-500 to-orange-600",accent:"#f59e0b",covers:[["#f59e0b","#ea580c"],["#d97706","#dc2626"],["#fbbf24","#f97316"],["#f59e0b","#b45309"]]},connector:{label:"Connector",labelZh:"连接器",gradient:"from-emerald-500 to-teal-600",accent:"#10b981",covers:[["#10b981","#0d9488"],["#059669","#0891b2"],["#34d399","#14b8a6"],["#16a34a","#0f766e"]]}};function Xo(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function e6(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 bW={agent:258,team:205,skill:32,connector:162};function Xg(e,t){const n=bW[e],r=e6(t),o=((n+(r%68-34))%360+360)%360,l=(o+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${o} 72% 56%), hsl(${l} 66% 43%))`}const O4=["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 t6(e){return O4[e6(e+"g")%O4.length]}function n6(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 xW(e){return!e||n6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function yW(e,t="user"){const n=t==="org"?"shapes":"thumbs",r=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${r}&radius=50&backgroundType=gradientLinear`}function Mo(e){const t=e??0;return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)}k`.replace(".0k","k"):`${(t/1e6).toFixed(1)}M`.replace(".0M","M")}function L4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const D4={agent:{icon:"✦",label:"Agent",color:"text-brand-500",gradient:"from-brand-500 to-purple-600",bg:"bg-brand-500/10",ring:"ring-brand-500/30"},team:{icon:"◈",label:"Team",color:"text-blue-600",gradient:"from-blue-500 to-blue-600",bg:"bg-blue-500/10",ring:"ring-blue-500/30"},skill:{icon:"⬡",label:"Skill",color:"text-green-600",gradient:"from-green-500 to-green-600",bg:"bg-green-500/10",ring:"ring-green-500/30"}},vW=["development","devops","management","productivity","browser","custom","general"],wW=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],kW={shell:{icon:">",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"},file:{icon:"◫",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"},network:{icon:"◎",color:"bg-purple-500/15 text-purple-400 border-purple-500/30"},browser:{icon:"◉",color:"bg-brand-500/15 text-brand-400 border-brand-500/30"}};function ah({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:c,readOnly:d}){if(d){const j=e||l,P=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:P,children:j}):n==="p"?s.jsx("p",{className:P,children:j}):s.jsx("span",{className:P,children:j})}const[m,p]=k.useState(!1),[h,g]=k.useState(e),x=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]);const y=()=>{p(!1),h!==e&&t(h)},w=()=>{g(e),p(!1)},C=j=>{j.key==="Escape"&&w(),j.key==="Enter"&&!c&&y()};if(m){const j=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?s.jsx("textarea",{ref:x,value:h,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:C,className:`${j} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:h,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:C,className:j,placeholder:l})}const T=e||l,S=!e,_="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T})}function SW({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,c]=k.useState(!1),[d,m]=k.useState(e),p=k.useRef(null),h=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>p.current?.focus(),0))},[l,e]);const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),c(!1)};return l?s.jsxs("div",{ref:h,className:"relative inline-block",children:[s.jsx("input",{ref:p,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&c(!1)},onBlur:y=>{h.current?.contains(y.relatedTarget)||x(d)},className:`${r??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:g.map(y=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):s.jsx("span",{onClick:()=>c(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function NW({tags:e,onChange:t,readOnly:n}){if(n)return s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h))});const{t:r}=ft(["builder"]),[o,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const p=h=>{if((h.key==="Enter"||h.key===",")&&c.trim()){h.preventDefault();const g=c.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else h.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):h.key==="Escape"&&(l(!1),d(""))};return o?s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ring-1 ring-brand-500/50 rounded px-2 py-1 -mx-1 min-h-[32px]",children:[e.map(h=>s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] bg-surface-elevated text-fg-secondary rounded-full px-2 py-0.5 border border-border-default",children:[h,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==h)),className:"text-fg-muted hover:text-red-500",children:"×"})]},h)),s.jsx("input",{ref:m,value:c,onChange:h=>d(h.target.value),onKeyDown: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:r("detail.typeTagAndEnter")})]}):s.jsx("div",{onClick:()=>l(!0),className:"flex flex-wrap items-center gap-1.5 cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 py-0.5 transition-all min-h-[24px]",children:e.length>0?e.map(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function ag({content:e}){return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
661
|
+
`)||void 0;o({approved:L,comment:V,selectedOption:F,answers:P})};return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:P=>{P.target===P.currentTarget&&r()},children:s.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[s.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),s.jsx("path",{d:"M12 8v4"}),s.jsx("path",{d:"M12 16h.01"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),s.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:l("common:close"),children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&s.jsx("div",{className:"flex items-center gap-2",children:c.map((P,L)=>s.jsx("button",{onClick:()=>m(L),className:`h-1.5 flex-1 rounded-full transition-colors ${L===d?"bg-brand-500":S(P)?"bg-green-500/60":"bg-border-default"}`,title:`${L+1}. ${P.prompt.slice(0,40)}`},P.id))}),y&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:c.length,defaultValue:`Question ${d+1} of ${c.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Er,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((P,L)=>{const F=w(g.id).selectedOptionIds.includes(P.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,P.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${F?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!F?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${F?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:F?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+L)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Er,{content:P.label}),P.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Er,{content:P.description})})]})]},P.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&s.jsx("textarea",{rows:g.inputType==="text"?4:2,readOnly:n,placeholder:g.inputType==="text"?l("team:userInput.textPlaceholder",{defaultValue:"Type your answer…"}):l("team:userInput.freeformPlaceholder",{defaultValue:"Or write your own answer…"}),value:w(g.id).text,onChange:P=>{const L=P.target.value;C(g.id,{text:L,selectedOptionIds:L.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:y&&d>0&&s.jsx("button",{onClick:()=>m(P=>Math.max(0,P-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("team:userInput.previous",{defaultValue:"Previous"})})}),s.jsx("div",{className:"flex items-center gap-2",children:y&&!x?s.jsx("button",{disabled:!n&&!S(g),onClick:()=>m(P=>Math.min(c.length-1,P+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:l("team:userInput.next",{defaultValue:"Next"})}):n?s.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("common:close",{defaultValue:"Close"})}):s.jsxs("button",{disabled:t||!_,onClick:O,className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[t&&s.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l("team:userInput.submit",{defaultValue:"Submit"})]})})]})]})}),document.body)}function Ad(e){return Array.isArray(e.questions)&&e.questions.length>0}const Ed={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},To={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},j4={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function Ao(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}const M4="markus:template-updates-ack";let th=!1,_d=null;function oW(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function R4(e,t){if(e.type!=="system"||!e.metadata?.templateUpdates)return!1;if(!t)return!0;const n=e.metadata.templateUpdatesFingerprint;return!n||n===t}function jd(e,t){const n=e.actionType;if(n==="open_chat")return t("team:notifications.actionHints.openChat");if(n==="navigate")return t("team:notifications.actionHints.viewDetails");const r=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return r.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return r.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return r.agentId?t("team:notifications.actionHints.viewAgent"):null;case"direct_message":return t("team:notifications.actionHints.openChat");case"group_message":return t("team:notifications.actionHints.openChat");case"approval_request":return t("team:notifications.actionHints.viewApproval");case"system":return r.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return r.taskId?t("team:notifications.actionHints.viewTask"):r.requirementId?t("team:notifications.actionHints.viewRequirement"):r.agentId?t("team:notifications.actionHints.viewAgent"):null}}function nh(){try{const e=new AudioContext,t=e.currentTime,n=e.createGain();n.connect(e.destination),n.gain.setValueAtTime(.15,t),n.gain.exponentialRampToValueAtTime(.01,t+.6);const r=e.createOscillator();r.type="sine",r.frequency.setValueAtTime(880,t),r.frequency.setValueAtTime(1174.66,t+.15),r.connect(n),r.start(t),r.stop(t+.6),r.onended=()=>e.close()}catch{}}function lW({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:c,iconPath:d}){const{t:m}=ft(["team","common"]),[p,h]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[C,T]=k.useState([]),[S,_]=k.useState(null),[j,O]=k.useState(null),[P,L]=k.useState(null),[F,V]=k.useState({}),[X,z]=k.useState(0),G=k.useRef(null),ae=k.useRef(null),[Z,q]=k.useState({top:0,left:0,width:448,maxHeight:576}),te=k.useRef(null),U=k.useRef(!1),[Q,me]=k.useState(!0),[Ce,H]=k.useState(!1),W=k.useRef(null),fe=k.useRef("approvals"),[I,Re]=k.useState(!1),Be=30,Pe=k.useCallback(async()=>{try{Ya("/approvals"),Ya("/notifications");const[R,ie]=await Promise.all([Me.notifications.list(t,!1,{limit:Be,offset:0}),Me.approvals.list()]);w(R.notifications);const Le=R.unreadCount??R.notifications.filter(xe=>!xe.read).length;if(z(Le),me(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=Be),T(ie.approvals),!U.current){const xe=ie.approvals.filter(Ge=>Ge.status==="pending").length;te.current=xe,U.current=!0}}catch{}},[t]),Fe=k.useCallback(async()=>{if(!(Ce||!Q)){H(!0);try{const R=await Me.notifications.list(t,!1,{limit:Be,offset:y.length});R.notifications.length>0&&w(ie=>[...ie,...R.notifications.filter(Le=>!ie.some(xe=>xe.id===Le.id))]),me(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=Be)}catch{}H(!1)}},[t,y.length,Ce,Q]),dt=k.useCallback(R=>{const ie=R.detail;if(!ie)return;const{taskId:Le,requirementId:xe}=ie;!Le&&!xe||w(Ge=>{const Qe=Ge.filter(K=>!K.read&&(Le&&K.metadata?.taskId===Le||xe&&K.metadata?.requirementId===xe));if(Qe.length===0)return Ge;for(const K of Qe)Me.notifications.markRead(K.id).catch(()=>{});return z(K=>Math.max(0,K-Qe.length)),Ge.map(K=>Qe.some(le=>le.id===K.id)?{...K,read:!0}:K)})},[]),mt=k.useRef(y);mt.current=y;const Nt=k.useCallback(async()=>{if(!mt.current.some(ie=>!ie.read&&ie.type==="system"&&ie.metadata?.creditExhausted))try{await Me.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),Pe(),nh()}catch{}},[Pe,m]),Ot=k.useCallback(async()=>{if(!th){th=!0;try{const{updates:R}=await Me.skills.updates();if(!R.length)return;const ie=oW(R);try{if(localStorage.getItem(M4)===ie)return}catch{}if(_d===ie||mt.current.some(xe=>!xe.read&&R4(xe,ie)))return;try{const Ge=(await Me.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(Qe=>R4(Qe,ie)).sort((Qe,K)=>new Date(K.createdAt).getTime()-new Date(Qe.createdAt).getTime());if(Ge.length>0){for(const Qe of Ge.slice(1))Me.notifications.markRead(Qe.id).catch(()=>{});Ge.length>1&&Pe(),_d=ie;return}}catch{}_d=ie,await Me.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:R.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:ie,count:R.length,skills:R.map(xe=>xe.name)}}),Pe(),nh()}catch{_d=null}finally{th=!1}}},[Pe,m,t]);k.useEffect(()=>{Pe();const R=setInterval(Pe,6e4);let ie=null;const Le=()=>{ie||(ie=setTimeout(()=>{ie=null,Pe()},400))},xe=()=>Le(),Ge=()=>{h(!0),Pe()};window.addEventListener("markus:notifications-changed",xe),window.addEventListener("markus:mark-read-by-ref",dt),window.addEventListener("markus:open-notifications",Ge),window.addEventListener("markus:credit-exhausted",Nt);const Qe=va.on("notification",Le),K=va.on("approval:requested",Le);return()=>{clearInterval(R),ie&&clearTimeout(ie),window.removeEventListener("markus:notifications-changed",xe),window.removeEventListener("markus:mark-read-by-ref",dt),window.removeEventListener("markus:open-notifications",Ge),window.removeEventListener("markus:credit-exhausted",Nt),Qe(),K()}},[Pe,dt,Nt]),k.useEffect(()=>{Ot();const R=setInterval(()=>{Ot()},5*6e4),ie=()=>{Ot()};return window.addEventListener("markus:data-changed",ie),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",ie)}},[t]);const At=k.useCallback(()=>{if(!G.current)return;const R=G.current.getBoundingClientRect(),ie=window.innerWidth,Le=window.innerHeight,xe=Math.min(448,ie-16),Ge=Math.min(576,Le-16);let Qe=R.right+8,K=R.top;Qe+xe>ie-8&&(Qe=Math.max(8,ie-xe-8)),K+Ge>Le-8&&(K=Math.max(8,Le-Ge-8)),q({top:K,left:Qe,width:xe,maxHeight:Ge})},[]);k.useLayoutEffect(()=>{p&&At()},[p,At]),k.useEffect(()=>{if(p)return window.addEventListener("resize",At),()=>window.removeEventListener("resize",At)},[p,At]),k.useEffect(()=>{if(!p)return;const R=ie=>{G.current?.contains(ie.target)||ae.current?.contains(ie.target)||h(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[p]),k.useEffect(()=>{if(!p)return;const R=C.some(Le=>Le.status==="pending"),ie=y.some(Le=>!Le.read);x(R&&!ie?"approvals":!R&&ie?"notifications":fe.current)},[p]);const qt=new Set(C.filter(R=>R.status==="pending").map(R=>R.id)),jt=new Set(C.map(R=>R.id)),$e=y.filter(R=>!(R.type==="approval_request"&&R.metadata?.approvalId&&jt.has(R.metadata.approvalId))),ut=y.filter(R=>R.type==="approval_request"&&!R.read&&R.metadata?.approvalId&&qt.has(R.metadata.approvalId)).length,kt=Math.max(0,X-ut),xt=qt.size,Ct=kt+xt;k.useEffect(()=>{te.current!==null&&xt>te.current&&nh(),te.current=xt},[xt]);const ce=async R=>{await Me.notifications.markRead(R),w(ie=>ie.map(Le=>Le.id===R?{...Le,read:!0}:Le)),z(ie=>Math.max(0,ie-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},rt=R=>{const ie=R.metadata??{},Le=R.actionType,xe=R.actionTarget;if(Le==="open_chat"&&xe)try{const Ge=typeof xe=="string"?JSON.parse(xe):xe;if(Ge.agentId){const Qe={agentId:Ge.agentId};Ge.sessionId&&(Qe.sessionId=Ge.sessionId),it.navigate(ue.TEAM,Qe);return}}catch{}if(Le==="navigate"&&xe)try{const Ge=typeof xe=="string"?JSON.parse(xe):xe;if(Ge.path){if(Ge.path.startsWith("/team")){const Qe={},K=new URLSearchParams(Ge.path.split("?")[1]||"");for(const[le,je]of K.entries())Qe[le]=je;it.navigate(ue.TEAM,Qe);return}if(Ge.path.startsWith("/work")){const Qe={},K=new URLSearchParams(Ge.path.split("?")[1]||"");for(const[le,je]of K.entries())Qe[le]=je;it.navigate(ue.WORK,Qe);return}}}catch{}switch(R.type){case"approval_request":{const Ge=ie.approvalId,Qe=Ge?C.find(Ue=>Ue.id===Ge):void 0;if(Qe&&Ad(Qe)){O(Qe);break}const K=Qe?.details?.taskId??ie.taskId,le=Qe?.details?.requirementId??ie.requirementId,je=Qe?.details?.agentId??Qe?.agentId;K?it.navigate(ue.WORK,{openTask:K}):le?it.navigate(ue.WORK,{openRequirement:le}):je?it.navigate(ue.TEAM,{agentId:je}):it.navigate(ue.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":ie.taskId?it.navigate(ue.WORK,{openTask:ie.taskId}):it.navigate(ue.WORK);break;case"requirement_created":case"requirement_decision":ie.requirementId?it.navigate(ue.WORK,{openRequirement:ie.requirementId}):it.navigate(ue.WORK);break;case"agent_report":case"system":{if(ie.creditExhausted){Re(!0);return}if(ie.templateUpdates){const Ge=ie.templateUpdatesFingerprint;if(Ge)try{localStorage.setItem(M4,Ge)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),it.navigate(ue.STORE);return}if(ie.agentId){const Ge={agentId:ie.agentId};ie.sessionId&&(Ge.sessionId=ie.sessionId),it.navigate(ue.TEAM,Ge)}else it.navigate(ue.TEAM);break}case"direct_message":{const Ge=ie.senderId;Ge?it.navigate(ue.TEAM,{dm:Ge}):it.navigate(ue.TEAM);break}case"group_message":{const Ge=ie.channel;Ge?it.navigate(ue.TEAM,{channel:Ge}):it.navigate(ue.TEAM);break}default:ie.taskId?it.navigate(ue.WORK,{openTask:ie.taskId}):ie.requirementId?it.navigate(ue.WORK,{openRequirement:ie.requirementId}):ie.projectId?it.navigate(ue.WORK,{projectId:ie.projectId}):ie.agentId&&it.navigate(ue.TEAM,{agentId:ie.agentId});break}},at=async R=>{const ie=R.metadata??{},Le=R.actionType,xe=R.type==="agent_report"&&!ie.creditExhausted&&!ie.templateUpdates&&(Le==="open_chat"||!!ie.agentId&&Le!=="navigate");!R.read&&!xe&&ce(R.id);const Ge=ie.taskId,Qe=ie.requirementId;if(!xe&&(Ge||Qe)){const K=y.filter(le=>le.id!==R.id&&!le.read&&(Ge&&le.metadata?.taskId===Ge||Qe&&le.metadata?.requirementId===Qe));for(const le of K)ce(le.id)}rt(R)},ve=async(R,ie,Le,xe,Ge)=>{_(R);try{const{approval:Qe}=await Me.approvals.respond(R,ie,t,Le,xe,Ge);T(Ue=>Ue.map(tt=>tt.id===R?Qe:tt)),O(null),L(null),V(Ue=>{const tt={...Ue};return delete tt[R],tt});const K=Qe.details?.taskId,le=Qe.details?.requirementId,je=y.filter(Ue=>!Ue.read&&(Ue.type==="approval_request"&&Ue.metadata?.approvalId===R||K&&Ue.metadata?.taskId===K||le&&Ue.metadata?.requirementId===le));if(je.length>0){for(const tt of je)Me.notifications.markRead(tt.id).catch(()=>{});const Ue=new Set(je.map(tt=>tt.id));w(tt=>tt.map(yt=>Ue.has(yt.id)?{...yt,read:!0}:yt)),z(tt=>Math.max(0,tt-je.length))}Ya("/approvals"),Ya("/notifications"),Ya("/tasks"),Ya("/taskboard"),Ya("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Pe(),800)}catch{}_(null)},_e=async()=>{try{if(!t)return;await Me.notifications.markAllRead(t),w(R=>R.map(ie=>({...ie,read:!0}))),z(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const R=$e.filter(ie=>!ie.read);await Promise.all(R.map(ie=>Me.notifications.markRead(ie.id))),w(ie=>ie.map(Le=>({...Le,read:!0}))),z(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ee=R=>{const ie=R.details?.subType;return ie==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):ie==="requirement"||R.details?.requirementId?m("team:notifications.approvalType.requirement"):ie==="task_review"?m("team:notifications.approvalType.taskReview"):ie==="task"||R.details?.taskId?m("team:notifications.approvalType.task"):R.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},oe=R=>{const ie=[];ie.push(R.agentName);const Le=R.details?.taskTitle,xe=R.details?.taskId;Le?ie.push(Le):xe&&ie.push(`Task ${xe.slice(0,8)}`);const Ge=R.details?.requirementId;return Ge&&!xe&&ie.push(`Req ${Ge.slice(0,8)}`),ie.join(" · ")},$=[...C].sort((R,ie)=>new Date(ie.requestedAt).getTime()-new Date(R.requestedAt).getTime()),J=$.filter(R=>R.status==="pending"),Te=$.filter(R=>R.status!=="pending"),ne=R=>{const ie=R.details?.taskId,Le=R.details?.requirementId,xe=R.details?.agentId??R.agentId;ie?it.navigate(ue.WORK,{openTask:ie}):Le?it.navigate(ue.WORK,{openRequirement:Le}):xe?it.navigate(ue.TEAM,{agentId:xe}):it.navigate(ue.WORK)},he=()=>{h(!1),r?.()},be=R=>s.jsxs("button",{disabled:S===R.id,onClick:()=>O(R),className:"w-full px-3 py-2 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center justify-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),m("team:userInput.respond",{defaultValue:"Respond"}),R.questions&&R.questions.length>1?` (${R.questions.length})`:""]}),ge=j?s.jsx(iW,{approval:j,submitting:S===j.id,readOnly:j.status!=="pending",onClose:()=>O(null),onSubmit:R=>ve(j.id,R.approved,R.comment,R.selectedOption,R.answers)}):null,Se=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{x("approvals"),fe.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"),xt>0?` (${xt})`:""]}),s.jsxs("button",{onClick:()=>{x("notifications"),fe.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),kt>0?` (${kt})`:""]}),s.jsx("button",{onClick:he,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&X>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:_e,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:W,className:"flex-1 overflow-y-auto",onScroll:R=>{if(g!=="notifications"||!Q||Ce)return;const ie=R.currentTarget;ie.scrollTop+ie.clientHeight>=ie.scrollHeight-80&&Fe()},children:[g==="approvals"&&(C.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[J.map(R=>{const ie=R.details?.command,Le=ie?R.description.replace(/\s*Command:.*$/,""):R.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>ne(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:To.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ee(R)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ee(R)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ao(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Le,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),ie&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:ie})]}),(()=>{if(Ad(R))return be(R);const xe=R.details?.subType,Ge=xe==="task"||xe==="requirement"||xe==="requirement_resubmit",Qe=R.options&&R.options.length>0,K=(F[R.id]??"").trim();return Qe?s.jsxs("div",{className:"space-y-1.5",children:[R.options.map((le,je)=>s.jsxs("button",{disabled:S===R.id,onClick:()=>ve(R.id,le.id!=="reject",K||void 0,le.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${le.id==="reject"||le.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:le.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+je)}),le.label]},le.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:F[R.id]??"",onChange:le=>V(je=>({...je,[R.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&(F[R.id]??"").trim()&&ve(R.id,!0,(F[R.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===R.id||!(F[R.id]??"").trim(),onClick:()=>ve(R.id,!0,(F[R.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")})]})]}):Ge?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===R.id,onClick:()=>ve(R.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:S===R.id,onClick:()=>ve(R.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==R.id&&s.jsxs("button",{disabled:S===R.id,onClick:()=>L(R.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),P===R.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:F[R.id]??"",onChange:le=>V(je=>({...je,[R.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&(F[R.id]??"").trim()&&ve(R.id,!1,(F[R.id]??"").trim(),"needs_adjustment"),le.key==="Escape"&&L(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===R.id||!(F[R.id]??"").trim(),onClick:()=>ve(R.id,!1,(F[R.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>L(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:F[R.id]??"",onChange:le=>V(je=>({...je,[R.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&ve(R.id,!0,K||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===R.id,onClick:()=>ve(R.id,!0,K||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:S===R.id,onClick:()=>ve(R.id,!1,K||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},R.id)}),Te.length>0&&s.jsxs(s.Fragment,{children:[J.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Te.slice(0,50).map(R=>s.jsxs("button",{onClick:()=>Ad(R)?O(R):ne(R),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${R.status==="approved"?"bg-green-500":R.status==="cancelled"||R.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ee(R)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ee(R)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:R.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${R.status==="approved"?"text-green-500":R.status==="cancelled"||R.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${R.status}`,{defaultValue:R.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:oe(R)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ao(R.respondedAt??R.requestedAt,m)})]}),R.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",R.responseComment,"”"]})]},R.id))]})]})),g==="notifications"&&($e.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[$e.map(R=>{const ie=j4[R.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>at(R),onKeyDown:Le=>{(Le.key==="Enter"||Le.key===" ")&&(Le.preventDefault(),at(R))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${R.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:ie,children:s.jsx("path",{d:To[R.type]??To.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!R.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[R.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:Ao(R.createdAt,m)}),jd(R,m)&&s.jsx("span",{className:`text-[10px] font-medium ${ie}`,children:jd(R,m)})]})]})]},R.id)}),Ce&&s.jsx("div",{className:"py-3 text-center",children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),st=k.useCallback(R=>{R?.mute&&aW()},[]),Ve=k.useCallback(R=>{st(R),Re(!1)},[st]),Je=I?s.jsx(dr,{title:m("credits.dialogTitle",{ns:"common"}),message:m("credits.dialogDesc",{ns:"common"}),variant:"primary",cancelLabel:m("credits.configureModels",{ns:"common"}),confirmLabel:m("credits.topUp",{ns:"common"}),checkboxes:[{id:"mute",label:m("credits.dontRemind",{ns:"common"})}],onCancel:()=>Re(!1),onCancelClick:R=>{Ve(R),it.navigate(ue.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:R=>{const ie=`${lt.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Ve(R),_i(ie)}}):null;if(n){const R=["approvals","notifications"],ie=R.indexOf(g),Le=(()=>{let xe=0,Ge=0;return{onTouchStart:Qe=>{xe=Qe.touches[0].clientX,Ge=Qe.touches[0].clientY},onTouchEnd:Qe=>{const K=Qe.changedTouches[0].clientX-xe,le=Qe.changedTouches[0].clientY-Ge;Math.abs(K)>60&&Math.abs(K)>Math.abs(le)*1.5&&(K<0&&ie<R.length-1&&x(R[ie+1]),K>0&&ie>0&&x(R[ie-1]))}}})();return s.jsxs(s.Fragment,{children:[Je,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[ge,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:R.map(xe=>s.jsx("button",{onClick:()=>x(xe),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===xe?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:xe==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),xt>0?` (${xt})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),kt>0?` (${kt})`:""]})},xe))}),g==="notifications"&&X>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:_e,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsx("div",{className:"flex-1 overflow-hidden relative",...Le,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${ie*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:C.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[J.map(xe=>{const Ge=xe.details?.command,Qe=Ge?xe.description.replace(/\s*Command:.*$/,""):xe.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>ne(xe),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:To.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ee(xe)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ee(xe)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ao(xe.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:xe.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),Ge&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:Ge})]}),(()=>{if(Ad(xe))return be(xe);const K=xe.details?.subType,le=K==="task"||K==="requirement"||K==="requirement_resubmit",je=xe.options&&xe.options.length>0,Ue=(F[xe.id]??"").trim();return je?s.jsxs("div",{className:"space-y-1.5",children:[xe.options.map((tt,yt)=>s.jsxs("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,tt.id!=="reject",Ue||void 0,tt.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${tt.id==="reject"||tt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:tt.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+yt)}),tt.label]},tt.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:F[xe.id]??"",onChange:tt=>V(yt=>({...yt,[xe.id]:tt.target.value})),onKeyDown:tt=>{tt.key==="Enter"&&(F[xe.id]??"").trim()&&ve(xe.id,!0,(F[xe.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===xe.id||!(F[xe.id]??"").trim(),onClick:()=>ve(xe.id,!0,(F[xe.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):le?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==xe.id&&s.jsxs("button",{disabled:S===xe.id,onClick:()=>L(xe.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),P===xe.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:F[xe.id]??"",onChange:tt=>V(yt=>({...yt,[xe.id]:tt.target.value})),onKeyDown:tt=>{tt.key==="Enter"&&(F[xe.id]??"").trim()&&ve(xe.id,!1,(F[xe.id]??"").trim(),"needs_adjustment"),tt.key==="Escape"&&L(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===xe.id||!(F[xe.id]??"").trim(),onClick:()=>ve(xe.id,!1,(F[xe.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>L(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:F[xe.id]??"",onChange:tt=>V(yt=>({...yt,[xe.id]:tt.target.value})),onKeyDown:tt=>{tt.key==="Enter"&&ve(xe.id,!0,Ue||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,!0,Ue||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:S===xe.id,onClick:()=>ve(xe.id,!1,Ue||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},xe.id)}),Te.length>0&&s.jsxs(s.Fragment,{children:[J.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Te.slice(0,50).map(xe=>s.jsxs("button",{onClick:()=>ne(xe),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${xe.status==="approved"?"bg-green-500":xe.status==="cancelled"||xe.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:xe.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${xe.status==="approved"?"text-green-500":xe.status==="cancelled"||xe.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${xe.status}`,{defaultValue:xe.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:oe(xe)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ao(xe.respondedAt??xe.requestedAt,m)})]})]},xe.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:$e.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsx("div",{className:"divide-y divide-border-default/50",children:$e.slice(0,50).map(xe=>{const Ge=j4[xe.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>at(xe),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${xe.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:Ge,children:s.jsx("path",{d:To[xe.type]??To.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!xe.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[xe.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:xe.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:Ao(xe.createdAt,m)}),jd(xe,m)&&s.jsx("span",{className:`text-[10px] font-medium ${Ge}`,children:jd(xe,m)})]})]})]},xe.id)})})})]})})]})]})}if(o){const R=d||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return s.jsxs(s.Fragment,{children:[ge,s.jsxs("button",{ref:G,onClick:()=>{h(!p),p||Pe()},title:e?c||m("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors relative text-fg-primary ${p||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:R})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):s.jsx("span",{className:"truncate",children:c}),Ct>0&&s.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:Ct>99?m("common:badgeOverLimit"):Ct})]}),p&&Sa.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:Z.top,left:Z.left,width:Z.width,maxHeight:Z.maxHeight},children:Se}),document.body),Je]})}return s.jsxs(s.Fragment,{children:[ge,s.jsxs("button",{ref:G,onClick:()=>{h(!p),p||Pe()},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:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),Ct>0&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:Ct>99?m("common:badgeOverLimit"):Ct})]}),p&&Sa.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:Z.top,left:Z.left,width:Z.width,maxHeight:Z.maxHeight},children:Se}),document.body),Je]})}function Md({d:e,size:t=14}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}const rh=200;function cW({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:c}=ft(["nav","common"]),[d,m]=k.useState(!1),[p,h]=k.useState(!1),[g,x]=k.useState(()=>lt.isAuthenticated()),[y,w]=k.useState(()=>sa()),[C,T]=k.useState({top:0,left:0}),S=k.useRef(null),_=k.useRef(null),j=k.useCallback(Z=>{if(w(sa()),!lt.isAuthenticated()){x(!1);return}if(!Z?.validate){x(!0);return}Cw().then(q=>{x(q),w(sa())})},[]);k.useEffect(()=>{j({validate:!0});const Z=()=>j(),q=()=>j({validate:!0});return window.addEventListener("markus:hub-auth",Z),window.addEventListener("focus",q),()=>{window.removeEventListener("markus:hub-auth",Z),window.removeEventListener("focus",q)}},[j]);const O=k.useCallback(()=>{if(!S.current)return;const Z=S.current.getBoundingClientRect(),q=window.innerWidth,te=window.innerHeight,U=_.current?.offsetHeight??220;let Q=Z.right+8;Q+rh>q-8&&(Q=Math.max(8,Z.left-rh-8));let me=Z.top-U-8;me<8&&(me=Math.min(Z.bottom+8,te-U-8)),T({top:Math.max(8,me),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const Z=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(Z)},[d,O,o]),k.useEffect(()=>{if(!d)return;const Z=te=>{const U=te.target;S.current?.contains(U)||_.current?.contains(U)||m(!1)},q=()=>O();return document.addEventListener("mousedown",Z),window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{document.removeEventListener("mousedown",Z),window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[d,O]);const P=e?.name||y?.displayName||y?.username||c("common:userPlaceholder"),L=e?.email||y?.email||"",F=Ew(e?.avatarUrl,y?.avatarUrl),V=g?"bg-emerald-500":"bg-fg-muted",X=g?y?.username?c("sidebar.hubConnectedAs",{username:y.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),z=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),G=()=>{m(!1),j({validate:!0}),it.navigate(ue.SETTINGS,{tab:"account"})},ae=d&&Sa.createPortal(s.jsxs("div",{ref:_,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:C.top,left:C.left,width:rh},children:[s.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:P}),L&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:L})]}),n&&s.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:c("common:profile.editProfile"),className:"shrink-0 mt-0.5 p-1.5 rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:s.jsx(Md,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),s.jsxs("button",{type:"button",onClick:G,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${V}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:X}),z&&y?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:y.username})})]}),s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-muted shrink-0",children:s.jsx("path",{d:"m9 18 6-6-6-6"})})]}),s.jsxs("div",{className:"py-1",children:[r&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),it.navigate(ue.SETTINGS)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(Md,{d:hc[ue.SETTINGS]}),c("settings")]}),window.markusDesktop&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),window.markusDesktop?.openInBrowser()},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(Md,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3"}),c("common:openInBrowser")]}),t&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),h(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(Md,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),c("common:signOut")]})]})]}),document.body);return s.jsxs("div",{className:`relative ${o?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:S,type:"button",onClick:()=>m(Z=>!Z),title:P,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Hs,{name:P,avatarUrl:F,size:o?28:32,fallback:"icon"}),s.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${V}`,title:X})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.6-rc.1"]}),ae,p&&t&&s.jsx(dr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function uW({d:e,size:t=18}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}function dW({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:d}){const{t:m}=ft(["nav","common"]);return s.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{"data-no-drag":!0,onClick:o,title:m(r?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!r&&s.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),s.jsx("nav",{className:`${r?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:FL.map((p,h)=>{const g=vw.filter(y=>y.section===p.key);if(g.length===0)return null;const x=m(`sections.${p.key}`);return s.jsx("div",{children:s.jsxs("div",{className:h>0?"mt-3":"",children:[!r&&x&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:x}),r&&h>0&&s.jsx("div",{className:"my-3"}),g.map(y=>{if(y.id===ue.NOTIFICATIONS)return s.jsx(lW,{sidebarMode:!0,collapsed:r,userId:n?.id,label:m(y.id),iconPath:hc[y.id],isActive:e===y.id},y.id);const w=e===y.id,C=d&&c===y.id;return s.jsxs("button",{"data-l0-page-id":y.id,onClick:()=>t(y.id),title:r?m(y.id):void 0,className:`w-full flex items-center ${r?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${C?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":w?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(uW,{d:hc[y.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(y.id)}):s.jsx("span",{className:"truncate",children:m(y.id)})]},y.id)})]})},p.key)})}),s.jsx("div",{className:`shrink-0 border-t border-border-subtle ${r?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:s.jsx(cW,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const mW=6e4;let zs={},xi={};const tg=new Set,ng=new Set;let J3=0,uc=null,Rd=0,Vd=null;function w0(){for(const e of tg)e()}async function rg(){try{const e=await Me.unread.getCounts();zs=e.counts??{},xi=e.sessionAgentMap??{},w0()}catch{}}function fW(){uc||(rg(),uc=setInterval(rg,mW),Vd=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!ng.has(t)&&Date.now()>J3&&(zs[t]=(zs[t]??0)+1,w0())}))}function pW(){uc&&(clearInterval(uc),uc=null),Vd&&(Vd(),Vd=null)}function hW(e){const t=e?.enabled??!0,[n,r]=k.useState(zs),[o,l]=k.useState(xi),c=k.useCallback(async()=>{await rg()},[]),d=k.useCallback(async w=>{const C=new Date().toISOString();delete zs[w],w0();try{await Me.unread.markRead(w,C)}catch{}},[]),m=k.useCallback(async()=>{zs={},w0();try{await Me.unread.markAllRead()}catch{}},[]),p=k.useCallback(w=>{ng.add(w)},[]),h=k.useCallback(w=>{ng.delete(w),J3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;Rd++,fW();let w=xi;const C=()=>{r({...zs}),w!==xi&&(w=xi,l({...xi}))};return tg.add(C),r({...zs}),l({...xi}),()=>{tg.delete(C),Rd--,Rd<=0&&(Rd=0,pW())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,C)=>w+C,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:c,setActiveKey:p,clearActiveKey:h}}function uX(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,o]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+o)}return n},[e,t])}function gW({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:c}=hW({enabled:!0}),d=k.useMemo(()=>{let p=0;for(const h of Object.values(c))p+=h;return p},[c]),m=k.useCallback(async()=>{try{const p=await Me.notifications.list(n,!1);l(p.unreadCount??p.notifications.filter(h=>!h.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const p=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),h=()=>m();return window.addEventListener("markus:notifications-changed",h),()=>{clearInterval(p),window.removeEventListener("markus:notifications-changed",h)}},[m]),s.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:GL.map(p=>{const h=p.group.includes(e),g=p.id===ue.NOTIFICATIONS,x=p.id===ue.TEAM;return s.jsxs("button",{onClick:()=>t(p.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${h?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[s.jsxs("div",{className:"relative",children:[s.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:h?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:hc[p.id]})}),g&&o>0&&s.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:o>99?"99+":o}),x&&d>0&&s.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:d>99?"99+":d})]}),s.jsx("span",{className:`text-[10px] leading-tight ${h?"font-semibold":""}`,children:r(p.id)})]},p.id)})})}const k0=new Map;function gi(e,t){k0.has(e)||k0.set(e,t().catch(()=>{}))}function Si(e){const t=k0.get(e);return k0.delete(e),t}const Tr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Ei={agent:{label:"Agent",labelZh:"智能体",gradient:"from-violet-500 to-indigo-600",accent:"#8b5cf6",covers:[["#7c3aed","#4f46e5"],["#8b5cf6","#6366f1"],["#a855f7","#4338ca"],["#6d28d9","#2563eb"]]},team:{label:"Team",labelZh:"AI 小队",gradient:"from-cyan-500 to-blue-600",accent:"#06b6d4",covers:[["#0891b2","#2563eb"],["#06b6d4","#3b82f6"],["#0e7490","#1d4ed8"],["#22d3ee","#4f46e5"]]},skill:{label:"Skill",labelZh:"技能",gradient:"from-amber-500 to-orange-600",accent:"#f59e0b",covers:[["#f59e0b","#ea580c"],["#d97706","#dc2626"],["#fbbf24","#f97316"],["#f59e0b","#b45309"]]},connector:{label:"Connector",labelZh:"连接器",gradient:"from-emerald-500 to-teal-600",accent:"#10b981",covers:[["#10b981","#0d9488"],["#059669","#0891b2"],["#34d399","#14b8a6"],["#16a34a","#0f766e"]]}};function Xo(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function e6(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 bW={agent:258,team:205,skill:32,connector:162};function Xg(e,t){const n=bW[e],r=e6(t),o=((n+(r%68-34))%360+360)%360,l=(o+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${o} 72% 56%), hsl(${l} 66% 43%))`}const O4=["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 t6(e){return O4[e6(e+"g")%O4.length]}function n6(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 xW(e){return!e||n6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function yW(e,t="user"){const n=t==="org"?"shapes":"thumbs",r=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${r}&radius=50&backgroundType=gradientLinear`}function Mo(e){const t=e??0;return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)}k`.replace(".0k","k"):`${(t/1e6).toFixed(1)}M`.replace(".0M","M")}function L4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const D4={agent:{icon:"✦",label:"Agent",color:"text-brand-500",gradient:"from-brand-500 to-purple-600",bg:"bg-brand-500/10",ring:"ring-brand-500/30"},team:{icon:"◈",label:"Team",color:"text-blue-600",gradient:"from-blue-500 to-blue-600",bg:"bg-blue-500/10",ring:"ring-blue-500/30"},skill:{icon:"⬡",label:"Skill",color:"text-green-600",gradient:"from-green-500 to-green-600",bg:"bg-green-500/10",ring:"ring-green-500/30"}},vW=["development","devops","management","productivity","browser","custom","general"],wW=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],kW={shell:{icon:">",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"},file:{icon:"◫",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"},network:{icon:"◎",color:"bg-purple-500/15 text-purple-400 border-purple-500/30"},browser:{icon:"◉",color:"bg-brand-500/15 text-brand-400 border-brand-500/30"}};function ah({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:c,readOnly:d}){if(d){const j=e||l,P=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:P,children:j}):n==="p"?s.jsx("p",{className:P,children:j}):s.jsx("span",{className:P,children:j})}const[m,p]=k.useState(!1),[h,g]=k.useState(e),x=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]);const y=()=>{p(!1),h!==e&&t(h)},w=()=>{g(e),p(!1)},C=j=>{j.key==="Escape"&&w(),j.key==="Enter"&&!c&&y()};if(m){const j=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?s.jsx("textarea",{ref:x,value:h,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:C,className:`${j} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:h,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:C,className:j,placeholder:l})}const T=e||l,S=!e,_="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>p(!0),className:`${r??""} ${_} ${S?"text-fg-muted italic":""}`,children:T})}function SW({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,c]=k.useState(!1),[d,m]=k.useState(e),p=k.useRef(null),h=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>p.current?.focus(),0))},[l,e]);const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),c(!1)};return l?s.jsxs("div",{ref:h,className:"relative inline-block",children:[s.jsx("input",{ref:p,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&c(!1)},onBlur:y=>{h.current?.contains(y.relatedTarget)||x(d)},className:`${r??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:g.map(y=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):s.jsx("span",{onClick:()=>c(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function NW({tags:e,onChange:t,readOnly:n}){if(n)return s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h))});const{t:r}=ft(["builder"]),[o,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const p=h=>{if((h.key==="Enter"||h.key===",")&&c.trim()){h.preventDefault();const g=c.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else h.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):h.key==="Escape"&&(l(!1),d(""))};return o?s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ring-1 ring-brand-500/50 rounded px-2 py-1 -mx-1 min-h-[32px]",children:[e.map(h=>s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] bg-surface-elevated text-fg-secondary rounded-full px-2 py-0.5 border border-border-default",children:[h,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==h)),className:"text-fg-muted hover:text-red-500",children:"×"})]},h)),s.jsx("input",{ref:m,value:c,onChange:h=>d(h.target.value),onKeyDown: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:r("detail.typeTagAndEnter")})]}):s.jsx("div",{onClick:()=>l(!0),className:"flex flex-wrap items-center gap-1.5 cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 py-0.5 transition-all min-h-[24px]",children:e.length>0?e.map(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function ag({content:e}){return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
662
662
|
prose-headings:text-fg-primary prose-headings:font-semibold
|
|
663
663
|
prose-p:text-fg-secondary prose-p:leading-relaxed
|
|
664
664
|
prose-a:text-brand-400 prose-a:no-underline hover:prose-a:underline
|
|
@@ -667,4 +667,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=Ke,rn=vt),Ht===void
|
|
|
667
667
|
prose-strong:text-fg-primary
|
|
668
668
|
prose-li:text-fg-secondary
|
|
669
669
|
prose-hr:border-border-default
|
|
670
|
-
prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(Eh,{remarkPlugins:[q5,Kk],rehypePlugins:[[x3,{detect:!0,ignoreMissing:!0}]],children:e})})}function sh({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=ft(["builder","common"]),[c,d]=k.useState(!1),[m,p]=k.useState(t),[h,g]=k.useState(!1),x=/\.(md|mdx|markdown)$/i.test(e),y=k.useRef(null);k.useEffect(()=>{p(t)},[t]),k.useEffect(()=>{if(c&&y.current){const T=y.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[c,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},C=o?null:s.jsx("div",{className:"flex items-center gap-2",children:c?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{p(t),d(!1)},className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors",children:l("common:cancel")}),s.jsx("button",{onClick:w,disabled:h,className:"text-[10px] px-2.5 py-1 rounded-md bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:l(h?"common:saving":"common:save")})]}):s.jsxs("button",{onClick:()=>d(!0),className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),l("detail.edit")]})});return r?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-end px-4 py-2 border-b border-border-default bg-surface-elevated/20",children:C}),c?s.jsx("textarea",{ref:y,value:m,onChange:T=>p(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(ag,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]}):s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border-default bg-surface-elevated/30",children:[s.jsx("span",{className:"text-xs font-medium text-fg-secondary font-mono",children:e}),C]}),c?s.jsx("textarea",{ref:y,value:m,onChange:T=>p(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(ag,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const I4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function CW(e){return[...e].sort(([t],[n])=>{const r=I4[t]??99,o=I4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function S0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>CW(e),[e]),[l,c]=k.useState(0);if(o.length===1)return n?s.jsx(sh,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r}):s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),s.jsx(sh,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r})]});const[d,m]=o[l]??o[0],p=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30",children:o.map(([h],g)=>s.jsx("button",{onClick:()=>c(g),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors ${g===l?"border-brand-500 text-brand-400 bg-surface-secondary/50":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:h},h))}),s.jsx(sh,{filename:d,content:m,onSave:h=>t(d,h),embedded:!0,readOnly:r},d)]});return n?p:s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),p]})}function TW({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l}){const{t:c}=ft(["builder"]),d=k.useRef(null);return e.length===0?l?null:s.jsxs("div",{className:"border-2 border-dashed border-border-default rounded-xl p-6 text-center text-fg-muted text-sm cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>d.current?.click(),onDragOver:m=>m.preventDefault(),onDrop:m=>{m.preventDefault();const p=m.dataTransfer.files[0];p?.type.startsWith("image/")&&r(p)},children:[s.jsxs("svg",{className:"w-8 h-8 mx-auto mb-2 text-fg-muted/50",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsx("span",{className:"block",children:c("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:c("images.hint")}),s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const p=m.target.files?.[0];p&&r(p),m.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(m=>{const p=m.split("/").pop()??m;return s.jsxs("div",{className:"relative group shrink-0 rounded-lg border border-border-default overflow-hidden bg-surface-elevated",children:[s.jsx("img",{src:`/api/builder/artifacts/${t}s/${encodeURIComponent(n)}/images/${encodeURIComponent(p)}`,alt:p,className:"h-32 w-auto object-cover"}),!l&&s.jsx("button",{onClick:()=>o(p),className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-red-600/80 text-white flex items-center justify-center text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},m)}),!l&&s.jsx("button",{onClick:()=>d.current?.click(),className:"shrink-0 h-32 w-24 rounded-lg border-2 border-dashed border-border-default flex items-center justify-center text-fg-muted hover:border-brand-500/30 hover:text-brand-400 transition-colors",children:s.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),!l&&s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const p=m.target.files?.[0];p&&r(p),m.target.value=""}})]})}function AW({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=ft(["builder"]),[c,d]=k.useState(0),m=k.useMemo(()=>{const C=new Set;for(const T of Object.keys(n)){const S=T.match(/^members\/([^/]+)\//);S&&C.add(S[1])}return[...C]},[n]),p=k.useMemo(()=>{const C=new Map,T=new Set;for(let j=0;j<e.length;j++){const O=r0(e[j].name);m.includes(O)&&!T.has(O)&&(C.set(j,O),T.add(O))}for(let j=0;j<e.length;j++){if(C.has(j))continue;const O=e[j].roleName;if(O){const P=r0(O);m.includes(P)&&!T.has(P)&&(C.set(j,P),T.add(P))}}for(let j=0;j<e.length;j++){if(C.has(j))continue;const O=e[j].name;for(const P of m){if(T.has(P))continue;const L=n[`members/${P}/ROLE.md`];if(!L)continue;const F=L.match(/^#\s+(.+)$/m)?.[1]?.trim();if(F&&(F.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes(F.toLowerCase()))){C.set(j,P),T.add(P);break}}}const S=m.filter(j=>!T.has(j));let _=0;for(let j=0;j<e.length;j++)C.has(j)||_<S.length&&(C.set(j,S[_]),_++);return C},[e,m,n]),h=k.useCallback((C,T)=>{const S=p.get(T);return S?Object.entries(n).filter(([_])=>_.startsWith(`members/${S}/`)):[]},[n,p]),g=k.useMemo(()=>{const C=[{label:l("detail.overview")}];for(const T of e)C.push({label:T.name,role:T.role});return C},[e,l]),x=c>0?e[c-1]:null,y=c-1;return s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30 border-b border-border-default",children:g.map((C,T)=>{const S=T===c,_=C.role==="manager",j=T===0?S?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":_?S?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":S?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>d(T),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${j} ${S?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[T===0&&s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),T>0&&s.jsx("span",{className:`w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center shrink-0 ${_?"bg-amber-500/20 text-amber-400":"bg-blue-500/20 text-blue-400"}`,children:(C.label[0]??"?").toUpperCase()}),C.label]},T)})}),s.jsx("div",{className:"p-5",children:c===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(S0,{noHeader:!0,files:t,onSave:w,readOnly:o}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:l("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((C,T)=>{const S=C.role==="manager";return s.jsxs("button",{onClick:()=>d(T+1),className:"text-left rounded-lg border border-border-default bg-surface-elevated/30 px-4 py-3 flex gap-3 items-center hover:border-gray-600 transition-colors cursor-pointer",children:[s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${S?"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:(C.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:C.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${S?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:C.role}),C.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",C.count]})]}),C.skills&&C.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[C.skills.slice(0,3).map(_=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:_},_)),C.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",C.skills.length-3]})]})]}),s.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},T)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${x.role==="manager"?"bg-amber-500/15 text-amber-400 ring-2 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-2 ring-blue-500/30"}`,children:(x.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:x.name}),s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${x.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:x.role}),x.count>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",x.count]})]}),x.roleName&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 italic",children:x.roleName})]})]}),x.skills&&x.skills.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.skills.map(C=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:C},C))}),(()=>{const C=h(x.name,y);return C.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(S0,{noHeader:!0,readOnly:o,files:C.map(([T,S])=>[T.replace(/^members\/[^/]+\//,""),S]),onSave:(T,S)=>{const _=C.find(([j])=>j.endsWith(`/${T}`));_&&r(_[0],S)}})})()]}):null})]});function w(C,T){r(C,T)}}function Mi({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:c,contentSlot:d}){const{t:m}=ft(["builder","common"]),p=Uo(),[h,g]=k.useState(!0),[x,y]=k.useState(t),[w,C]=k.useState({}),[T,S]=k.useState(null),[_,j]=k.useState(""),[O,P]=k.useState("idle"),[L,F]=k.useState({shared:!1}),[V,X]=k.useState(!1),[z,G]=k.useState(!1),[ae,Z]=k.useState(!1),[q,te]=k.useState(!1),[U,Q]=k.useState(!1),[me,Ce]=k.useState(!1),[H,W]=k.useState(null),[fe,I]=k.useState(""),[Re,Be]=k.useState(""),[Pe,Fe]=k.useState(""),[dt,mt]=k.useState(""),[Nt,Ot]=k.useState([]),[At,qt]=k.useState(""),jt=k.useRef(null),$e=k.useRef(l);$e.current=l,k.useEffect(()=>{y(t)},[t]);const ut=k.useCallback(async()=>{const ne=$e.current;if(ne){S(ne),I(ne.displayName||ne.name||t),Be(ne.description||""),Fe(ne.version||"1.0.0"),mt(ne.category||"general"),Ot(ne.tags||[]),qt(ne.icon||""),C(ne.files??{}),g(!1);return}g(!0);try{let he=t;try{const Se=await Me.builder.artifacts.ensureSlugSafe(e,t);he=Se.name,y(he),Se.converted&&(history.replaceState(null,"",Ti(ue.BUILDER,`${e}/${encodeURIComponent(he)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const be=await Me.builder.artifacts.get(e,he);C(be.files??{}),j(be.path??"");const ge=be.files[`${e}.json`]??be.files["agent.json"]??be.files["team.json"]??be.files["skill.json"];if(ge){const Se=JSON.parse(ge);S(Se),I(Se.displayName||Se.name||t),Be(Se.description||""),Fe(Se.version||"1.0.0"),mt(Se.category||"general"),Ot(Se.tags||[]),qt(Se.icon||"")}}catch(he){console.error("Failed to load artifact:",he)}finally{g(!1)}},[e,t]);k.useEffect(()=>{ut()},[ut]),k.useEffect(()=>{l?.files&&C(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const ne=localStorage.getItem("markus_builder_shared_map");if(ne){const he=JSON.parse(ne),be=`${e}/${t}`;he[be]&&F({shared:!0,id:he[be].id,slug:he[be].slug,version:he[be].version,visibility:he[be].visibility??"public"})}}catch{}lt.myItems().then(ne=>{const he=ne?.items??[],be=e==="agent"?"agent":e==="team"?"team":"skill";for(const ge of he)if(ge.itemType===be&&(ge.slug===t||ge.name===t)){F({shared:!0,id:ge.id,slug:ge.slug,version:ge.version,visibility:ge.visibility??"public",moderationStatus:ge.moderationStatus,pendingReview:ge.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const kt=k.useCallback(async ne=>{if(!(!T||o)){P("saving");try{const he={...T,...ne};await Me.builder.artifacts.save(e,he),S(he),P("saved"),setTimeout(()=>P(be=>be==="saved"?"idle":be),2e3)}catch{P("error"),setTimeout(()=>P("idle"),3e3)}}},[T,e]),xt=k.useCallback(ne=>{jt.current&&clearTimeout(jt.current),jt.current=setTimeout(()=>kt(ne),800)},[kt]),Ct=k.useCallback((ne,he)=>{const be={};ne==="displayName"?(I(he),be.displayName=he,G(!0)):ne==="description"?(Be(he),be.description=he,G(!0)):ne==="version"?(Fe(he),be.version=he,G(!1),Z(!1)):ne==="category"?(mt(he),be.category=he,G(!0)):ne==="tags"?(Ot(he),be.tags=he,G(!0)):ne==="icon"&&(qt(he),be.icon=he||void 0,G(!0)),xt({...T,...be})},[T,xt]),ce=k.useCallback(async(ne,he)=>{try{const be={...w,[ne]:he};C(be);const ge={...T,files:be};await Me.builder.artifacts.save(e,ge),P("saved"),G(!0),setTimeout(()=>P(Se=>Se==="saved"?"idle":Se),2e3)}catch{P("error")}},[w,e,T]),rt=k.useCallback(async ne=>{if(T){X(!0);try{await lt.ensureAuth();const he=await Me.builder.artifacts.ensureSlugSafe(e,x,T.displayName||T.name||x),be=he.name,ge=he.slug||xc(be);if(!ge)throw new Error("Invalid package slug: use English kebab-case for the artifact name (e.g. qwen-multimodal). Chinese-only names cannot be shared — rename the package slug and put the Chinese title in displayName.");const Se=he.displayName||T.displayName||T.name||x;he.converted&&(y(be),S(le=>le&&{...le,name:ge,displayName:Se}),history.replaceState(null,"",Ti(ue.BUILDER,`${e}/${encodeURIComponent(be)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const st={...T,name:ge,displayName:Se},Ve=st.description||"",Je=st.category||"general",R=st.tags??[];let ie=st.icon||void 0;const Le=st.version||"1.0.0";if(ie&&!ie.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(ie)){const le=ie.split("/").pop()??ie;try{const je=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(be)}/images/${encodeURIComponent(le)}`);if(je.ok){const Ue=await je.blob(),tt=new File([Ue],le,{type:Ue.type}),yt=await lt.uploadImage(tt);yt?.url&&(ie=yt.url)}}catch{}}let xe;const Ge=[],Qe=st.screenshots??[];for(let le=0;le<Qe.length;le++){const je=Qe[le],Ue=je.split("/").pop()??je;try{const tt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(be)}/images/${encodeURIComponent(Ue)}`);if(tt.ok){const yt=await tt.blob(),qe=new File([yt],Ue,{type:yt.type}),nt=await lt.uploadImage(qe);nt?.url&&(Ge.push({url:nt.url,alt:Ue,order:le}),le===0&&(xe=nt.url))}}catch{}}const K=await lt.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:Se,slug:ge,description:Ve,category:Je,tags:R,icon:ie,version:Le,config:st,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:xe,images:Ge.length>0?Ge:void 0,priceCents:ne?.priceCents,donationsEnabled:ne?.donationsEnabled,visibility:ne?.visibility,orgId:ne?.orgId});K.id&&(F({shared:!0,id:K.id,slug:K.slug??ge,version:Le,visibility:K.visibility??ne?.visibility??"public",moderationStatus:K.moderationStatus,pendingReview:K.pendingReview}),G(!1),(K.visibility??ne?.visibility??"public")!=="org"&&(K.moderationStatus==="pending"||K.pendingReview)?W({title:m("common:share"),message:he.converted?m("share.convertedAndSubmitted",{previous:t,slug:ge}):K.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):he.converted&&W({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:ge}),variant:"primary"}))}catch(he){console.error("Share to Hub failed:",he),W({title:m("common:share"),message:he instanceof Error?he.message:String(he),variant:"danger"})}finally{X(!1)}}},[T,w,e,t,x,m]),at=async ne=>{const he=new FormData;he.append("image",ne);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:he,credentials:"include"}),await ut(),G(!0)}catch(be){console.error("Image upload failed:",be)}},ve=async ne=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(ne)}`,{method:"DELETE",credentials:"include"}),await ut(),G(!0)}catch(he){console.error("Image remove failed:",he)}},_e=D4[e]??D4.agent,Ee=T?.screenshots??[],oe=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],$=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([ne])=>!ne.endsWith(".json")&&!ne.startsWith("images/")&&!ne.startsWith("members/")),[w,e]),J=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([ne])=>!ne.endsWith(".json")&&!ne.startsWith("images/")&&!ne.startsWith("members/")),[w,e]),Te=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const ne=new Set;if(e==="skill"){const he=T?.skill?.skillFile;he&&w[he]&&ne.add(he),!he&&w["SKILL.md"]&&ne.add("SKILL.md"),!he&&!w["SKILL.md"]&&w["README.md"]&&ne.add("README.md")}return Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")&&!ne.has(he))},[w,e,T?.skill?.skillFile]);return h?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse py-20 text-center",children:m("common:loading")})]})}):T?s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:`${p?"px-4 py-5":"px-6 py-8"}`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m(o?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!o&&O==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&O==="saved"&&s.jsxs("span",{className:"text-[10px] text-green-500 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),m("detail.saved")]}),!o&&O==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),c,!o&&L.shared&&(()=>{const ne=lt.getUser(),he=ne&&L.slug?`${lt.getUrl()}/@${encodeURIComponent(ne.username)}/${encodeURIComponent(L.slug)}`:null,be=Pe||T?.version||"1.0.0",ge=L.version!==be;return s.jsxs(s.Fragment,{children:[L.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):L.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):L.pendingReview?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,he&&s.jsxs("a",{href:he,target:"_blank",rel:"noopener noreferrer",onClick:Se=>{yc()&&(Se.preventDefault(),_i(he))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${L.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":L.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:[L.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):L.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),L.visibility==="org"?m("visibility.sharedOrg"):L.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),ge&&s.jsx("button",{onClick:()=>{rt({visibility:L.visibility})},disabled:V,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50",children:V?m("share.updating"):m("share.updateVersion",{version:be})})]})})(),!o&&!L.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:V,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:m(V?"share.sharing":"share.toHub")})]})]}),!o&&z&&!ae&&s.jsxs("div",{className:"mb-4 px-4 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20 flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),s.jsx("button",{onClick:()=>Z(!0),className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("versionBump.bumpVersion")})]}),!o&&ae&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),s.jsx("input",{type:"text",defaultValue:(()=>{const ne=(Pe||"1.0.0").split(".");return ne[2]=String(Number(ne[2]??0)+1),ne.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:ne=>{ne.key==="Enter"&&Ct("version",ne.target.value)}}),s.jsx("button",{onClick:ne=>{const he=ne.target.parentElement?.querySelector("input");he&&Ct("version",he.value)},className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("common:confirm")}),s.jsx("button",{onClick:()=>Z(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),L.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${p?"flex-col":""}`,children:[s.jsxs("div",{className:`${p?"w-full":"flex-1 min-w-0"}`,children:[s.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>!o&&Ce(!me),className:`w-16 h-16 rounded-xl ${_e.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${_e.ring} transition-all overflow-hidden`,children:At&&At.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(At.replace("images/",""))}`,alt:"",className:"w-full h-full object-cover"}):At&&(At.startsWith("http")||At.startsWith("/"))?s.jsx("img",{src:At,alt:"",className:"w-full h-full object-cover"}):(()=>{const ne=At||"";if(ne&&[...ne].length<=2&&new RegExp("\\p{Emoji}","u").test(ne))return ne;const be=Ei[Xo(e)].accent;return s.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:t6(fe||t||e),fill:be})})})()}),!o&&me&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Ce(!1)}),s.jsxs("div",{className:"absolute top-full left-0 mt-2 z-50 bg-surface-secondary border border-border-default rounded-xl p-3 shadow-xl w-80",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("input",{type:"text",placeholder:m("detail.pasteEmojiOrUrl"),className:"flex-1 text-sm px-2 py-1.5 rounded-lg bg-surface-elevated border border-border-default text-fg-primary placeholder:text-fg-muted",defaultValue:At,onKeyDown:ne=>{ne.key==="Enter"&&(Ct("icon",ne.target.value),Ce(!1))}}),s.jsxs("label",{className:"text-[10px] text-brand-400 hover:text-brand-300 cursor-pointer px-1.5 py-1 border border-brand-500/30 rounded-lg",children:[m("detail.upload"),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async ne=>{const he=ne.target.files?.[0];if(!he)return;const be=new FormData;be.append("image",he);try{const ge=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:be,credentials:"include"});if(ge.ok){const st=(await ge.json()).path;if(qt(st),Ce(!1),T){const Ve={...T,icon:st};S(Ve),await Me.builder.artifacts.save(e,Ve)}G(!0)}}catch{}}})]}),At&&s.jsx("button",{onClick:()=>{Ct("icon",""),Ce(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto",children:wW.map(ne=>s.jsxs("div",{className:"mb-2.5",children:[s.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:ne.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:ne.emojis.map(he=>s.jsx("button",{onClick:()=>{Ct("icon",he),Ce(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${At===he?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:he},he))})]},ne.label))})]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(ah,{value:fe,onChange:ne=>Ct("displayName",ne),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:o}),s.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${_e.bg} ${_e.color}`,children:_e.label}),s.jsx(ah,{value:Pe,onChange:ne=>Ct("version",ne),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:o})]}),s.jsx(ah,{value:Re,onChange:ne=>Ct("description",ne),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:o}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(SW,{value:dt,options:vW,onChange:ne=>Ct("category",ne),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(NW,{tags:Nt,onChange:ne=>Ct("tags",ne),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(TW,{images:Ee,artifactType:e,artifactName:t,onUpload:at,onRemove:ve,readOnly:o})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(AW,{members:T.team.members,teamTopFiles:J,files:w,onFileSave:ce,readOnly:o})}),e==="agent"&&$.length>0&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),s.jsx(S0,{noHeader:!0,files:$,onSave:ce,readOnly:o})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[T.skill?.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:T.skill.requiredPermissions.map(ne=>{const he=kW[ne];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${he?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:he?.icon??"?"})," ",ne]},ne)})})]}),T.skill?.mcpServers&&Object.keys(T.skill.mcpServers).length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),s.jsx("div",{className:"grid gap-2",children:Object.entries(T.skill.mcpServers).map(([ne,he])=>s.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[s.jsx("span",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center text-purple-400 text-sm shrink-0",children:"◎"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary",children:ne}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof he=="object"?JSON.stringify(he).slice(0,80):String(he)})]})]},ne))})]}),oe&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),s.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:s.jsx(ag,{content:oe})})]})]}),Te.length>0&&s.jsx(S0,{files:Te,onSave:ce,readOnly:o})]}),s.jsx("div",{className:`${p?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${p?"":"sticky top-6"} space-y-4`,children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),s.jsx("span",{className:`font-medium ${_e.color}`,children:_e.label})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),s.jsx("span",{className:"text-fg-secondary",children:dt})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:Pe})]}),T.author&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),s.jsx("span",{className:"text-fg-secondary",children:typeof T.author=="string"?T.author:T.author?.name??""})]})]})]}),e==="agent"&&T.agent&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.agent.roleName&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.roleName})]}),T.agent.llmProvider&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.llmProvider})]}),T.agent.llmModel&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:T.agent.llmModel})]}),T.agent.temperature!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.temperature})]})]})]}),e==="team"&&T.team&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),s.jsx("span",{className:"text-fg-secondary",children:T.team.members.reduce((ne,he)=>ne+he.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),s.jsx("span",{className:"text-amber-400",children:T.team.members.filter(ne=>ne.role==="manager").reduce((ne,he)=>ne+he.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),s.jsx("span",{className:"text-blue-400",children:T.team.members.filter(ne=>ne.role!=="manager").reduce((ne,he)=>ne+he.count,0)})]})]})]}),e==="skill"&&T.skill&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.skill.alwaysOn!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),s.jsx("span",{className:T.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:T.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),s.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:T.skill.skillFile})]}),T.skill.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:T.skill.requiredPermissions.map(ne=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:ne},ne))})]})]})]}),T.dependencies&&(T.dependencies.skills?.length||T.dependencies.env?.length)?s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),T.dependencies.skills?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.skills.map(ne=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:ne},ne))})]}):null,T.dependencies.env?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.env.map(ne=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:ne},ne))})]}):null]}):null,!o&&_&&s.jsxs("button",{onClick:()=>Me.system.openPath(_).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:_,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),_.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&q&&s.jsx(_W,{onClose:()=>te(!1),onConfirm:(ne,he)=>{te(!1),rt({donationsEnabled:!1,priceCents:ne==="paid"?he:void 0})},isUpdate:L.shared}),!o&&U&&s.jsx(EW,{onClose:()=>Q(!1),onConfirm:(ne,he,be,ge)=>{Q(!1),rt({visibility:ne,orgId:he,priceCents:be,donationsEnabled:ge})}}),H&&s.jsx(dr,{alertOnly:!0,variant:H.variant??"primary",title:H.title,message:H.message,onConfirm:()=>W(null),onCancel:()=>W(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function EW({onClose:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),lt.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:S=>S.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:S=>m(S.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&s.jsxs("div",{className:"mb-5",children:[s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:r6.map(S=>s.jsx("button",{type:"button",onClick:()=>x(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,C&&g>0?g:void 0,C?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const r6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function _W({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:c=>c.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(n?"shareMode.titleUpdate":"share.toHub")}),s.jsx("div",{className:"space-y-2 mb-5",children:r6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>t(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(n?"shareMode.update":"shareMode.share")})]})]})})}function N0(e,t){return!e||!n6(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function jW({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:c="rounded-xl"}){const d=Xo(e),m=N0(n,r),p=k.useMemo(()=>Xg(d,t),[d,t]),h=k.useMemo(()=>t6(t),[t]),[g,x]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>x(!0),style:{width:o,height:o},className:`${c} object-cover shrink-0 ${l}`}):xW(n)?s.jsx("div",{style:{width:o,height:o,background:p,fontSize:o*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&_V(n)?s.jsx("div",{style:{width:o,height:o,background:p},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Yo,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:p},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:o*.55,height:o*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:h,fill:"rgba(255,255,255,0.92)"})})})}function C0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:c}){const d=t||e||"markus",m=N0(n,r),[p,h]=k.useState(!1),g=m&&!p?m:yW(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:o,height:o},children:[s.jsx("img",{src:g,alt:e||t||"",onError:()=>h(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),c&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 ring-2 ring-surface-primary",style:{width:o*.42,height:o*.42},children:s.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"white","aria-hidden":!0,children:s.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function MW({type:e,className:t=""}){const n=Xo(e),r=Ei[n];return s.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white bg-gradient-to-r ${r.gradient} ${t}`,children:r.label})}function P4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",className:n<t?"text-amber-400":"text-fg-muted/40",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z"})},n))})}function ia(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:c,hubBase:d,author:m,authorLabel:p,version:h,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:C=0,priceCents:T,currency:S="usd",installed:_,glowing:j,selected:O,showTypeBadge:P=!0,hideStats:L=!1,cornerLabel:F,actions:V,footerLeft:X,headerAction:z,onClick:G,className:ae=""}=e,Z=Xo(t),q=Ei[Z],te=o||n,U=(T??0)>0,Q=!!N0(c||void 0,d),me=Xg(Z,te),Ce=p??m?.displayName??m?.username??"",[H,W]=k.useState(null),fe=_?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/12 text-emerald-400 border border-emerald-500/25 px-2 py-0.5 text-[10px] font-semibold",children:s.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):F?s.jsx("span",{className:"chip",children:F}):U?s.jsx("span",{className:"badge-paid",children:L4(T,S)}):null;if(Q){const I=N0(c||void 0,d);return s.jsxs("div",{onClick:G,style:{aspectRatio:H??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${G?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Re=>{const Be=Re.currentTarget;Be.naturalWidth&&Be.naturalHeight&&W(Math.min(1.9,Math.max(1,Be.naturalWidth/Be.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),s.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),s.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[s.jsx("span",{children:P&&s.jsx(MW,{type:Z})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Re=>Re.stopPropagation(),children:[_?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/25 text-emerald-50 border border-emerald-300/40 px-2 py-0.5 text-[10px] font-semibold backdrop-blur-md",children:s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):F?s.jsx("span",{className:"inline-flex items-center rounded-full bg-white/15 text-white border border-white/25 px-2 py-0.5 text-[10px] font-medium backdrop-blur-md",children:F}):z?null:s.jsx("span",{className:U?"badge-paid":"badge-free",children:L4(T,S)}),z]})]}),s.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),h&&s.jsxs("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/25 px-1.5 py-0.5 text-[10px] font-medium backdrop-blur-md",children:["v",h]})]}),Ce&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(C0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:Ce})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[g&&s.jsx("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/20 text-white/95 px-2 py-0.5 text-[10px] font-semibold capitalize backdrop-blur-md",children:g}),x?.slice(0,3).map(Re=>s.jsx("span",{className:"shrink-0 rounded-full bg-white/10 border border-white/15 text-white/85 px-2 py-0.5 text-[10px] backdrop-blur-md",children:Re},Re))]}),(!L||V)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[L?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(P4,{rating:y}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Mo(w),")"]})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Mo(C)]})]}),V&&s.jsx("div",{className:"flex items-center gap-2",onClick:Re=>Re.stopPropagation(),children:V})]})]})]})}return s.jsxs("div",{onClick:G,className:`group asset-card card-shine relative flex flex-col ${G?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${q.accent}, transparent)`}}),s.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:me}}),z&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:z}),s.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(jW,{type:Z,seed:te,icon:l,hubBase:d,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),s.jsxs("div",{className:`min-w-0 flex-1 ${z?"pr-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),h&&s.jsxs("span",{className:"chip shrink-0",children:["v",h]}),fe&&s.jsx("span",{className:"ml-auto shrink-0",children:fe})]}),(Ce||P)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(C0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),Ce&&s.jsx("span",{className:"truncate",children:Ce}),P&&s.jsxs(s.Fragment,{children:[Ce&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:q.accent},children:q.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),x?.slice(0,3).map(I=>s.jsx("span",{className:"chip",children:I},I)),(x?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(x?.length??0)-3]})]}),(()=>{const I=X??(L?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(P4,{rating:y}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Mo(w)})`:""})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Mo(C)]})]}));return!I&&!V?null:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Re=>Re.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),V&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:V})]})})()]})]})}function Ar({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const h=o.current;if(!h)return;c(h.clientWidth);const g=new ResizeObserver(x=>{for(const y of x)c(y.contentRect.width)});return g.observe(h),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),p=Array.from({length:d},()=>[]);return m.forEach((h,g)=>{p[g%d].push(h)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:p.map((h,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:h},g))})}function RW(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const OW=[{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 LW(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return fc(r[0])===ue.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const o=window.location.hash.slice(1).split("/");fc(o[0])===ue.BUILDER&&o[1]&&o[2]?t({type:o[1],name:decodeURIComponent(o[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const a6="markus_builder_shared_map";function DW(){try{const e=localStorage.getItem(a6);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Od(e){try{localStorage.setItem(a6,JSON.stringify(Object.fromEntries(e)))}catch{}}function s6({authUser:e}={}){const{t}=ft(["builder","common"]),n=Uo(),r=LW(),[o,l]=k.useState([]),[c,d]=k.useState([]),[m,p]=k.useState(!1),[h,g]=k.useState("all"),[x,y]=k.useState(null),[w,C]=k.useState(new Map),[T,S]=k.useState(null),[_,j]=k.useState(null),[O,P]=k.useState(null),[L,F]=k.useState(DW),[V,X]=k.useState(null),[z,G]=k.useState(null),[ae,Z]=k.useState(null),[q,te]=k.useState(null),[U,Q]=k.useState(null),[me,Ce]=k.useState("creations"),[H,W]=k.useState([]),[fe,I]=k.useState(""),[Re,Be]=k.useState([]),[Pe,Fe]=k.useState(!1),[dt,mt]=k.useState("all"),Nt=k.useCallback(()=>{p(!0),Promise.all([(Si(Tr.builderArtifacts)??Me.builder.artifacts.list()).then(ce=>ce?.artifacts??[]).catch(()=>[]),(Si(Tr.builderAgents)??Me.agents.list()).then(ce=>ce?.agents??[]).catch(()=>[]),(Si(Tr.builderHubMyItems)??lt.myItems()).then(ce=>ce?.items??[]).catch(()=>[]),(Si(Tr.builderInstalled)??Me.builder.artifacts.installed()).then(ce=>ce?.installed??{}).catch(()=>({}))]).then(([ce,rt,at,ve])=>{if(d(ce),l(rt),at.length>0){const Ee=new Map;for(const oe of at){const $=oe.itemType==="agent"?"agent":oe.itemType==="team"?"team":"skill";for(const J of ce)J.type===$&&(oe.slug===J.name||oe.name===(J.meta.displayName||J.meta.name||J.name))&&Ee.set(`${J.type}/${J.name}`,{id:oe.id,name:oe.name,slug:oe.slug||J.name,version:oe.version||"1.0.0",visibility:oe.visibility??"public",moderationStatus:oe.moderationStatus,pendingReview:oe.pendingReview})}Ee.size>0&&F(oe=>{const $=new Map(oe);for(const[J,Te]of Ee)$.set(J,Te);return Od($),$})}const _e=new Map;for(const Ee of ce){const oe=`${Ee.type}/${Ee.name}`,$=ve[oe];$&&_e.set(oe,{agentId:$.agentId,agentIds:$.agentIds,teamId:$.teamId})}C(_e)}).finally(()=>p(!1))},[]);k.useEffect(()=>{Nt();const ce=rt=>{rt.detail?.page===ue.BUILDER&&Nt()};return window.addEventListener("markus:navigate",ce),()=>window.removeEventListener("markus:navigate",ce)},[Nt]);const Ot=ce=>{const rt=o.find(at=>at.role==="Secretary"||at.name==="Secretary");rt?it.navigate(ue.TEAM,{agentId:rt.id,prefillMessage:ce}):it.navigate(ue.TEAM,{prefillMessage:ce})},At=async ce=>{const rt=`${ce.type}/${ce.name}`;if(!w.has(rt)){y({key:rt,action:"install"});try{const at=await Me.builder.artifacts.install(ce.type,ce.name),ve={};at.agent&&typeof at.agent=="object"&&(ve.agentId=at.agent.id),at.team&&typeof at.team=="object"&&(ve.teamId=at.team.id),Array.isArray(at.agents)&&(ve.agentIds=at.agents.map(_e=>_e.id)),C(_e=>new Map(_e).set(rt,ve)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(at){console.error("Install failed:",at),G({title:t("common:install"),message:t("installFailed",{error:String(at)}),variant:"danger"})}finally{y(null)}}},qt=async ce=>{const rt=`${ce.type}/${ce.name}`;if(w.has(rt)){y({key:rt,action:"uninstall"});try{await Me.builder.artifacts.uninstall(ce.type,ce.name),C(at=>{const ve=new Map(at);return ve.delete(rt),ve}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(at){console.error("Uninstall failed:",at),G({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(at)}),variant:"danger"})}finally{y(null)}}},jt=async(ce,rt)=>{const at=`${ce.type}/${ce.name}`;y({key:at,action:"share"});try{const ve=await Me.builder.artifacts.ensureSlugSafe(ce.type,ce.name,ce.meta.displayName||ce.meta.name||ce.name),_e=ve.name,Ee=ve.slug||xc(_e);if(!Ee)throw new Error("Invalid package slug: use English kebab-case for the artifact name (e.g. qwen-multimodal). Chinese-only names cannot be shared — rename the package slug and put the Chinese title in displayName.");const oe=`${ce.type}/${_e}`;ve.converted&&(d(ie=>ie.map(Le=>Le.type===ce.type&&Le.name===ce.name?{...Le,name:_e,path:ve.path,meta:{...Le.meta,name:_e,displayName:ve.displayName??Le.meta.displayName??ce.name}}:Le)),F(ie=>{const Le=new Map(ie),xe=Le.get(at);return xe&&(Le.delete(at),Le.set(oe,{...xe,slug:Ee,name:ve.displayName??xe.name})),Od(Le),Le}),C(ie=>{const Le=new Map(ie),xe=Le.get(at);return xe&&(Le.delete(at),Le.set(oe,xe)),Le}));const $=await Me.builder.artifacts.get(ce.type,_e);let J={...ce.meta,name:_e,displayName:ve.displayName??ce.meta.displayName??ce.name};try{const ie=$.files?.[`${ce.type}.json`]??$.files?.["agent.json"]??$.files?.["team.json"]??$.files?.["skill.json"];ie&&(J={...JSON.parse(ie),...J,name:_e,displayName:J.displayName})}catch{}const Te=J.displayName||J.name||_e,ne=J.description||"",he=J.category||"general",be=Array.isArray(J.tags)?J.tags:[];let ge=J.icon||void 0;const Se=J.version||"1.0.0";if(ge&&!ge.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(ge)){const ie=ge.split("/").pop()??ge;try{const Le=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(_e)}/images/${encodeURIComponent(ie)}`);if(Le.ok){const xe=await Le.blob(),Ge=new File([xe],ie,{type:xe.type}),Qe=await lt.uploadImage(Ge);Qe?.url&&(ge=Qe.url)}}catch{}}let st;const Ve=[],Je=Array.isArray(J.screenshots)?J.screenshots:[];for(let ie=0;ie<Je.length;ie++){const Le=Je[ie],xe=Le.split("/").pop()??Le;try{const Ge=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(_e)}/images/${encodeURIComponent(xe)}`);if(Ge.ok){const Qe=await Ge.blob(),K=new File([Qe],xe,{type:Qe.type}),le=await lt.uploadImage(K);le?.url&&(Ve.push({url:le.url,alt:xe,order:ie}),(ie===0||J.thumbnail===Le)&&(st=le.url))}}catch{}}const R=await lt.publishViaProxy({itemType:ce.type==="team"?"team":ce.type==="skill"?"skill":"agent",name:Te,slug:Ee,description:ne,category:he,tags:be,icon:ge,version:Se,config:{...J,name:_e,displayName:Te},files:$.files&&Object.keys($.files).length>0?$.files:void 0,thumbnailUrl:st,images:Ve.length>0?Ve:void 0,priceCents:rt?.priceCents,donationsEnabled:rt?.donationsEnabled,visibility:rt?.visibility,orgId:rt?.orgId});R.id&&(F(Le=>{const xe=new Map(Le);return xe.set(oe,{id:R.id,name:Te,slug:R.slug??Ee,version:Se,visibility:R.visibility??rt?.visibility??"public",moderationStatus:R.moderationStatus,pendingReview:R.pendingReview}),Od(xe),xe}),(R.visibility??rt?.visibility??"public")!=="org"&&(R.moderationStatus==="pending"||R.pendingReview)?G({title:t("common:share"),message:ve.converted?t("share.convertedAndSubmitted",{previous:ce.name,slug:Ee}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):ve.converted&&G({title:t("common:share"),message:t("share.convertedSlug",{previous:ce.name,slug:Ee}),variant:"primary"}))}catch(ve){console.error("Share failed:",ve),G({title:t("common:share"),message:t("shareFailed",{error:ve instanceof Error?ve.message:String(ve)}),variant:"danger"})}finally{y(null)}},$e=async()=>{if(!V)return;const{key:ce}=V,rt=L.get(ce);if(X(null),!rt)return;const at=rt.id;y({key:ce,action:"hubDelete"});try{await lt.deleteItem(at),F(ve=>{const _e=new Map(ve);return _e.delete(ce),Od(_e),_e})}catch(ve){console.error("Hub delete failed:",ve),G({title:t("unshare"),message:t("hubDeleteFailed",{error:String(ve)}),variant:"danger"})}finally{y(null)}},ut=async()=>{if(!T)return;const ce=T,rt=`${ce.type}/${ce.name}`;S(null),y({key:rt,action:"delete"});try{await Me.builder.artifacts.delete(ce.type,ce.name),d(at=>at.filter(ve=>!(ve.type===ce.type&&ve.name===ce.name))),C(at=>{const ve=new Map(at);return ve.delete(rt),ve}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(at){console.error("Delete failed:",at)}finally{y(null)}},kt=h==="all"?c:c.filter(ce=>ce.type===h);k.useEffect(()=>{me!=="orgAssets"||H.length>0||lt.myOrgs().then(ce=>{W(ce.memberships),ce.memberships.length>0&&!fe&&I(ce.memberships[0].id)}).catch(()=>{})},[me,H.length,fe]),k.useEffect(()=>{me!=="orgAssets"||!fe||(Fe(!0),lt.browseItems({orgId:fe,limit:100}).then(ce=>Be(ce.items??[])).catch(()=>Be([])).finally(()=>Fe(!1)))},[me,fe]);const xt=dt==="all"?Re:Re.filter(ce=>ce.itemType===dt),Ct=ce=>{history.pushState(null,"",Ti(ue.BUILDER,`${ce.type}/${encodeURIComponent(ce.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Mi,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Ti(ue.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),s.jsx("button",{onClick:Nt,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:t("common:refresh")})]}),s.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:OW.map(ce=>{const rt=t(`prompts.${ce.id}Prompt`),at=t(`prompts.${ce.id}Examples`,{returnObjects:!0}),ve=Array.isArray(at)?at:[];return s.jsx("button",{onClick:()=>Ot(rt),className:`group text-left w-full rounded-xl border ${ce.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${ce.bgColor} flex items-center justify-center shrink-0`,children:ce.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ce.color} bg-clip-text text-transparent`,children:t(`prompts.${ce.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ce.id}Desc`)}),ve.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ve.slice(0,2).map((_e,Ee)=>s.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:oe=>{oe.stopPropagation(),Ot(rt+_e)},children:["“",_e,"”"]},Ee))})]})]})},ce.id)})})]}),s.jsx("div",{className:"mb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>Ce("creations"),className:`text-sm font-semibold transition-colors ${me==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>Ce("orgAssets"),className:`text-sm font-semibold transition-colors ${me==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),me==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>s.jsx("button",{onClick:()=>g(ce),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${h===ce?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ce==="all"?"myCreations.filterAll":ce==="agent"?"myCreations.filterAgents":ce==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ce))}),me==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>s.jsx("button",{onClick:()=>mt(ce),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${dt===ce?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ce==="all"?"myCreations.filterAll":ce==="agent"?"myCreations.filterAgents":ce==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ce))})]})}),me==="orgAssets"&&H.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:H.map(ce=>s.jsx("button",{onClick:()=>I(ce.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${fe===ce.id?"bg-blue-500/15 border-blue-500/40 text-blue-400":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:ce.name},ce.id))}),me==="orgAssets"&&(H.length===0&&!Pe?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):Pe?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):xt.length===0?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):s.jsx(Ar,{children:xt.map(ce=>{const rt=ce.author?.username&&ce.slug?`${lt.getUrl()}/@${encodeURIComponent(ce.author.username)}/${encodeURIComponent(ce.slug)}`:null;return s.jsx(ia,{type:ce.itemType,name:ce.name,description:ce.description,seed:ce.slug||ce.id||ce.name,icon:ce.icon,cover:ce.thumbnailUrl,hubBase:lt.getUrl(),author:ce.author,version:ce.version,rating:parseFloat(ce.avgRating)||0,ratingCount:ce.ratingCount,downloadCount:ce.downloadCount,actions:rt?s.jsxs("a",{href:rt,target:"_blank",rel:"noopener noreferrer",onClick:at=>{at.stopPropagation(),yc()&&(at.preventDefault(),_i(rt))},className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},ce.id)})})),me==="creations"&&(m&&c.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):kt.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),s.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):s.jsx(Ar,{children:kt.map(ce=>{const rt=ce.meta.displayName||ce.meta.name||ce.name,at=ce.meta.description||"",ve=`${ce.type}/${ce.name}`,_e=x?.key===ve?x.action:null,Ee=L.get(ve),oe=ce.meta.version||"1.0.0",$=!!Ee,J=$&&Ee.version!==oe,Te=()=>{const Ve=lt.getUser();return!Ee||!Ve?null:`${lt.getUrl()}/@${encodeURIComponent(Ve.username)}/${encodeURIComponent(Ee.slug)}`},ne=$&&(Ee?.moderationStatus==="pending"||Ee?.moderationStatus==="rejected"||!!Ee?.pendingReview),he=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:Ve=>Ve.stopPropagation(),children:[w.has(ve)?s.jsxs("button",{onClick:()=>P(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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"17 8 12 3 7 8"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(_e==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>j(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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(_e==="install"?"common:installing":"common:install")]}),$&&ne?Ee?.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.underReview")]}):Ee?.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}):s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.updateUnderReview")]}):$?s.jsxs(s.Fragment,{children:[J&&s.jsxs("button",{onClick:()=>{const Ve=Ee?.visibility??"public";jt(ce,{visibility:Ve})},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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("polyline",{points:"1 20 1 14 7 14"}),s.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),_e==="share"?t("common:sharing"):t("share.updateVersion",{version:oe})]}),s.jsxs("a",{href:Te()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Ve=>{const Je=Te();yc()&&Je&&(Ve.preventDefault(),_i(Je))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ee?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ee?.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:[Ee?.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):Ee?.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Ee?.visibility==="org"?t("visibility.sharedOrg"):Ee?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>X({key:ve,name:rt}),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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):s.jsxs("button",{onClick:async()=>{await lt.ensureAuth(),Array.isArray(ce.meta.screenshots)&&ce.meta.screenshots.length>0?Q(ce):Z(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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"18",cy:"5",r:"3"}),s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"19",r:"3"}),s.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),s.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(_e==="share"?"common:sharing":"common:share")]})]}),be=s.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:s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"3 6 5 6 21 6"}),s.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),ge=ce.meta.icon,st=!!ge&&/\.(png|jpe?g|gif|webp|svg)$/i.test(ge)?ge.startsWith("http")||ge.startsWith("/")?ge:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(ge.split("/").pop()??"")}`:ge;return s.jsx(ia,{type:ce.type,name:rt,description:at,seed:ve,icon:st,version:oe,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:Ve=>{Ve.stopPropagation(),Me.system.openPath(ce.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ce.path,children:RW(ce.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:be,actions:he,onClick:()=>Ct(ce)},ve)})})),_&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:_.meta.displayName||_.meta.name||_.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ce=_;j(null),At(ce)},onCancel:()=>j(null)}),O&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:O.meta.displayName||O.meta.name||O.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ce=O;P(null),qt(ce)},onCancel:()=>P(null)}),T&&s.jsx(dr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:ut,onCancel:()=>S(null)}),V&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:V.name}),confirmLabel:t("unshare"),onConfirm:()=>{$e()},onCancel:()=>X(null)}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"primary",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)}),ae&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Z(null),children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),s.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>{const ce=ae;Z(null),Q(ce)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),s.jsx("button",{onClick:()=>{const ce=ae;Z(null),Ct(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")})]})]})}),q&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>te(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:s.jsx(PW,{isUpdate:L.has(`${q.type}/${q.name}`),onCancel:()=>te(null),onConfirm:(ce,rt)=>{const at=q;te(null),jt(at,{priceCents:rt>0?rt:void 0})}})})}),U&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Q(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:s.jsx(IW,{onCancel:()=>Q(null),onConfirm:(ce,rt,at,ve)=>{const _e=U;Q(null),jt(_e,{visibility:ce,orgId:rt,priceCents:at,donationsEnabled:ve})}})})})]})})}function IW({onCancel:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),lt.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:S=>m(S.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:i6.map(S=>s.jsx("button",{type:"button",onClick:()=>x(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,C&&g>0?g:void 0,C?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const i6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function PW({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(e?"shareMode.titleUpdate":"shareMode.title")}),s.jsx("div",{className:"space-y-2 mb-5",children:i6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>n(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(e?"shareMode.update":"shareMode.share")})]})]})}const zW=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:s6},Symbol.toStringTag,{value:"Module"}));async function o6(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(r=>r.id===t);if(n)return{items:[n,...e.filter(r=>r.id!==t)],highlighted:n,missing:!1};try{const{item:r}=await lt.getItem(t);return r?{items:[r,...e],highlighted:r,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function BW(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function T0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function z4(e,t){return e.i18n?.[t]?.description||e.description}const $W={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function HW({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=ft(["store","common"]),l=o.language,[c,d]=k.useState(""),[m,p]=k.useState([]),[h,g]=k.useState([]),[x,y]=k.useState(null),[w,C]=k.useState({}),[T,S]=k.useState(!1),[_,j]=k.useState(!0),[O,P]=k.useState(new Map),[L,F]=k.useState(new Set),[V,X]=k.useState(null),[z,G]=k.useState(null),ae=k.useCallback(async()=>{try{const[te,U]=await Promise.all([Me.builder.artifacts.list().catch(()=>({artifacts:[]})),Me.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const me of te.artifacts){if(me.type!=="agent")continue;const Ce=!!U.installed[`agent/${me.name}`];Q.set(me.name,{installed:Ce,localVersion:me.meta.version||void 0,localUpdatedAt:me.updatedAt})}P(Q)}catch{}},[]),Z=k.useCallback(async()=>{j(!0);try{const te=c?lt.search({type:"agent",q:c,limit:50}):Si(Tr.hubAgents)??lt.search({type:"agent",limit:50}),U=new URLSearchParams;c&&U.set("q",c);const Q=fetch("/api/templates?"+U.toString()).then(W=>W.json()).catch(()=>({templates:[]})),[me,Ce]=await Promise.all([te.catch(()=>({items:[],total:0})),Q,ae(),lt.isAuthenticated()?lt.purchases.mine().then(W=>F(new Set(W.purchases.map(fe=>fe.itemId)))).catch(()=>{}):Promise.resolve()]),H=await o6(me?.items??[],t);g(H.items),p(Array.isArray(Ce.templates)?Ce.templates:[]),H.missing&&n?.()}catch{p([]),g([])}finally{j(!1)}},[c,ae,t,n]);k.useEffect(()=>{Z()},[Z]),k.useEffect(()=>{if(!x){C({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(te=>te.json()).then(te=>C(te.files??{})).catch(()=>C({}))},[x]);const q=async(te,U,Q)=>{try{const me=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:te,name:U,orgId:"default",teamId:Q})});if(!me.ok)throw new Error(`Failed: ${me.status}`);S(!1),y(null)}catch(me){G({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${me}`,variant:"danger"})}};if(V)return s.jsx(Mi,{type:V.type,name:V.name,onBack:()=>X(null)});if(x){const te={type:"agent",name:x.id,displayName:T0(x,l),version:x.version,description:z4(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},U=s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.roleConfig")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.role")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.position")}),s.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${$W[x.agentRole]??""}`,children:x.agentRole})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.skills")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(Q=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:Q},Q)),x.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.starterTasks")}),s.jsx("div",{className:"space-y-2",children:x.starterTasks.map((Q,me)=>s.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${Q.priority==="high"?"bg-red-400":Q.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:Q.title}),Q.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:Q.description})]})]},me))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Mi,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:te,actionSlot:s.jsx("button",{onClick:()=>S(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium",children:r("agentStore.hireAgent")}),contentSlot:U}),T&&s.jsx(B4,{template:x,lang:l,onClose:()=>S(!1),onHire:q}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"danger",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:r("agentStore.title")}),s.jsx("input",{type:"text",placeholder:r("agentStore.searchPlaceholder"),value:c,onChange:te=>d(te.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:_?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((te,U)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},U))}):m.length===0&&h.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?r("agentStore.noResults",{search:c}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):s.jsxs(s.Fragment,{children:[m.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:r("agentStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:r("agentStore.available",{count:m.length})})]}),s.jsx(Ar,{columns:3,children:m.map(te=>s.jsx(ia,{type:"agent",name:T0(te,l),description:z4(te,l),seed:te.id,icon:te.icon,version:te.version,category:te.category,tags:te.tags,authorLabel:te.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>y(te)},te.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Ar,{columns:3,children:h.map(te=>s.jsx(UW,{item:te,localInfo:O.get(Lc(te)),purchased:e0(te,L),onStatusChange:ae,highlight:te.id===t,onHighlightDone:n,onViewDetail:U=>X({type:"agent",name:U})},te.id))})]})]})}),T&&x&&s.jsx(B4,{template:x,lang:l,onClose:()=>S(!1),onHire:q}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"danger",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]})}function Lc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return r0(n||e.name,"hub-pkg")}function Ni(e){return(async()=>{const t=await lt.download(e.id),n=t.name||e.name,r=t.config??{},o=Lc(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},d=(t.version||e.version||(typeof r.version=="string"?r.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Me.builder.artifacts.import(l,o,t.files,c,d);else{const m={...r,...d?{version:d}:{},name:o,displayName:r.displayName||n,description:e.description,source:c};await Me.builder.artifacts.save(l,m)}return await Me.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Qg(e,t){t("checking"),await lt.ensureAuth();const n=await lt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Ni(e),"installed";try{if((await lt.creator.getBalance()).availableBalance>=(e.priceCents??0)){const l=await lt.purchases.payWithEarnings(e.id);if(l.ok||l.alreadyOwned)return t("installing"),await Ni(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=window.open(n.checkoutUrl,"_blank","noopener");return new Promise((o,l)=>{const c=setInterval(async()=>{const d=r?r.closed:!1;try{if((await lt.purchases.checkout(e.id)).alreadyOwned){clearInterval(c),t("installing");try{await Ni(e),o("installed")}catch(p){l(p)}return}}catch{}if(d){clearInterval(c);try{if((await lt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Ni(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function UW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=ft(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const V=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(V)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&BW(e.version,t.localVersion),S=(e.priceCents??0)>0,_=async V=>{if(V.stopPropagation(),!m){p(!0),g("");try{await Ni(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(X){const z=X instanceof Error?X.message:"";z.includes("402")||z.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},j=async V=>{if(V.stopPropagation(),!m){p(!0),g("");try{await Qg(e,z=>{z==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):z==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(X){g(X instanceof Error?X.message:d("card.failed"))}finally{p(!1)}}},O=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,P=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,L=()=>{C&&c?c(Lc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},F=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:V=>{_(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):C?s.jsxs("button",{onClick:V=>{_(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?s.jsx("button",{onClick:V=>{j(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",O]})}):s.jsx("button",{onClick:V=>{_(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),h&&!(S&&!n)&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(ia,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:C,glowing:y,onClick:L,actions:F})})}function B4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,c]=k.useState(`${T0(e,t)} Agent`),[d,m]=k.useState(""),[p,h]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>h(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await r(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsx("div",{className:"flex items-center gap-3 mb-5",children:s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold",children:o("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:o("hireModal.creating",{name:T0(e,t)})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.agentName")}),s.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"input-field",autoFocus:!0})]}),p.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:o("hireModal.noTeam")}),p.map(w=>s.jsx("option",{value:w.id,children:w.name},w.id))]})]}),s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:o("hireModal.agentConfig")}),s.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||o("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:o("hireModal.cancel")}),s.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function ih(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function $4(e,t){return e.i18n?.[t]?.description||e.description}function H4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function FW(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function qW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[p,h]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[C,T]=k.useState(!0),[S,_]=k.useState(!1),[j,O]=k.useState(null),[P,L]=k.useState(new Map),[F,V]=k.useState(new Set),[X,z]=k.useState(null),G=k.useCallback(async()=>{try{const[q,te]=await Promise.all([Me.builder.artifacts.list().catch(()=>({artifacts:[]})),Me.builder.artifacts.installed().catch(()=>({installed:{}}))]),U=new Map;for(const Q of q.artifacts){if(Q.type!=="team")continue;const me=!!te.installed[`team/${Q.name}`];U.set(Q.name,{installed:me,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}L(U)}catch{}},[]),ae=k.useCallback(async()=>{T(!0);try{const q=l?lt.search({type:"team",q:l,limit:50}):Si(Tr.hubTeams)??lt.search({type:"team",limit:50}),[te,U]=await Promise.all([q.catch(()=>({items:[],total:0})),Me.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),G(),lt.isAuthenticated()?lt.purchases.mine().then(me=>V(new Set(me.purchases.map(Ce=>Ce.itemId)))).catch(()=>{}):Promise.resolve()]),Q=await o6(te?.items??[],e);h(Q.items),m(U?.templates??[]),Q.missing&&t?.()}catch{m([]),h([])}finally{T(!1)}},[l,G,e,t]);k.useEffect(()=>{ae()},[ae]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(q=>q.json()).then(q=>w(q.files??{})).catch(()=>w({}))},[g]);const Z=async q=>{_(!0),O(null);try{const U=(await Me.teams.create(q.name,q.description)).team.id;let Q,me=0;const Ce=[];for(const W of q.members){const fe=W.count??1;for(let I=0;I<fe;I++){const Re=W.name??`${q.name} Agent ${I+1}`,Be=fe>1?`${Re} ${I+1}`:Re,Pe=W.roleName??W.templateId;try{const Fe=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Be,...Pe?{roleName:Pe}:{},orgId:"default",teamId:U,agentRole:W.role??"worker",skills:W.skills??[]})});if(Fe.ok){me++;const dt=await Fe.json();W.role==="manager"&&!Q&&(Q=dt.agent?.id)}else{const dt=await Fe.json().catch(()=>({error:`HTTP ${Fe.status}`}));Ce.push(`${Be}: ${dt.error??Fe.statusText}`)}}catch(Fe){Ce.push(`${Be}: ${String(Fe)}`)}}}Q&&await Me.teams.update(U,{managerId:Q,managerType:"agent"}).catch(()=>{});const H=Ce.length>0?` (${Ce.length} failed: ${Ce[0]})`:"";O({ok:me>0,message:`Team "${ih(q,o)}" deployed with ${me} agent(s)${H}`})}catch(te){O({ok:!1,message:`Failed: ${te}`})}finally{_(!1)}};if(X)return s.jsx(Mi,{type:X.type,name:X.name,onBack:()=>z(null)});if(g){const q={...y};g.announcements&&(q["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(q["NORMS.md"]=g.norms);const te={type:"team",name:g.id,displayName:ih(g,o),version:g.version,description:$4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:q,team:{members:g.members.map(Q=>({name:H4(g,Q.name??Q.roleName??Q.templateId??"Agent",o),role:Q.role??"worker",roleName:Q.roleName??Q.templateId,count:Q.count??1,skills:Q.skills??[]}))}},U=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),s.jsx("div",{className:"p-5 space-y-2",children:g.members.map((Q,me)=>{const Ce=H4(g,Q.name??Q.roleName??Q.templateId??"Agent",o);return s.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${Q.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(Ce[0]??"?").toUpperCase()}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-fg-primary font-medium",children:Ce}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${Q.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:Q.role??"worker"}),(Q.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",Q.count]})]}),(Q.roleName||Q.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:Q.roleName??Q.templateId})]}),Q.skills&&Q.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[Q.skills.slice(0,3).map(H=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:H},H)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},me)})})]});return s.jsx(s.Fragment,{children:s.jsx(Mi,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:te,contentSlot:U,actionSlot:s.jsxs(s.Fragment,{children:[j&&s.jsx("span",{className:`text-xs ${j.ok?"text-green-500":"text-red-500"}`,children:j.message}),s.jsx("button",{onClick:()=>{Z(g)},disabled:S,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(S?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),s.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:q=>c(q.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:C?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((q,te)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},te))}):d.length===0&&p.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):s.jsxs(s.Fragment,{children:[d.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),s.jsx(Ar,{columns:2,children:d.map(q=>s.jsx(ia,{type:"team",name:ih(q,o),description:$4(q,o),seed:q.id,icon:q.icon||"users",version:q.version,category:q.category,tags:q.tags,authorLabel:q.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(q)},q.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Ar,{columns:2,children:p.map(q=>s.jsx(GW,{item:q,localInfo:P.get(Lc(q)),purchased:e0(q,F),onStatusChange:G,highlight:q.id===e,onHighlightDone:t,onViewDetail:te=>z({type:"team",name:te})},q.id))})]})]})})]})}function GW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=ft(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const V=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(V)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&FW(e.version,t.localVersion),S=(e.priceCents??0)>0,_=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,j=async V=>{if(V.stopPropagation(),!m){p(!0),g("");try{await Ni(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(X){const z=X instanceof Error?X.message:"";z.includes("402")||z.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},O=async V=>{if(V.stopPropagation(),!m){p(!0),g("");try{await Qg(e,z=>{z==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):z==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(X){g(X instanceof Error?X.message:d("card.failed"))}finally{p(!1)}}},P=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,L=()=>{C&&c?c(Lc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},F=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:V=>{j(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):C?s.jsxs("button",{onClick:V=>{j(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?s.jsx("button",{onClick:V=>{O(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",_]})}):s.jsx("button",{onClick:V=>{j(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),h&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(ia,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:C,glowing:y,onClick:L,actions:F})})}function oh(e,t){return e.i18n?.[t]?.displayName||e.name}function lh(e,t){return e.i18n?.[t]?.description||e.description||""}function l6(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}const KW={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 VW({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=ft(["store"]),[c,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",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&&l6(e.version,p.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),C=async()=>{if(!c){d(!0),w("");try{await Ni(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(S){const _=S instanceof Error?S.message:"";_.includes("402")||_.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!c){d(!0),w("");try{await Qg(e,_=>{_==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):_==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(S){r(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:c?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(h)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),p?.version?` (v${p.version})`:""]});if(x&&!n){const S=`$${((e.priceCents??0)/100).toFixed(2)}`;return s.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.jsx("button",{onClick:()=>{T()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 inline-flex items-center gap-1",children:c?y||l("card.installing"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",S]})})})}return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function U4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:c,type:d="skill"}){const m=k.useRef(null),[p,h]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),h(!0);const y=setTimeout(()=>{h(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const g=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:p?"animate-pulse":"",children:s.jsx(ia,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Kd(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:x,actions:s.jsx(VW,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function WW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,l=Uo(),[c,d]=k.useState("skills"),[m,p]=k.useState(null),[h,g]=k.useState(new Set),[x,y]=k.useState([]),[w,C]=k.useState(null),[T,S]=k.useState([]),[_,j]=k.useState(0),[O,P]=k.useState(1),[L,F]=k.useState([]),[V,X]=k.useState(""),[z,G]=k.useState("score"),[ae,Z]=k.useState(""),[q,te]=k.useState(!1),[U,Q]=k.useState([]),[me,Ce]=k.useState(!1),[H,W]=k.useState([]),[fe,I]=k.useState(""),[Re,Be]=k.useState(!1),[Pe,Fe]=k.useState([]),[dt,mt]=k.useState([]),[Nt,Ot]=k.useState(new Set),[At,qt]=k.useState(!1),[jt,$e]=k.useState(""),ut=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],kt=($,J="success")=>{p({text:$,type:J}),setTimeout(()=>p(null),J==="error"?1e4:4e3)},xt=k.useCallback(async()=>{try{const $=await Me.skills.list();y($.skills)}catch{}},[]),Ct=k.useCallback(async()=>{Ce(!0);try{const $=await Me.skills.builtin();Q($.skills)}catch{}Ce(!1)},[]),ce=k.useCallback(async $=>{te(!0);try{const J=await Me.skills.registrySkillhub({q:$?.q,category:$?.category,page:$?.page??1,limit:24,sort:$?.sort??z});S(J.skills),j(J.total),J.categories?.length&&F(J.categories)}catch{}te(!1)},[z]),rt=k.useCallback(async $=>{Be(!0);try{const J=await Me.skills.registrySkillssh($);W(J.skills)}catch{}Be(!1)},[]),at=k.useCallback(async $=>{qt(!0);try{const J=$?lt.search({type:"skill",q:$,limit:50}):Si(Tr.hubSkills)??lt.search({type:"skill",limit:50}),Te=lt.search({subtype:"connector",q:$||void 0,limit:50}).catch(()=>({items:[]})),[ne,he]=await Promise.all([J,Te,lt.isAuthenticated()?lt.purchases.mine().then(Se=>Ot(new Set(Se.purchases.map(st=>st.itemId)))).catch(()=>{}):Promise.resolve()]);let be=ne?.items??[],ge=he?.items??[];if(e){const Se=be.some(Ve=>Ve.id===e),st=ge.some(Ve=>Ve.id===e);if(!Se&&!st)try{const{item:Ve}=await lt.getItem(e);Ve?.subtype==="connector"?ge=[Ve,...ge]:Ve?be=[Ve,...be]:t?.()}catch{t?.()}else Se&&(be=[be.find(Je=>Je.id===e),...be.filter(Je=>Je.id!==e)]),st&&(ge=[ge.find(Je=>Je.id===e),...ge.filter(Je=>Je.id!==e)])}Fe(be),mt(ge)}catch{}qt(!1)},[e,t]);k.useEffect(()=>{xt(),Ct(),ce(),rt()},[]),k.useEffect(()=>{c==="skills"&&at(jt)},[c,jt,at]);const ve=async $=>{g(J=>new Set(J).add($.name));try{const J=await Me.skills.install({name:$.name,source:"skillhub",slug:$.slug,sourceUrl:$.homepage,description:$.description_zh??$.description,category:"custom",version:$.version});await xt(),kt(`"${$.name}" installed (${J.method}) → ${J.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{kt(`Download failed for "${$.name}". You can try manually from: ${$.homepage}`,"error")}g(J=>{const Te=new Set(J);return Te.delete($.name),Te})},_e=async $=>{g(J=>new Set(J).add($.name));try{const J=await Me.skills.install({name:$.name,source:"skillssh",sourceUrl:$.url,githubRepo:`${$.author}/${$.repo}`,githubSkillPath:$.name});await xt(),kt(`"${$.name}" installed (${J.method}) → ${J.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{kt(`Download failed for "${$.name}". You can try manually from: ${$.url}`,"error")}g(J=>{const Te=new Set(J);return Te.delete($.name),Te})},Ee=async $=>{g(J=>new Set(J).add($.name));try{const J=await Me.skills.install({name:$.name,source:"builtin"});await xt(),await Ct(),kt(`"${$.name}" installed (${J.method}) → ${J.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(J){kt(`Install failed for "${$.name}": ${J}`,"error")}g(J=>{const Te=new Set(J);return Te.delete($.name),Te})},oe=H.filter($=>{if(!fe)return!0;const J=fe.toLowerCase();return $.name.toLowerCase().includes(J)||$.repo.toLowerCase().includes(J)});if(w){const $=w,J={};$.instructions&&(J["SKILL.md"]=$.instructions);const Te={type:"skill",name:$.name,displayName:oh($,o),version:$.version,description:lh($,o),author:$.author??"",category:$.category??"general",tags:$.tags,files:J,skill:{skillFile:$.instructions?"SKILL.md":"",requiredPermissions:$.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},ne=$.installed&&$.installedVersion&&l6($.version,$.installedVersion)?s.jsx("button",{onClick:()=>{Ee($)},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?s.jsxs("span",{className:"px-4 py-1.5 text-xs bg-green-500/10 text-green-500 rounded-lg border border-green-500/20 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),$.installedVersion?` v${$.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{Ee($)},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")}),he=s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[$.category&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),s.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${KW[$.category]??"bg-gray-500/15 text-fg-secondary"}`,children:$.category})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:$.version})]}),$.hasMcpServers&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),$.hasInstructions&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),s.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),($.requiredPermissions.length>0||$.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[$.requiredPermissions.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:$.requiredPermissions.map(be=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:be},be))})]}),$.tags.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:$.tags.map(be=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:be},be))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Mi,{type:"skill",name:$.name,onBack:()=>C(null),readOnly:!0,initialManifest:Te,actionSlot:ne,contentSlot:he}),m&&s.jsx("div",{className:`mx-7 mb-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[s.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:s.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),s.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:ut.map($=>s.jsx("button",{onClick:()=>d($.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&&s.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text}),c==="skills"&&(()=>{const $=jt.trim().toLowerCase(),J=$?U.filter(he=>oh(he,o).toLowerCase().includes($)||lh(he,o).toLowerCase().includes($)):U,Te=me&&At,ne=J.length===0&&Pe.length===0&&dt.length===0;return s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{value:jt,onChange:he=>$e(he.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"}`})}),Te&&ne?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((he,be)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},be))}):ne?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),s.jsx("div",{children:n("skillStore.noBuiltin")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):s.jsxs(s.Fragment,{children:[J.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:J.length})})]}),s.jsx(Ar,{columns:3,children:J.map(he=>s.jsx(ia,{type:"skill",name:oh(he,o),description:lh(he,o),seed:he.name,icon:Kd(he.name,he.category),version:he.version,category:he.category,tags:he.tags,authorLabel:he.author||void 0,installed:he.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:he.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>C(he)},he.name))})]}),Pe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Ar,{columns:3,children:Pe.map(he=>s.jsx(U4,{item:he,installedSkills:x,purchased:e0(he,Nt),onMsg:kt,onRefresh:()=>{xt(),at(jt)},highlight:he.id===e,onHighlightDone:t},he.id))})]}),dt.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"mb-3",children:[s.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),s.jsx(Ar,{columns:3,children:dt.map(he=>s.jsx(U4,{item:he,type:"connector",installedSkills:x,purchased:e0(he,Nt),onMsg:kt,onRefresh:()=>{xt(),at(jt)},highlight:he.id===e,onHighlightDone:t},he.id))})]})]})]})})(),c==="skillhub"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsxs("select",{value:V,onChange:$=>{X($.target.value),P(1),ce({q:ae||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:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),L.map($=>s.jsx("option",{value:$,children:$},$))]}),s.jsxs("select",{value:z,onChange:$=>{G($.target.value),P(1),ce({q:ae||void 0,category:V||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:[s.jsx("option",{value:"score",children:n("skillStore.sortScore")}),s.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),s.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),s.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),s.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[s.jsx("input",{value:ae,onChange:$=>Z($.target.value),onKeyDown:$=>{$.key==="Enter"&&(P(1),ce({q:ae||void 0,category:V||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),s.jsx("button",{onClick:()=>{P(1),ce({q:ae||void 0,category:V||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),q?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),s.jsx("div",{children:n("skillStore.noSkillhub")})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:_.toLocaleString()})}),s.jsx(Ar,{columns:3,children:T.map($=>{const J=x.some(Te=>Te.name===$.name||Te.name===$.slug);return s.jsx(ia,{type:"skill",name:$.name,description:$.description_zh??$.description??"",seed:$.slug,icon:Kd($.slug||$.name,$.tags?.[0]),version:$.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:$.tags,installed:J,hideStats:!0,onClick:()=>window.open($.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[$.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",$.stars.toLocaleString()]}),$.downloads>0&&s.jsxs("span",{children:[$.downloads>=1e4?`${($.downloads/1e4).toFixed(1)}万`:$.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:J?void 0:s.jsx("button",{onClick:()=>{ve($)},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)})}),_>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:O<=1,onClick:()=>{const $=O-1;P($),ce({q:ae||void 0,category:V||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")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:O,total:Math.ceil(_/24)})}),s.jsx("button",{disabled:O>=Math.ceil(_/24),onClick:()=>{const $=O+1;P($),ce({q:ae||void 0,category:V||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"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[s.jsx("input",{value:fe,onChange:$=>I($.target.value),onKeyDown:$=>{$.key==="Enter"&&fe.trim()&&rt(fe)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),s.jsx("button",{onClick:()=>{fe.trim()&&rt(fe)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Re?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):oe.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),s.jsx("div",{children:n("skillStore.browseSkillssh")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):s.jsx(Ar,{columns:3,children:oe.map($=>{const J=x.some(Te=>Te.name===$.name);return s.jsx(ia,{type:"skill",name:$.name,description:$.description||"",seed:`${$.author}-${$.name}`,icon:Kd($.name),authorLabel:`${$.author}/${$.repo}`,showTypeBadge:!1,installed:J,hideStats:!0,cornerLabel:J?void 0:"skills.sh",onClick:()=>window.open($.url,"_blank","noopener,noreferrer"),footerLeft:$.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[$.installs," installs"]}):void 0,actions:J?void 0:s.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 YW=["agent","team","skill","connector"];function ch({title:e,subtitle:t,onMore:n,moreLabel:r}){return s.jsxs("div",{className:"flex items-end justify-between mb-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"section-title",children:e}),t&&s.jsx("p",{className:"section-subtitle",children:t})]}),n&&s.jsxs("button",{className:"section-link",onClick:n,children:[r??"View all"," →"]})]})}function XW({item:e,onOpen:t}){const n=Xo(e.subtype==="connector"?"connector":e.itemType),r=Xg(n,e.slug||e.name),o=Ei[n];return s.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:r},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),s.jsx("svg",{className:"absolute -right-8 -bottom-10 opacity-20",width:"220",height:"220",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",fill:"white"})}),s.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[s.jsxs("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:["★ Featured · ",o.label]}),s.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),s.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(C0,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:lt.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),s.jsxs("span",{children:["↓ ",Mo(e.downloadCount)]}),(e.priceCents??0)>0?s.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):s.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function F4({items:e,onOpen:t}){return s.jsx(Ar,{columns:3,children:e.map(n=>s.jsx(ia,{type:n.subtype==="connector"?"connector":n.itemType,name:n.name,description:n.description,seed:n.slug||n.name,icon:n.icon,cover:n.thumbnailUrl,hubBase:lt.getUrl(),author:n.author,category:n.category,tags:n.tags,rating:parseFloat(n.avgRating)||0,ratingCount:n.ratingCount,downloadCount:n.downloadCount,priceCents:n.priceCents,currency:n.currency,onClick:()=>t(n)},n.id))})}function q4(){return s.jsx(Ar,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function QW({onOpenType:e}){const{t}=ft(["store","common"]),[n,r]=k.useState([]),[o,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await lt.search({limit:60,sort:"popular"});g||r(x.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),p=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),h=g=>e(Xo(g.subtype==="connector"?"connector":g.itemType),g.id);return s.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[s.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),s.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:YW.map(g=>s.jsxs("button",{onClick:()=>e(g),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Ei[g].gradient} hover:opacity-90 transition-opacity`,children:[Ei[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ei[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(g=>s.jsx(XW,{item:g,onOpen:()=>h(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(q4,{}):d.length>0?s.jsx(F4,{items:d,onOpen:h}):s.jsx(ZW,{})]}),s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(q4,{}):m.length>0?s.jsx(F4,{items:m,onOpen:h}):null]}),p.length>0&&s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:p.map((g,x)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(C0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:lt.getUrl(),size:48,verified:x<3}),x<3&&s.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:x+1})]}),s.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),s.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",Mo(g.downloads)]})]},g.author?.username||x))})]})]})}function ZW(){const{t:e}=ft(["store"]);return s.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[s.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),s.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),s.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Ld(e,t,n){return e.i18n?.[n]?.[t]}function JW(){const{t:e,i18n:t}=ft(["store","common"]),n=Uo(),r=t.language,[o,l]=k.useState([]),[c,d]=k.useState({}),[m,p]=k.useState(new Set),[h,g]=k.useState(null),[x,y]=k.useState(!0),[w,C]=k.useState(""),[T,S]=k.useState("all"),[_,j]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[F,V,X,z]=await Promise.all([Me.builder.artifacts.list().catch(()=>({artifacts:[]})),Me.builder.artifacts.installed().catch(()=>({installed:{}})),Me.skills.updates().catch(()=>({updates:[],count:0})),Me.skills.builtin().catch(()=>({skills:[]}))]),G={};for(const q of X.updates)G[q.name]={availableVersion:q.availableVersion,installedVersion:q.installedVersion,displayName:q.displayName,description:q.description};d(G);const ae=F.artifacts.filter(q=>{const te=`${q.type}/${q.name}`;return!!V.installed[te]}),Z=new Set(ae.filter(q=>q.type==="skill").map(q=>q.name));for(const q of z.skills)!q.installed||Z.has(q.name)||!(V.installed[`skill/${q.name}`]||G[q.name])&&!q.updateAvailable||!V.installed[`skill/${q.name}`]&&!G[q.name]||(ae.push({type:"skill",name:q.name,meta:{displayName:q.i18n?.[r]?.displayName||q.name,description:q.i18n?.[r]?.description||q.description||"",version:q.installedVersion||q.version,author:q.author,category:q.category,tags:q.tags,i18n:q.i18n},path:"",updatedAt:""}),Z.add(q.name));for(const[q,te]of Object.entries(G))Z.has(q)||(ae.push({type:"skill",name:q,meta:{displayName:te.displayName||q,description:te.description||"",version:te.installedVersion},path:"",updatedAt:""}),Z.add(q));l(ae)}catch{}y(!1)},[r]);k.useEffect(()=>{O()},[O]),k.useEffect(()=>{const F=()=>{O()};return window.addEventListener("markus:data-changed",F),()=>window.removeEventListener("markus:data-changed",F)},[O]),k.useEffect(()=>{if(!h)return;const F=setTimeout(()=>g(null),3e3);return()=>clearTimeout(F)},[h]);const P=async(F,V)=>{if(!m.has(F)){p(X=>new Set(X).add(F));try{await Me.skills.install({name:F,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:F,version:V}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:F}),type:"error"})}p(X=>{const z=new Set(X);return z.delete(F),z})}},L=o.filter(F=>{if(T!=="all"&&F.type!==T)return!1;if(!w)return!0;const V=w.toLowerCase(),X=(Ld(F.meta,"displayName",r)||F.meta.displayName||F.name).toLowerCase(),z=(Ld(F.meta,"description",r)||F.meta.description||"").toLowerCase();return X.includes(V)||z.includes(V)}).sort((F,V)=>{const X=F.type==="skill"&&c[F.name]?1:0;return(V.type==="skill"&&c[V.name]?1:0)-X});return _?s.jsx(Mi,{type:_.type,name:_.name,onBack:()=>j(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&s.jsxs("span",{className:"px-2 py-0.5 text-[11px] font-medium rounded-md bg-amber-500/15 text-amber-600 border border-amber-500/25",children:[e("installedTab.updateAvailable")," · ",Object.keys(c).length]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[s.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(F=>s.jsx("button",{onClick:()=>S(F),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===F?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${F==="all"?"All":F==="agent"?"Agents":F==="team"?"Teams":"Skills"}`)},F))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:F=>C(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):L.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Ar,{columns:3,children:L.map(F=>{const V=Ld(F.meta,"displayName",r)||F.meta.displayName||F.name,X=Ld(F.meta,"description",r)||F.meta.description||"",z=F.meta.version||"",G=F.meta.author||"",ae=F.meta.tags??[],Z=F.meta.category||"",q=F.meta.icon,te=F.type==="skill"?c[F.name]:void 0;return s.jsx(ia,{type:F.type,name:V,description:X,seed:F.name,icon:q,author:null,authorLabel:G||void 0,version:te?te.installedVersion:z,category:Z,tags:ae,installed:!te,hideStats:!0,cornerLabel:te?e("installedTab.updateAvailable"):void 0,onClick:()=>{F.path&&j({type:F.type,name:F.name})},actions:te?s.jsx("button",{type:"button",disabled:m.has(F.name),onClick:()=>{P(F.name,te.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(F.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:te.availableVersion})}):void 0},`${F.type}/${F.name}`)})})}),h&&s.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-sm shadow-lg ${h.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:h.text})]})}const eY=50,tY=30;function nY(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const p=m.changedTouches[0].clientX-o.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(p),x=Math.abs(h);if(g<eY||Math.atan2(x,g)*(180/Math.PI)>tY)return;if(r?.scrollContainerRef?.current){const C=r.scrollContainerRef.current,T=C.scrollLeft<=1,S=C.scrollLeft+C.clientWidth>=C.scrollWidth-1;if(p>0&&!T||p<0&&!S)return}const w=e.findIndex(C=>C.id===t);p<0&&w<e.length-1?n(e[w+1].id):p>0&&w>0?n(e[w-1].id):p>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():p<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:c,onTouchEnd:d}}const rY=["builder","discover","agents","teams","skills","installed"],aY={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function sg(e){return!!e&&rY.includes(e)}function G4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:sg(t)?t:"builder",installId:e}}function sY({authUser:e}){const{t}=ft(["nav","store","common"]),n=k.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[r]=k.useState(G4),[o,l]=k.useState(r.tab),[c,d]=k.useState(r.installId),m=nY(n,o,l);k.useEffect(()=>{const h=G4();h.installId&&(d(h.installId),sg(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const h=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");sg(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",h),()=>window.removeEventListener("markus:navigate",h)},[]);const p=(h,g)=>{g&&d(g),l(aY[h]??"agents")};return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[s.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[s.jsx(Mw,{className:"ml-2"}),n.map(h=>s.jsx("button",{onClick:()=>l(h.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${o===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(s6,{authUser:e}),o==="discover"&&s.jsx(QW,{onOpenType:p}),o==="agents"&&s.jsx(HW,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(qW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(WW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(JW,{})]})]})}const K4="usageType",uh="profile";function iY({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=ft(["onboarding","common"]),[c,d]=k.useState(0),[m,p]=k.useState(""),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,C]=k.useState(""),[T,S]=k.useState(!1),[_,j]=k.useState(""),[O,P]=k.useState(!1),[L,F]=k.useState(null);k.useEffect(()=>{Me.auth.me().then(({user:$e})=>{$e.name&&p($e.name),$e.email&&g($e.email),$e.avatarUrl&&F($e.avatarUrl);const ut=$e.name||$e.email?.split("@")[0]||"";ut&&G(kt=>kt||l("usageType.defaultOrgName",{name:ut}))}).catch(()=>{}),Me.settings.getOrg().then(({org:$e})=>{$e?.name&&$e.name!=="My Organization"&&G($e.name)}).catch(()=>{}),yn()&&Me.hubOrgs.invitations().then($e=>{$e.invitations?.length>0&&Ce($e.invitations)}).catch(()=>{})},[]);const[V,X]=k.useState(null),[z,G]=k.useState(""),[ae,Z]=k.useState(!1),[q,te]=k.useState(!1),[U,Q]=k.useState(""),[me,Ce]=k.useState([]),[H,W]=k.useState(null),[fe,I]=k.useState(null),Re=async()=>{const $e=z.trim();if($e){Z(!0),Q("");try{if(await Me.settings.updateOrg($e),yn()){const ut=await Me.hubOrgs.mine(),kt=ut.orgs?.find(xt=>xt.role==="owner")??ut.orgs?.[0];kt?.id?await Me.hubOrgs.update(kt.id,{name:$e}):await Me.hubOrgs.create($e)}te(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{Z(!1)}}},[Be,Pe]=k.useState(!0),Fe=async()=>{if(j(""),!m.trim()){j(l("profile.errors.nameRequired"));return}if(!h.trim()){j(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h.trim())){j(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){j(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){j(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:$e}=await Me.auth.updateProfile(m.trim(),h.trim());x&&await Me.auth.changePassword("",x),o?.($e),P(!0)}catch{j(l("profile.errors.saveFailed"))}finally{S(!1)}},dt=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],mt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:s.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:s.jsx(m8,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:K4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>{X("personal"),te(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${V==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"👤"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),s.jsxs("button",{onClick:()=>{X("organization"),te(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${V==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"🏢"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),V==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[me.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),me.map($e=>s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:$e.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:$e.invitedBy})})]}),s.jsx("button",{onClick:async()=>{W($e.orgId);try{await Me.hubOrgs.acceptInvitation($e.orgId),I($e.orgId),te(!0)}catch{}finally{W(null)}},disabled:H===$e.orgId||fe===$e.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:fe===$e.orgId?l("usageType.accepted"):H===$e.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},$e.orgId)),s.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),s.jsx("input",{type:"text",value:z,onChange:$e=>{G($e.target.value),te(!1),Q("")},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"})]}),U&&s.jsx("p",{className:"text-xs text-red-500",children:U}),s.jsx("button",{onClick:()=>{Re()},disabled:ae||!z.trim()||q,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(ae?"common:saving":q?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:uh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:O?s.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[s.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",h]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(jw,{currentUrl:L,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange:$e=>p($e.target.value),placeholder:l("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",value:h,onChange:$e=>g($e.target.value),placeholder:l("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),s.jsx("input",{type:"password",value:x,onChange:$e=>y($e.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),x&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),s.jsx("input",{type:"password",value:w,onChange:$e=>C($e.target.value),placeholder:l("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),_&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:_}),s.jsx("button",{onClick:()=>{Fe()},disabled:T||!m.trim()||!h.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(T?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"grid grid-cols-3 gap-3",children:dt.map($e=>s.jsxs("button",{onClick:()=>n($e.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===$e.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:$e.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:$e.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:$e.desc})]},$e.value))}),s.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[s.jsx("input",{type:"checkbox",checked:Be,onChange:$e=>Pe($e.target.checked),className:"accent-brand-500 shrink-0"}),s.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],Nt=r?mt.filter($e=>$e.id!==uh):mt,Ot=Nt.findIndex($e=>$e.id===K4),At=Nt.findIndex($e=>$e.id===uh),qt=()=>{c===Ot&&Ot>=0&&!V||c===Ot&&V==="organization"&&!q||c===At&&At>=0&&!O||(c<Nt.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Be})}).catch(()=>{}),e()))},jt=Nt[c];return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:s.jsx("div",{className:"w-full max-w-lg",children:s.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[s.jsx("div",{className:"flex gap-1.5 mb-8",children:Nt.map(($e,ut)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ut<=c?"bg-brand-500":"bg-surface-elevated"}`},ut))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:jt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:jt.subtitle}),jt.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?s.jsx("button",{onClick:()=>d(c-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):s.jsx("span",{}),s.jsx("button",{onClick:qt,disabled:At>=0&&c===At&&!O||Ot>=0&&c===Ot&&(!V||V==="organization"&&!q),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${At>=0&&c===At&&!O||Ot>=0&&c===Ot&&(!V||V==="organization"&&!q)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===Nt.length-1?l("getStarted"):l("common:next")})]})]})})})}const V4="markus:legal-consent",oY="https://markus.global";function lY({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=ft("auth"),[o,l]=k.useState(null),[c,d]=k.useState(""),[m,p]=k.useState(!1),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,C]=k.useState(!1),[T,S]=k.useState(!1),_=G=>{const ae=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${oY}${G}${ae}`},j=()=>{try{localStorage.setItem(V4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(j(),!0):(C(!1),requestAnimationFrame(()=>C(!0)),!1),P=async()=>{const G=yn(),ae=sa();if(!G||!ae){d(n("login.hubUnavailable"));return}const Z=await Me.auth.hubLogin(G,ae);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),Z.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",Z.cloudAiError?n("login.cloudAiNotReady",{error:Z.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(Z.user,Z.needsOnboarding??!1,{fromHub:!0})},L=async(G,ae=!1)=>{if(!(!ae&&!O())){d(""),l(G??"hub");try{if(ae&&yn()&&sa()){await P();return}await na(G),await P()}catch(Z){const q=Z instanceof Error?Z.message:"";if(!q.includes("cancelled")){if(!ae&&yn())return L(G,!0);d(q||n("login.hubUnavailable"))}}finally{l(null)}}},F=()=>{eD(),l(null),d("")};k.useEffect(()=>{const G=window.markusDesktop;if(!G?.peekPendingDeepLinkAuth&&!G?.consumePendingDeepLinkAuth)return;let ae=!1;return(async()=>{const Z=G.peekPendingDeepLinkAuth?await G.peekPendingDeepLinkAuth():null;if(ae||!Z)return;let q=!1;try{q=!!localStorage.getItem(V4)}catch{}if(!T&&!q){d(n("login.consentRequired"));return}q&&!T&&S(!0),j();const te=G.consumePendingDeepLinkAuth?await G.consumePendingDeepLinkAuth():Z;if(!(ae||!te)){d(""),l("hub");try{if(!await JL(te)||!yn()||!sa()){d(n("login.hubUnavailable"));return}await P()}catch{d(n("login.hubUnavailable"))}finally{ae||l(null)}}})().catch(()=>{}),()=>{ae=!0}},[T]);const V=async G=>{if(G.preventDefault(),!(!h.trim()||!x)&&O()){d(""),l("local");try{const{user:ae,needsOnboarding:Z}=await Me.auth.login(h.trim(),x);e(ae,Z??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},X=n(t?"login.welcomeBack":"login.getStarted"),z="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[s.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute -top-48 left-1/2 -translate-x-1/2 h-[42rem] w-[42rem] rounded-full bg-brand-500/20 blur-[120px]"}),s.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),s.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),s.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-16 h-16 mx-auto mb-4 rounded-2xl shadow-xl shadow-brand-900/20 ring-1 ring-border-default/40"}),s.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:X})]}),s.jsx("div",{className:"bg-surface-secondary/70 backdrop-blur-xl border border-border-default/80 rounded-3xl p-7 sm:p-8 shadow-2xl shadow-black/10",children:m?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),s.jsxs("form",{onSubmit:V,className:"space-y-3",children:[s.jsx("input",{type:"email",value:h,onChange:G=>g(G.target.value),autoComplete:"email",autoFocus:!0,placeholder:n("login.email"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),s.jsx("input",{type:"password",value:x,onChange:G=>y(G.target.value),autoComplete:"current-password",placeholder:n("login.password"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),c&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:c}),!t&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!h||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(o==="local"?"login.signingIn":"login.signIn")})]}),s.jsx("div",{className:"text-center",children:s.jsx("button",{onClick:()=>{p(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("button",{onClick:()=>L("google"),disabled:!!o,className:z,children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),s.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),s.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),s.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),n(o==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>L("github"),disabled:!!o,className:z,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),n(o==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>L("email"),disabled:!!o,className:z,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(o==="email"?"login.connectingHub":"login.withEmail")]}),o&&(o==="google"||o==="github"||o==="email"||o==="hub")&&s.jsxs("div",{className:"px-3 py-2.5 bg-brand-500/10 border border-brand-500/30 rounded-lg text-xs text-fg-secondary space-y-2",children:[s.jsx("p",{children:n("login.browserOpened")}),s.jsx("button",{type:"button",onClick:F,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:c}),s.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[s.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),s.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),s.jsx("button",{onClick:()=>{p(!0),d("")},disabled:!!o,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),s.jsxs("label",{onAnimationEnd:()=>C(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[s.jsx("input",{type:"checkbox",checked:T,onChange:G=>{S(G.target.checked),G.target.checked&&C(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),s.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",s.jsx("a",{href:_("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",s.jsx("a",{href:_("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),s.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[s.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),s.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function cY({token:e,onComplete:t}){const{t:n}=ft("auth"),[r,o]=k.useState(null),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[C,T]=k.useState(!1);k.useEffect(()=>{Me.auth.inviteInfo(e).then(_=>o(_)).catch(()=>T(!0))},[e]);const S=async _=>{if(_.preventDefault(),h(""),l.length<6){h(n("invite.passwordMinLength"));return}if(l!==d){h(n("invite.passwordsDoNotMatch"));return}x(!0);try{await Me.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),s.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:C?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),s.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):r?s.jsxs("form",{onSubmit:S,className:"space-y-5",children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:r.name})}),s.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:r.email}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),s.jsx("input",{type:"password",value:l,onChange:_=>c(_.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),s.jsx("input",{type:"password",value:d,onChange:_=>m(_.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&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(g?"invite.settingUp":"invite.setupAccount")})]}):s.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function uY({onComplete:e,isFirstTime:t}){const{t:n}=ft("auth"),[r,o]=k.useState(""),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==d){h(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Me.auth.changePassword(r,l),e()}catch{h(n("changePassword.failedToChange"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),s.jsxs("form",{onSubmit: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:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&s.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:r,onChange:w=>o(w.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),s.jsx("input",{type:"password",value:l,onChange:w=>c(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),s.jsx("input",{type:"password",value:d,onChange:w=>m(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),p&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:n(g?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}function dY({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const C=localStorage.getItem(`${l}_w`);if(C)return Math.max(n,Math.min(r,parseInt(C,10)))}catch{}return t}),[m,p]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=k.useRef(!1),g=k.useRef(n),x=k.useRef(r);g.current=n,x.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(C=>Math.max(n,Math.min(r,C)))},[n,r]);const y=k.useCallback(C=>{C.preventDefault(),h.current=!0;const T=C.clientX,S=c,_=O=>{if(!h.current)return;const P=O.clientX-T;d(Math.max(g.current,Math.min(x.current,S+P)))},j=()=>{h.current=!1,document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",_),document.addEventListener("mouseup",j),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>p(C=>!C),[]);return{width:m?o:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:p,setWidth:d,onResizeStart:y}}const dX=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],ig="markus-theme";function W4(e){const t=document.documentElement;t.classList.remove("light","dark","cyberpunk","mono"),e==="light"?t.classList.add("light"):e==="dark"?t.classList.add("dark"):e==="cyberpunk"?t.classList.add("cyberpunk"):e==="mono"&&t.classList.add("mono")}function mY(){try{const e=localStorage.getItem(ig);if(e==="midnight")return localStorage.setItem(ig,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function fY(){const[e,t]=k.useState(mY),n=k.useCallback(r=>{t(r);try{localStorage.setItem(ig,r)}catch{}W4(r)},[]);return k.useEffect(()=>{W4(e)},[e]),{mode:e,setMode:n}}const Wd={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},pY={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},hY=["agents","tasks","requirements","projects","deliverables","workflows"];let Y4="",X4="all",Q4=Wd,Z4=!1;function gY({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);Ho(!0);const[r,o]=k.useState(Y4),[l,c]=k.useState(X4),[d,m]=k.useState(Q4),[p,h]=k.useState(!1),[g,x]=k.useState(Z4),[y,w]=k.useState(-1);k.useEffect(()=>{Y4=r},[r]),k.useEffect(()=>{X4=l},[l]),k.useEffect(()=>{Q4=d},[d]),k.useEffect(()=>{Z4=g},[g]);const C=k.useRef(null),T=k.useRef(void 0),S=k.useRef(null),_=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{C.current?.focus(),C.current?.select()},100)},[]);const j=k.useCallback(async Z=>{if(!Z.trim()){m(Wd),x(!1),w(-1);return}h(!0),x(!0),w(-1);const q=Z.toLowerCase();try{const[te,U,Q,me,Ce,H]=await Promise.allSettled([Me.agents.list(),Me.tasks.list({search:Z,pageSize:20}),Me.requirements.list(),Me.projects.list(),Me.deliverables.search({q:Z,limit:20}),Me.teams.list()]),W=te.status==="fulfilled"?te.value.agents.filter(Fe=>Fe.name?.toLowerCase().includes(q)||Fe.role?.toLowerCase().includes(q)):[],fe=U.status==="fulfilled"?U.value.tasks:[],I=Q.status==="fulfilled"?Q.value.requirements.filter(Fe=>Fe.title?.toLowerCase().includes(q)||Fe.description?.toLowerCase().includes(q)):[],Re=me.status==="fulfilled"?me.value.projects.filter(Fe=>Fe.name?.toLowerCase().includes(q)||Fe.description?.toLowerCase().includes(q)):[],Be=Ce.status==="fulfilled"?Ce.value.results:[],Pe=[];if(H.status==="fulfilled"){const Fe=await Promise.allSettled(H.value.teams.map(dt=>Me.workflows.list(dt.id)));for(const dt of Fe)if(dt.status==="fulfilled")for(const mt of dt.value.workflows)(mt.name.toLowerCase().includes(q)||(mt.displayName||"").toLowerCase().includes(q)||mt.description?.toLowerCase().includes(q))&&Pe.push(mt)}m({agents:W,tasks:fe,requirements:I,projects:Re,deliverables:Be,workflows:Pe})}catch{m(Wd)}finally{h(!1)}},[]),O=Z=>{o(Z),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>j(Z),400)},P=k.useCallback((Z,q)=>{e(),it.navigate(Z,q)},[e]),L=[{id:"all",label:n("common:all",{defaultValue:"全部"})},{id:"agents",label:n("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:n("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:n("common:requirements",{defaultValue:"需求"})},{id:"projects",label:n("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:n("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:n("common:workflows",{defaultValue:"工作流"})}],F=k.useMemo(()=>pY[t||""]||hY,[t]),V=k.useMemo(()=>{const Z=[],q=l==="all"?8:void 0,te=U=>{if(l!=="all"&&l!==U)return;const Q=d[U].length;if(U==="workflows"){const me=q?d.workflows.slice(0,q):d.workflows;for(const Ce of me)Z.push({id:Ce.name,type:"workflow",page:ue.WORK,params:{boardType:"workflows"}})}else{const me=d[U],Ce=q?me.slice(0,q):me;for(const H of Ce)switch(U){case"agents":Z.push({id:H.id,type:"agent",page:ue.TEAM,params:{agentId:H.id}});break;case"tasks":Z.push({id:H.id,type:"task",page:ue.WORK,params:{openTask:H.id}});break;case"requirements":Z.push({id:H.id,type:"requirement",page:ue.WORK,params:{openRequirement:H.id}});break;case"projects":Z.push({id:H.id,type:"project",page:ue.WORK,params:{projectId:H.id}});break;case"deliverables":Z.push({id:H.id,type:"deliverable",page:ue.DELIVERABLES,params:{openDeliverable:H.id}});break}}q&&Q>q&&Z.push({id:`more_${U}`,type:"showMore",page:"",expandCategory:U,totalCount:Q})};for(const U of F)te(U);return Z},[d,l,F]),X=k.useCallback(Z=>{if(Z.type==="showMore"&&Z.expandCategory){c(Z.expandCategory),w(-1);return}P(Z.page,Z.params)},[P]);k.useEffect(()=>{const Z=_.current;if(!Z||y<0)return;const q=Z.querySelector(`[data-idx="${y}"]`);q&&q.scrollIntoView({block:"nearest"})},[y]);const z=k.useCallback(Z=>{if(Z.key==="Escape"){e();return}if(Z.key==="Tab"){Z.preventDefault();const U=L.map(Ce=>Ce.id),Q=U.indexOf(l),me=Z.shiftKey?Q<=0?U.length-1:Q-1:Q>=U.length-1?0:Q+1;c(U[me]),w(-1);return}const q=Z.ctrlKey&&Z.key==="n"||Z.key==="ArrowDown",te=Z.ctrlKey&&Z.key==="p"||Z.key==="ArrowUp";if(q||te){Z.preventDefault(),w(U=>{const Q=V.length-1;return Q<0?-1:q?U>=Q?0:U+1:U<=0?Q:U-1});return}Z.key==="Enter"&&(Z.preventDefault(),y>=0&&y<V.length&&X(V[y]))},[e,V,y,X,L,l]);k.useEffect(()=>(document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)),[z]);const G=V.length>0;let ae=0;return s.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:Z=>{Z.target===S.current&&e()},children:s.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[s.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("input",{ref:C,value:r,onChange:Z=>O(Z.target.value),placeholder:n("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),r&&s.jsx("button",{onClick:()=>{o(""),m(Wd),x(!1),w(-1),C.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:L.map(Z=>s.jsx("button",{onClick:()=>{c(Z.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===Z.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:Z.label},Z.id))})]}),s.jsxs("div",{ref:_,className:"flex-1 overflow-y-auto px-5 py-3",children:[p&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!p&&g&&!G&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!p&&G&&s.jsx("div",{className:"space-y-4",children:F.map(Z=>{if(l!=="all"&&l!==Z)return null;const q=l==="all"?8:void 0,te=U=>{const Q=ae++,me=U==="agents"?d.agents.length:U==="tasks"?d.tasks.length:U==="requirements"?d.requirements.length:U==="projects"?d.projects.length:U==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{c(U),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",me,")"]})};return Z==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.agents.slice(0,q):d.agents).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.TEAM,{agentId:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Hs,{name:U.name||"Agent",avatarUrl:U.avatarUrl,size:28}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:U.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:U.role||U.status})]}),s.jsx(bY,{status:U.status})]},U.id)})}),q&&d.agents.length>q&&te("agents")]},"agents"):Z==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.tasks.slice(0,q):d.tasks).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.WORK,{openTask:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(xY,{status:U.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.status," · ",U.priority||""]})]})]},U.id)})}),q&&d.tasks.length>q&&te("tasks")]},"tasks"):Z==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.requirements.slice(0,q):d.requirements).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.WORK,{openRequirement:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${U.status==="approved"?"text-green-500 bg-green-500/15":U.status==="pending"?"text-amber-500 bg-amber-500/15":U.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),s.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.status," · ",U.priority||""]})]})]},U.id)})}),q&&d.requirements.length>q&&te("requirements")]},"requirements"):Z==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.projects.slice(0,q):d.projects).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.WORK,{projectId:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:s.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.name}),U.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:U.description})]})]},U.id)})}),q&&d.projects.length>q&&te("projects")]},"projects"):Z==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.deliverables.slice(0,q):d.deliverables).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.DELIVERABLES,{openDeliverable:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.type," · ",U.status]})]})]},U.id)})}),q&&d.deliverables.length>q&&te("deliverables")]},"deliverables"):Z==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.workflows.slice(0,q):d.workflows).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.displayName||U.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.stepCount," steps · v",U.version]})]})]},U.name)})}),q&&d.workflows.length>q&&te("workflows")]},"workflows"):null})}),!p&&!g&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),s.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",n("common:toggle",{defaultValue:"唤起/关闭"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",n("common:switchTab",{defaultValue:"切换分类"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",n("common:navigate",{defaultValue:"导航"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",n("common:open",{defaultValue:"打开"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",n("common:close",{defaultValue:"关闭"})]})]})]})})}function bY({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function xY({status:e}){const t=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M9 11l3 3L22 4"}),s.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const yY=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar (L0 + page L1)",labelKey:"shortcuts.toggleLeft",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"nav-l0-jk",group:"navigation",keys:["J / K"],label:"L0: switch page up / down",labelKey:"shortcuts.navL0Jk",page:"any",bare:!0},{id:"nav-l0-l",group:"navigation",keys:["L"],label:"L0: enter page L1 (Team / Tasks / Output / Store / Settings)",labelKey:"shortcuts.navL0L",page:"any",bare:!0},{id:"nav-l0-h",group:"navigation",keys:["H"],label:"From page L1: focus app rail (L0)",labelKey:"shortcuts.navL0H",page:"any",bare:!0},{id:"settings-back",group:"navigation",keys:["H"],label:"Settings: go back to previous page",labelKey:"shortcuts.settingsBack",page:"any",bare:!0},{id:"nav-jk-settings",group:"navigation",keys:["J / K"],label:"Settings L1: switch settings tabs",labelKey:"shortcuts.navJkSettings",page:"any",bare:!0},{id:"nav-hl-work",group:"navigation",keys:["H / L"],label:"Tasks: item list ↔ project L1 ↔ app rail",labelKey:"shortcuts.navHlWork",page:"work",bare:!0},{id:"nav-jk-work",group:"navigation",keys:["J / K"],label:"Tasks: move project / item selection",labelKey:"shortcuts.navJkWork",page:"work",bare:!0},{id:"nav-hl-team",group:"navigation",keys:["H / L"],label:"Team: L0 ↔ L1 ↔ L2 (L ignored on deepest pane)",labelKey:"shortcuts.navHlTeam",page:"team",bare:!0},{id:"nav-jk-team",group:"navigation",keys:["J / K"],label:"Team L1: move roster selection",labelKey:"shortcuts.navJkTeam",page:"team",bare:!0},{id:"nav-jk-team-l2",group:"navigation",keys:["J / K"],label:"Team L2: move team member selection",labelKey:"shortcuts.navJkTeamL2",page:"team",bare:!0},{id:"nav-jk-deliverables",group:"navigation",keys:["J / K"],label:"Output L1: move deliverable selection",labelKey:"shortcuts.navJkDeliverables",page:"deliverables",bare:!0},{id:"nav-jk-store",group:"navigation",keys:["J / K"],label:"Store L1: switch store tabs",labelKey:"shortcuts.navJkStore",page:"store",bare:!0},{id:"toggle-project-detail",group:"tasks",keys:["J"],label:"Toggle project detail (Tasks)",labelKey:"shortcuts.toggleProjectDetail",page:"work"},{id:"toggle-item-detail",group:"tasks",keys:["L"],label:"Toggle task / requirement detail (Tasks)",labelKey:"shortcuts.toggleItemDetail",page:"work"},{id:"cycle-board",group:"tasks",keys:["Ctrl","Tab"],label:"Cycle Tasks views",labelKey:"shortcuts.cycleBoard",page:"work",bare:!0},{id:"toggle-browser",group:"team",keys:["L"],label:"Toggle right panel · Browser",labelKey:"shortcuts.toggleBrowser",page:"team"},{id:"toggle-terminal",group:"team",keys:["J"],label:"Toggle right panel · Terminal",labelKey:"shortcuts.toggleTerminal",page:"team"},{id:"next-tab",group:"rightPanel",keys:["Shift","]"],label:"Next right-panel tab",labelKey:"shortcuts.nextTab",page:"team"},{id:"prev-tab",group:"rightPanel",keys:["Shift","["],label:"Previous right-panel tab",labelKey:"shortcuts.prevTab",page:"team"},{id:"tab-n",group:"rightPanel",keys:["1…9"],label:"Jump to Nth right-panel tab",labelKey:"shortcuts.tabN",page:"team"},{id:"close-tab",group:"rightPanel",keys:["W"],label:"Close right-panel tab",labelKey:"shortcuts.closeTab",page:"team"},{id:"new-tab",group:"rightPanel",keys:["T"],label:"New browser tab / shell",labelKey:"shortcuts.newTab",page:"team"},{id:"term-search",group:"terminal",keys:["F"],label:"Search in terminal",labelKey:"shortcuts.termSearch",page:"team"},{id:"term-to-chat",group:"terminal",keys:["Shift","A"],label:"Add terminal selection to chat",labelKey:"shortcuts.termToChat",page:"team"}];function vY(e,t,n){return n||e[0]==="Ctrl"||e[0]==="Tab"||e[0]==="J / K"||e[0]==="H / L"?e.join(e[0]==="Ctrl"?"+":" "):e.length===1&&(e[0]==="H"||e[0]==="L"||e[0]==="J"||e[0]==="K")?e[0]:[t?"⌘":"Ctrl",...e].join(t?"":"+")}function wY(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable?!0:e.closest(".xterm")!==null}function J4(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const kY=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function SY(e){return e===ue.TEAM?"team":e===ue.WORK?"work":e===ue.DELIVERABLES?"deliverables":e===ue.STORE?"store":"any"}function NY({open:e,onClose:t,page:n}){const{t:r}=ft("common"),o=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=SY(n);return k.useEffect(()=>{if(!e)return;const c=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),t())};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,t]),e?s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:c=>{c.target===c.currentTarget&&t()},role:"dialog","aria-modal":"true","aria-label":r("shortcuts.title"),children:s.jsxs("div",{className:"w-full max-w-lg max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[s.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 px-4 py-3 border-b border-border-default bg-surface-primary",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:r("shortcuts.title")}),s.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":r("shortcuts.close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"px-4 py-3 space-y-4",children:kY.map(c=>{const d=yY.filter(m=>{if(m.group!==c)return!1;const p=m.page??"any";return p==="any"?!0:p===l});return d.length===0?null:s.jsxs("section",{children:[s.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:r(`shortcuts.groups.${c}`)}),s.jsx("ul",{className:"space-y-1.5",children:d.map(m=>s.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[s.jsx("span",{className:"text-fg-secondary min-w-0",children:r(m.labelKey??m.label,{defaultValue:m.label})}),s.jsx("kbd",{className:"shrink-0 px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium text-fg-primary font-mono",children:vY(m.keys,o,m.bare)})]},m.id))})]},c)})})]})}):null}function CY({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=ft("common");Ho(!0);const[l,c]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[p,h]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>Ew(e.avatarUrl,sa()?.avatarUrl)),C=async T=>{if(T.preventDefault(),!l.trim()){x(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(o("profile.invalidEmail"));return}h(!0),x("");try{const{user:S}=await Me.auth.updateProfile(l.trim(),d.trim());n({...S,avatarUrl:y??S.avatarUrl})}catch{x(o("profile.failedToSave"))}finally{h(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:s.jsxs("form",{onSubmit:C,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold mb-5",children:o("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(jw,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{w(T),r?.({...e,avatarUrl:T})}})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.name")}),s.jsx("input",{value:l,onChange:T=>c(T.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.email")}),s.jsx("input",{value:d,onChange:T=>m(T.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),g&&s.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:g})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:o("cancel")}),s.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(p?"saving":"save")})]})]})})}const ew=k.lazy(()=>qr(()=>import("./Team-zOWObrjC.js"),__vite__mapDeps([2,3,4,5])).then(e=>({default:e.TeamPage}))),tw=k.lazy(()=>qr(()=>import("./Settings-0bN9LNlr.js"),[]).then(e=>({default:e.Settings}))),TY=k.lazy(()=>qr(()=>import("./Store-CGSeZJqn.js"),[]).then(e=>({default:e.StorePage}))),AY=k.lazy(()=>qr(()=>Promise.resolve().then(()=>zW),void 0).then(e=>({default:e.AgentBuilder}))),nw=k.lazy(()=>qr(()=>import("./Work-D1BC-rJN.js"),__vite__mapDeps([6,4,1,7,3,8])).then(e=>({default:e.WorkPage}))),rw=k.lazy(()=>qr(()=>import("./Deliverables-DsAhIzy4.js"),__vite__mapDeps([9,4])).then(e=>({default:e.DeliverablesPage}))),EY=k.lazy(()=>qr(()=>import("./Notifications-DUsdhlI8.js"),[]).then(e=>({default:e.NotificationsPage}))),_Y=k.lazy(()=>qr(()=>import("./Search-BJtkRIyn.js"),[]).then(e=>({default:e.SearchPage}))),jY={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function MY(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Me.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function RY(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const OY=k.memo(function({id:t,activePage:n,children:r}){const o=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:o?void 0:jY,children:s.jsx(k.Suspense,{fallback:s.jsx(RY,{}),children:r})})},(e,t)=>{const n=e.id===e.activePage,r=t.id===t.activePage;return n!==r?!1:r?e.children===t.children:!0}),Dd={};function c6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?yw[e]??e:e}function aw(){return c6(pc())}function LY(){const{t:e}=ft("common"),[t,n]=k.useState(aw),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,c]=k.useState(!0),d=Uo(),m=fY(),p=dY({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([aw()])),[x,y]=k.useState("loading"),[w,C]=k.useState(!1),[T,S]=k.useState(null),[_,j]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[O,P]=k.useState(!1),[L,F]=k.useState(!1),[V,X]=k.useState(null),[z,G]=k.useState(!1),[ae,Z]=k.useState(null),[q,te]=k.useState(()=>{const be=localStorage.getItem("markus_update_dismissed");return be||null}),[U,Q]=k.useState(!1),[me,Ce]=k.useState(!1),H=Oc(),W=H?.leftCollapsed??!1,fe=H?.toggleLeftCollapsed,I=H?.setLeftCollapsed,Re=H?.keyboardPane??"l0",Be=H?.setKeyboardPane,Pe=H?.l0FocusPageId??null,Fe=H?.setL0FocusPageId,dt=k.useRef(t);dt.current=t;const mt=k.useRef(ue.HOME),Nt=H?.toggleRightPanel,Ot=H?.toggleTerminalPanel,At=H?.cycleRightPanelTab,qt=H?.activateRightPanelTabAt,jt=H?.openNewRightPanelTab,$e=H?.rightPanelOpen??!1,ut=H?.activeRightPanelTabId??null,kt=H?.openRightPanel,xt=H?.closeRightPanelTab,Ct=H?.updateRightPanelBrowserTab,ce=H?.updateRightPanelTerminalTab,rt=k.useRef(H?.rightPanelTabs);rt.current=H?.rightPanelTabs,k.useEffect(()=>{const be=window.markusDesktop?.browser?.onPageEvent;if(!(!be||!kt))return be(ge=>{if(ge.type==="closed"){const Se=rt.current?.find(st=>st.payload.kind==="url"&&st.payload.browserId===ge.browserId);Se&&xt&&xt(Se.id);return}if(ge.type==="navigated"){if(ge.url&&gc(ge.url))return;ge.browserId&&Ct&&Ct(ge.browserId,{url:ge.url,title:ge.title||ge.url});return}if(ge.type==="opened"||ge.type==="selected"){if(!ge.url&&!ge.browserId||ge.browserId.startsWith("eb_")||JG(ge.browserId)||ge.url&&gc(ge.url))return;kt({kind:"url",url:ge.url||"about:blank",title:ge.title||ge.url||"Browser",browserId:ge.browserId,pageId:ge.pageId})}})},[kt,xt,Ct]),k.useEffect(()=>{const be=window.markusDesktop?.terminal?.onEvent;if(!(!be||!kt))return be(ge=>{if(ge.type==="closed"){const Se=rt.current?.find(st=>st.payload.kind==="terminal"&&st.payload.terminalId===ge.id);Se&&xt&&xt(Se.id);return}if(ge.type==="cwd"){ge.cwd&&ce?.(ge.id,{cwd:ge.cwd});return}if(ge.type==="selected"){(ge.title||ge.cwd)&&ce?.(ge.id,{title:ge.title,cwd:ge.cwd});return}if(ge.type==="opened"){if(Kg.has(ge.id)){(ge.title||ge.cwd)&&ce?.(ge.id,{title:ge.title,cwd:ge.cwd});return}wi(ge.id),kt({kind:"terminal",terminalId:ge.id,title:ge.title||"Terminal",cwd:ge.cwd})}})},[kt,xt,ce]);const at=H?.handleTerminalExit;k.useEffect(()=>{const be=window.markusDesktop?.terminal?.onExit;if(!(!be||!at))return be(ge=>{at(ge.id)})},[at]),k.useLayoutEffect(()=>{const be=t===ue.TEAM&&$e&&H?.rightPanelMode==="browser";up(be)},[t,$e,H?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const ve=k.useRef(!1);k.useEffect(()=>{if(!ve.current){ve.current=!0;return}p.setCollapsed(W)},[W,p.setCollapsed]),k.useEffect(()=>{if(d)return;const be=navigator.platform.toUpperCase().includes("MAC"),ge=st=>{be&&st.metaKey&&!st.ctrlKey&&st.key==="p"?(st.preventDefault(),Q(Ve=>!Ve)):!be&&st.ctrlKey&&!st.metaKey&&st.key==="p"&&(st.preventDefault(),Q(Ve=>!Ve))},Se=()=>Q(!0);return document.addEventListener("keydown",ge),window.addEventListener("markus:open-search",Se),()=>{document.removeEventListener("keydown",ge),window.removeEventListener("markus:open-search",Se)}},[d]);const _e=k.useCallback(()=>!$e||!ut||!xt?!1:(xt(ut),!0),[$e,ut,xt]);k.useEffect(()=>{const be=window.markusDesktop?.onAppShortcut?.(ge=>{if(ge.type==="close-tab"){_e();return}ge.type==="new-tab"&&jt?.()});return()=>{be?.()}},[_e,jt]),k.useEffect(()=>{if(d||!fe||!Nt)return;const be=navigator.platform.toUpperCase().includes("MAC"),ge=Se=>{if(!(be?Se.metaKey&&!Se.ctrlKey:Se.ctrlKey&&!Se.metaKey)||Se.altKey)return;if(!Se.shiftKey&&(Se.key==="/"||Se.code==="Slash")){Se.preventDefault(),Ce(Je=>!Je);return}if(Se.shiftKey&&(Se.key==="?"||Se.key==="/")){Se.preventDefault(),Ce(Je=>!Je);return}if(Se.shiftKey&&$e&&At){if(Se.key==="]"||Se.code==="BracketRight"){Se.preventDefault(),At(1);return}if(Se.key==="["||Se.code==="BracketLeft"){Se.preventDefault(),At(-1);return}}if(!Se.shiftKey&&$e&&qt){const Je=Se.key>="1"&&Se.key<="9"?Number(Se.key):0;if(Je>=1){Se.preventDefault(),qt(Je-1);return}}if(Se.shiftKey)return;const Ve=Se.key.toLowerCase();if(Ve==="w"){Se.preventDefault(),Se.stopPropagation(),_e();return}if(Ve==="t"){Se.preventDefault(),jt?.();return}if(Ve==="b")Se.preventDefault(),fe();else if(t===ue.TEAM&&Ve==="l"){if(!be&&J4(Se.target)||be&&J4(Se.target)&&Se.ctrlKey)return;Se.preventDefault(),Nt()}else t===ue.TEAM&&Ve==="j"&&Ot&&(Se.preventDefault(),Ot())};return document.addEventListener("keydown",ge,!0),()=>document.removeEventListener("keydown",ge,!0)},[d,t,fe,Nt,Ot,At,qt,$e,_e,jt]);const Ee=k.useCallback((be,ge)=>{let Se=fc(be);d?Se=yw[Se]??Se:Se===ue.NOTIFICATIONS&&(Se=ue.HOME),Se!==ue.TEAM&&up(!1);const st=pc(),Ve=window.location.hash.slice(1);Ve!==hh(st)?Dd[st]=Ve:delete Dd[st];const Je=dt.current;if(Se===ue.SETTINGS&&Je!==ue.SETTINGS&&(mt.current=Je,it.setSettingsReturnPage(Je),Be?.("l1"),Fe?.(ue.SETTINGS)),Je===ue.SETTINGS&&Se!==ue.SETTINGS&&(Be?.("l0"),Fe?.(Se)),Se===ue.SETTINGS&&ge?.tab){const ie=`settings/${ge.tab}`;Dd[Se]=ie,history.pushState(null,"","#"+ie),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Se),g(Le=>Le.has(Se)?Le:new Set([...Le,Se]));return}const R=Se!==ue.WORK?Dd[Se]:void 0;R&&R!==hh(Se)?(history.pushState(null,"",Ti(Se)),history.pushState(null,"","#"+R)):history.pushState(null,"",Ti(Se)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Se),g(ie=>ie.has(Se)?ie:new Set([...ie,Se]))},[d,Be,Fe]);k.useEffect(()=>{it.setHandler((be,ge)=>Ee(be,ge))},[Ee]),k.useEffect(()=>{Re==="l0"&&t!==ue.SETTINGS&&Fe?.(t)},[Re,t,Fe]),k.useEffect(()=>{if(d||!Be||!Fe)return;const be=ge=>{if(ge.metaKey||ge.ctrlKey||ge.altKey||wY(ge.target))return;const Se=ge.key.length===1?ge.key.toLowerCase():ge.key;if(t===ue.SETTINGS&&(Se==="h"||Se==="ArrowLeft")){ge.preventDefault(),ge.stopImmediatePropagation(),it.leaveSettings();return}if(Re!=="l0"||t===ue.SETTINGS)return;const st=Pe&&vo.includes(Pe)?Pe:t,Ve=Math.max(0,vo.indexOf(st));if(Se==="j"||Se==="ArrowDown"){ge.preventDefault(),ge.stopImmediatePropagation();const Je=vo[Math.min(vo.length-1,Ve+1)];Fe(Je),Je!==t&&Ee(Je),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Je}"]`)?.scrollIntoView({block:"nearest"})});return}if(Se==="k"||Se==="ArrowUp"){ge.preventDefault(),ge.stopImmediatePropagation();const Je=vo[Math.max(0,Ve-1)];Fe(Je),Je!==t&&Ee(Je),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Je}"]`)?.scrollIntoView({block:"nearest"})});return}if(Se==="l"||Se==="ArrowRight"||Se==="Enter"){const Je=Pe&&vo.includes(Pe)?Pe:t;if(!qL.has(Je)){ge.preventDefault(),ge.stopImmediatePropagation();return}ge.preventDefault(),ge.stopImmediatePropagation(),Je!==t&&Ee(Je),I?.(!1),Be("l1");return}(Se==="h"||Se==="ArrowLeft")&&(ge.preventDefault(),ge.stopImmediatePropagation())};return document.addEventListener("keydown",be,!0),()=>document.removeEventListener("keydown",be,!0)},[d,Re,Pe,t,Ee,Be,Fe,I]),k.useEffect(()=>{const be=()=>C(!0);return window.addEventListener("markus:open-edit-profile",be),()=>window.removeEventListener("markus:open-edit-profile",be)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==ue.SETTINGS&&!p.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[p.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(be=>{if(be.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),be.page){const ge=fc(be.page);be.params&&Object.entries(be.params).forEach(([Se,st])=>localStorage.setItem(`markus_nav_${Se}`,st)),Ee(ge),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:ge,params:be.params}}))}})},[Ee]);const oe=k.useCallback(()=>{fetch("/api/settings/llm").then(be=>be.ok?be.json():null).then(be=>{if(be?.providers){const ge=Object.values(be.providers).some(Se=>Se.configured);X(ge)}}).catch(()=>{})},[]),$=k.useCallback((be,ge)=>{if(!be)return;const st=ge&&{agent:"agents",team:"teams",skill:"skills"}[ge]||"agents";localStorage.setItem("markus_nav_installItem",be),localStorage.setItem("markus_nav_storeTab",st);const Ve=new URLSearchParams(window.location.search);Ve.get("install")||(Ve.set("install",be),ge&&Ve.set("type",ge));const Je=Ve.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Je}${Ti(ue.STORE)}`);const R=()=>it.navigate(ue.STORE,{storeTab:st,installItem:be});R(),setTimeout(R,500),setTimeout(R,1500)},[]);k.useEffect(()=>{const be=new URLSearchParams(window.location.search),ge=be.get("install");ge&&$(ge,be.get("type"));const Se=window.markusDesktop;Se?.onDeepLinkInstall?.(({id:Je,type:R})=>$(Je,R)),Se?.consumePendingDeepLinkInstall?.().then(Je=>{Je?.id&&$(Je.id,Je.type)}),Me.auth.me().then(({user:Je})=>{y(Je),S(!0),MY(Je),va.connect(Je.id),oe(),Me.health().then(ie=>{ie.updateAvailable&&ie.latestVersion&&Z({latestVersion:ie.latestVersion,currentVersion:ie.version})}).catch(()=>{});const R=()=>{gi(Tr.builderArtifacts,()=>Me.builder.artifacts.list()),gi(Tr.builderAgents,()=>Me.agents.list()),gi(Tr.builderHubMyItems,()=>lt.myItems()),gi(Tr.builderInstalled,()=>Me.builder.artifacts.installed()),gi(Tr.hubAgents,()=>lt.search({type:"agent",limit:50})),gi(Tr.hubTeams,()=>lt.search({type:"team",limit:50})),gi(Tr.hubSkills,()=>lt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(R,{timeout:5e3}):setTimeout(R,3e3)}).catch(()=>{y(null),Me.auth.status().then(({initialized:Je,hasOwner:R,hasMultipleUsers:ie})=>{S(Je),j({hasOwner:R,hasMultipleUsers:ie})}).catch(()=>S(!0))}),va.connect();const st=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),Ve=()=>{const Je=c6(pc());Je!==ue.TEAM&&up(!1),n(Je),g(R=>R.has(Je)?R:new Set([...R,Je]))};return window.addEventListener("hashchange",Ve),window.addEventListener("popstate",Ve),()=>{st(),va.disconnect(),window.removeEventListener("hashchange",Ve),window.removeEventListener("popstate",Ve)}},[]);const J=x!=="loading"&&x!==null?x:void 0,Te=k.useMemo(()=>d?{[ue.HOME]:s.jsx(dv,{authUser:J}),[ue.TEAM]:s.jsx(ew,{authUser:J}),[ue.BUILDER]:s.jsx(sY,{authUser:J}),[ue.SETTINGS]:s.jsx(tw,{theme:m.mode,onThemeChange:m.setMode,authUser:J,onLogout:()=>{Me.auth.logout().catch(()=>{}),Ro(),y(null)},onUserUpdated:be=>y(be)}),[ue.WORK]:s.jsx(nw,{authUser:J}),[ue.DELIVERABLES]:s.jsx(rw,{authUser:J}),[ue.NOTIFICATIONS]:s.jsx(EY,{authUser:J}),[ue.SEARCH]:s.jsx(_Y,{})}:{[ue.HOME]:s.jsx(dv,{authUser:J}),[ue.TEAM]:s.jsx(ew,{authUser:J}),[ue.SETTINGS]:s.jsx(tw,{theme:m.mode,onThemeChange:m.setMode,authUser:J,onLogout:()=>{Me.auth.logout().catch(()=>{}),Ro(),y(null)},onUserUpdated:be=>y(be)}),[ue.STORE]:s.jsx(TY,{authUser:J}),[ue.BUILDER]:s.jsx(AY,{authUser:J}),[ue.WORK]:s.jsx(nw,{authUser:J}),[ue.DELIVERABLES]:s.jsx(rw,{authUser:J})},[J?.id,J?.role,m.mode,d]);if(x==="loading"||x===null&&T===null)return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const he=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return he?s.jsx(cY,{token:he[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),P(!0),y("loading"),Me.auth.me().then(be=>y(be.user)).catch(()=>y(null))}}):x===null?s.jsx(lY,{hasOwner:_.hasOwner,hasMultipleUsers:_.hasMultipleUsers,onLogin:(be,ge,Se)=>{y(be),va.connect(be.id),ge?(localStorage.removeItem("markus_onboarded"),o(!0),Se?.fromHub&&P(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):L?s.jsx(uY,{onComplete:()=>F(!1),isFirstTime:!0}):r?s.jsx(iY,{theme:m.mode,onThemeChange:m.setMode,skipProfile:O,onProfileUpdated:be=>{const ge={id:be.id,name:be.name,email:be.email,role:be.role,orgId:be.orgId??"default",avatarUrl:be.avatarUrl};y(ge)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),P(!1),Me.auth.me().then(be=>y(be.user)).catch(()=>{}),oe(),Ee(ue.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==ue.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:p.width},children:s.jsx(dW,{currentPage:t,onNavigate:be=>{Ee(be),c(!1),Be?.("l0"),Fe?.(be)},authUser:x,collapsed:p.collapsed,onToggleCollapse:p.toggle,onLogout:()=>{Me.auth.logout().catch(()=>{}),Ro(),y(null)},keyboardFocusPageId:Pe,keyboardPaneActive:Re==="l0"})}),s.jsx("div",{className:`${p.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:p.collapsed?void 0:p.onResizeStart,children:!p.collapsed&&s.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),s.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==ue.SETTINGS&&t!==ue.SEARCH?"pb-14":""}`,children:[V===!1&&!z&&t!==ue.SETTINGS&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[s.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),s.jsx("button",{onClick:()=>G(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),ae&&q!==ae.latestVersion&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[s.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:ae.latestVersion,current:ae.currentVersion})}),s.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[s.jsx("a",{href:"https://markus.global/#download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),s.jsx("button",{onClick:()=>{te(ae.latestVersion),localStorage.setItem("markus_update_dismissed",ae.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),s.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(Te).map(be=>h.has(be)?s.jsx(OY,{id:be,activePage:t,children:Te[be]},be):null)})]}),d&&t!==ue.SETTINGS&&t!==ue.SEARCH&&s.jsx(gW,{currentPage:t,onNavigate:Ee,userId:J?.id}),d&&s.jsx(iD,{authUser:J,onNavigate:Ee}),!d&&U&&s.jsx(gY,{onClose:()=>Q(!1),currentPage:t}),!d&&s.jsx(NY,{open:me,onClose:()=>Ce(!1),page:t}),w&&J&&s.jsx(CY,{authUser:J,onClose:()=>C(!1),onUserUpdated:be=>y(be),onSaved:be=>{C(!1),y(be)}})]})}v7.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(sK,{children:s.jsx(LY,{})})}));export{b4 as $,Hs as A,YY as B,KY as C,VY as D,dY as E,fc as F,Vg as G,Tc as H,JW as I,A0 as J,p8 as K,DY as L,Mw as M,lW as N,Ho as O,ue as P,Ya as Q,lX as R,QW as S,HW as T,Ti as U,dr as V,VL as W,BY as X,F3 as Y,qY as Z,qr as _,Uo as a,A4 as a0,$V as a1,BV as a2,$Y as a3,XV as a4,GY as a5,yc as a6,dX as a7,IY as a8,sa as a9,$3 as aA,rW as aB,sX as aC,UY as aD,H3 as aE,yn as aa,na as ab,m8 as ac,PY as ad,zY as ae,wi as af,Nd as ag,_i as ah,r0 as ai,WV as aj,tV as ak,l4 as al,nV as am,Ai as an,Yo as ao,QY as ap,hW as aq,uX as ar,tX as as,FY as at,XY as au,rX as av,lV as aw,nX as ax,aX as ay,iW as az,sD as b,Oc as c,nY as d,qW as e,WW as f,Ni as g,lt as h,wY as i,s as j,Sa as k,Me as l,WY as m,it as n,nW as o,iX as p,JY as q,k as r,Yg as s,eX as t,ft as u,ZY as v,va as w,cX as x,Er as y,oX as z};
|
|
670
|
+
prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(Eh,{remarkPlugins:[q5,Kk],rehypePlugins:[[x3,{detect:!0,ignoreMissing:!0}]],children:e})})}function sh({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=ft(["builder","common"]),[c,d]=k.useState(!1),[m,p]=k.useState(t),[h,g]=k.useState(!1),x=/\.(md|mdx|markdown)$/i.test(e),y=k.useRef(null);k.useEffect(()=>{p(t)},[t]),k.useEffect(()=>{if(c&&y.current){const T=y.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[c,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},C=o?null:s.jsx("div",{className:"flex items-center gap-2",children:c?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{p(t),d(!1)},className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors",children:l("common:cancel")}),s.jsx("button",{onClick:w,disabled:h,className:"text-[10px] px-2.5 py-1 rounded-md bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:l(h?"common:saving":"common:save")})]}):s.jsxs("button",{onClick:()=>d(!0),className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),l("detail.edit")]})});return r?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-end px-4 py-2 border-b border-border-default bg-surface-elevated/20",children:C}),c?s.jsx("textarea",{ref:y,value:m,onChange:T=>p(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(ag,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]}):s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border-default bg-surface-elevated/30",children:[s.jsx("span",{className:"text-xs font-medium text-fg-secondary font-mono",children:e}),C]}),c?s.jsx("textarea",{ref:y,value:m,onChange:T=>p(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(ag,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const I4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function CW(e){return[...e].sort(([t],[n])=>{const r=I4[t]??99,o=I4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function S0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>CW(e),[e]),[l,c]=k.useState(0);if(o.length===1)return n?s.jsx(sh,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r}):s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),s.jsx(sh,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r})]});const[d,m]=o[l]??o[0],p=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30",children:o.map(([h],g)=>s.jsx("button",{onClick:()=>c(g),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors ${g===l?"border-brand-500 text-brand-400 bg-surface-secondary/50":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:h},h))}),s.jsx(sh,{filename:d,content:m,onSave:h=>t(d,h),embedded:!0,readOnly:r},d)]});return n?p:s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),p]})}function TW({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l}){const{t:c}=ft(["builder"]),d=k.useRef(null);return e.length===0?l?null:s.jsxs("div",{className:"border-2 border-dashed border-border-default rounded-xl p-6 text-center text-fg-muted text-sm cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>d.current?.click(),onDragOver:m=>m.preventDefault(),onDrop:m=>{m.preventDefault();const p=m.dataTransfer.files[0];p?.type.startsWith("image/")&&r(p)},children:[s.jsxs("svg",{className:"w-8 h-8 mx-auto mb-2 text-fg-muted/50",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsx("span",{className:"block",children:c("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:c("images.hint")}),s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const p=m.target.files?.[0];p&&r(p),m.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(m=>{const p=m.split("/").pop()??m;return s.jsxs("div",{className:"relative group shrink-0 rounded-lg border border-border-default overflow-hidden bg-surface-elevated",children:[s.jsx("img",{src:`/api/builder/artifacts/${t}s/${encodeURIComponent(n)}/images/${encodeURIComponent(p)}`,alt:p,className:"h-32 w-auto object-cover"}),!l&&s.jsx("button",{onClick:()=>o(p),className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-red-600/80 text-white flex items-center justify-center text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},m)}),!l&&s.jsx("button",{onClick:()=>d.current?.click(),className:"shrink-0 h-32 w-24 rounded-lg border-2 border-dashed border-border-default flex items-center justify-center text-fg-muted hover:border-brand-500/30 hover:text-brand-400 transition-colors",children:s.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),!l&&s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const p=m.target.files?.[0];p&&r(p),m.target.value=""}})]})}function AW({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=ft(["builder"]),[c,d]=k.useState(0),m=k.useMemo(()=>{const C=new Set;for(const T of Object.keys(n)){const S=T.match(/^members\/([^/]+)\//);S&&C.add(S[1])}return[...C]},[n]),p=k.useMemo(()=>{const C=new Map,T=new Set;for(let j=0;j<e.length;j++){const O=r0(e[j].name);m.includes(O)&&!T.has(O)&&(C.set(j,O),T.add(O))}for(let j=0;j<e.length;j++){if(C.has(j))continue;const O=e[j].roleName;if(O){const P=r0(O);m.includes(P)&&!T.has(P)&&(C.set(j,P),T.add(P))}}for(let j=0;j<e.length;j++){if(C.has(j))continue;const O=e[j].name;for(const P of m){if(T.has(P))continue;const L=n[`members/${P}/ROLE.md`];if(!L)continue;const F=L.match(/^#\s+(.+)$/m)?.[1]?.trim();if(F&&(F.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes(F.toLowerCase()))){C.set(j,P),T.add(P);break}}}const S=m.filter(j=>!T.has(j));let _=0;for(let j=0;j<e.length;j++)C.has(j)||_<S.length&&(C.set(j,S[_]),_++);return C},[e,m,n]),h=k.useCallback((C,T)=>{const S=p.get(T);return S?Object.entries(n).filter(([_])=>_.startsWith(`members/${S}/`)):[]},[n,p]),g=k.useMemo(()=>{const C=[{label:l("detail.overview")}];for(const T of e)C.push({label:T.name,role:T.role});return C},[e,l]),x=c>0?e[c-1]:null,y=c-1;return s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30 border-b border-border-default",children:g.map((C,T)=>{const S=T===c,_=C.role==="manager",j=T===0?S?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":_?S?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":S?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>d(T),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${j} ${S?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[T===0&&s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),T>0&&s.jsx("span",{className:`w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center shrink-0 ${_?"bg-amber-500/20 text-amber-400":"bg-blue-500/20 text-blue-400"}`,children:(C.label[0]??"?").toUpperCase()}),C.label]},T)})}),s.jsx("div",{className:"p-5",children:c===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(S0,{noHeader:!0,files:t,onSave:w,readOnly:o}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:l("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((C,T)=>{const S=C.role==="manager";return s.jsxs("button",{onClick:()=>d(T+1),className:"text-left rounded-lg border border-border-default bg-surface-elevated/30 px-4 py-3 flex gap-3 items-center hover:border-gray-600 transition-colors cursor-pointer",children:[s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${S?"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:(C.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:C.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${S?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:C.role}),C.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",C.count]})]}),C.skills&&C.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[C.skills.slice(0,3).map(_=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:_},_)),C.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",C.skills.length-3]})]})]}),s.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},T)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${x.role==="manager"?"bg-amber-500/15 text-amber-400 ring-2 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-2 ring-blue-500/30"}`,children:(x.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:x.name}),s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${x.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:x.role}),x.count>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",x.count]})]}),x.roleName&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 italic",children:x.roleName})]})]}),x.skills&&x.skills.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.skills.map(C=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:C},C))}),(()=>{const C=h(x.name,y);return C.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(S0,{noHeader:!0,readOnly:o,files:C.map(([T,S])=>[T.replace(/^members\/[^/]+\//,""),S]),onSave:(T,S)=>{const _=C.find(([j])=>j.endsWith(`/${T}`));_&&r(_[0],S)}})})()]}):null})]});function w(C,T){r(C,T)}}function Mi({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:c,contentSlot:d}){const{t:m}=ft(["builder","common"]),p=Uo(),[h,g]=k.useState(!0),[x,y]=k.useState(t),[w,C]=k.useState({}),[T,S]=k.useState(null),[_,j]=k.useState(""),[O,P]=k.useState("idle"),[L,F]=k.useState({shared:!1}),[V,X]=k.useState(!1),[z,G]=k.useState(!1),[ae,Z]=k.useState(!1),[q,te]=k.useState(!1),[U,Q]=k.useState(!1),[me,Ce]=k.useState(!1),[H,W]=k.useState(null),[fe,I]=k.useState(""),[Re,Be]=k.useState(""),[Pe,Fe]=k.useState(""),[dt,mt]=k.useState(""),[Nt,Ot]=k.useState([]),[At,qt]=k.useState(""),jt=k.useRef(null),$e=k.useRef(l);$e.current=l,k.useEffect(()=>{y(t)},[t]);const ut=k.useCallback(async()=>{const ne=$e.current;if(ne){S(ne),I(ne.displayName||ne.name||t),Be(ne.description||""),Fe(ne.version||"1.0.0"),mt(ne.category||"general"),Ot(ne.tags||[]),qt(ne.icon||""),C(ne.files??{}),g(!1);return}g(!0);try{let he=t;try{const Se=await Me.builder.artifacts.ensureSlugSafe(e,t);he=Se.name,y(he),Se.converted&&(history.replaceState(null,"",Ti(ue.BUILDER,`${e}/${encodeURIComponent(he)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const be=await Me.builder.artifacts.get(e,he);C(be.files??{}),j(be.path??"");const ge=be.files[`${e}.json`]??be.files["agent.json"]??be.files["team.json"]??be.files["skill.json"];if(ge){const Se=JSON.parse(ge);S(Se),I(Se.displayName||Se.name||t),Be(Se.description||""),Fe(Se.version||"1.0.0"),mt(Se.category||"general"),Ot(Se.tags||[]),qt(Se.icon||"")}}catch(he){console.error("Failed to load artifact:",he)}finally{g(!1)}},[e,t]);k.useEffect(()=>{ut()},[ut]),k.useEffect(()=>{l?.files&&C(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const ne=localStorage.getItem("markus_builder_shared_map");if(ne){const he=JSON.parse(ne),be=`${e}/${t}`;he[be]&&F({shared:!0,id:he[be].id,slug:he[be].slug,version:he[be].version,visibility:he[be].visibility??"public"})}}catch{}lt.myItems().then(ne=>{const he=ne?.items??[],be=e==="agent"?"agent":e==="team"?"team":"skill";for(const ge of he)if(ge.itemType===be&&(ge.slug===t||ge.name===t)){F({shared:!0,id:ge.id,slug:ge.slug,version:ge.version,visibility:ge.visibility??"public",moderationStatus:ge.moderationStatus,pendingReview:ge.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const kt=k.useCallback(async ne=>{if(!(!T||o)){P("saving");try{const he={...T,...ne};await Me.builder.artifacts.save(e,he),S(he),P("saved"),setTimeout(()=>P(be=>be==="saved"?"idle":be),2e3)}catch{P("error"),setTimeout(()=>P("idle"),3e3)}}},[T,e]),xt=k.useCallback(ne=>{jt.current&&clearTimeout(jt.current),jt.current=setTimeout(()=>kt(ne),800)},[kt]),Ct=k.useCallback((ne,he)=>{const be={};ne==="displayName"?(I(he),be.displayName=he,G(!0)):ne==="description"?(Be(he),be.description=he,G(!0)):ne==="version"?(Fe(he),be.version=he,G(!1),Z(!1)):ne==="category"?(mt(he),be.category=he,G(!0)):ne==="tags"?(Ot(he),be.tags=he,G(!0)):ne==="icon"&&(qt(he),be.icon=he||void 0,G(!0)),xt({...T,...be})},[T,xt]),ce=k.useCallback(async(ne,he)=>{try{const be={...w,[ne]:he};C(be);const ge={...T,files:be};await Me.builder.artifacts.save(e,ge),P("saved"),G(!0),setTimeout(()=>P(Se=>Se==="saved"?"idle":Se),2e3)}catch{P("error")}},[w,e,T]),rt=k.useCallback(async ne=>{if(T){X(!0);try{await lt.ensureAuth();const he=await Me.builder.artifacts.ensureSlugSafe(e,x,T.displayName||T.name||x),be=he.name,ge=he.slug||xc(be);if(!ge)throw new Error("Invalid package slug: use English kebab-case for the artifact name (e.g. qwen-multimodal). Chinese-only names cannot be shared — rename the package slug and put the Chinese title in displayName.");const Se=he.displayName||T.displayName||T.name||x;he.converted&&(y(be),S(le=>le&&{...le,name:ge,displayName:Se}),history.replaceState(null,"",Ti(ue.BUILDER,`${e}/${encodeURIComponent(be)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const st={...T,name:ge,displayName:Se},Ve=st.description||"",Je=st.category||"general",R=st.tags??[];let ie=st.icon||void 0;const Le=st.version||"1.0.0";if(ie&&!ie.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(ie)){const le=ie.split("/").pop()??ie;try{const je=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(be)}/images/${encodeURIComponent(le)}`);if(je.ok){const Ue=await je.blob(),tt=new File([Ue],le,{type:Ue.type}),yt=await lt.uploadImage(tt);yt?.url&&(ie=yt.url)}}catch{}}let xe;const Ge=[],Qe=st.screenshots??[];for(let le=0;le<Qe.length;le++){const je=Qe[le],Ue=je.split("/").pop()??je;try{const tt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(be)}/images/${encodeURIComponent(Ue)}`);if(tt.ok){const yt=await tt.blob(),qe=new File([yt],Ue,{type:yt.type}),nt=await lt.uploadImage(qe);nt?.url&&(Ge.push({url:nt.url,alt:Ue,order:le}),le===0&&(xe=nt.url))}}catch{}}const K=await lt.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:Se,slug:ge,description:Ve,category:Je,tags:R,icon:ie,version:Le,config:st,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:xe,images:Ge.length>0?Ge:void 0,priceCents:ne?.priceCents,donationsEnabled:ne?.donationsEnabled,visibility:ne?.visibility,orgId:ne?.orgId});K.id&&(F({shared:!0,id:K.id,slug:K.slug??ge,version:Le,visibility:K.visibility??ne?.visibility??"public",moderationStatus:K.moderationStatus,pendingReview:K.pendingReview}),G(!1),(K.visibility??ne?.visibility??"public")!=="org"&&(K.moderationStatus==="pending"||K.pendingReview)?W({title:m("common:share"),message:he.converted?m("share.convertedAndSubmitted",{previous:t,slug:ge}):K.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):he.converted&&W({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:ge}),variant:"primary"}))}catch(he){console.error("Share to Hub failed:",he),W({title:m("common:share"),message:he instanceof Error?he.message:String(he),variant:"danger"})}finally{X(!1)}}},[T,w,e,t,x,m]),at=async ne=>{const he=new FormData;he.append("image",ne);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:he,credentials:"include"}),await ut(),G(!0)}catch(be){console.error("Image upload failed:",be)}},ve=async ne=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(ne)}`,{method:"DELETE",credentials:"include"}),await ut(),G(!0)}catch(he){console.error("Image remove failed:",he)}},_e=D4[e]??D4.agent,Ee=T?.screenshots??[],oe=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],$=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([ne])=>!ne.endsWith(".json")&&!ne.startsWith("images/")&&!ne.startsWith("members/")),[w,e]),J=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([ne])=>!ne.endsWith(".json")&&!ne.startsWith("images/")&&!ne.startsWith("members/")),[w,e]),Te=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const ne=new Set;if(e==="skill"){const he=T?.skill?.skillFile;he&&w[he]&&ne.add(he),!he&&w["SKILL.md"]&&ne.add("SKILL.md"),!he&&!w["SKILL.md"]&&w["README.md"]&&ne.add("README.md")}return Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")&&!ne.has(he))},[w,e,T?.skill?.skillFile]);return h?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse py-20 text-center",children:m("common:loading")})]})}):T?s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:`${p?"px-4 py-5":"px-6 py-8"}`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m(o?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!o&&O==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&O==="saved"&&s.jsxs("span",{className:"text-[10px] text-green-500 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),m("detail.saved")]}),!o&&O==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),c,!o&&L.shared&&(()=>{const ne=lt.getUser(),he=ne&&L.slug?`${lt.getUrl()}/@${encodeURIComponent(ne.username)}/${encodeURIComponent(L.slug)}`:null,be=Pe||T?.version||"1.0.0",ge=L.version!==be;return s.jsxs(s.Fragment,{children:[L.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):L.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):L.pendingReview?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,he&&s.jsxs("a",{href:he,target:"_blank",rel:"noopener noreferrer",onClick:Se=>{yc()&&(Se.preventDefault(),_i(he))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${L.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":L.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:[L.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):L.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),L.visibility==="org"?m("visibility.sharedOrg"):L.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),ge&&s.jsx("button",{onClick:()=>{rt({visibility:L.visibility})},disabled:V,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50",children:V?m("share.updating"):m("share.updateVersion",{version:be})})]})})(),!o&&!L.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:V,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:m(V?"share.sharing":"share.toHub")})]})]}),!o&&z&&!ae&&s.jsxs("div",{className:"mb-4 px-4 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20 flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),s.jsx("button",{onClick:()=>Z(!0),className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("versionBump.bumpVersion")})]}),!o&&ae&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),s.jsx("input",{type:"text",defaultValue:(()=>{const ne=(Pe||"1.0.0").split(".");return ne[2]=String(Number(ne[2]??0)+1),ne.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:ne=>{ne.key==="Enter"&&Ct("version",ne.target.value)}}),s.jsx("button",{onClick:ne=>{const he=ne.target.parentElement?.querySelector("input");he&&Ct("version",he.value)},className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("common:confirm")}),s.jsx("button",{onClick:()=>Z(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),L.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${p?"flex-col":""}`,children:[s.jsxs("div",{className:`${p?"w-full":"flex-1 min-w-0"}`,children:[s.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>!o&&Ce(!me),className:`w-16 h-16 rounded-xl ${_e.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${_e.ring} transition-all overflow-hidden`,children:At&&At.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(At.replace("images/",""))}`,alt:"",className:"w-full h-full object-cover"}):At&&(At.startsWith("http")||At.startsWith("/"))?s.jsx("img",{src:At,alt:"",className:"w-full h-full object-cover"}):(()=>{const ne=At||"";if(ne&&[...ne].length<=2&&new RegExp("\\p{Emoji}","u").test(ne))return ne;const be=Ei[Xo(e)].accent;return s.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:t6(fe||t||e),fill:be})})})()}),!o&&me&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Ce(!1)}),s.jsxs("div",{className:"absolute top-full left-0 mt-2 z-50 bg-surface-secondary border border-border-default rounded-xl p-3 shadow-xl w-80",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("input",{type:"text",placeholder:m("detail.pasteEmojiOrUrl"),className:"flex-1 text-sm px-2 py-1.5 rounded-lg bg-surface-elevated border border-border-default text-fg-primary placeholder:text-fg-muted",defaultValue:At,onKeyDown:ne=>{ne.key==="Enter"&&(Ct("icon",ne.target.value),Ce(!1))}}),s.jsxs("label",{className:"text-[10px] text-brand-400 hover:text-brand-300 cursor-pointer px-1.5 py-1 border border-brand-500/30 rounded-lg",children:[m("detail.upload"),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async ne=>{const he=ne.target.files?.[0];if(!he)return;const be=new FormData;be.append("image",he);try{const ge=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:be,credentials:"include"});if(ge.ok){const st=(await ge.json()).path;if(qt(st),Ce(!1),T){const Ve={...T,icon:st};S(Ve),await Me.builder.artifacts.save(e,Ve)}G(!0)}}catch{}}})]}),At&&s.jsx("button",{onClick:()=>{Ct("icon",""),Ce(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto",children:wW.map(ne=>s.jsxs("div",{className:"mb-2.5",children:[s.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:ne.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:ne.emojis.map(he=>s.jsx("button",{onClick:()=>{Ct("icon",he),Ce(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${At===he?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:he},he))})]},ne.label))})]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(ah,{value:fe,onChange:ne=>Ct("displayName",ne),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:o}),s.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${_e.bg} ${_e.color}`,children:_e.label}),s.jsx(ah,{value:Pe,onChange:ne=>Ct("version",ne),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:o})]}),s.jsx(ah,{value:Re,onChange:ne=>Ct("description",ne),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:o}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(SW,{value:dt,options:vW,onChange:ne=>Ct("category",ne),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(NW,{tags:Nt,onChange:ne=>Ct("tags",ne),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(TW,{images:Ee,artifactType:e,artifactName:t,onUpload:at,onRemove:ve,readOnly:o})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(AW,{members:T.team.members,teamTopFiles:J,files:w,onFileSave:ce,readOnly:o})}),e==="agent"&&$.length>0&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),s.jsx(S0,{noHeader:!0,files:$,onSave:ce,readOnly:o})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[T.skill?.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:T.skill.requiredPermissions.map(ne=>{const he=kW[ne];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${he?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:he?.icon??"?"})," ",ne]},ne)})})]}),T.skill?.mcpServers&&Object.keys(T.skill.mcpServers).length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),s.jsx("div",{className:"grid gap-2",children:Object.entries(T.skill.mcpServers).map(([ne,he])=>s.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[s.jsx("span",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center text-purple-400 text-sm shrink-0",children:"◎"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary",children:ne}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof he=="object"?JSON.stringify(he).slice(0,80):String(he)})]})]},ne))})]}),oe&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),s.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:s.jsx(ag,{content:oe})})]})]}),Te.length>0&&s.jsx(S0,{files:Te,onSave:ce,readOnly:o})]}),s.jsx("div",{className:`${p?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${p?"":"sticky top-6"} space-y-4`,children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),s.jsx("span",{className:`font-medium ${_e.color}`,children:_e.label})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),s.jsx("span",{className:"text-fg-secondary",children:dt})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:Pe})]}),T.author&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),s.jsx("span",{className:"text-fg-secondary",children:typeof T.author=="string"?T.author:T.author?.name??""})]})]})]}),e==="agent"&&T.agent&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.agent.roleName&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.roleName})]}),T.agent.llmProvider&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.llmProvider})]}),T.agent.llmModel&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:T.agent.llmModel})]}),T.agent.temperature!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.temperature})]})]})]}),e==="team"&&T.team&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),s.jsx("span",{className:"text-fg-secondary",children:T.team.members.reduce((ne,he)=>ne+he.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),s.jsx("span",{className:"text-amber-400",children:T.team.members.filter(ne=>ne.role==="manager").reduce((ne,he)=>ne+he.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),s.jsx("span",{className:"text-blue-400",children:T.team.members.filter(ne=>ne.role!=="manager").reduce((ne,he)=>ne+he.count,0)})]})]})]}),e==="skill"&&T.skill&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.skill.alwaysOn!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),s.jsx("span",{className:T.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:T.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),s.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:T.skill.skillFile})]}),T.skill.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:T.skill.requiredPermissions.map(ne=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:ne},ne))})]})]})]}),T.dependencies&&(T.dependencies.skills?.length||T.dependencies.env?.length)?s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),T.dependencies.skills?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.skills.map(ne=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:ne},ne))})]}):null,T.dependencies.env?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.env.map(ne=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:ne},ne))})]}):null]}):null,!o&&_&&s.jsxs("button",{onClick:()=>Me.system.openPath(_).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:_,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),_.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&q&&s.jsx(_W,{onClose:()=>te(!1),onConfirm:(ne,he)=>{te(!1),rt({donationsEnabled:!1,priceCents:ne==="paid"?he:void 0})},isUpdate:L.shared}),!o&&U&&s.jsx(EW,{onClose:()=>Q(!1),onConfirm:(ne,he,be,ge)=>{Q(!1),rt({visibility:ne,orgId:he,priceCents:be,donationsEnabled:ge})}}),H&&s.jsx(dr,{alertOnly:!0,variant:H.variant??"primary",title:H.title,message:H.message,onConfirm:()=>W(null),onCancel:()=>W(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function EW({onClose:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),lt.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:S=>S.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:S=>m(S.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&s.jsxs("div",{className:"mb-5",children:[s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:r6.map(S=>s.jsx("button",{type:"button",onClick:()=>x(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,C&&g>0?g:void 0,C?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const r6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function _W({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:c=>c.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(n?"shareMode.titleUpdate":"share.toHub")}),s.jsx("div",{className:"space-y-2 mb-5",children:r6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>t(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(n?"shareMode.update":"shareMode.share")})]})]})})}function N0(e,t){return!e||!n6(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function jW({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:c="rounded-xl"}){const d=Xo(e),m=N0(n,r),p=k.useMemo(()=>Xg(d,t),[d,t]),h=k.useMemo(()=>t6(t),[t]),[g,x]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>x(!0),style:{width:o,height:o},className:`${c} object-cover shrink-0 ${l}`}):xW(n)?s.jsx("div",{style:{width:o,height:o,background:p,fontSize:o*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&_V(n)?s.jsx("div",{style:{width:o,height:o,background:p},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Yo,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:p},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:o*.55,height:o*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:h,fill:"rgba(255,255,255,0.92)"})})})}function C0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:c}){const d=t||e||"markus",m=N0(n,r),[p,h]=k.useState(!1),g=m&&!p?m:yW(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:o,height:o},children:[s.jsx("img",{src:g,alt:e||t||"",onError:()=>h(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),c&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 ring-2 ring-surface-primary",style:{width:o*.42,height:o*.42},children:s.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"white","aria-hidden":!0,children:s.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function MW({type:e,className:t=""}){const n=Xo(e),r=Ei[n];return s.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white bg-gradient-to-r ${r.gradient} ${t}`,children:r.label})}function P4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",className:n<t?"text-amber-400":"text-fg-muted/40",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z"})},n))})}function ia(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:c,hubBase:d,author:m,authorLabel:p,version:h,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:C=0,priceCents:T,currency:S="usd",installed:_,glowing:j,selected:O,showTypeBadge:P=!0,hideStats:L=!1,cornerLabel:F,actions:V,footerLeft:X,headerAction:z,onClick:G,className:ae=""}=e,Z=Xo(t),q=Ei[Z],te=o||n,U=(T??0)>0,Q=!!N0(c||void 0,d),me=Xg(Z,te),Ce=p??m?.displayName??m?.username??"",[H,W]=k.useState(null),fe=_?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/12 text-emerald-400 border border-emerald-500/25 px-2 py-0.5 text-[10px] font-semibold",children:s.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):F?s.jsx("span",{className:"chip",children:F}):U?s.jsx("span",{className:"badge-paid",children:L4(T,S)}):null;if(Q){const I=N0(c||void 0,d);return s.jsxs("div",{onClick:G,style:{aspectRatio:H??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${G?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Re=>{const Be=Re.currentTarget;Be.naturalWidth&&Be.naturalHeight&&W(Math.min(1.9,Math.max(1,Be.naturalWidth/Be.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),s.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),s.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[s.jsx("span",{children:P&&s.jsx(MW,{type:Z})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Re=>Re.stopPropagation(),children:[_?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/25 text-emerald-50 border border-emerald-300/40 px-2 py-0.5 text-[10px] font-semibold backdrop-blur-md",children:s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):F?s.jsx("span",{className:"inline-flex items-center rounded-full bg-white/15 text-white border border-white/25 px-2 py-0.5 text-[10px] font-medium backdrop-blur-md",children:F}):z?null:s.jsx("span",{className:U?"badge-paid":"badge-free",children:L4(T,S)}),z]})]}),s.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),h&&s.jsxs("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/25 px-1.5 py-0.5 text-[10px] font-medium backdrop-blur-md",children:["v",h]})]}),Ce&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(C0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:Ce})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[g&&s.jsx("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/20 text-white/95 px-2 py-0.5 text-[10px] font-semibold capitalize backdrop-blur-md",children:g}),x?.slice(0,3).map(Re=>s.jsx("span",{className:"shrink-0 rounded-full bg-white/10 border border-white/15 text-white/85 px-2 py-0.5 text-[10px] backdrop-blur-md",children:Re},Re))]}),(!L||V)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[L?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(P4,{rating:y}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Mo(w),")"]})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Mo(C)]})]}),V&&s.jsx("div",{className:"flex items-center gap-2",onClick:Re=>Re.stopPropagation(),children:V})]})]})]})}return s.jsxs("div",{onClick:G,className:`group asset-card card-shine relative flex flex-col ${G?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${q.accent}, transparent)`}}),s.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:me}}),z&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:z}),s.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(jW,{type:Z,seed:te,icon:l,hubBase:d,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),s.jsxs("div",{className:`min-w-0 flex-1 ${z?"pr-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),h&&s.jsxs("span",{className:"chip shrink-0",children:["v",h]}),fe&&s.jsx("span",{className:"ml-auto shrink-0",children:fe})]}),(Ce||P)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(C0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),Ce&&s.jsx("span",{className:"truncate",children:Ce}),P&&s.jsxs(s.Fragment,{children:[Ce&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:q.accent},children:q.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),x?.slice(0,3).map(I=>s.jsx("span",{className:"chip",children:I},I)),(x?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(x?.length??0)-3]})]}),(()=>{const I=X??(L?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(P4,{rating:y}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Mo(w)})`:""})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Mo(C)]})]}));return!I&&!V?null:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Re=>Re.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),V&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:V})]})})()]})]})}function Ar({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const h=o.current;if(!h)return;c(h.clientWidth);const g=new ResizeObserver(x=>{for(const y of x)c(y.contentRect.width)});return g.observe(h),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),p=Array.from({length:d},()=>[]);return m.forEach((h,g)=>{p[g%d].push(h)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:p.map((h,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:h},g))})}function RW(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const OW=[{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 LW(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return fc(r[0])===ue.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const o=window.location.hash.slice(1).split("/");fc(o[0])===ue.BUILDER&&o[1]&&o[2]?t({type:o[1],name:decodeURIComponent(o[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const a6="markus_builder_shared_map";function DW(){try{const e=localStorage.getItem(a6);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Od(e){try{localStorage.setItem(a6,JSON.stringify(Object.fromEntries(e)))}catch{}}function s6({authUser:e}={}){const{t}=ft(["builder","common"]),n=Uo(),r=LW(),[o,l]=k.useState([]),[c,d]=k.useState([]),[m,p]=k.useState(!1),[h,g]=k.useState("all"),[x,y]=k.useState(null),[w,C]=k.useState(new Map),[T,S]=k.useState(null),[_,j]=k.useState(null),[O,P]=k.useState(null),[L,F]=k.useState(DW),[V,X]=k.useState(null),[z,G]=k.useState(null),[ae,Z]=k.useState(null),[q,te]=k.useState(null),[U,Q]=k.useState(null),[me,Ce]=k.useState("creations"),[H,W]=k.useState([]),[fe,I]=k.useState(""),[Re,Be]=k.useState([]),[Pe,Fe]=k.useState(!1),[dt,mt]=k.useState("all"),Nt=k.useCallback(()=>{p(!0),Promise.all([(Si(Tr.builderArtifacts)??Me.builder.artifacts.list()).then(ce=>ce?.artifacts??[]).catch(()=>[]),(Si(Tr.builderAgents)??Me.agents.list()).then(ce=>ce?.agents??[]).catch(()=>[]),(Si(Tr.builderHubMyItems)??lt.myItems()).then(ce=>ce?.items??[]).catch(()=>[]),(Si(Tr.builderInstalled)??Me.builder.artifacts.installed()).then(ce=>ce?.installed??{}).catch(()=>({}))]).then(([ce,rt,at,ve])=>{if(d(ce),l(rt),at.length>0){const Ee=new Map;for(const oe of at){const $=oe.itemType==="agent"?"agent":oe.itemType==="team"?"team":"skill";for(const J of ce)J.type===$&&(oe.slug===J.name||oe.name===(J.meta.displayName||J.meta.name||J.name))&&Ee.set(`${J.type}/${J.name}`,{id:oe.id,name:oe.name,slug:oe.slug||J.name,version:oe.version||"1.0.0",visibility:oe.visibility??"public",moderationStatus:oe.moderationStatus,pendingReview:oe.pendingReview})}Ee.size>0&&F(oe=>{const $=new Map(oe);for(const[J,Te]of Ee)$.set(J,Te);return Od($),$})}const _e=new Map;for(const Ee of ce){const oe=`${Ee.type}/${Ee.name}`,$=ve[oe];$&&_e.set(oe,{agentId:$.agentId,agentIds:$.agentIds,teamId:$.teamId})}C(_e)}).finally(()=>p(!1))},[]);k.useEffect(()=>{Nt();const ce=rt=>{rt.detail?.page===ue.BUILDER&&Nt()};return window.addEventListener("markus:navigate",ce),()=>window.removeEventListener("markus:navigate",ce)},[Nt]);const Ot=ce=>{const rt=o.find(at=>at.role==="Secretary"||at.name==="Secretary");rt?it.navigate(ue.TEAM,{agentId:rt.id,prefillMessage:ce}):it.navigate(ue.TEAM,{prefillMessage:ce})},At=async ce=>{const rt=`${ce.type}/${ce.name}`;if(!w.has(rt)){y({key:rt,action:"install"});try{const at=await Me.builder.artifacts.install(ce.type,ce.name),ve={};at.agent&&typeof at.agent=="object"&&(ve.agentId=at.agent.id),at.team&&typeof at.team=="object"&&(ve.teamId=at.team.id),Array.isArray(at.agents)&&(ve.agentIds=at.agents.map(_e=>_e.id)),C(_e=>new Map(_e).set(rt,ve)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(at){console.error("Install failed:",at),G({title:t("common:install"),message:t("installFailed",{error:String(at)}),variant:"danger"})}finally{y(null)}}},qt=async ce=>{const rt=`${ce.type}/${ce.name}`;if(w.has(rt)){y({key:rt,action:"uninstall"});try{await Me.builder.artifacts.uninstall(ce.type,ce.name),C(at=>{const ve=new Map(at);return ve.delete(rt),ve}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(at){console.error("Uninstall failed:",at),G({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(at)}),variant:"danger"})}finally{y(null)}}},jt=async(ce,rt)=>{const at=`${ce.type}/${ce.name}`;y({key:at,action:"share"});try{const ve=await Me.builder.artifacts.ensureSlugSafe(ce.type,ce.name,ce.meta.displayName||ce.meta.name||ce.name),_e=ve.name,Ee=ve.slug||xc(_e);if(!Ee)throw new Error("Invalid package slug: use English kebab-case for the artifact name (e.g. qwen-multimodal). Chinese-only names cannot be shared — rename the package slug and put the Chinese title in displayName.");const oe=`${ce.type}/${_e}`;ve.converted&&(d(ie=>ie.map(Le=>Le.type===ce.type&&Le.name===ce.name?{...Le,name:_e,path:ve.path,meta:{...Le.meta,name:_e,displayName:ve.displayName??Le.meta.displayName??ce.name}}:Le)),F(ie=>{const Le=new Map(ie),xe=Le.get(at);return xe&&(Le.delete(at),Le.set(oe,{...xe,slug:Ee,name:ve.displayName??xe.name})),Od(Le),Le}),C(ie=>{const Le=new Map(ie),xe=Le.get(at);return xe&&(Le.delete(at),Le.set(oe,xe)),Le}));const $=await Me.builder.artifacts.get(ce.type,_e);let J={...ce.meta,name:_e,displayName:ve.displayName??ce.meta.displayName??ce.name};try{const ie=$.files?.[`${ce.type}.json`]??$.files?.["agent.json"]??$.files?.["team.json"]??$.files?.["skill.json"];ie&&(J={...JSON.parse(ie),...J,name:_e,displayName:J.displayName})}catch{}const Te=J.displayName||J.name||_e,ne=J.description||"",he=J.category||"general",be=Array.isArray(J.tags)?J.tags:[];let ge=J.icon||void 0;const Se=J.version||"1.0.0";if(ge&&!ge.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(ge)){const ie=ge.split("/").pop()??ge;try{const Le=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(_e)}/images/${encodeURIComponent(ie)}`);if(Le.ok){const xe=await Le.blob(),Ge=new File([xe],ie,{type:xe.type}),Qe=await lt.uploadImage(Ge);Qe?.url&&(ge=Qe.url)}}catch{}}let st;const Ve=[],Je=Array.isArray(J.screenshots)?J.screenshots:[];for(let ie=0;ie<Je.length;ie++){const Le=Je[ie],xe=Le.split("/").pop()??Le;try{const Ge=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(_e)}/images/${encodeURIComponent(xe)}`);if(Ge.ok){const Qe=await Ge.blob(),K=new File([Qe],xe,{type:Qe.type}),le=await lt.uploadImage(K);le?.url&&(Ve.push({url:le.url,alt:xe,order:ie}),(ie===0||J.thumbnail===Le)&&(st=le.url))}}catch{}}const R=await lt.publishViaProxy({itemType:ce.type==="team"?"team":ce.type==="skill"?"skill":"agent",name:Te,slug:Ee,description:ne,category:he,tags:be,icon:ge,version:Se,config:{...J,name:_e,displayName:Te},files:$.files&&Object.keys($.files).length>0?$.files:void 0,thumbnailUrl:st,images:Ve.length>0?Ve:void 0,priceCents:rt?.priceCents,donationsEnabled:rt?.donationsEnabled,visibility:rt?.visibility,orgId:rt?.orgId});R.id&&(F(Le=>{const xe=new Map(Le);return xe.set(oe,{id:R.id,name:Te,slug:R.slug??Ee,version:Se,visibility:R.visibility??rt?.visibility??"public",moderationStatus:R.moderationStatus,pendingReview:R.pendingReview}),Od(xe),xe}),(R.visibility??rt?.visibility??"public")!=="org"&&(R.moderationStatus==="pending"||R.pendingReview)?G({title:t("common:share"),message:ve.converted?t("share.convertedAndSubmitted",{previous:ce.name,slug:Ee}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):ve.converted&&G({title:t("common:share"),message:t("share.convertedSlug",{previous:ce.name,slug:Ee}),variant:"primary"}))}catch(ve){console.error("Share failed:",ve),G({title:t("common:share"),message:t("shareFailed",{error:ve instanceof Error?ve.message:String(ve)}),variant:"danger"})}finally{y(null)}},$e=async()=>{if(!V)return;const{key:ce}=V,rt=L.get(ce);if(X(null),!rt)return;const at=rt.id;y({key:ce,action:"hubDelete"});try{await lt.deleteItem(at),F(ve=>{const _e=new Map(ve);return _e.delete(ce),Od(_e),_e})}catch(ve){console.error("Hub delete failed:",ve),G({title:t("unshare"),message:t("hubDeleteFailed",{error:String(ve)}),variant:"danger"})}finally{y(null)}},ut=async()=>{if(!T)return;const ce=T,rt=`${ce.type}/${ce.name}`;S(null),y({key:rt,action:"delete"});try{await Me.builder.artifacts.delete(ce.type,ce.name),d(at=>at.filter(ve=>!(ve.type===ce.type&&ve.name===ce.name))),C(at=>{const ve=new Map(at);return ve.delete(rt),ve}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(at){console.error("Delete failed:",at)}finally{y(null)}},kt=h==="all"?c:c.filter(ce=>ce.type===h);k.useEffect(()=>{me!=="orgAssets"||H.length>0||lt.myOrgs().then(ce=>{W(ce.memberships),ce.memberships.length>0&&!fe&&I(ce.memberships[0].id)}).catch(()=>{})},[me,H.length,fe]),k.useEffect(()=>{me!=="orgAssets"||!fe||(Fe(!0),lt.browseItems({orgId:fe,limit:100}).then(ce=>Be(ce.items??[])).catch(()=>Be([])).finally(()=>Fe(!1)))},[me,fe]);const xt=dt==="all"?Re:Re.filter(ce=>ce.itemType===dt),Ct=ce=>{history.pushState(null,"",Ti(ue.BUILDER,`${ce.type}/${encodeURIComponent(ce.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Mi,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Ti(ue.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),s.jsx("button",{onClick:Nt,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:t("common:refresh")})]}),s.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:OW.map(ce=>{const rt=t(`prompts.${ce.id}Prompt`),at=t(`prompts.${ce.id}Examples`,{returnObjects:!0}),ve=Array.isArray(at)?at:[];return s.jsx("button",{onClick:()=>Ot(rt),className:`group text-left w-full rounded-xl border ${ce.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${ce.bgColor} flex items-center justify-center shrink-0`,children:ce.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ce.color} bg-clip-text text-transparent`,children:t(`prompts.${ce.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ce.id}Desc`)}),ve.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ve.slice(0,2).map((_e,Ee)=>s.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:oe=>{oe.stopPropagation(),Ot(rt+_e)},children:["“",_e,"”"]},Ee))})]})]})},ce.id)})})]}),s.jsx("div",{className:"mb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>Ce("creations"),className:`text-sm font-semibold transition-colors ${me==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>Ce("orgAssets"),className:`text-sm font-semibold transition-colors ${me==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),me==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>s.jsx("button",{onClick:()=>g(ce),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${h===ce?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ce==="all"?"myCreations.filterAll":ce==="agent"?"myCreations.filterAgents":ce==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ce))}),me==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>s.jsx("button",{onClick:()=>mt(ce),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${dt===ce?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ce==="all"?"myCreations.filterAll":ce==="agent"?"myCreations.filterAgents":ce==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ce))})]})}),me==="orgAssets"&&H.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:H.map(ce=>s.jsx("button",{onClick:()=>I(ce.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${fe===ce.id?"bg-blue-500/15 border-blue-500/40 text-blue-400":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:ce.name},ce.id))}),me==="orgAssets"&&(H.length===0&&!Pe?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):Pe?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):xt.length===0?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):s.jsx(Ar,{children:xt.map(ce=>{const rt=ce.author?.username&&ce.slug?`${lt.getUrl()}/@${encodeURIComponent(ce.author.username)}/${encodeURIComponent(ce.slug)}`:null;return s.jsx(ia,{type:ce.itemType,name:ce.name,description:ce.description,seed:ce.slug||ce.id||ce.name,icon:ce.icon,cover:ce.thumbnailUrl,hubBase:lt.getUrl(),author:ce.author,version:ce.version,rating:parseFloat(ce.avgRating)||0,ratingCount:ce.ratingCount,downloadCount:ce.downloadCount,actions:rt?s.jsxs("a",{href:rt,target:"_blank",rel:"noopener noreferrer",onClick:at=>{at.stopPropagation(),yc()&&(at.preventDefault(),_i(rt))},className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},ce.id)})})),me==="creations"&&(m&&c.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):kt.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),s.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):s.jsx(Ar,{children:kt.map(ce=>{const rt=ce.meta.displayName||ce.meta.name||ce.name,at=ce.meta.description||"",ve=`${ce.type}/${ce.name}`,_e=x?.key===ve?x.action:null,Ee=L.get(ve),oe=ce.meta.version||"1.0.0",$=!!Ee,J=$&&Ee.version!==oe,Te=()=>{const Ve=lt.getUser();return!Ee||!Ve?null:`${lt.getUrl()}/@${encodeURIComponent(Ve.username)}/${encodeURIComponent(Ee.slug)}`},ne=$&&(Ee?.moderationStatus==="pending"||Ee?.moderationStatus==="rejected"||!!Ee?.pendingReview),he=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:Ve=>Ve.stopPropagation(),children:[w.has(ve)?s.jsxs("button",{onClick:()=>P(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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"17 8 12 3 7 8"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(_e==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>j(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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(_e==="install"?"common:installing":"common:install")]}),$&&ne?Ee?.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.underReview")]}):Ee?.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}):s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.updateUnderReview")]}):$?s.jsxs(s.Fragment,{children:[J&&s.jsxs("button",{onClick:()=>{const Ve=Ee?.visibility??"public";jt(ce,{visibility:Ve})},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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("polyline",{points:"1 20 1 14 7 14"}),s.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),_e==="share"?t("common:sharing"):t("share.updateVersion",{version:oe})]}),s.jsxs("a",{href:Te()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Ve=>{const Je=Te();yc()&&Je&&(Ve.preventDefault(),_i(Je))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ee?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ee?.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:[Ee?.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):Ee?.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Ee?.visibility==="org"?t("visibility.sharedOrg"):Ee?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>X({key:ve,name:rt}),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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):s.jsxs("button",{onClick:async()=>{await lt.ensureAuth(),Array.isArray(ce.meta.screenshots)&&ce.meta.screenshots.length>0?Q(ce):Z(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:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"18",cy:"5",r:"3"}),s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"19",r:"3"}),s.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),s.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(_e==="share"?"common:sharing":"common:share")]})]}),be=s.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:s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"3 6 5 6 21 6"}),s.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),ge=ce.meta.icon,st=!!ge&&/\.(png|jpe?g|gif|webp|svg)$/i.test(ge)?ge.startsWith("http")||ge.startsWith("/")?ge:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(ge.split("/").pop()??"")}`:ge;return s.jsx(ia,{type:ce.type,name:rt,description:at,seed:ve,icon:st,version:oe,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:Ve=>{Ve.stopPropagation(),Me.system.openPath(ce.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ce.path,children:RW(ce.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:be,actions:he,onClick:()=>Ct(ce)},ve)})})),_&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:_.meta.displayName||_.meta.name||_.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ce=_;j(null),At(ce)},onCancel:()=>j(null)}),O&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:O.meta.displayName||O.meta.name||O.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ce=O;P(null),qt(ce)},onCancel:()=>P(null)}),T&&s.jsx(dr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:ut,onCancel:()=>S(null)}),V&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:V.name}),confirmLabel:t("unshare"),onConfirm:()=>{$e()},onCancel:()=>X(null)}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"primary",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)}),ae&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Z(null),children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),s.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>{const ce=ae;Z(null),Q(ce)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),s.jsx("button",{onClick:()=>{const ce=ae;Z(null),Ct(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")})]})]})}),q&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>te(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:s.jsx(PW,{isUpdate:L.has(`${q.type}/${q.name}`),onCancel:()=>te(null),onConfirm:(ce,rt)=>{const at=q;te(null),jt(at,{priceCents:rt>0?rt:void 0})}})})}),U&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Q(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:s.jsx(IW,{onCancel:()=>Q(null),onConfirm:(ce,rt,at,ve)=>{const _e=U;Q(null),jt(_e,{visibility:ce,orgId:rt,priceCents:at,donationsEnabled:ve})}})})})]})})}function IW({onCancel:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),lt.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:S=>m(S.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:i6.map(S=>s.jsx("button",{type:"button",onClick:()=>x(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,C&&g>0?g:void 0,C?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const i6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function PW({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(e?"shareMode.titleUpdate":"shareMode.title")}),s.jsx("div",{className:"space-y-2 mb-5",children:i6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>n(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(e?"shareMode.update":"shareMode.share")})]})]})}const zW=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:s6},Symbol.toStringTag,{value:"Module"}));async function o6(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(r=>r.id===t);if(n)return{items:[n,...e.filter(r=>r.id!==t)],highlighted:n,missing:!1};try{const{item:r}=await lt.getItem(t);return r?{items:[r,...e],highlighted:r,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function BW(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function T0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function z4(e,t){return e.i18n?.[t]?.description||e.description}const $W={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function HW({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=ft(["store","common"]),l=o.language,[c,d]=k.useState(""),[m,p]=k.useState([]),[h,g]=k.useState([]),[x,y]=k.useState(null),[w,C]=k.useState({}),[T,S]=k.useState(!1),[_,j]=k.useState(!0),[O,P]=k.useState(new Map),[L,F]=k.useState(new Set),[V,X]=k.useState(null),[z,G]=k.useState(null),ae=k.useCallback(async()=>{try{const[te,U]=await Promise.all([Me.builder.artifacts.list().catch(()=>({artifacts:[]})),Me.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const me of te.artifacts){if(me.type!=="agent")continue;const Ce=!!U.installed[`agent/${me.name}`];Q.set(me.name,{installed:Ce,localVersion:me.meta.version||void 0,localUpdatedAt:me.updatedAt})}P(Q)}catch{}},[]),Z=k.useCallback(async()=>{j(!0);try{const te=c?lt.search({type:"agent",q:c,limit:50}):Si(Tr.hubAgents)??lt.search({type:"agent",limit:50}),U=new URLSearchParams;c&&U.set("q",c);const Q=fetch("/api/templates?"+U.toString()).then(W=>W.json()).catch(()=>({templates:[]})),[me,Ce]=await Promise.all([te.catch(()=>({items:[],total:0})),Q,ae(),lt.isAuthenticated()?lt.purchases.mine().then(W=>F(new Set(W.purchases.map(fe=>fe.itemId)))).catch(()=>{}):Promise.resolve()]),H=await o6(me?.items??[],t);g(H.items),p(Array.isArray(Ce.templates)?Ce.templates:[]),H.missing&&n?.()}catch{p([]),g([])}finally{j(!1)}},[c,ae,t,n]);k.useEffect(()=>{Z()},[Z]),k.useEffect(()=>{if(!x){C({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(te=>te.json()).then(te=>C(te.files??{})).catch(()=>C({}))},[x]);const q=async(te,U,Q)=>{try{const me=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:te,name:U,orgId:"default",teamId:Q})});if(!me.ok)throw new Error(`Failed: ${me.status}`);S(!1),y(null)}catch(me){G({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${me}`,variant:"danger"})}};if(V)return s.jsx(Mi,{type:V.type,name:V.name,onBack:()=>X(null)});if(x){const te={type:"agent",name:x.id,displayName:T0(x,l),version:x.version,description:z4(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},U=s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.roleConfig")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.role")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.position")}),s.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${$W[x.agentRole]??""}`,children:x.agentRole})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.skills")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(Q=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:Q},Q)),x.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.starterTasks")}),s.jsx("div",{className:"space-y-2",children:x.starterTasks.map((Q,me)=>s.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${Q.priority==="high"?"bg-red-400":Q.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:Q.title}),Q.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:Q.description})]})]},me))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Mi,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:te,actionSlot:s.jsx("button",{onClick:()=>S(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium",children:r("agentStore.hireAgent")}),contentSlot:U}),T&&s.jsx(B4,{template:x,lang:l,onClose:()=>S(!1),onHire:q}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"danger",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:r("agentStore.title")}),s.jsx("input",{type:"text",placeholder:r("agentStore.searchPlaceholder"),value:c,onChange:te=>d(te.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:_?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((te,U)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},U))}):m.length===0&&h.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?r("agentStore.noResults",{search:c}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):s.jsxs(s.Fragment,{children:[m.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:r("agentStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:r("agentStore.available",{count:m.length})})]}),s.jsx(Ar,{columns:3,children:m.map(te=>s.jsx(ia,{type:"agent",name:T0(te,l),description:z4(te,l),seed:te.id,icon:te.icon,version:te.version,category:te.category,tags:te.tags,authorLabel:te.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>y(te)},te.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Ar,{columns:3,children:h.map(te=>s.jsx(UW,{item:te,localInfo:O.get(Lc(te)),purchased:e0(te,L),onStatusChange:ae,highlight:te.id===t,onHighlightDone:n,onViewDetail:U=>X({type:"agent",name:U})},te.id))})]})]})}),T&&x&&s.jsx(B4,{template:x,lang:l,onClose:()=>S(!1),onHire:q}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"danger",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]})}function Lc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return r0(n||e.name,"hub-pkg")}function Ni(e){return(async()=>{const t=await lt.download(e.id),n=t.name||e.name,r=t.config??{},o=Lc(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},d=(t.version||e.version||(typeof r.version=="string"?r.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Me.builder.artifacts.import(l,o,t.files,c,d);else{const m={...r,...d?{version:d}:{},name:o,displayName:r.displayName||n,description:e.description,source:c};await Me.builder.artifacts.save(l,m)}return await Me.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Qg(e,t){t("checking"),await lt.ensureAuth();const n=await lt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Ni(e),"installed";try{if((await lt.creator.getBalance()).availableBalance>=(e.priceCents??0)){const l=await lt.purchases.payWithEarnings(e.id);if(l.ok||l.alreadyOwned)return t("installing"),await Ni(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=window.open(n.checkoutUrl,"_blank","noopener");return new Promise((o,l)=>{const c=setInterval(async()=>{const d=r?r.closed:!1;try{if((await lt.purchases.checkout(e.id)).alreadyOwned){clearInterval(c),t("installing");try{await Ni(e),o("installed")}catch(p){l(p)}return}}catch{}if(d){clearInterval(c);try{if((await lt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Ni(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function UW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=ft(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const V=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(V)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&BW(e.version,t.localVersion),S=(e.priceCents??0)>0,_=async V=>{if(V.stopPropagation(),!m){p(!0),g("");try{await Ni(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(X){const z=X instanceof Error?X.message:"";z.includes("402")||z.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},j=async V=>{if(V.stopPropagation(),!m){p(!0),g("");try{await Qg(e,z=>{z==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):z==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(X){g(X instanceof Error?X.message:d("card.failed"))}finally{p(!1)}}},O=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,P=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,L=()=>{C&&c?c(Lc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},F=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:V=>{_(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):C?s.jsxs("button",{onClick:V=>{_(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?s.jsx("button",{onClick:V=>{j(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",O]})}):s.jsx("button",{onClick:V=>{_(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),h&&!(S&&!n)&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(ia,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:C,glowing:y,onClick:L,actions:F})})}function B4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,c]=k.useState(`${T0(e,t)} Agent`),[d,m]=k.useState(""),[p,h]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>h(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await r(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsx("div",{className:"flex items-center gap-3 mb-5",children:s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold",children:o("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:o("hireModal.creating",{name:T0(e,t)})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.agentName")}),s.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"input-field",autoFocus:!0})]}),p.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:o("hireModal.noTeam")}),p.map(w=>s.jsx("option",{value:w.id,children:w.name},w.id))]})]}),s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:o("hireModal.agentConfig")}),s.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||o("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:o("hireModal.cancel")}),s.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function ih(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function $4(e,t){return e.i18n?.[t]?.description||e.description}function H4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function FW(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function qW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[p,h]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[C,T]=k.useState(!0),[S,_]=k.useState(!1),[j,O]=k.useState(null),[P,L]=k.useState(new Map),[F,V]=k.useState(new Set),[X,z]=k.useState(null),G=k.useCallback(async()=>{try{const[q,te]=await Promise.all([Me.builder.artifacts.list().catch(()=>({artifacts:[]})),Me.builder.artifacts.installed().catch(()=>({installed:{}}))]),U=new Map;for(const Q of q.artifacts){if(Q.type!=="team")continue;const me=!!te.installed[`team/${Q.name}`];U.set(Q.name,{installed:me,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}L(U)}catch{}},[]),ae=k.useCallback(async()=>{T(!0);try{const q=l?lt.search({type:"team",q:l,limit:50}):Si(Tr.hubTeams)??lt.search({type:"team",limit:50}),[te,U]=await Promise.all([q.catch(()=>({items:[],total:0})),Me.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),G(),lt.isAuthenticated()?lt.purchases.mine().then(me=>V(new Set(me.purchases.map(Ce=>Ce.itemId)))).catch(()=>{}):Promise.resolve()]),Q=await o6(te?.items??[],e);h(Q.items),m(U?.templates??[]),Q.missing&&t?.()}catch{m([]),h([])}finally{T(!1)}},[l,G,e,t]);k.useEffect(()=>{ae()},[ae]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(q=>q.json()).then(q=>w(q.files??{})).catch(()=>w({}))},[g]);const Z=async q=>{_(!0),O(null);try{const U=(await Me.teams.create(q.name,q.description)).team.id;let Q,me=0;const Ce=[];for(const W of q.members){const fe=W.count??1;for(let I=0;I<fe;I++){const Re=W.name??`${q.name} Agent ${I+1}`,Be=fe>1?`${Re} ${I+1}`:Re,Pe=W.roleName??W.templateId;try{const Fe=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Be,...Pe?{roleName:Pe}:{},orgId:"default",teamId:U,agentRole:W.role??"worker",skills:W.skills??[]})});if(Fe.ok){me++;const dt=await Fe.json();W.role==="manager"&&!Q&&(Q=dt.agent?.id)}else{const dt=await Fe.json().catch(()=>({error:`HTTP ${Fe.status}`}));Ce.push(`${Be}: ${dt.error??Fe.statusText}`)}}catch(Fe){Ce.push(`${Be}: ${String(Fe)}`)}}}Q&&await Me.teams.update(U,{managerId:Q,managerType:"agent"}).catch(()=>{});const H=Ce.length>0?` (${Ce.length} failed: ${Ce[0]})`:"";O({ok:me>0,message:`Team "${ih(q,o)}" deployed with ${me} agent(s)${H}`})}catch(te){O({ok:!1,message:`Failed: ${te}`})}finally{_(!1)}};if(X)return s.jsx(Mi,{type:X.type,name:X.name,onBack:()=>z(null)});if(g){const q={...y};g.announcements&&(q["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(q["NORMS.md"]=g.norms);const te={type:"team",name:g.id,displayName:ih(g,o),version:g.version,description:$4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:q,team:{members:g.members.map(Q=>({name:H4(g,Q.name??Q.roleName??Q.templateId??"Agent",o),role:Q.role??"worker",roleName:Q.roleName??Q.templateId,count:Q.count??1,skills:Q.skills??[]}))}},U=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),s.jsx("div",{className:"p-5 space-y-2",children:g.members.map((Q,me)=>{const Ce=H4(g,Q.name??Q.roleName??Q.templateId??"Agent",o);return s.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${Q.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(Ce[0]??"?").toUpperCase()}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-fg-primary font-medium",children:Ce}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${Q.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:Q.role??"worker"}),(Q.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",Q.count]})]}),(Q.roleName||Q.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:Q.roleName??Q.templateId})]}),Q.skills&&Q.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[Q.skills.slice(0,3).map(H=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:H},H)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},me)})})]});return s.jsx(s.Fragment,{children:s.jsx(Mi,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:te,contentSlot:U,actionSlot:s.jsxs(s.Fragment,{children:[j&&s.jsx("span",{className:`text-xs ${j.ok?"text-green-500":"text-red-500"}`,children:j.message}),s.jsx("button",{onClick:()=>{Z(g)},disabled:S,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(S?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),s.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:q=>c(q.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:C?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((q,te)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},te))}):d.length===0&&p.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):s.jsxs(s.Fragment,{children:[d.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),s.jsx(Ar,{columns:2,children:d.map(q=>s.jsx(ia,{type:"team",name:ih(q,o),description:$4(q,o),seed:q.id,icon:q.icon||"users",version:q.version,category:q.category,tags:q.tags,authorLabel:q.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(q)},q.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Ar,{columns:2,children:p.map(q=>s.jsx(GW,{item:q,localInfo:P.get(Lc(q)),purchased:e0(q,F),onStatusChange:G,highlight:q.id===e,onHighlightDone:t,onViewDetail:te=>z({type:"team",name:te})},q.id))})]})]})})]})}function GW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=ft(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const V=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(V)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&FW(e.version,t.localVersion),S=(e.priceCents??0)>0,_=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,j=async V=>{if(V.stopPropagation(),!m){p(!0),g("");try{await Ni(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(X){const z=X instanceof Error?X.message:"";z.includes("402")||z.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},O=async V=>{if(V.stopPropagation(),!m){p(!0),g("");try{await Qg(e,z=>{z==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):z==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(X){g(X instanceof Error?X.message:d("card.failed"))}finally{p(!1)}}},P=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,L=()=>{C&&c?c(Lc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},F=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:V=>{j(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):C?s.jsxs("button",{onClick:V=>{j(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):S&&!n?s.jsx("button",{onClick:V=>{O(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",_]})}):s.jsx("button",{onClick:V=>{j(V)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),h&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(ia,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:C,glowing:y,onClick:L,actions:F})})}function oh(e,t){return e.i18n?.[t]?.displayName||e.name}function lh(e,t){return e.i18n?.[t]?.description||e.description||""}function l6(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}const KW={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 VW({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=ft(["store"]),[c,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",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&&l6(e.version,p.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),C=async()=>{if(!c){d(!0),w("");try{await Ni(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(S){const _=S instanceof Error?S.message:"";_.includes("402")||_.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!c){d(!0),w("");try{await Qg(e,_=>{_==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):_==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(S){r(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:c?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(h)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),p?.version?` (v${p.version})`:""]});if(x&&!n){const S=`$${((e.priceCents??0)/100).toFixed(2)}`;return s.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.jsx("button",{onClick:()=>{T()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 inline-flex items-center gap-1",children:c?y||l("card.installing"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",S]})})})}return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function U4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:c,type:d="skill"}){const m=k.useRef(null),[p,h]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),h(!0);const y=setTimeout(()=>{h(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const g=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:p?"animate-pulse":"",children:s.jsx(ia,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Kd(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:x,actions:s.jsx(VW,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function WW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,l=Uo(),[c,d]=k.useState("skills"),[m,p]=k.useState(null),[h,g]=k.useState(new Set),[x,y]=k.useState([]),[w,C]=k.useState(null),[T,S]=k.useState([]),[_,j]=k.useState(0),[O,P]=k.useState(1),[L,F]=k.useState([]),[V,X]=k.useState(""),[z,G]=k.useState("score"),[ae,Z]=k.useState(""),[q,te]=k.useState(!1),[U,Q]=k.useState([]),[me,Ce]=k.useState(!1),[H,W]=k.useState([]),[fe,I]=k.useState(""),[Re,Be]=k.useState(!1),[Pe,Fe]=k.useState([]),[dt,mt]=k.useState([]),[Nt,Ot]=k.useState(new Set),[At,qt]=k.useState(!1),[jt,$e]=k.useState(""),ut=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],kt=($,J="success")=>{p({text:$,type:J}),setTimeout(()=>p(null),J==="error"?1e4:4e3)},xt=k.useCallback(async()=>{try{const $=await Me.skills.list();y($.skills)}catch{}},[]),Ct=k.useCallback(async()=>{Ce(!0);try{const $=await Me.skills.builtin();Q($.skills)}catch{}Ce(!1)},[]),ce=k.useCallback(async $=>{te(!0);try{const J=await Me.skills.registrySkillhub({q:$?.q,category:$?.category,page:$?.page??1,limit:24,sort:$?.sort??z});S(J.skills),j(J.total),J.categories?.length&&F(J.categories)}catch{}te(!1)},[z]),rt=k.useCallback(async $=>{Be(!0);try{const J=await Me.skills.registrySkillssh($);W(J.skills)}catch{}Be(!1)},[]),at=k.useCallback(async $=>{qt(!0);try{const J=$?lt.search({type:"skill",q:$,limit:50}):Si(Tr.hubSkills)??lt.search({type:"skill",limit:50}),Te=lt.search({subtype:"connector",q:$||void 0,limit:50}).catch(()=>({items:[]})),[ne,he]=await Promise.all([J,Te,lt.isAuthenticated()?lt.purchases.mine().then(Se=>Ot(new Set(Se.purchases.map(st=>st.itemId)))).catch(()=>{}):Promise.resolve()]);let be=ne?.items??[],ge=he?.items??[];if(e){const Se=be.some(Ve=>Ve.id===e),st=ge.some(Ve=>Ve.id===e);if(!Se&&!st)try{const{item:Ve}=await lt.getItem(e);Ve?.subtype==="connector"?ge=[Ve,...ge]:Ve?be=[Ve,...be]:t?.()}catch{t?.()}else Se&&(be=[be.find(Je=>Je.id===e),...be.filter(Je=>Je.id!==e)]),st&&(ge=[ge.find(Je=>Je.id===e),...ge.filter(Je=>Je.id!==e)])}Fe(be),mt(ge)}catch{}qt(!1)},[e,t]);k.useEffect(()=>{xt(),Ct(),ce(),rt()},[]),k.useEffect(()=>{c==="skills"&&at(jt)},[c,jt,at]);const ve=async $=>{g(J=>new Set(J).add($.name));try{const J=await Me.skills.install({name:$.name,source:"skillhub",slug:$.slug,sourceUrl:$.homepage,description:$.description_zh??$.description,category:"custom",version:$.version});await xt(),kt(`"${$.name}" installed (${J.method}) → ${J.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{kt(`Download failed for "${$.name}". You can try manually from: ${$.homepage}`,"error")}g(J=>{const Te=new Set(J);return Te.delete($.name),Te})},_e=async $=>{g(J=>new Set(J).add($.name));try{const J=await Me.skills.install({name:$.name,source:"skillssh",sourceUrl:$.url,githubRepo:`${$.author}/${$.repo}`,githubSkillPath:$.name});await xt(),kt(`"${$.name}" installed (${J.method}) → ${J.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{kt(`Download failed for "${$.name}". You can try manually from: ${$.url}`,"error")}g(J=>{const Te=new Set(J);return Te.delete($.name),Te})},Ee=async $=>{g(J=>new Set(J).add($.name));try{const J=await Me.skills.install({name:$.name,source:"builtin"});await xt(),await Ct(),kt(`"${$.name}" installed (${J.method}) → ${J.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(J){kt(`Install failed for "${$.name}": ${J}`,"error")}g(J=>{const Te=new Set(J);return Te.delete($.name),Te})},oe=H.filter($=>{if(!fe)return!0;const J=fe.toLowerCase();return $.name.toLowerCase().includes(J)||$.repo.toLowerCase().includes(J)});if(w){const $=w,J={};$.instructions&&(J["SKILL.md"]=$.instructions);const Te={type:"skill",name:$.name,displayName:oh($,o),version:$.version,description:lh($,o),author:$.author??"",category:$.category??"general",tags:$.tags,files:J,skill:{skillFile:$.instructions?"SKILL.md":"",requiredPermissions:$.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},ne=$.installed&&$.installedVersion&&l6($.version,$.installedVersion)?s.jsx("button",{onClick:()=>{Ee($)},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?s.jsxs("span",{className:"px-4 py-1.5 text-xs bg-green-500/10 text-green-500 rounded-lg border border-green-500/20 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),$.installedVersion?` v${$.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{Ee($)},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")}),he=s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[$.category&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),s.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${KW[$.category]??"bg-gray-500/15 text-fg-secondary"}`,children:$.category})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:$.version})]}),$.hasMcpServers&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),$.hasInstructions&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),s.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),($.requiredPermissions.length>0||$.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[$.requiredPermissions.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:$.requiredPermissions.map(be=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:be},be))})]}),$.tags.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:$.tags.map(be=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:be},be))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Mi,{type:"skill",name:$.name,onBack:()=>C(null),readOnly:!0,initialManifest:Te,actionSlot:ne,contentSlot:he}),m&&s.jsx("div",{className:`mx-7 mb-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[s.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:s.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),s.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:ut.map($=>s.jsx("button",{onClick:()=>d($.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&&s.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text}),c==="skills"&&(()=>{const $=jt.trim().toLowerCase(),J=$?U.filter(he=>oh(he,o).toLowerCase().includes($)||lh(he,o).toLowerCase().includes($)):U,Te=me&&At,ne=J.length===0&&Pe.length===0&&dt.length===0;return s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{value:jt,onChange:he=>$e(he.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"}`})}),Te&&ne?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((he,be)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},be))}):ne?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),s.jsx("div",{children:n("skillStore.noBuiltin")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):s.jsxs(s.Fragment,{children:[J.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:J.length})})]}),s.jsx(Ar,{columns:3,children:J.map(he=>s.jsx(ia,{type:"skill",name:oh(he,o),description:lh(he,o),seed:he.name,icon:Kd(he.name,he.category),version:he.version,category:he.category,tags:he.tags,authorLabel:he.author||void 0,installed:he.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:he.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>C(he)},he.name))})]}),Pe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Ar,{columns:3,children:Pe.map(he=>s.jsx(U4,{item:he,installedSkills:x,purchased:e0(he,Nt),onMsg:kt,onRefresh:()=>{xt(),at(jt)},highlight:he.id===e,onHighlightDone:t},he.id))})]}),dt.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"mb-3",children:[s.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),s.jsx(Ar,{columns:3,children:dt.map(he=>s.jsx(U4,{item:he,type:"connector",installedSkills:x,purchased:e0(he,Nt),onMsg:kt,onRefresh:()=>{xt(),at(jt)},highlight:he.id===e,onHighlightDone:t},he.id))})]})]})]})})(),c==="skillhub"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsxs("select",{value:V,onChange:$=>{X($.target.value),P(1),ce({q:ae||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:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),L.map($=>s.jsx("option",{value:$,children:$},$))]}),s.jsxs("select",{value:z,onChange:$=>{G($.target.value),P(1),ce({q:ae||void 0,category:V||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:[s.jsx("option",{value:"score",children:n("skillStore.sortScore")}),s.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),s.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),s.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),s.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[s.jsx("input",{value:ae,onChange:$=>Z($.target.value),onKeyDown:$=>{$.key==="Enter"&&(P(1),ce({q:ae||void 0,category:V||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),s.jsx("button",{onClick:()=>{P(1),ce({q:ae||void 0,category:V||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),q?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),s.jsx("div",{children:n("skillStore.noSkillhub")})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:_.toLocaleString()})}),s.jsx(Ar,{columns:3,children:T.map($=>{const J=x.some(Te=>Te.name===$.name||Te.name===$.slug);return s.jsx(ia,{type:"skill",name:$.name,description:$.description_zh??$.description??"",seed:$.slug,icon:Kd($.slug||$.name,$.tags?.[0]),version:$.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:$.tags,installed:J,hideStats:!0,onClick:()=>window.open($.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[$.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",$.stars.toLocaleString()]}),$.downloads>0&&s.jsxs("span",{children:[$.downloads>=1e4?`${($.downloads/1e4).toFixed(1)}万`:$.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:J?void 0:s.jsx("button",{onClick:()=>{ve($)},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)})}),_>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:O<=1,onClick:()=>{const $=O-1;P($),ce({q:ae||void 0,category:V||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")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:O,total:Math.ceil(_/24)})}),s.jsx("button",{disabled:O>=Math.ceil(_/24),onClick:()=>{const $=O+1;P($),ce({q:ae||void 0,category:V||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"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[s.jsx("input",{value:fe,onChange:$=>I($.target.value),onKeyDown:$=>{$.key==="Enter"&&fe.trim()&&rt(fe)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),s.jsx("button",{onClick:()=>{fe.trim()&&rt(fe)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Re?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):oe.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),s.jsx("div",{children:n("skillStore.browseSkillssh")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):s.jsx(Ar,{columns:3,children:oe.map($=>{const J=x.some(Te=>Te.name===$.name);return s.jsx(ia,{type:"skill",name:$.name,description:$.description||"",seed:`${$.author}-${$.name}`,icon:Kd($.name),authorLabel:`${$.author}/${$.repo}`,showTypeBadge:!1,installed:J,hideStats:!0,cornerLabel:J?void 0:"skills.sh",onClick:()=>window.open($.url,"_blank","noopener,noreferrer"),footerLeft:$.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[$.installs," installs"]}):void 0,actions:J?void 0:s.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 YW=["agent","team","skill","connector"];function ch({title:e,subtitle:t,onMore:n,moreLabel:r}){return s.jsxs("div",{className:"flex items-end justify-between mb-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"section-title",children:e}),t&&s.jsx("p",{className:"section-subtitle",children:t})]}),n&&s.jsxs("button",{className:"section-link",onClick:n,children:[r??"View all"," →"]})]})}function XW({item:e,onOpen:t}){const n=Xo(e.subtype==="connector"?"connector":e.itemType),r=Xg(n,e.slug||e.name),o=Ei[n];return s.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:r},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),s.jsx("svg",{className:"absolute -right-8 -bottom-10 opacity-20",width:"220",height:"220",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",fill:"white"})}),s.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[s.jsxs("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:["★ Featured · ",o.label]}),s.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),s.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(C0,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:lt.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),s.jsxs("span",{children:["↓ ",Mo(e.downloadCount)]}),(e.priceCents??0)>0?s.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):s.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function F4({items:e,onOpen:t}){return s.jsx(Ar,{columns:3,children:e.map(n=>s.jsx(ia,{type:n.subtype==="connector"?"connector":n.itemType,name:n.name,description:n.description,seed:n.slug||n.name,icon:n.icon,cover:n.thumbnailUrl,hubBase:lt.getUrl(),author:n.author,category:n.category,tags:n.tags,rating:parseFloat(n.avgRating)||0,ratingCount:n.ratingCount,downloadCount:n.downloadCount,priceCents:n.priceCents,currency:n.currency,onClick:()=>t(n)},n.id))})}function q4(){return s.jsx(Ar,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function QW({onOpenType:e}){const{t}=ft(["store","common"]),[n,r]=k.useState([]),[o,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await lt.search({limit:60,sort:"popular"});g||r(x.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),p=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),h=g=>e(Xo(g.subtype==="connector"?"connector":g.itemType),g.id);return s.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[s.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),s.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:YW.map(g=>s.jsxs("button",{onClick:()=>e(g),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Ei[g].gradient} hover:opacity-90 transition-opacity`,children:[Ei[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ei[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(g=>s.jsx(XW,{item:g,onOpen:()=>h(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(q4,{}):d.length>0?s.jsx(F4,{items:d,onOpen:h}):s.jsx(ZW,{})]}),s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(q4,{}):m.length>0?s.jsx(F4,{items:m,onOpen:h}):null]}),p.length>0&&s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:p.map((g,x)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(C0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:lt.getUrl(),size:48,verified:x<3}),x<3&&s.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:x+1})]}),s.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),s.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",Mo(g.downloads)]})]},g.author?.username||x))})]})]})}function ZW(){const{t:e}=ft(["store"]);return s.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[s.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),s.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),s.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Ld(e,t,n){return e.i18n?.[n]?.[t]}function JW(){const{t:e,i18n:t}=ft(["store","common"]),n=Uo(),r=t.language,[o,l]=k.useState([]),[c,d]=k.useState({}),[m,p]=k.useState(new Set),[h,g]=k.useState(null),[x,y]=k.useState(!0),[w,C]=k.useState(""),[T,S]=k.useState("all"),[_,j]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[F,V,X,z]=await Promise.all([Me.builder.artifacts.list().catch(()=>({artifacts:[]})),Me.builder.artifacts.installed().catch(()=>({installed:{}})),Me.skills.updates().catch(()=>({updates:[],count:0})),Me.skills.builtin().catch(()=>({skills:[]}))]),G={};for(const q of X.updates)G[q.name]={availableVersion:q.availableVersion,installedVersion:q.installedVersion,displayName:q.displayName,description:q.description};d(G);const ae=F.artifacts.filter(q=>{const te=`${q.type}/${q.name}`;return!!V.installed[te]}),Z=new Set(ae.filter(q=>q.type==="skill").map(q=>q.name));for(const q of z.skills)!q.installed||Z.has(q.name)||!(V.installed[`skill/${q.name}`]||G[q.name])&&!q.updateAvailable||!V.installed[`skill/${q.name}`]&&!G[q.name]||(ae.push({type:"skill",name:q.name,meta:{displayName:q.i18n?.[r]?.displayName||q.name,description:q.i18n?.[r]?.description||q.description||"",version:q.installedVersion||q.version,author:q.author,category:q.category,tags:q.tags,i18n:q.i18n},path:"",updatedAt:""}),Z.add(q.name));for(const[q,te]of Object.entries(G))Z.has(q)||(ae.push({type:"skill",name:q,meta:{displayName:te.displayName||q,description:te.description||"",version:te.installedVersion},path:"",updatedAt:""}),Z.add(q));l(ae)}catch{}y(!1)},[r]);k.useEffect(()=>{O()},[O]),k.useEffect(()=>{const F=()=>{O()};return window.addEventListener("markus:data-changed",F),()=>window.removeEventListener("markus:data-changed",F)},[O]),k.useEffect(()=>{if(!h)return;const F=setTimeout(()=>g(null),3e3);return()=>clearTimeout(F)},[h]);const P=async(F,V)=>{if(!m.has(F)){p(X=>new Set(X).add(F));try{await Me.skills.install({name:F,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:F,version:V}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:F}),type:"error"})}p(X=>{const z=new Set(X);return z.delete(F),z})}},L=o.filter(F=>{if(T!=="all"&&F.type!==T)return!1;if(!w)return!0;const V=w.toLowerCase(),X=(Ld(F.meta,"displayName",r)||F.meta.displayName||F.name).toLowerCase(),z=(Ld(F.meta,"description",r)||F.meta.description||"").toLowerCase();return X.includes(V)||z.includes(V)}).sort((F,V)=>{const X=F.type==="skill"&&c[F.name]?1:0;return(V.type==="skill"&&c[V.name]?1:0)-X});return _?s.jsx(Mi,{type:_.type,name:_.name,onBack:()=>j(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&s.jsxs("span",{className:"px-2 py-0.5 text-[11px] font-medium rounded-md bg-amber-500/15 text-amber-600 border border-amber-500/25",children:[e("installedTab.updateAvailable")," · ",Object.keys(c).length]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[s.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(F=>s.jsx("button",{onClick:()=>S(F),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===F?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${F==="all"?"All":F==="agent"?"Agents":F==="team"?"Teams":"Skills"}`)},F))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:F=>C(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):L.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Ar,{columns:3,children:L.map(F=>{const V=Ld(F.meta,"displayName",r)||F.meta.displayName||F.name,X=Ld(F.meta,"description",r)||F.meta.description||"",z=F.meta.version||"",G=F.meta.author||"",ae=F.meta.tags??[],Z=F.meta.category||"",q=F.meta.icon,te=F.type==="skill"?c[F.name]:void 0;return s.jsx(ia,{type:F.type,name:V,description:X,seed:F.name,icon:q,author:null,authorLabel:G||void 0,version:te?te.installedVersion:z,category:Z,tags:ae,installed:!te,hideStats:!0,cornerLabel:te?e("installedTab.updateAvailable"):void 0,onClick:()=>{F.path&&j({type:F.type,name:F.name})},actions:te?s.jsx("button",{type:"button",disabled:m.has(F.name),onClick:()=>{P(F.name,te.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(F.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:te.availableVersion})}):void 0},`${F.type}/${F.name}`)})})}),h&&s.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-sm shadow-lg ${h.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:h.text})]})}const eY=50,tY=30;function nY(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const p=m.changedTouches[0].clientX-o.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(p),x=Math.abs(h);if(g<eY||Math.atan2(x,g)*(180/Math.PI)>tY)return;if(r?.scrollContainerRef?.current){const C=r.scrollContainerRef.current,T=C.scrollLeft<=1,S=C.scrollLeft+C.clientWidth>=C.scrollWidth-1;if(p>0&&!T||p<0&&!S)return}const w=e.findIndex(C=>C.id===t);p<0&&w<e.length-1?n(e[w+1].id):p>0&&w>0?n(e[w-1].id):p>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():p<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:c,onTouchEnd:d}}const rY=["builder","discover","agents","teams","skills","installed"],aY={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function sg(e){return!!e&&rY.includes(e)}function G4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:sg(t)?t:"builder",installId:e}}function sY({authUser:e}){const{t}=ft(["nav","store","common"]),n=k.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[r]=k.useState(G4),[o,l]=k.useState(r.tab),[c,d]=k.useState(r.installId),m=nY(n,o,l);k.useEffect(()=>{const h=G4();h.installId&&(d(h.installId),sg(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const h=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");sg(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",h),()=>window.removeEventListener("markus:navigate",h)},[]);const p=(h,g)=>{g&&d(g),l(aY[h]??"agents")};return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[s.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[s.jsx(Mw,{className:"ml-2"}),n.map(h=>s.jsx("button",{onClick:()=>l(h.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${o===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(s6,{authUser:e}),o==="discover"&&s.jsx(QW,{onOpenType:p}),o==="agents"&&s.jsx(HW,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(qW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(WW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(JW,{})]})]})}const K4="usageType",uh="profile";function iY({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=ft(["onboarding","common"]),[c,d]=k.useState(0),[m,p]=k.useState(""),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,C]=k.useState(""),[T,S]=k.useState(!1),[_,j]=k.useState(""),[O,P]=k.useState(!1),[L,F]=k.useState(null);k.useEffect(()=>{Me.auth.me().then(({user:$e})=>{$e.name&&p($e.name),$e.email&&g($e.email),$e.avatarUrl&&F($e.avatarUrl);const ut=$e.name||$e.email?.split("@")[0]||"";ut&&G(kt=>kt||l("usageType.defaultOrgName",{name:ut}))}).catch(()=>{}),Me.settings.getOrg().then(({org:$e})=>{$e?.name&&$e.name!=="My Organization"&&G($e.name)}).catch(()=>{}),yn()&&Me.hubOrgs.invitations().then($e=>{$e.invitations?.length>0&&Ce($e.invitations)}).catch(()=>{})},[]);const[V,X]=k.useState(null),[z,G]=k.useState(""),[ae,Z]=k.useState(!1),[q,te]=k.useState(!1),[U,Q]=k.useState(""),[me,Ce]=k.useState([]),[H,W]=k.useState(null),[fe,I]=k.useState(null),Re=async()=>{const $e=z.trim();if($e){Z(!0),Q("");try{if(await Me.settings.updateOrg($e),yn()){const ut=await Me.hubOrgs.mine(),kt=ut.orgs?.find(xt=>xt.role==="owner")??ut.orgs?.[0];kt?.id?await Me.hubOrgs.update(kt.id,{name:$e}):await Me.hubOrgs.create($e)}te(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{Z(!1)}}},[Be,Pe]=k.useState(!0),Fe=async()=>{if(j(""),!m.trim()){j(l("profile.errors.nameRequired"));return}if(!h.trim()){j(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h.trim())){j(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){j(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){j(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:$e}=await Me.auth.updateProfile(m.trim(),h.trim());x&&await Me.auth.changePassword("",x),o?.($e),P(!0)}catch{j(l("profile.errors.saveFailed"))}finally{S(!1)}},dt=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],mt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:s.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:s.jsx(m8,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:K4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>{X("personal"),te(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${V==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"👤"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),s.jsxs("button",{onClick:()=>{X("organization"),te(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${V==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"🏢"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),V==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[me.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),me.map($e=>s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:$e.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:$e.invitedBy})})]}),s.jsx("button",{onClick:async()=>{W($e.orgId);try{await Me.hubOrgs.acceptInvitation($e.orgId),I($e.orgId),te(!0)}catch{}finally{W(null)}},disabled:H===$e.orgId||fe===$e.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:fe===$e.orgId?l("usageType.accepted"):H===$e.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},$e.orgId)),s.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),s.jsx("input",{type:"text",value:z,onChange:$e=>{G($e.target.value),te(!1),Q("")},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"})]}),U&&s.jsx("p",{className:"text-xs text-red-500",children:U}),s.jsx("button",{onClick:()=>{Re()},disabled:ae||!z.trim()||q,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(ae?"common:saving":q?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:uh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:O?s.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[s.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",h]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(jw,{currentUrl:L,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange:$e=>p($e.target.value),placeholder:l("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",value:h,onChange:$e=>g($e.target.value),placeholder:l("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),s.jsx("input",{type:"password",value:x,onChange:$e=>y($e.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),x&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),s.jsx("input",{type:"password",value:w,onChange:$e=>C($e.target.value),placeholder:l("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),_&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:_}),s.jsx("button",{onClick:()=>{Fe()},disabled:T||!m.trim()||!h.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(T?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"grid grid-cols-3 gap-3",children:dt.map($e=>s.jsxs("button",{onClick:()=>n($e.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===$e.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:$e.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:$e.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:$e.desc})]},$e.value))}),s.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[s.jsx("input",{type:"checkbox",checked:Be,onChange:$e=>Pe($e.target.checked),className:"accent-brand-500 shrink-0"}),s.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],Nt=r?mt.filter($e=>$e.id!==uh):mt,Ot=Nt.findIndex($e=>$e.id===K4),At=Nt.findIndex($e=>$e.id===uh),qt=()=>{c===Ot&&Ot>=0&&!V||c===Ot&&V==="organization"&&!q||c===At&&At>=0&&!O||(c<Nt.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Be})}).catch(()=>{}),e()))},jt=Nt[c];return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:s.jsx("div",{className:"w-full max-w-lg",children:s.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[s.jsx("div",{className:"flex gap-1.5 mb-8",children:Nt.map(($e,ut)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ut<=c?"bg-brand-500":"bg-surface-elevated"}`},ut))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:jt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:jt.subtitle}),jt.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?s.jsx("button",{onClick:()=>d(c-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):s.jsx("span",{}),s.jsx("button",{onClick:qt,disabled:At>=0&&c===At&&!O||Ot>=0&&c===Ot&&(!V||V==="organization"&&!q),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${At>=0&&c===At&&!O||Ot>=0&&c===Ot&&(!V||V==="organization"&&!q)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===Nt.length-1?l("getStarted"):l("common:next")})]})]})})})}const V4="markus:legal-consent",oY="https://markus.global";function lY({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=ft("auth"),[o,l]=k.useState(null),[c,d]=k.useState(""),[m,p]=k.useState(!1),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,C]=k.useState(!1),[T,S]=k.useState(!1),_=G=>{const ae=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${oY}${G}${ae}`},j=()=>{try{localStorage.setItem(V4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(j(),!0):(C(!1),requestAnimationFrame(()=>C(!0)),!1),P=async()=>{const G=yn(),ae=sa();if(!G||!ae){d(n("login.hubUnavailable"));return}const Z=await Me.auth.hubLogin(G,ae);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),Z.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",Z.cloudAiError?n("login.cloudAiNotReady",{error:Z.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(Z.user,Z.needsOnboarding??!1,{fromHub:!0})},L=async(G,ae=!1)=>{if(!(!ae&&!O())){d(""),l(G??"hub");try{if(ae&&yn()&&sa()){await P();return}await na(G),await P()}catch(Z){const q=Z instanceof Error?Z.message:"";if(!q.includes("cancelled")){if(!ae&&yn())return L(G,!0);d(q||n("login.hubUnavailable"))}}finally{l(null)}}},F=()=>{eD(),l(null),d("")};k.useEffect(()=>{const G=window.markusDesktop;if(!G?.peekPendingDeepLinkAuth&&!G?.consumePendingDeepLinkAuth)return;let ae=!1;return(async()=>{const Z=G.peekPendingDeepLinkAuth?await G.peekPendingDeepLinkAuth():null;if(ae||!Z)return;let q=!1;try{q=!!localStorage.getItem(V4)}catch{}if(!T&&!q){d(n("login.consentRequired"));return}q&&!T&&S(!0),j();const te=G.consumePendingDeepLinkAuth?await G.consumePendingDeepLinkAuth():Z;if(!(ae||!te)){d(""),l("hub");try{if(!await JL(te)||!yn()||!sa()){d(n("login.hubUnavailable"));return}await P()}catch{d(n("login.hubUnavailable"))}finally{ae||l(null)}}})().catch(()=>{}),()=>{ae=!0}},[T]);const V=async G=>{if(G.preventDefault(),!(!h.trim()||!x)&&O()){d(""),l("local");try{const{user:ae,needsOnboarding:Z}=await Me.auth.login(h.trim(),x);e(ae,Z??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},X=n(t?"login.welcomeBack":"login.getStarted"),z="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[s.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute -top-48 left-1/2 -translate-x-1/2 h-[42rem] w-[42rem] rounded-full bg-brand-500/20 blur-[120px]"}),s.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),s.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),s.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-16 h-16 mx-auto mb-4 rounded-2xl shadow-xl shadow-brand-900/20 ring-1 ring-border-default/40"}),s.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:X})]}),s.jsx("div",{className:"bg-surface-secondary/70 backdrop-blur-xl border border-border-default/80 rounded-3xl p-7 sm:p-8 shadow-2xl shadow-black/10",children:m?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),s.jsxs("form",{onSubmit:V,className:"space-y-3",children:[s.jsx("input",{type:"email",value:h,onChange:G=>g(G.target.value),autoComplete:"email",autoFocus:!0,placeholder:n("login.email"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),s.jsx("input",{type:"password",value:x,onChange:G=>y(G.target.value),autoComplete:"current-password",placeholder:n("login.password"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),c&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:c}),!t&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!h||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(o==="local"?"login.signingIn":"login.signIn")})]}),s.jsx("div",{className:"text-center",children:s.jsx("button",{onClick:()=>{p(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("button",{onClick:()=>L("google"),disabled:!!o,className:z,children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),s.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),s.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),s.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),n(o==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>L("github"),disabled:!!o,className:z,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),n(o==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>L("email"),disabled:!!o,className:z,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(o==="email"?"login.connectingHub":"login.withEmail")]}),o&&(o==="google"||o==="github"||o==="email"||o==="hub")&&s.jsxs("div",{className:"px-3 py-2.5 bg-brand-500/10 border border-brand-500/30 rounded-lg text-xs text-fg-secondary space-y-2",children:[s.jsx("p",{children:n("login.browserOpened")}),s.jsx("button",{type:"button",onClick:F,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:c}),s.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[s.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),s.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),s.jsx("button",{onClick:()=>{p(!0),d("")},disabled:!!o,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),s.jsxs("label",{onAnimationEnd:()=>C(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[s.jsx("input",{type:"checkbox",checked:T,onChange:G=>{S(G.target.checked),G.target.checked&&C(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),s.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",s.jsx("a",{href:_("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",s.jsx("a",{href:_("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),s.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[s.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),s.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function cY({token:e,onComplete:t}){const{t:n}=ft("auth"),[r,o]=k.useState(null),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[C,T]=k.useState(!1);k.useEffect(()=>{Me.auth.inviteInfo(e).then(_=>o(_)).catch(()=>T(!0))},[e]);const S=async _=>{if(_.preventDefault(),h(""),l.length<6){h(n("invite.passwordMinLength"));return}if(l!==d){h(n("invite.passwordsDoNotMatch"));return}x(!0);try{await Me.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),s.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:C?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),s.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):r?s.jsxs("form",{onSubmit:S,className:"space-y-5",children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:r.name})}),s.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:r.email}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),s.jsx("input",{type:"password",value:l,onChange:_=>c(_.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),s.jsx("input",{type:"password",value:d,onChange:_=>m(_.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&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(g?"invite.settingUp":"invite.setupAccount")})]}):s.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function uY({onComplete:e,isFirstTime:t}){const{t:n}=ft("auth"),[r,o]=k.useState(""),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==d){h(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Me.auth.changePassword(r,l),e()}catch{h(n("changePassword.failedToChange"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),s.jsxs("form",{onSubmit: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:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&s.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:r,onChange:w=>o(w.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),s.jsx("input",{type:"password",value:l,onChange:w=>c(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),s.jsx("input",{type:"password",value:d,onChange:w=>m(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),p&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:n(g?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}function dY({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const C=localStorage.getItem(`${l}_w`);if(C)return Math.max(n,Math.min(r,parseInt(C,10)))}catch{}return t}),[m,p]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=k.useRef(!1),g=k.useRef(n),x=k.useRef(r);g.current=n,x.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(C=>Math.max(n,Math.min(r,C)))},[n,r]);const y=k.useCallback(C=>{C.preventDefault(),h.current=!0;const T=C.clientX,S=c,_=O=>{if(!h.current)return;const P=O.clientX-T;d(Math.max(g.current,Math.min(x.current,S+P)))},j=()=>{h.current=!1,document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",_),document.addEventListener("mouseup",j),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>p(C=>!C),[]);return{width:m?o:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:p,setWidth:d,onResizeStart:y}}const dX=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],ig="markus-theme";function W4(e){const t=document.documentElement;t.classList.remove("light","dark","cyberpunk","mono"),e==="light"?t.classList.add("light"):e==="dark"?t.classList.add("dark"):e==="cyberpunk"?t.classList.add("cyberpunk"):e==="mono"&&t.classList.add("mono")}function mY(){try{const e=localStorage.getItem(ig);if(e==="midnight")return localStorage.setItem(ig,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function fY(){const[e,t]=k.useState(mY),n=k.useCallback(r=>{t(r);try{localStorage.setItem(ig,r)}catch{}W4(r)},[]);return k.useEffect(()=>{W4(e)},[e]),{mode:e,setMode:n}}const Wd={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},pY={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},hY=["agents","tasks","requirements","projects","deliverables","workflows"];let Y4="",X4="all",Q4=Wd,Z4=!1;function gY({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);Ho(!0);const[r,o]=k.useState(Y4),[l,c]=k.useState(X4),[d,m]=k.useState(Q4),[p,h]=k.useState(!1),[g,x]=k.useState(Z4),[y,w]=k.useState(-1);k.useEffect(()=>{Y4=r},[r]),k.useEffect(()=>{X4=l},[l]),k.useEffect(()=>{Q4=d},[d]),k.useEffect(()=>{Z4=g},[g]);const C=k.useRef(null),T=k.useRef(void 0),S=k.useRef(null),_=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{C.current?.focus(),C.current?.select()},100)},[]);const j=k.useCallback(async Z=>{if(!Z.trim()){m(Wd),x(!1),w(-1);return}h(!0),x(!0),w(-1);const q=Z.toLowerCase();try{const[te,U,Q,me,Ce,H]=await Promise.allSettled([Me.agents.list(),Me.tasks.list({search:Z,pageSize:20}),Me.requirements.list(),Me.projects.list(),Me.deliverables.search({q:Z,limit:20}),Me.teams.list()]),W=te.status==="fulfilled"?te.value.agents.filter(Fe=>Fe.name?.toLowerCase().includes(q)||Fe.role?.toLowerCase().includes(q)):[],fe=U.status==="fulfilled"?U.value.tasks:[],I=Q.status==="fulfilled"?Q.value.requirements.filter(Fe=>Fe.title?.toLowerCase().includes(q)||Fe.description?.toLowerCase().includes(q)):[],Re=me.status==="fulfilled"?me.value.projects.filter(Fe=>Fe.name?.toLowerCase().includes(q)||Fe.description?.toLowerCase().includes(q)):[],Be=Ce.status==="fulfilled"?Ce.value.results:[],Pe=[];if(H.status==="fulfilled"){const Fe=await Promise.allSettled(H.value.teams.map(dt=>Me.workflows.list(dt.id)));for(const dt of Fe)if(dt.status==="fulfilled")for(const mt of dt.value.workflows)(mt.name.toLowerCase().includes(q)||(mt.displayName||"").toLowerCase().includes(q)||mt.description?.toLowerCase().includes(q))&&Pe.push(mt)}m({agents:W,tasks:fe,requirements:I,projects:Re,deliverables:Be,workflows:Pe})}catch{m(Wd)}finally{h(!1)}},[]),O=Z=>{o(Z),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>j(Z),400)},P=k.useCallback((Z,q)=>{e(),it.navigate(Z,q)},[e]),L=[{id:"all",label:n("common:all",{defaultValue:"全部"})},{id:"agents",label:n("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:n("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:n("common:requirements",{defaultValue:"需求"})},{id:"projects",label:n("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:n("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:n("common:workflows",{defaultValue:"工作流"})}],F=k.useMemo(()=>pY[t||""]||hY,[t]),V=k.useMemo(()=>{const Z=[],q=l==="all"?8:void 0,te=U=>{if(l!=="all"&&l!==U)return;const Q=d[U].length;if(U==="workflows"){const me=q?d.workflows.slice(0,q):d.workflows;for(const Ce of me)Z.push({id:Ce.name,type:"workflow",page:ue.WORK,params:{boardType:"workflows"}})}else{const me=d[U],Ce=q?me.slice(0,q):me;for(const H of Ce)switch(U){case"agents":Z.push({id:H.id,type:"agent",page:ue.TEAM,params:{agentId:H.id}});break;case"tasks":Z.push({id:H.id,type:"task",page:ue.WORK,params:{openTask:H.id}});break;case"requirements":Z.push({id:H.id,type:"requirement",page:ue.WORK,params:{openRequirement:H.id}});break;case"projects":Z.push({id:H.id,type:"project",page:ue.WORK,params:{projectId:H.id}});break;case"deliverables":Z.push({id:H.id,type:"deliverable",page:ue.DELIVERABLES,params:{openDeliverable:H.id}});break}}q&&Q>q&&Z.push({id:`more_${U}`,type:"showMore",page:"",expandCategory:U,totalCount:Q})};for(const U of F)te(U);return Z},[d,l,F]),X=k.useCallback(Z=>{if(Z.type==="showMore"&&Z.expandCategory){c(Z.expandCategory),w(-1);return}P(Z.page,Z.params)},[P]);k.useEffect(()=>{const Z=_.current;if(!Z||y<0)return;const q=Z.querySelector(`[data-idx="${y}"]`);q&&q.scrollIntoView({block:"nearest"})},[y]);const z=k.useCallback(Z=>{if(Z.key==="Escape"){e();return}if(Z.key==="Tab"){Z.preventDefault();const U=L.map(Ce=>Ce.id),Q=U.indexOf(l),me=Z.shiftKey?Q<=0?U.length-1:Q-1:Q>=U.length-1?0:Q+1;c(U[me]),w(-1);return}const q=Z.ctrlKey&&Z.key==="n"||Z.key==="ArrowDown",te=Z.ctrlKey&&Z.key==="p"||Z.key==="ArrowUp";if(q||te){Z.preventDefault(),w(U=>{const Q=V.length-1;return Q<0?-1:q?U>=Q?0:U+1:U<=0?Q:U-1});return}Z.key==="Enter"&&(Z.preventDefault(),y>=0&&y<V.length&&X(V[y]))},[e,V,y,X,L,l]);k.useEffect(()=>(document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)),[z]);const G=V.length>0;let ae=0;return s.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:Z=>{Z.target===S.current&&e()},children:s.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[s.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("input",{ref:C,value:r,onChange:Z=>O(Z.target.value),placeholder:n("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),r&&s.jsx("button",{onClick:()=>{o(""),m(Wd),x(!1),w(-1),C.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:L.map(Z=>s.jsx("button",{onClick:()=>{c(Z.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===Z.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:Z.label},Z.id))})]}),s.jsxs("div",{ref:_,className:"flex-1 overflow-y-auto px-5 py-3",children:[p&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!p&&g&&!G&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!p&&G&&s.jsx("div",{className:"space-y-4",children:F.map(Z=>{if(l!=="all"&&l!==Z)return null;const q=l==="all"?8:void 0,te=U=>{const Q=ae++,me=U==="agents"?d.agents.length:U==="tasks"?d.tasks.length:U==="requirements"?d.requirements.length:U==="projects"?d.projects.length:U==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{c(U),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",me,")"]})};return Z==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.agents.slice(0,q):d.agents).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.TEAM,{agentId:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Hs,{name:U.name||"Agent",avatarUrl:U.avatarUrl,size:28}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:U.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:U.role||U.status})]}),s.jsx(bY,{status:U.status})]},U.id)})}),q&&d.agents.length>q&&te("agents")]},"agents"):Z==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.tasks.slice(0,q):d.tasks).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.WORK,{openTask:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(xY,{status:U.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.status," · ",U.priority||""]})]})]},U.id)})}),q&&d.tasks.length>q&&te("tasks")]},"tasks"):Z==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.requirements.slice(0,q):d.requirements).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.WORK,{openRequirement:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${U.status==="approved"?"text-green-500 bg-green-500/15":U.status==="pending"?"text-amber-500 bg-amber-500/15":U.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),s.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.status," · ",U.priority||""]})]})]},U.id)})}),q&&d.requirements.length>q&&te("requirements")]},"requirements"):Z==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.projects.slice(0,q):d.projects).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.WORK,{projectId:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:s.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.name}),U.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:U.description})]})]},U.id)})}),q&&d.projects.length>q&&te("projects")]},"projects"):Z==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.deliverables.slice(0,q):d.deliverables).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.DELIVERABLES,{openDeliverable:U.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.type," · ",U.status]})]})]},U.id)})}),q&&d.deliverables.length>q&&te("deliverables")]},"deliverables"):Z==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(q?d.workflows.slice(0,q):d.workflows).map(U=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>P(ue.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:U.displayName||U.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[U.stepCount," steps · v",U.version]})]})]},U.name)})}),q&&d.workflows.length>q&&te("workflows")]},"workflows"):null})}),!p&&!g&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),s.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",n("common:toggle",{defaultValue:"唤起/关闭"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",n("common:switchTab",{defaultValue:"切换分类"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",n("common:navigate",{defaultValue:"导航"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",n("common:open",{defaultValue:"打开"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",n("common:close",{defaultValue:"关闭"})]})]})]})})}function bY({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function xY({status:e}){const t=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M9 11l3 3L22 4"}),s.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const yY=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar (L0 + page L1)",labelKey:"shortcuts.toggleLeft",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"nav-l0-jk",group:"navigation",keys:["J / K"],label:"L0: switch page up / down",labelKey:"shortcuts.navL0Jk",page:"any",bare:!0},{id:"nav-l0-l",group:"navigation",keys:["L"],label:"L0: enter page L1 (Team / Tasks / Output / Store / Settings)",labelKey:"shortcuts.navL0L",page:"any",bare:!0},{id:"nav-l0-h",group:"navigation",keys:["H"],label:"From page L1: focus app rail (L0)",labelKey:"shortcuts.navL0H",page:"any",bare:!0},{id:"settings-back",group:"navigation",keys:["H"],label:"Settings: go back to previous page",labelKey:"shortcuts.settingsBack",page:"any",bare:!0},{id:"nav-jk-settings",group:"navigation",keys:["J / K"],label:"Settings L1: switch settings tabs",labelKey:"shortcuts.navJkSettings",page:"any",bare:!0},{id:"nav-hl-work",group:"navigation",keys:["H / L"],label:"Tasks: item list ↔ project L1 ↔ app rail",labelKey:"shortcuts.navHlWork",page:"work",bare:!0},{id:"nav-jk-work",group:"navigation",keys:["J / K"],label:"Tasks: move project / item selection",labelKey:"shortcuts.navJkWork",page:"work",bare:!0},{id:"nav-hl-team",group:"navigation",keys:["H / L"],label:"Team: L0 ↔ L1 ↔ L2 (L ignored on deepest pane)",labelKey:"shortcuts.navHlTeam",page:"team",bare:!0},{id:"nav-jk-team",group:"navigation",keys:["J / K"],label:"Team L1: move roster selection",labelKey:"shortcuts.navJkTeam",page:"team",bare:!0},{id:"nav-jk-team-l2",group:"navigation",keys:["J / K"],label:"Team L2: move team member selection",labelKey:"shortcuts.navJkTeamL2",page:"team",bare:!0},{id:"nav-jk-deliverables",group:"navigation",keys:["J / K"],label:"Output L1: move deliverable selection",labelKey:"shortcuts.navJkDeliverables",page:"deliverables",bare:!0},{id:"nav-jk-store",group:"navigation",keys:["J / K"],label:"Store L1: switch store tabs",labelKey:"shortcuts.navJkStore",page:"store",bare:!0},{id:"toggle-project-detail",group:"tasks",keys:["J"],label:"Toggle project detail (Tasks)",labelKey:"shortcuts.toggleProjectDetail",page:"work"},{id:"toggle-item-detail",group:"tasks",keys:["L"],label:"Toggle task / requirement detail (Tasks)",labelKey:"shortcuts.toggleItemDetail",page:"work"},{id:"cycle-board",group:"tasks",keys:["Ctrl","Tab"],label:"Cycle Tasks views",labelKey:"shortcuts.cycleBoard",page:"work",bare:!0},{id:"toggle-browser",group:"team",keys:["L"],label:"Toggle right panel · Browser",labelKey:"shortcuts.toggleBrowser",page:"team"},{id:"toggle-terminal",group:"team",keys:["J"],label:"Toggle right panel · Terminal",labelKey:"shortcuts.toggleTerminal",page:"team"},{id:"next-tab",group:"rightPanel",keys:["Shift","]"],label:"Next right-panel tab",labelKey:"shortcuts.nextTab",page:"team"},{id:"prev-tab",group:"rightPanel",keys:["Shift","["],label:"Previous right-panel tab",labelKey:"shortcuts.prevTab",page:"team"},{id:"tab-n",group:"rightPanel",keys:["1…9"],label:"Jump to Nth right-panel tab",labelKey:"shortcuts.tabN",page:"team"},{id:"close-tab",group:"rightPanel",keys:["W"],label:"Close right-panel tab",labelKey:"shortcuts.closeTab",page:"team"},{id:"new-tab",group:"rightPanel",keys:["T"],label:"New browser tab / shell",labelKey:"shortcuts.newTab",page:"team"},{id:"term-search",group:"terminal",keys:["F"],label:"Search in terminal",labelKey:"shortcuts.termSearch",page:"team"},{id:"term-to-chat",group:"terminal",keys:["Shift","A"],label:"Add terminal selection to chat",labelKey:"shortcuts.termToChat",page:"team"}];function vY(e,t,n){return n||e[0]==="Ctrl"||e[0]==="Tab"||e[0]==="J / K"||e[0]==="H / L"?e.join(e[0]==="Ctrl"?"+":" "):e.length===1&&(e[0]==="H"||e[0]==="L"||e[0]==="J"||e[0]==="K")?e[0]:[t?"⌘":"Ctrl",...e].join(t?"":"+")}function wY(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable?!0:e.closest(".xterm")!==null}function J4(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const kY=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function SY(e){return e===ue.TEAM?"team":e===ue.WORK?"work":e===ue.DELIVERABLES?"deliverables":e===ue.STORE?"store":"any"}function NY({open:e,onClose:t,page:n}){const{t:r}=ft("common"),o=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=SY(n);return k.useEffect(()=>{if(!e)return;const c=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),t())};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,t]),e?s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:c=>{c.target===c.currentTarget&&t()},role:"dialog","aria-modal":"true","aria-label":r("shortcuts.title"),children:s.jsxs("div",{className:"w-full max-w-lg max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[s.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 px-4 py-3 border-b border-border-default bg-surface-primary",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:r("shortcuts.title")}),s.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":r("shortcuts.close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"px-4 py-3 space-y-4",children:kY.map(c=>{const d=yY.filter(m=>{if(m.group!==c)return!1;const p=m.page??"any";return p==="any"?!0:p===l});return d.length===0?null:s.jsxs("section",{children:[s.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:r(`shortcuts.groups.${c}`)}),s.jsx("ul",{className:"space-y-1.5",children:d.map(m=>s.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[s.jsx("span",{className:"text-fg-secondary min-w-0",children:r(m.labelKey??m.label,{defaultValue:m.label})}),s.jsx("kbd",{className:"shrink-0 px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium text-fg-primary font-mono",children:vY(m.keys,o,m.bare)})]},m.id))})]},c)})})]})}):null}function CY({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=ft("common");Ho(!0);const[l,c]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[p,h]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>Ew(e.avatarUrl,sa()?.avatarUrl)),C=async T=>{if(T.preventDefault(),!l.trim()){x(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(o("profile.invalidEmail"));return}h(!0),x("");try{const{user:S}=await Me.auth.updateProfile(l.trim(),d.trim());n({...S,avatarUrl:y??S.avatarUrl})}catch{x(o("profile.failedToSave"))}finally{h(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:s.jsxs("form",{onSubmit:C,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold mb-5",children:o("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(jw,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{w(T),r?.({...e,avatarUrl:T})}})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.name")}),s.jsx("input",{value:l,onChange:T=>c(T.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.email")}),s.jsx("input",{value:d,onChange:T=>m(T.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),g&&s.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:g})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:o("cancel")}),s.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(p?"saving":"save")})]})]})})}const ew=k.lazy(()=>qr(()=>import("./Team-gO8trCNU.js"),__vite__mapDeps([2,3,4,5])).then(e=>({default:e.TeamPage}))),tw=k.lazy(()=>qr(()=>import("./Settings-DPoSSAgs.js"),[]).then(e=>({default:e.Settings}))),TY=k.lazy(()=>qr(()=>import("./Store-CLmn7GZP.js"),[]).then(e=>({default:e.StorePage}))),AY=k.lazy(()=>qr(()=>Promise.resolve().then(()=>zW),void 0).then(e=>({default:e.AgentBuilder}))),nw=k.lazy(()=>qr(()=>import("./Work-DZrsJS4u.js"),__vite__mapDeps([6,4,1,7,3,8])).then(e=>({default:e.WorkPage}))),rw=k.lazy(()=>qr(()=>import("./Deliverables-taaUZEbu.js"),__vite__mapDeps([9,4])).then(e=>({default:e.DeliverablesPage}))),EY=k.lazy(()=>qr(()=>import("./Notifications-C3tsNNUx.js"),[]).then(e=>({default:e.NotificationsPage}))),_Y=k.lazy(()=>qr(()=>import("./Search-Bye2uSm-.js"),[]).then(e=>({default:e.SearchPage}))),jY={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function MY(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Me.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function RY(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const OY=k.memo(function({id:t,activePage:n,children:r}){const o=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:o?void 0:jY,children:s.jsx(k.Suspense,{fallback:s.jsx(RY,{}),children:r})})},(e,t)=>{const n=e.id===e.activePage,r=t.id===t.activePage;return n!==r?!1:r?e.children===t.children:!0}),Dd={};function c6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?yw[e]??e:e}function aw(){return c6(pc())}function LY(){const{t:e}=ft("common"),[t,n]=k.useState(aw),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,c]=k.useState(!0),d=Uo(),m=fY(),p=dY({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([aw()])),[x,y]=k.useState("loading"),[w,C]=k.useState(!1),[T,S]=k.useState(null),[_,j]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[O,P]=k.useState(!1),[L,F]=k.useState(!1),[V,X]=k.useState(null),[z,G]=k.useState(!1),[ae,Z]=k.useState(null),[q,te]=k.useState(()=>{const be=localStorage.getItem("markus_update_dismissed");return be||null}),[U,Q]=k.useState(!1),[me,Ce]=k.useState(!1),H=Oc(),W=H?.leftCollapsed??!1,fe=H?.toggleLeftCollapsed,I=H?.setLeftCollapsed,Re=H?.keyboardPane??"l0",Be=H?.setKeyboardPane,Pe=H?.l0FocusPageId??null,Fe=H?.setL0FocusPageId,dt=k.useRef(t);dt.current=t;const mt=k.useRef(ue.HOME),Nt=H?.toggleRightPanel,Ot=H?.toggleTerminalPanel,At=H?.cycleRightPanelTab,qt=H?.activateRightPanelTabAt,jt=H?.openNewRightPanelTab,$e=H?.rightPanelOpen??!1,ut=H?.activeRightPanelTabId??null,kt=H?.openRightPanel,xt=H?.closeRightPanelTab,Ct=H?.updateRightPanelBrowserTab,ce=H?.updateRightPanelTerminalTab,rt=k.useRef(H?.rightPanelTabs);rt.current=H?.rightPanelTabs,k.useEffect(()=>{const be=window.markusDesktop?.browser?.onPageEvent;if(!(!be||!kt))return be(ge=>{if(ge.type==="closed"){const Se=rt.current?.find(st=>st.payload.kind==="url"&&st.payload.browserId===ge.browserId);Se&&xt&&xt(Se.id);return}if(ge.type==="navigated"){if(ge.url&&gc(ge.url))return;ge.browserId&&Ct&&Ct(ge.browserId,{url:ge.url,title:ge.title||ge.url});return}if(ge.type==="opened"||ge.type==="selected"){if(!ge.url&&!ge.browserId||ge.browserId.startsWith("eb_")||JG(ge.browserId)||ge.url&&gc(ge.url))return;kt({kind:"url",url:ge.url||"about:blank",title:ge.title||ge.url||"Browser",browserId:ge.browserId,pageId:ge.pageId})}})},[kt,xt,Ct]),k.useEffect(()=>{const be=window.markusDesktop?.terminal?.onEvent;if(!(!be||!kt))return be(ge=>{if(ge.type==="closed"){const Se=rt.current?.find(st=>st.payload.kind==="terminal"&&st.payload.terminalId===ge.id);Se&&xt&&xt(Se.id);return}if(ge.type==="cwd"){ge.cwd&&ce?.(ge.id,{cwd:ge.cwd});return}if(ge.type==="selected"){(ge.title||ge.cwd)&&ce?.(ge.id,{title:ge.title,cwd:ge.cwd});return}if(ge.type==="opened"){if(Kg.has(ge.id)){(ge.title||ge.cwd)&&ce?.(ge.id,{title:ge.title,cwd:ge.cwd});return}wi(ge.id),kt({kind:"terminal",terminalId:ge.id,title:ge.title||"Terminal",cwd:ge.cwd})}})},[kt,xt,ce]);const at=H?.handleTerminalExit;k.useEffect(()=>{const be=window.markusDesktop?.terminal?.onExit;if(!(!be||!at))return be(ge=>{at(ge.id)})},[at]),k.useLayoutEffect(()=>{const be=t===ue.TEAM&&$e&&H?.rightPanelMode==="browser";up(be)},[t,$e,H?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const ve=k.useRef(!1);k.useEffect(()=>{if(!ve.current){ve.current=!0;return}p.setCollapsed(W)},[W,p.setCollapsed]),k.useEffect(()=>{if(d)return;const be=navigator.platform.toUpperCase().includes("MAC"),ge=st=>{be&&st.metaKey&&!st.ctrlKey&&st.key==="p"?(st.preventDefault(),Q(Ve=>!Ve)):!be&&st.ctrlKey&&!st.metaKey&&st.key==="p"&&(st.preventDefault(),Q(Ve=>!Ve))},Se=()=>Q(!0);return document.addEventListener("keydown",ge),window.addEventListener("markus:open-search",Se),()=>{document.removeEventListener("keydown",ge),window.removeEventListener("markus:open-search",Se)}},[d]);const _e=k.useCallback(()=>!$e||!ut||!xt?!1:(xt(ut),!0),[$e,ut,xt]);k.useEffect(()=>{const be=window.markusDesktop?.onAppShortcut?.(ge=>{if(ge.type==="close-tab"){_e();return}ge.type==="new-tab"&&jt?.()});return()=>{be?.()}},[_e,jt]),k.useEffect(()=>{if(d||!fe||!Nt)return;const be=navigator.platform.toUpperCase().includes("MAC"),ge=Se=>{if(!(be?Se.metaKey&&!Se.ctrlKey:Se.ctrlKey&&!Se.metaKey)||Se.altKey)return;if(!Se.shiftKey&&(Se.key==="/"||Se.code==="Slash")){Se.preventDefault(),Ce(Je=>!Je);return}if(Se.shiftKey&&(Se.key==="?"||Se.key==="/")){Se.preventDefault(),Ce(Je=>!Je);return}if(Se.shiftKey&&$e&&At){if(Se.key==="]"||Se.code==="BracketRight"){Se.preventDefault(),At(1);return}if(Se.key==="["||Se.code==="BracketLeft"){Se.preventDefault(),At(-1);return}}if(!Se.shiftKey&&$e&&qt){const Je=Se.key>="1"&&Se.key<="9"?Number(Se.key):0;if(Je>=1){Se.preventDefault(),qt(Je-1);return}}if(Se.shiftKey)return;const Ve=Se.key.toLowerCase();if(Ve==="w"){Se.preventDefault(),Se.stopPropagation(),_e();return}if(Ve==="t"){Se.preventDefault(),jt?.();return}if(Ve==="b")Se.preventDefault(),fe();else if(t===ue.TEAM&&Ve==="l"){if(!be&&J4(Se.target)||be&&J4(Se.target)&&Se.ctrlKey)return;Se.preventDefault(),Nt()}else t===ue.TEAM&&Ve==="j"&&Ot&&(Se.preventDefault(),Ot())};return document.addEventListener("keydown",ge,!0),()=>document.removeEventListener("keydown",ge,!0)},[d,t,fe,Nt,Ot,At,qt,$e,_e,jt]);const Ee=k.useCallback((be,ge)=>{let Se=fc(be);d?Se=yw[Se]??Se:Se===ue.NOTIFICATIONS&&(Se=ue.HOME),Se!==ue.TEAM&&up(!1);const st=pc(),Ve=window.location.hash.slice(1);Ve!==hh(st)?Dd[st]=Ve:delete Dd[st];const Je=dt.current;if(Se===ue.SETTINGS&&Je!==ue.SETTINGS&&(mt.current=Je,it.setSettingsReturnPage(Je),Be?.("l1"),Fe?.(ue.SETTINGS)),Je===ue.SETTINGS&&Se!==ue.SETTINGS&&(Be?.("l0"),Fe?.(Se)),Se===ue.SETTINGS&&ge?.tab){const ie=`settings/${ge.tab}`;Dd[Se]=ie,history.pushState(null,"","#"+ie),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Se),g(Le=>Le.has(Se)?Le:new Set([...Le,Se]));return}const R=Se!==ue.WORK?Dd[Se]:void 0;R&&R!==hh(Se)?(history.pushState(null,"",Ti(Se)),history.pushState(null,"","#"+R)):history.pushState(null,"",Ti(Se)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Se),g(ie=>ie.has(Se)?ie:new Set([...ie,Se]))},[d,Be,Fe]);k.useEffect(()=>{it.setHandler((be,ge)=>Ee(be,ge))},[Ee]),k.useEffect(()=>{Re==="l0"&&t!==ue.SETTINGS&&Fe?.(t)},[Re,t,Fe]),k.useEffect(()=>{if(d||!Be||!Fe)return;const be=ge=>{if(ge.metaKey||ge.ctrlKey||ge.altKey||wY(ge.target))return;const Se=ge.key.length===1?ge.key.toLowerCase():ge.key;if(t===ue.SETTINGS&&(Se==="h"||Se==="ArrowLeft")){ge.preventDefault(),ge.stopImmediatePropagation(),it.leaveSettings();return}if(Re!=="l0"||t===ue.SETTINGS)return;const st=Pe&&vo.includes(Pe)?Pe:t,Ve=Math.max(0,vo.indexOf(st));if(Se==="j"||Se==="ArrowDown"){ge.preventDefault(),ge.stopImmediatePropagation();const Je=vo[Math.min(vo.length-1,Ve+1)];Fe(Je),Je!==t&&Ee(Je),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Je}"]`)?.scrollIntoView({block:"nearest"})});return}if(Se==="k"||Se==="ArrowUp"){ge.preventDefault(),ge.stopImmediatePropagation();const Je=vo[Math.max(0,Ve-1)];Fe(Je),Je!==t&&Ee(Je),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Je}"]`)?.scrollIntoView({block:"nearest"})});return}if(Se==="l"||Se==="ArrowRight"||Se==="Enter"){const Je=Pe&&vo.includes(Pe)?Pe:t;if(!qL.has(Je)){ge.preventDefault(),ge.stopImmediatePropagation();return}ge.preventDefault(),ge.stopImmediatePropagation(),Je!==t&&Ee(Je),I?.(!1),Be("l1");return}(Se==="h"||Se==="ArrowLeft")&&(ge.preventDefault(),ge.stopImmediatePropagation())};return document.addEventListener("keydown",be,!0),()=>document.removeEventListener("keydown",be,!0)},[d,Re,Pe,t,Ee,Be,Fe,I]),k.useEffect(()=>{const be=()=>C(!0);return window.addEventListener("markus:open-edit-profile",be),()=>window.removeEventListener("markus:open-edit-profile",be)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==ue.SETTINGS&&!p.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[p.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(be=>{if(be.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),be.page){const ge=fc(be.page);be.params&&Object.entries(be.params).forEach(([Se,st])=>localStorage.setItem(`markus_nav_${Se}`,st)),Ee(ge),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:ge,params:be.params}}))}})},[Ee]);const oe=k.useCallback(()=>{fetch("/api/settings/llm").then(be=>be.ok?be.json():null).then(be=>{if(be?.providers){const ge=Object.values(be.providers).some(Se=>Se.configured);X(ge)}}).catch(()=>{})},[]),$=k.useCallback((be,ge)=>{if(!be)return;const st=ge&&{agent:"agents",team:"teams",skill:"skills"}[ge]||"agents";localStorage.setItem("markus_nav_installItem",be),localStorage.setItem("markus_nav_storeTab",st);const Ve=new URLSearchParams(window.location.search);Ve.get("install")||(Ve.set("install",be),ge&&Ve.set("type",ge));const Je=Ve.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Je}${Ti(ue.STORE)}`);const R=()=>it.navigate(ue.STORE,{storeTab:st,installItem:be});R(),setTimeout(R,500),setTimeout(R,1500)},[]);k.useEffect(()=>{const be=new URLSearchParams(window.location.search),ge=be.get("install");ge&&$(ge,be.get("type"));const Se=window.markusDesktop;Se?.onDeepLinkInstall?.(({id:Je,type:R})=>$(Je,R)),Se?.consumePendingDeepLinkInstall?.().then(Je=>{Je?.id&&$(Je.id,Je.type)}),Me.auth.me().then(({user:Je})=>{y(Je),S(!0),MY(Je),va.connect(Je.id),oe(),Me.health().then(ie=>{ie.updateAvailable&&ie.latestVersion&&Z({latestVersion:ie.latestVersion,currentVersion:ie.version})}).catch(()=>{});const R=()=>{gi(Tr.builderArtifacts,()=>Me.builder.artifacts.list()),gi(Tr.builderAgents,()=>Me.agents.list()),gi(Tr.builderHubMyItems,()=>lt.myItems()),gi(Tr.builderInstalled,()=>Me.builder.artifacts.installed()),gi(Tr.hubAgents,()=>lt.search({type:"agent",limit:50})),gi(Tr.hubTeams,()=>lt.search({type:"team",limit:50})),gi(Tr.hubSkills,()=>lt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(R,{timeout:5e3}):setTimeout(R,3e3)}).catch(()=>{y(null),Me.auth.status().then(({initialized:Je,hasOwner:R,hasMultipleUsers:ie})=>{S(Je),j({hasOwner:R,hasMultipleUsers:ie})}).catch(()=>S(!0))}),va.connect();const st=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),Ve=()=>{const Je=c6(pc());Je!==ue.TEAM&&up(!1),n(Je),g(R=>R.has(Je)?R:new Set([...R,Je]))};return window.addEventListener("hashchange",Ve),window.addEventListener("popstate",Ve),()=>{st(),va.disconnect(),window.removeEventListener("hashchange",Ve),window.removeEventListener("popstate",Ve)}},[]);const J=x!=="loading"&&x!==null?x:void 0,Te=k.useMemo(()=>d?{[ue.HOME]:s.jsx(dv,{authUser:J}),[ue.TEAM]:s.jsx(ew,{authUser:J}),[ue.BUILDER]:s.jsx(sY,{authUser:J}),[ue.SETTINGS]:s.jsx(tw,{theme:m.mode,onThemeChange:m.setMode,authUser:J,onLogout:()=>{Me.auth.logout().catch(()=>{}),Ro(),y(null)},onUserUpdated:be=>y(be)}),[ue.WORK]:s.jsx(nw,{authUser:J}),[ue.DELIVERABLES]:s.jsx(rw,{authUser:J}),[ue.NOTIFICATIONS]:s.jsx(EY,{authUser:J}),[ue.SEARCH]:s.jsx(_Y,{})}:{[ue.HOME]:s.jsx(dv,{authUser:J}),[ue.TEAM]:s.jsx(ew,{authUser:J}),[ue.SETTINGS]:s.jsx(tw,{theme:m.mode,onThemeChange:m.setMode,authUser:J,onLogout:()=>{Me.auth.logout().catch(()=>{}),Ro(),y(null)},onUserUpdated:be=>y(be)}),[ue.STORE]:s.jsx(TY,{authUser:J}),[ue.BUILDER]:s.jsx(AY,{authUser:J}),[ue.WORK]:s.jsx(nw,{authUser:J}),[ue.DELIVERABLES]:s.jsx(rw,{authUser:J})},[J?.id,J?.role,m.mode,d]);if(x==="loading"||x===null&&T===null)return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const he=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return he?s.jsx(cY,{token:he[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),P(!0),y("loading"),Me.auth.me().then(be=>y(be.user)).catch(()=>y(null))}}):x===null?s.jsx(lY,{hasOwner:_.hasOwner,hasMultipleUsers:_.hasMultipleUsers,onLogin:(be,ge,Se)=>{y(be),va.connect(be.id),ge?(localStorage.removeItem("markus_onboarded"),o(!0),Se?.fromHub&&P(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):L?s.jsx(uY,{onComplete:()=>F(!1),isFirstTime:!0}):r?s.jsx(iY,{theme:m.mode,onThemeChange:m.setMode,skipProfile:O,onProfileUpdated:be=>{const ge={id:be.id,name:be.name,email:be.email,role:be.role,orgId:be.orgId??"default",avatarUrl:be.avatarUrl};y(ge)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),P(!1),Me.auth.me().then(be=>y(be.user)).catch(()=>{}),oe(),Ee(ue.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==ue.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:p.width},children:s.jsx(dW,{currentPage:t,onNavigate:be=>{Ee(be),c(!1),Be?.("l0"),Fe?.(be)},authUser:x,collapsed:p.collapsed,onToggleCollapse:p.toggle,onLogout:()=>{Me.auth.logout().catch(()=>{}),Ro(),y(null)},keyboardFocusPageId:Pe,keyboardPaneActive:Re==="l0"})}),s.jsx("div",{className:`${p.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:p.collapsed?void 0:p.onResizeStart,children:!p.collapsed&&s.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),s.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==ue.SETTINGS&&t!==ue.SEARCH?"pb-14":""}`,children:[V===!1&&!z&&t!==ue.SETTINGS&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[s.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),s.jsx("button",{onClick:()=>G(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),ae&&q!==ae.latestVersion&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[s.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:ae.latestVersion,current:ae.currentVersion})}),s.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[s.jsx("a",{href:"https://markus.global/#download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),s.jsx("button",{onClick:()=>{te(ae.latestVersion),localStorage.setItem("markus_update_dismissed",ae.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),s.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(Te).map(be=>h.has(be)?s.jsx(OY,{id:be,activePage:t,children:Te[be]},be):null)})]}),d&&t!==ue.SETTINGS&&t!==ue.SEARCH&&s.jsx(gW,{currentPage:t,onNavigate:Ee,userId:J?.id}),d&&s.jsx(iD,{authUser:J,onNavigate:Ee}),!d&&U&&s.jsx(gY,{onClose:()=>Q(!1),currentPage:t}),!d&&s.jsx(NY,{open:me,onClose:()=>Ce(!1),page:t}),w&&J&&s.jsx(CY,{authUser:J,onClose:()=>C(!1),onUserUpdated:be=>y(be),onSaved:be=>{C(!1),y(be)}})]})}v7.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(sK,{children:s.jsx(LY,{})})}));export{b4 as $,Hs as A,YY as B,KY as C,VY as D,dY as E,fc as F,Vg as G,Tc as H,JW as I,A0 as J,p8 as K,DY as L,Mw as M,lW as N,Ho as O,ue as P,Ya as Q,lX as R,QW as S,HW as T,Ti as U,dr as V,VL as W,BY as X,F3 as Y,qY as Z,qr as _,Uo as a,A4 as a0,$V as a1,BV as a2,$Y as a3,XV as a4,GY as a5,yc as a6,dX as a7,IY as a8,sa as a9,$3 as aA,rW as aB,sX as aC,UY as aD,H3 as aE,yn as aa,na as ab,m8 as ac,PY as ad,zY as ae,wi as af,Nd as ag,_i as ah,r0 as ai,WV as aj,tV as ak,l4 as al,nV as am,Ai as an,Yo as ao,QY as ap,hW as aq,uX as ar,tX as as,FY as at,XY as au,rX as av,lV as aw,nX as ax,aX as ay,iW as az,sD as b,Oc as c,nY as d,qW as e,WW as f,Ni as g,lt as h,wY as i,s as j,Sa as k,Me as l,WY as m,it as n,nW as o,iX as p,JY as q,k as r,Yg as s,eX as t,ft as u,ZY as v,va as w,cX as x,Er as y,oX as z};
|