@markus-global/cli 0.12.3-rc.3 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web-ui/assets/{AsyncState-D2omBzdj.js → AsyncState-_UC7xcxJ.js} +1 -1
- package/dist/web-ui/assets/{ChatComponents-lSVBiM5B.js → ChatComponents-Ca9tWI9W.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-DxgRNOd1.js → ContentRenderer-C-V5k_3K.js} +2 -2
- package/dist/web-ui/assets/{DeliverableShareModal-DU0PupsS.js → DeliverableShareModal-BvpyowYJ.js} +1 -1
- package/dist/web-ui/assets/{Deliverables-BYacAH8w.js → Deliverables-CQnWqbTb.js} +1 -1
- package/dist/web-ui/assets/{MarkdownMessage-DwxvYN4X.js → MarkdownMessage-DedA8Zob.js} +1 -1
- package/dist/web-ui/assets/{Search-jBc36ZOH.js → Search-CVYQIy_D.js} +1 -1
- package/dist/web-ui/assets/{SendToChat-13m2h7gu.js → SendToChat-IOAvuta-.js} +1 -1
- package/dist/web-ui/assets/{Settings-BkKMrBt2.js → Settings-BQDqf4q5.js} +1 -1
- package/dist/web-ui/assets/{Store-dLubNc0P.js → Store-BEsLd_RN.js} +1 -1
- package/dist/web-ui/assets/{Switch-CXRQn2gn.js → Switch-C6InTNUi.js} +1 -1
- package/dist/web-ui/assets/{Team-zVv87kaX.js → Team-nfNyWj-s.js} +4 -4
- package/dist/web-ui/assets/{Work-DbPgRas-.js → Work-BQvgkynj.js} +1 -1
- package/dist/web-ui/assets/{arc-C6rhmRdi.js → arc-DP1Vf7Sx.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-BvaRSMDl.js → architectureDiagram-3BPJPVTR-Buq8JYN8.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-DP7IwNLE.js → blockDiagram-GPEHLZMM-BCa2p2_X.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-CEQJBqku.js → c4Diagram-AAUBKEIU-BxsgggQY.js} +1 -1
- package/dist/web-ui/assets/channel-BTSrOo6c.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-BtGwhrHv.js → chunk-2J33WTMH-BJZZ60c9.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-DNKfs4jy.js → chunk-4BX2VUAB-C5hc4E6J.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-Bd4eMlUg.js → chunk-55IACEB6-CbyvZ6Mk.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-CHmRT5rY.js → chunk-727SXJPM-JmNt9TVA.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-CmoWgw5d.js → chunk-AQP2D5EJ-BTk0v5ba.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-Csafnaj6.js → chunk-FMBD7UC4-BO-dhB1U.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-Cip_3Llj.js → chunk-ND2GUHAM-BdjCcLdb.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-C0WlO578.js → chunk-QZHKN3VN-BAzRC82n.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BSYlcnF9.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BSYlcnF9.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-ByhHiryW.js → cose-bilkent-S5V4N54A-CVffmErT.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-B5-K3iqP.js → dagre-BM42HDAG-Dd9pB2fX.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-Ci16wMOI.js → diagram-2AECGRRQ-BG_AUqzM.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-Dfnzu_xA.js → diagram-5GNKFQAL-D5qFMRFf.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-K9NvC1S4.js → diagram-KO2AKTUF-B3qTxSWl.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-CaKq8BY-.js → diagram-LMA3HP47-BrxC1636.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-DqY8Y9OR.js → diagram-OG6HWLK6-BvXyEQ9-.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-DS9aOywt.js → docx-preview-DBAZFeEb.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-iW17lrM1.js → erDiagram-TEJ5UH35-CMap9oy_.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BBkXZBPV.js → flowDiagram-I6XJVG4X-BZerJtvk.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-J2QuVqg4.js → ganttDiagram-6RSMTGT7-CagPMHMO.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-EhZa3sGY.js → gitGraphDiagram-PVQCEYII-DZ5dDKRu.js} +1 -1
- package/dist/web-ui/assets/{index-BHu6brRf.js → index-CKPQYzzR.js} +6 -6
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-BaiNGDG7.js → infoDiagram-5YYISTIA-CHLdsDUZ.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-BYN0gLmP.js → ishikawaDiagram-YF4QCWOH-SdeinQaS.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-CKUGXjL8.js → journeyDiagram-JHISSGLW-BtlL2fi0.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-iKb5H8rf.js → kanban-definition-UN3LZRKU-BKPQYXkB.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-BSghRCEC.js → mermaid.core-MkJR6w4B.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-JjtDu_0Z.js → mindmap-definition-RKZ34NQL-CbOmHX_u.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-BDXCI_g9.js → pieDiagram-4H26LBE5-CypGjJP1.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-bATU3F6v.js → quadrantDiagram-W4KKPZXB-CGtemfUz.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-BNJWpDxg.js → requirementDiagram-4Y6WPE33-N7YfpCvE.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-C3B8NPUe.js → sankeyDiagram-5OEKKPKP-CYnSrei-.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-DhGwy4UV.js → sequenceDiagram-3UESZ5HK-CsB7dCPF.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-BtfcmNhI.js → stateDiagram-AJRCARHV-DTDFUXFP.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-AVnDjlzF.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-BpY3qMyG.js → timeline-definition-PNZ67QCA-C_bWAN9B.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-S0f15t2D.js → vennDiagram-CIIHVFJN-CX_qAuUT.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-BdcJNPNt.js → wardley-L42UT6IY-q53jQ293.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-mR-gwtcd.js → wardleyDiagram-YWT4CUSO-D34dKCJU.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-Dq0PtvdL.js → xychartDiagram-2RQKCTM6-BFAngp66.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-pUJ_pqAp.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-Cs9dF-hf.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-Cs9dF-hf.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BOaSwLIS.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-MkJR6w4B.js","assets/transform-BqqRT-Iy.js","assets/Team-nfNyWj-s.js","assets/MarkdownMessage-DedA8Zob.js","assets/ChatComponents-Ca9tWI9W.js","assets/chatChips-DVIRVTpT.js","assets/AsyncState-_UC7xcxJ.js","assets/ContentRenderer-C-V5k_3K.js","assets/DeliverableShareModal-BvpyowYJ.js","assets/Switch-C6InTNUi.js","assets/Team-DFuMZ0ql.css","assets/Settings-BQDqf4q5.js","assets/Work-BQvgkynj.js","assets/SendToChat-IOAvuta-.js","assets/value-wA6veExk.js","assets/Work-BZV40eAE.css","assets/Deliverables-CQnWqbTb.js","assets/Search-CVYQIy_D.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();var mle=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ic(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var gf={exports:{}},Vl={};var gx;function $A(){if(gx)return Vl;gx=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,i,l){var c=null;if(l!==void 0&&(c=""+l),i.key!==void 0&&(c=""+i.key),"key"in i){l={};for(var u in i)u!=="key"&&(l[u]=i[u])}else l=i;return i=l.ref,{$$typeof:e,type:a,key:c,ref:i!==void 0?i:null,props:l}}return Vl.Fragment=t,Vl.jsx=n,Vl.jsxs=n,Vl}var bx;function qA(){return bx||(bx=1,gf.exports=$A()),gf.exports}var o=qA(),bf={exports:{}},It={};var yx;function FA(){if(yx)return It;yx=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),v=Symbol.iterator;function y(V){return V===null||typeof V!="object"?null:(V=v&&V[v]||V["@@iterator"],typeof V=="function"?V:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,C={};function A(V,ce,P){this.props=V,this.context=ce,this.refs=C,this.updater=P||w}A.prototype.isReactComponent={},A.prototype.setState=function(V,ce){if(typeof V!="object"&&typeof V!="function"&&V!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,V,ce,"setState")},A.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function M(){}M.prototype=A.prototype;function I(V,ce,P){this.props=V,this.context=ce,this.refs=C,this.updater=P||w}var B=I.prototype=new M;B.constructor=I,T(B,A.prototype),B.isPureReactComponent=!0;var K=Array.isArray;function j(){}var z={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function Y(V,ce,P){var Ee=P.ref;return{$$typeof:e,type:V,key:ce,ref:Ee!==void 0?Ee:null,props:P}}function $(V,ce){return Y(V.type,ce,V.props)}function D(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function W(V){var ce={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(P){return ce[P]})}var X=/\/+/g;function H(V,ce){return typeof V=="object"&&V!==null&&V.key!=null?W(""+V.key):ce.toString(36)}function se(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(j,j):(V.status="pending",V.then(function(ce){V.status==="pending"&&(V.status="fulfilled",V.value=ce)},function(ce){V.status==="pending"&&(V.status="rejected",V.reason=ce)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function R(V,ce,P,Ee,$e){var qe=typeof V;(qe==="undefined"||qe==="boolean")&&(V=null);var Ze=!1;if(V===null)Ze=!0;else switch(qe){case"bigint":case"string":case"number":Ze=!0;break;case"object":switch(V.$$typeof){case e:case t:Ze=!0;break;case g:return Ze=V._init,R(Ze(V._payload),ce,P,Ee,$e)}}if(Ze)return $e=$e(V),Ze=Ee===""?"."+H(V,0):Ee,K($e)?(P="",Ze!=null&&(P=Ze.replace(X,"$&/")+"/"),R($e,ce,P,"",function(Xe){return Xe})):$e!=null&&(D($e)&&($e=$($e,P+($e.key==null||V&&V.key===$e.key?"":(""+$e.key).replace(X,"$&/")+"/")+Ze)),ce.push($e)),1;Ze=0;var Qe=Ee===""?".":Ee+":";if(K(V))for(var Re=0;Re<V.length;Re++)Ee=V[Re],qe=Qe+H(Ee,Re),Ze+=R(Ee,ce,P,qe,$e);else if(Re=y(V),typeof Re=="function")for(V=Re.call(V),Re=0;!(Ee=V.next()).done;)Ee=Ee.value,qe=Qe+H(Ee,Re++),Ze+=R(Ee,ce,P,qe,$e);else if(qe==="object"){if(typeof V.then=="function")return R(se(V),ce,P,Ee,$e);throw ce=String(V),Error("Objects are not valid as a React child (found: "+(ce==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":ce)+"). If you meant to render a collection of children, use an array instead.")}return Ze}function re(V,ce,P){if(V==null)return V;var Ee=[],$e=0;return R(V,Ee,"","",function(qe){return ce.call(P,qe,$e++)}),Ee}function ue(V){if(V._status===-1){var ce=V._result;ce=ce(),ce.then(function(P){(V._status===0||V._status===-1)&&(V._status=1,V._result=P)},function(P){(V._status===0||V._status===-1)&&(V._status=2,V._result=P)}),V._status===-1&&(V._status=0,V._result=ce)}if(V._status===1)return V._result.default;throw V._result}var Ce=typeof reportError=="function"?reportError:function(V){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var ce=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof V=="object"&&V!==null&&typeof V.message=="string"?String(V.message):String(V),error:V});if(!window.dispatchEvent(ce))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",V);return}console.error(V)},q={map:re,forEach:function(V,ce,P){re(V,function(){ce.apply(this,arguments)},P)},count:function(V){var ce=0;return re(V,function(){ce++}),ce},toArray:function(V){return re(V,function(ce){return ce})||[]},only:function(V){if(!D(V))throw Error("React.Children.only expected to receive a single React element child.");return V}};return It.Activity=h,It.Children=q,It.Component=A,It.Fragment=n,It.Profiler=i,It.PureComponent=I,It.StrictMode=a,It.Suspense=m,It.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=z,It.__COMPILER_RUNTIME={__proto__:null,c:function(V){return z.H.useMemoCache(V)}},It.cache=function(V){return function(){return V.apply(null,arguments)}},It.cacheSignal=function(){return null},It.cloneElement=function(V,ce,P){if(V==null)throw Error("The argument must be a React element, but you passed "+V+".");var Ee=T({},V.props),$e=V.key;if(ce!=null)for(qe in ce.key!==void 0&&($e=""+ce.key),ce)!U.call(ce,qe)||qe==="key"||qe==="__self"||qe==="__source"||qe==="ref"&&ce.ref===void 0||(Ee[qe]=ce[qe]);var qe=arguments.length-2;if(qe===1)Ee.children=P;else if(1<qe){for(var Ze=Array(qe),Qe=0;Qe<qe;Qe++)Ze[Qe]=arguments[Qe+2];Ee.children=Ze}return Y(V.type,$e,Ee)},It.createContext=function(V){return V={$$typeof:c,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null},V.Provider=V,V.Consumer={$$typeof:l,_context:V},V},It.createElement=function(V,ce,P){var Ee,$e={},qe=null;if(ce!=null)for(Ee in ce.key!==void 0&&(qe=""+ce.key),ce)U.call(ce,Ee)&&Ee!=="key"&&Ee!=="__self"&&Ee!=="__source"&&($e[Ee]=ce[Ee]);var Ze=arguments.length-2;if(Ze===1)$e.children=P;else if(1<Ze){for(var Qe=Array(Ze),Re=0;Re<Ze;Re++)Qe[Re]=arguments[Re+2];$e.children=Qe}if(V&&V.defaultProps)for(Ee in Ze=V.defaultProps,Ze)$e[Ee]===void 0&&($e[Ee]=Ze[Ee]);return Y(V,qe,$e)},It.createRef=function(){return{current:null}},It.forwardRef=function(V){return{$$typeof:u,render:V}},It.isValidElement=D,It.lazy=function(V){return{$$typeof:g,_payload:{_status:-1,_result:V},_init:ue}},It.memo=function(V,ce){return{$$typeof:f,type:V,compare:ce===void 0?null:ce}},It.startTransition=function(V){var ce=z.T,P={};z.T=P;try{var Ee=V(),$e=z.S;$e!==null&&$e(P,Ee),typeof Ee=="object"&&Ee!==null&&typeof Ee.then=="function"&&Ee.then(j,Ce)}catch(qe){Ce(qe)}finally{ce!==null&&P.types!==null&&(ce.types=P.types),z.T=ce}},It.unstable_useCacheRefresh=function(){return z.H.useCacheRefresh()},It.use=function(V){return z.H.use(V)},It.useActionState=function(V,ce,P){return z.H.useActionState(V,ce,P)},It.useCallback=function(V,ce){return z.H.useCallback(V,ce)},It.useContext=function(V){return z.H.useContext(V)},It.useDebugValue=function(){},It.useDeferredValue=function(V,ce){return z.H.useDeferredValue(V,ce)},It.useEffect=function(V,ce){return z.H.useEffect(V,ce)},It.useEffectEvent=function(V){return z.H.useEffectEvent(V)},It.useId=function(){return z.H.useId()},It.useImperativeHandle=function(V,ce,P){return z.H.useImperativeHandle(V,ce,P)},It.useInsertionEffect=function(V,ce){return z.H.useInsertionEffect(V,ce)},It.useLayoutEffect=function(V,ce){return z.H.useLayoutEffect(V,ce)},It.useMemo=function(V,ce){return z.H.useMemo(V,ce)},It.useOptimistic=function(V,ce){return z.H.useOptimistic(V,ce)},It.useReducer=function(V,ce,P){return z.H.useReducer(V,ce,P)},It.useRef=function(V){return z.H.useRef(V)},It.useState=function(V){return z.H.useState(V)},It.useSyncExternalStore=function(V,ce,P){return z.H.useSyncExternalStore(V,ce,P)},It.useTransition=function(){return z.H.useTransition()},It.version="19.2.4",It}var vx;function $m(){return vx||(vx=1,bf.exports=FA()),bf.exports}var k=$m();const ple=Ic(k);var yf={exports:{}},Wl={},vf={exports:{}},xf={};var xx;function UA(){return xx||(xx=1,(function(e){function t(R,re){var ue=R.length;R.push(re);e:for(;0<ue;){var Ce=ue-1>>>1,q=R[Ce];if(0<i(q,re))R[Ce]=re,R[ue]=q,ue=Ce;else break e}}function n(R){return R.length===0?null:R[0]}function a(R){if(R.length===0)return null;var re=R[0],ue=R.pop();if(ue!==re){R[0]=ue;e:for(var Ce=0,q=R.length,V=q>>>1;Ce<V;){var ce=2*(Ce+1)-1,P=R[ce],Ee=ce+1,$e=R[Ee];if(0>i(P,ue))Ee<q&&0>i($e,P)?(R[Ce]=$e,R[Ee]=ue,Ce=Ee):(R[Ce]=P,R[ce]=ue,Ce=ce);else if(Ee<q&&0>i($e,ue))R[Ce]=$e,R[Ee]=ue,Ce=Ee;else break e}}return re}function i(R,re){var ue=R.sortIndex-re.sortIndex;return ue!==0?ue:R.id-re.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var m=[],f=[],g=1,h=null,v=3,y=!1,w=!1,T=!1,C=!1,A=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function B(R){for(var re=n(f);re!==null;){if(re.callback===null)a(f);else if(re.startTime<=R)a(f),re.sortIndex=re.expirationTime,t(m,re);else break;re=n(f)}}function K(R){if(T=!1,B(R),!w)if(n(m)!==null)w=!0,j||(j=!0,W());else{var re=n(f);re!==null&&se(K,re.startTime-R)}}var j=!1,z=-1,U=5,Y=-1;function $(){return C?!0:!(e.unstable_now()-Y<U)}function D(){if(C=!1,j){var R=e.unstable_now();Y=R;var re=!0;try{e:{w=!1,T&&(T=!1,M(z),z=-1),y=!0;var ue=v;try{t:{for(B(R),h=n(m);h!==null&&!(h.expirationTime>R&&$());){var Ce=h.callback;if(typeof Ce=="function"){h.callback=null,v=h.priorityLevel;var q=Ce(h.expirationTime<=R);if(R=e.unstable_now(),typeof q=="function"){h.callback=q,B(R),re=!0;break t}h===n(m)&&a(m),B(R)}else a(m);h=n(m)}if(h!==null)re=!0;else{var V=n(f);V!==null&&se(K,V.startTime-R),re=!1}}break e}finally{h=null,v=ue,y=!1}re=void 0}}finally{re?W():j=!1}}}var W;if(typeof I=="function")W=function(){I(D)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,H=X.port2;X.port1.onmessage=D,W=function(){H.postMessage(null)}}else W=function(){A(D,0)};function se(R,re){z=A(function(){R(e.unstable_now())},re)}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(R){R.callback=null},e.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<R?Math.floor(1e3/R):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function(R){switch(v){case 1:case 2:case 3:var re=3;break;default:re=v}var ue=v;v=re;try{return R()}finally{v=ue}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(R,re){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var ue=v;v=R;try{return re()}finally{v=ue}},e.unstable_scheduleCallback=function(R,re,ue){var Ce=e.unstable_now();switch(typeof ue=="object"&&ue!==null?(ue=ue.delay,ue=typeof ue=="number"&&0<ue?Ce+ue:Ce):ue=Ce,R){case 1:var q=-1;break;case 2:q=250;break;case 5:q=1073741823;break;case 4:q=1e4;break;default:q=5e3}return q=ue+q,R={id:g++,callback:re,priorityLevel:R,startTime:ue,expirationTime:q,sortIndex:-1},ue>Ce?(R.sortIndex=ue,t(f,R),n(m)===null&&R===n(f)&&(T?(M(z),z=-1):T=!0,se(K,ue-Ce))):(R.sortIndex=q,t(m,R),w||y||(w=!0,j||(j=!0,W()))),R},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(R){var re=v;return function(){var ue=v;v=re;try{return R.apply(this,arguments)}finally{v=ue}}}})(xf)),xf}var wx;function GA(){return wx||(wx=1,vf.exports=UA()),vf.exports}var wf={exports:{}},ua={};var kx;function KA(){if(kx)return ua;kx=1;var e=$m();function t(m){var f="https://react.dev/errors/"+m;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)f+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+m+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function l(m,f,g){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:h==null?null:""+h,children:m,containerInfo:f,implementation:g}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return ua.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,ua.createPortal=function(m,f){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return l(m,f,null,g)},ua.flushSync=function(m){var f=c.T,g=a.p;try{if(c.T=null,a.p=2,m)return m()}finally{c.T=f,a.p=g,a.d.f()}},ua.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,a.d.C(m,f))},ua.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},ua.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var g=f.as,h=u(g,f.crossOrigin),v=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;g==="style"?a.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:h,integrity:v,fetchPriority:y}):g==="script"&&a.d.X(m,{crossOrigin:h,integrity:v,fetchPriority:y,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},ua.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var g=u(f.as,f.crossOrigin);a.d.M(m,{crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&a.d.M(m)},ua.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var g=f.as,h=u(g,f.crossOrigin);a.d.L(m,g,{crossOrigin:h,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},ua.preloadModule=function(m,f){if(typeof m=="string")if(f){var g=u(f.as,f.crossOrigin);a.d.m(m,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else a.d.m(m)},ua.requestFormReset=function(m){a.d.r(m)},ua.unstable_batchedUpdates=function(m,f){return m(f)},ua.useFormState=function(m,f,g){return c.H.useFormState(m,f,g)},ua.useFormStatus=function(){return c.H.useHostTransitionStatus()},ua.version="19.2.4",ua}var Sx;function f4(){if(Sx)return wf.exports;Sx=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),wf.exports=KA(),wf.exports}var Cx;function VA(){if(Cx)return Wl;Cx=1;var e=GA(),t=$m(),n=f4();function a(r){var s="https://react.dev/errors/"+r;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)s+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+r+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function l(r){var s=r,d=r;if(r.alternate)for(;s.return;)s=s.return;else{r=s;do s=r,(s.flags&4098)!==0&&(d=s.return),r=s.return;while(r)}return s.tag===3?d:null}function c(r){if(r.tag===13){var s=r.memoizedState;if(s===null&&(r=r.alternate,r!==null&&(s=r.memoizedState)),s!==null)return s.dehydrated}return null}function u(r){if(r.tag===31){var s=r.memoizedState;if(s===null&&(r=r.alternate,r!==null&&(s=r.memoizedState)),s!==null)return s.dehydrated}return null}function m(r){if(l(r)!==r)throw Error(a(188))}function f(r){var s=r.alternate;if(!s){if(s=l(r),s===null)throw Error(a(188));return s!==r?null:r}for(var d=r,p=s;;){var b=d.return;if(b===null)break;var x=b.alternate;if(x===null){if(p=b.return,p!==null){d=p;continue}break}if(b.child===x.child){for(x=b.child;x;){if(x===d)return m(b),r;if(x===p)return m(b),s;x=x.sibling}throw Error(a(188))}if(d.return!==p.return)d=b,p=x;else{for(var N=!1,L=b.child;L;){if(L===d){N=!0,d=b,p=x;break}if(L===p){N=!0,p=b,d=x;break}L=L.sibling}if(!N){for(L=x.child;L;){if(L===d){N=!0,d=x,p=b;break}if(L===p){N=!0,p=x,d=b;break}L=L.sibling}if(!N)throw Error(a(189))}}if(d.alternate!==p)throw Error(a(190))}if(d.tag!==3)throw Error(a(188));return d.stateNode.current===d?r:s}function g(r){var s=r.tag;if(s===5||s===26||s===27||s===6)return r;for(r=r.child;r!==null;){if(s=g(r),s!==null)return s;r=r.sibling}return null}var h=Object.assign,v=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),I=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),Y=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),D=Symbol.iterator;function W(r){return r===null||typeof r!="object"?null:(r=D&&r[D]||r["@@iterator"],typeof r=="function"?r:null)}var X=Symbol.for("react.client.reference");function H(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===X?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case T:return"Fragment";case A:return"Profiler";case C:return"StrictMode";case K:return"Suspense";case j:return"SuspenseList";case Y:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case I:return r.displayName||"Context";case M:return(r._context.displayName||"Context")+".Consumer";case B:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case z:return s=r.displayName||null,s!==null?s:H(r.type)||"Memo";case U:s=r._payload,r=r._init;try{return H(r(s))}catch{}}return null}var se=Array.isArray,R=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},Ce=[],q=-1;function V(r){return{current:r}}function ce(r){0>q||(r.current=Ce[q],Ce[q]=null,q--)}function P(r,s){q++,Ce[q]=r.current,r.current=s}var Ee=V(null),$e=V(null),qe=V(null),Ze=V(null);function Qe(r,s){switch(P(qe,s),P($e,r),P(Ee,null),s.nodeType){case 9:case 11:r=(r=s.documentElement)&&(r=r.namespaceURI)?Hv(r):0;break;default:if(r=s.tagName,s=s.namespaceURI)s=Hv(s),r=Bv(s,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}ce(Ee),P(Ee,r)}function Re(){ce(Ee),ce($e),ce(qe)}function Xe(r){r.memoizedState!==null&&P(Ze,r);var s=Ee.current,d=Bv(s,r.type);s!==d&&(P($e,r),P(Ee,d))}function wt(r){$e.current===r&&(ce(Ee),ce($e)),Ze.current===r&&(ce(Ze),Fl._currentValue=ue)}var mt,kt;function lt(r){if(mt===void 0)try{throw Error()}catch(d){var s=d.stack.trim().match(/\n( *(at )?)/);mt=s&&s[1]||"",kt=-1<d.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<d.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+mt+r+kt}var Dt=!1;function ht(r,s){if(!r||Dt)return"";Dt=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(s){var Pe=function(){throw Error()};if(Object.defineProperty(Pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pe,[])}catch(ke){var ve=ke}Reflect.construct(r,[],Pe)}else{try{Pe.call()}catch(ke){ve=ke}r.call(Pe.prototype)}}else{try{throw Error()}catch(ke){ve=ke}(Pe=r())&&typeof Pe.catch=="function"&&Pe.catch(function(){})}}catch(ke){if(ke&&ve&&typeof ke.stack=="string")return[ke.stack,ve.stack]}return[null,null]}};p.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(p.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(p.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=p.DetermineComponentFrameRoot(),N=x[0],L=x[1];if(N&&L){var ne=N.split(`
|
|
@@ -517,7 +517,7 @@ tención F1 Score tención 95.2% TEN 97.4% TENIDO +2.2%
|
|
|
517
517
|
**Deployment:**Explotación de canario → 5% de tráfico → monitoreo 48hr → producción completa`,seoMatrix:"Matriz de investigación de palabras clave que cubre 1.200+ términos a través de 8 verticales de productos. Incluye tendencias de volumen de búsqueda, puntajes de competición, análisis de brechas de contenido, oportunidades de SERP y calendario editorial de 6 meses con impacto de tráfico proyectado (+340% orgánico).",financeReport:"Cierre financiero mensual para mayo de 2025. Ingresos: $2.4M (+18% MoM). Destacados clave: SaaS ARR cruzó el hito de $24M, la devolución del CAC cayó a 11 meses, el margen bruto mejoró al 78%. Incluye el desglose por departamento de P plaga y el pronóstico de la corriente de efectivo.",apiDocsV2:"Documentación del portal para desarrolladores para API v2. Autenticación de cubiertas (OAuth 2.0 + API keys), 86 puntos finales con ejemplos de código en 5 idiomas, guía de integración webhook, políticas de limitación de tarifas, estrategia de versionado y configuración interactiva de juegos API.",interviewNotes:"Síntesis de 24 entrevistas de usuarios a través de 4 personas (usuarios de potencia, administradores, nuevos usuarios, churned). Información clave: fricción a bordo al paso 3, la personalización de tablero es #1 petición de características, uso móvil 3× superior a lo esperado. Incluye diagramas de afinidad y clips de vídeo.",wireframes:"Cables de alta fidelidad para aplicación móvil v2.0. Cubre 32 pantallas a través de 5 flujos de usuario: a bordo, dashboard, notificaciones, ajustes y modo offline. Incluye anotaciones de gestos, especificaciones de transición y adaptaciones específicas de plataforma para iOS y Android.",patentAnalysis:"Análisis de paisajes de patentes que cubren 847 patentes a través de la automatización de flujo de trabajo impulsada por AI. Se identificaron 12 riesgos de libertad para operar, 3 oportunidades potenciales de concesión de licencias y 5 áreas de espacio blanco para la presentación de IP patentada. Incluye mapeo de reclamaciones y bibliografía de arte anterior.",testFramework:"Marco de automatización de pruebas de extremo a extremo que soporta API, interfaz de usuario y pruebas de rendimiento. 312 casos de prueba en 8 módulos. Incluye ejecución paralela (4× speedup), regresión visual a través de Playwright, escenarios de prueba de carga (10K usuarios concurrentes), y reportaje integrado por Slack.",socialAssets:"Biblioteca de contenidos con 60+ activos de redes sociales para la campaña de lanzamiento de productos. Incluye plantillas de carrusel, video storyboards, variantes de encabezado A/B, tamaño de plataforma específica (LinkedIn, Twitter/X, Instagram), paletas de colores compatibles con la marca y calendario de publicación."},cG={general:"#general",announcements:"#anuncios",watercooler:"#watercooler"},dG={general:{secretaryMorning:"Buen equipo de mañana. 18 empleados activos, 12 tareas en curso. Prioridades de hoy: Revisión de la API de pago, Componentes de panel, Q2 plazo de investigación.",alexReport:"Buen progreso. @Líder de investigación — necesito el informe competitivo para la reunión del consejo el viernes. Podemos tenerlo para el jueves?",researchLeadReply:"El informe es del 90%. Tendré la versión final con resumen ejecutivo para el jueves por la mañana.",engLeadApi:"La API de conciliación de pagos está lista para su revisión. @QA El plomo por favor prioriza — esto toca el oleoducto financiero.",qaLeadReply:"En ello. Test report by EOD. Suite de regresión atrapado 2 cajas de borde en el manejador de webhook - fijaciones empujadas.",pmStandup:"Actualización rápida — a bordo de mockups de rediseño aprobados por James. Moviéndose a la planificación de la huella. @Frontend Developer puede estimar los componentes del panel?",frontendEstimate:"Tarjetas de panel: 2 días. Componentes de carga: 3 días. Compartirá el desglose de componentes en los entregables al final del día.",chiefOfStaffSync:"Sincronización de equipo cruzado: La ingeniería está bloqueada en las fichas de diseño del producto. @UI Diseñador por favor empuje la exportación token al repo compartido hoy.",uiDesignerTokens:"¡Hecho! Tokens de diseño exportados al paquete compartido. 42 fichas de color, 8 escalas de espaciado, 6 presets de tipografía. Enlace de relaciones públicas en los productos.",sarahReview:"Excelente velocidad hoy. 3 PRs fusionados, 2 entregables verificados. Mantengamos este ritmo para la fecha límite de Q2..",dataAnalystInsight:"Analítica de panel: 89% de los usuarios terminan a bordo en menos de 3 minutos. La conversión móvil sigue disminuyendo en un 62% — priorizando la optimización móvil.",devopsDeployment:"Despliegue completo. Todos los cheques de salud pasan. Presupuesto de rendimiento: API p99 a 180ms, menos de 340ms la semana pasada.",strategyMarket:"Actualización de información competitiva: dos competidores lanzaron características similares esta semana. Nuestra ventaja sigue siendo la coordinación de los agentes autónomos, nadie más tiene una delegación de tareas multiagente."},engineering:{sarahArchitecture:"Equipo, he revisado el doc de la arquitectura de pago. El enfoque de idempotencia parece sólido. Una preocupación: hemos considerado la caducidad distribuida bajo carga alta?",srBackendReply:"Buena captura. He añadido una extensión de la ventana deslizante — si la operación sigue funcionando cuando TTL llega al 80%, se autoextienda. PR actualizado.",devopsCi:"CO2 verde. Construir el tiempo hasta 4m32s después de la optimización de caché. Despliegue el estancamiento ahora.",sarahBuildTime:"Gran trabajo en el tiempo de construcción. Apuntemos 3 minutos después. @DevOps Ingeniero puede mirar en paralelo las suites de prueba?",frontendLib:"Biblioteca de componentes 80% hecho. Gráficos, tablas, formas, modales en todos. Data grid next.",backendMigration:"Los scripts de migración de bases de datos listos para Pago v2. esquema compatible con la marcha atrás — cero despliegue de tiempo de inactividad confirmado.",engLeadCodeReview:"Revisión de código hecho para PRs #127–#134. Todo aprobado. @Senior Backend Dev fusionar la rama de conciliación del pago cuando esté listo.",securityDep:"@Senior Backend Dev head up — flagged 2 transitive deps with CVEs in the payment module. jsonwebtoken necesita actualizar a 9.x. Patch PR entrando.",qaE2e:"Suite E2E ampliada: 312 casos de prueba, 98,4% tasa de paso. Las 5 pruebas flaky eran problemas de tiempo - fijos con la lógica de retry. Regreso completo listo para la liberación.",sarahShipIt:"Excelente progreso todos. Vamos a apuntar el miércoles para la congelación. Envíenlo.! 🚀",engLeadWrapUp:"Entendido. He actualizado el tablero de sprint — 23 tareas completadas, 4 en revisión, 2 bloqueadas en el módulo de pago. Asignar las tareas bloqueadas a Senior Backend Dev para la resolución prioritaria. El miércoles se confirma la congelación de la sesión, coordinaré la ronda final de críticas de código mañana por la mañana."},product:{jamesFunnel:"Basado en @Data Análisis de embudos de Analyst, estamos priorizando el rediseño a bordo. Esta es la primera iniciativa de Q2.",pmMockups:"@UI Designer puede tener maquetas para el jueves? Prepararé el PRD hoy..",uiDesignerReply:"¡Ya empezó! El enlace de Figma será en entregables. Nuevas fichas de diseño también listas para la ingeniería.",emilyA11y:"Me encanta la dirección. Asegúrese de mantener los estándares de accesibilidad — WCAG AA mínimo. Revisaré el jueves por la tarde..",dataAnalystConversion:"El nuevo flujo de salida muestra una mejora de conversión del 23% en la prueba A/B. Informe completo sobre los productos."},alpha:{engLeadSprint:"Día de la huella alfa 3. API de backend hecho, comenzó la integración de frontend. @Mobile Developer — puntos finales de pago viven en el estancamiento.",mobileIntegration:"Empezar la integración ahora. Flujo de pago ETA: 2 días.",jamesTimeline:"Línea de tiempo apretada pero en pista. @QA Lead prepare el plan de prueba final a final para el viernes. Este lanzamiento es visible desde el tablero.",qaLeadTestPlan:"El plan de prueba cubrirá flujo de pago, recuperación de errores y pruebas de carga. Coordinaré con @Security Auditor para un escaneo prelanzamiento."}},uG={humans:ZU,agents:eG,teams:tG,projects:nG,tasks:aG,taskDesc:rG,requirements:iG,reqDesc:sG,deliverables:oG,delSummary:lG,channels:cG,messages:dG},fle=[{code:"en",label:"English"},{code:"zh-CN",label:"中文"},{code:"es",label:"Español"}],mG="common",pG=["common","nav","auth","home","team","work","settings","onboarding","builder","store","agent","deliverables","reports","showcase"];Sa.use(T4).use(HT).init({resources:{en:{common:L7,nav:V7,auth:J7,home:x8,team:I8,work:V8,settings:MM,onboarding:zM,builder:g9,store:R9,agent:U9,deliverables:Oj,reports:Qj,showcase:cR},"zh-CN":{common:PD,nav:WD,auth:ZD,home:wI,team:LI,work:WI,settings:jL,onboarding:HL,builder:bP,store:_P,agent:GP,deliverables:zO,reports:XO,showcase:dz},es:{common:OB,nav:YB,auth:e$,home:k$,team:P$,work:Y$,settings:Rq,onboarding:Bq,builder:yF,store:DF,agent:KF,deliverables:HU,reports:JU,showcase:uG}},fallbackLng:"en",defaultNS:mG,ns:[...pG],react:{nsMode:"fallback"},interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],lookupLocalStorage:"markus-language",caches:["localStorage"]}});const fG="modulepreload",hG=function(e){return"/"+e},Wx={},Ca=function(t,n,a){let i=Promise.resolve();if(n&&n.length>0){let m=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=c?.nonce||c?.getAttribute("nonce");i=m(n.map(f=>{if(f=hG(f),f in Wx)return;Wx[f]=!0;const g=f.endsWith(".css"),h=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const v=document.createElement("link");if(v.rel=g?"stylesheet":fG,g||(v.as="script"),v.crossOrigin="",v.href=f,u&&v.setAttribute("nonce",u),document.head.appendChild(v),g)return new Promise((y,w)=>{v.addEventListener("load",y),v.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function l(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return i.then(c=>{for(const u of c||[])u.status==="rejected"&&l(u.reason);return t().catch(l)})},me={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",SETTINGS:"settings",SEARCH:"search"},gG=new Set(Object.values(me)),bG={dashboard:me.HOME,chat:me.TEAM,projects:me.WORK,usage:me.HOME,reports:me.HOME,prompts:me.BUILDER,templates:me.STORE,agents:me.STORE,skills:me.STORE,teams:me.STORE,knowledge:me.DELIVERABLES,governance:me.SETTINGS,notifications:me.HOME},E4={[me.HOME]:"overview",[me.TEAM]:"team",[me.WORK]:"tasks",[me.STORE]:"explore",[me.BUILDER]:"assets",[me.DELIVERABLES]:"output",[me.SETTINGS]:"settings",[me.SEARCH]:"search"},Yx=Object.fromEntries(Object.entries(E4).map(([e,t])=>[t,e]));function Ph(e){return E4[e]??e}function kc(e){return Yx[e]?Yx[e]:gG.has(e)?e:bG[e]??me.HOME}function Sc(){const e=window.location.hash.slice(1).split("/")[0];return kc(e)}function Hs(e,t){const n=Ph(e);return t?`#${n}/${t}`:`#${n}`}const N4={[me.STORE]:me.BUILDER},Fm={[me.HOME]:"M4 3h5a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z M15 3h5a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z M15 12h5a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1z M4 16h5a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1z",[me.WORK]:"M9 2h6a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1z 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 M12 11h4 M12 16h4 M8 11h.01 M8 16h.01",[me.TEAM]:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",[me.DELIVERABLES]:"m7.5 4.27 9 5.15 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 16V8Z M3.3 7 12 12l8.7-5 M12 22V12",[me.BUILDER]:"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 M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12 M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",[me.STORE]:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z M16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88Z",[me.SETTINGS]:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.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-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-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 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 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 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"},yG=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],M4=[{id:me.HOME,label:"Overview",section:"workspace"},{id:me.TEAM,label:"Team",section:"workspace"},{id:me.WORK,label:"Tasks",section:"workspace"},{id:me.DELIVERABLES,label:"Output",section:"workspace"},{id:me.BUILDER,label:"Builder",section:"build"},{id:me.STORE,label:"Store",section:"build"},{id:me.SETTINGS,label:"Settings",section:"system"}],vG=new Set([me.TEAM,me.WORK,me.DELIVERABLES,me.STORE,me.SETTINGS]),No=M4.map(e=>e.id),xG=[{id:me.HOME,label:"Overview",group:[me.HOME]},{id:me.TEAM,label:"Team",group:[me.TEAM]},{id:me.WORK,label:"Tasks",group:[me.WORK]},{id:me.DELIVERABLES,label:"Output",group:[me.DELIVERABLES]}];let js=0,rm=!0;function j4(){return typeof window<"u"?window.markusDesktop?.browser:void 0}function hle(){return js>0}function gle(){return rm}function Nf(e){rm!==e&&(rm=e,e||j4()?.hideAll?.(),window.dispatchEvent(new CustomEvent("markus:native-browser-page",{detail:{allowed:e}})),e&&js===0&&window.dispatchEvent(new CustomEvent("markus:embedded-browser-resync")))}function wG(){js+=1,js===1&&(j4()?.hideAll?.(),window.dispatchEvent(new CustomEvent("markus:native-browser-overlay",{detail:{active:!0}})));let e=!1;return()=>{e||(e=!0,js=Math.max(0,js-1),js===0&&(window.dispatchEvent(new CustomEvent("markus:native-browser-overlay",{detail:{active:!1}})),rm&&window.dispatchEvent(new CustomEvent("markus:embedded-browser-resync"))))}}function Cc(e){const t=(e||"").trim();if(!t||t==="about:blank")return!1;let n="",a="";try{const i=new URL(/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`https://${t}`);n=i.hostname.toLowerCase(),a=i.pathname.toLowerCase()}catch{const i=t.toLowerCase();return i.includes("magic.link")||i.includes("/oauth")||i.includes("/authorize")||i.includes("walletconnect")}return n==="magic.link"||n.endsWith(".magic.link")||n==="privy.io"||n.endsWith(".privy.io")||n.endsWith(".walletconnect.com")||n==="verify.walletconnect.com"||n==="accounts.google.com"||n==="appleid.apple.com"||n==="login.microsoftonline.com"||n.endsWith(".auth0.com")||n.endsWith(".okta.com")||n.endsWith(".clerk.accounts.dev")||n.endsWith(".dynamic.xyz")||n.endsWith(".web3auth.io")?!0:a.includes("/oauth")||a.includes("/authorize")||a.includes("/auth/login")||a.includes("/auth/callback")||a.includes("/auth/connect")}const R4=Object.freeze({});let Bu=R4;const Oh=new Set;function kG(){for(const e of Oh)e()}function Qx(e,t){const n=t>0?1:0;if((Bu[e]??0)===n)return;const a={...Bu};n>0?a[e]=n:delete a[e],Bu=Object.freeze(a),kG()}function SG(e,t){return e[t]??0}function _4(e,t){return SG(e,t)===0}function CG(e){return Oh.add(e),()=>{Oh.delete(e)}}function D4(){return Bu}function AG(){return R4}const dc=[{id:"overview",page:me.HOME},{id:"team-l1",page:me.TEAM,sub:"l1"},{id:"tasks-backlog",page:me.WORK,sub:"backlog"},{id:"tasks-kanban",page:me.WORK,sub:"kanban"},{id:"tasks-dag",page:me.WORK,sub:"dag"},{id:"tasks-workflows",page:me.WORK,sub:"workflows"},{id:"deliverables",page:me.DELIVERABLES}],TG=50,EG=30,$u=new Map;function ble(e,t){return $u.set(e,t),()=>{$u.get(e)===t&&$u.delete(e)}}function NG(e){return $u.get(e)?.()}function MG(e,t){const n=dc.findIndex(a=>a.page===e&&a.sub===t);return n!==-1?n:dc.findIndex(a=>a.page===e)}function jG(e,t,n){const a=MG(e,t);if(a===-1)return null;const i=(a+n+dc.length)%dc.length;return dc[i]??null}function RG(e,t){return Math.abs(e)<TG||Math.atan2(Math.abs(t),Math.abs(e))*180/Math.PI>EG?0:e<0?1:-1}function _G(e,t,n,a){return n<=t+1?!1:a?e+t<n-1:e>1}function DG(e,t){let n=e;for(;n&&n!==document.documentElement;){const a=getComputedStyle(n).overflowX;if((a==="auto"||a==="scroll")&&n.scrollWidth>n.clientWidth+1&&_G(n.scrollLeft,n.clientWidth,n.scrollWidth,t))return!0;n=n.parentElement}return!1}const zh="markus:ring-sub";function IG(e,t){window.dispatchEvent(new CustomEvent(zh,{detail:{page:e,sub:t}}))}function yle(e){const t=n=>{const a=n.detail;a&&e(a.page,a.sub)};return window.addEventListener(zh,t),()=>window.removeEventListener(zh,t)}function LG(e){const t=e;if(t&&typeof t.closest=="function"&&t.closest("[data-swipe-owner]"))return!0;const n=document.querySelectorAll('[role="dialog"], [aria-modal="true"]');for(const a of n){const i=a.getBoundingClientRect();if(i.width>0&&i.height>0)return!0}return!1}function PG(e){return e?!_4(D4(),e):!1}let qu=null,Hh=null,Xx=!1,Bh=!1,im=null,I4=null;function OG(e){if(Bh=!0,I4=e.target??null,LG(e.target)){im=null;return}const t=e.touches[0];im=t?{x:t.clientX,y:t.clientY}:null}function zG(e){if(!Bh)return;Bh=!1;const t=im;if(im=null,!t)return;const n=e.changedTouches[0];if(!n)return;const a=RG(n.clientX-t.x,n.clientY-t.y);a!==0&&(PG(Hh?.()??null)||DG(I4,a===1)||qu?.(a))}function HG(){Xx||(document.addEventListener("touchstart",OG,{passive:!0}),document.addEventListener("touchend",zG,{passive:!0}),Xx=!0)}function BG(e){const t=k.useRef(e.onStep);t.current=e.onStep;const n=k.useRef(e.activePage);n.current=e.activePage,k.useEffect(()=>{if(!e.enabled)return;const a=i=>t.current(i);return qu=a,Hh=()=>n.current?.()??null,HG(),()=>{qu===a&&(qu=null),Hh=null}},[e.enabled])}const sm=new Set;let om=!1;function $G(){om=!0,sm.size!==0&&(om=!1,sm.forEach(e=>e()))}function qG(e){return sm.add(e),om&&(om=!1,e()),()=>{sm.delete(e)}}const FG=6e4;function Jx(e){const t=e.timeoutMs??FG;let n=null,a=!1;const i=()=>{n!==null&&(clearTimeout(n),n=null)},l=()=>{a||e.signal.aborted||(i(),n=setTimeout(()=>{n=null,!(a||e.signal.aborted)&&(a=!0,e.onStall?.())},t))},c=()=>i();return e.signal.addEventListener("abort",c,{once:!0}),l(),{bump(){n!==null&&l()},stop(){i(),e.signal.removeEventListener("abort",c)}}}function vle(e,t){const n=t?.baseMs,a=t?.maxMs,i=t?.maxAttempts,l=t?.random??Math.random,c=Math.min(e,Math.max(0,i-1)),u=Math.min(n*Math.pow(2,c),a);return Math.floor(l()*u)}function qo(e){if(e==null)return[];if(Array.isArray(e)){const t=[];for(const n of e)if(typeof n=="string"){const a=n.trim();a&&t.push(a)}else(typeof n=="number"||typeof n=="boolean")&&t.push(String(n));return t}if(typeof e=="string"){const t=e.trim();if(!t)return[];if(t.startsWith("[")||t.startsWith("{")||t.startsWith('"'))try{return qo(JSON.parse(t))}catch{}return t.split(",").map(n=>n.trim()).filter(Boolean)}if(typeof e=="object"){const t=Object.values(e).filter(Array.isArray);return t.length===1?qo(t[0]):[]}return[]}function nu(e){if(!e||typeof e!="object")return e;const t=e;return{...t,tags:qo(t.tags),taskIds:qo(t.taskIds)}}function UG(e){if(!e||typeof e!="object")return e;const t=e;return{...t,tags:qo(t.tags)}}function Mf(e){if(!e||typeof e!="object")return e;const t=e;return{...t,blockedBy:qo(t.blockedBy)}}const GG=["cloudflare_quick","cloudflare_named","tailscale_funnel","tailscale_serve","custom"],KG=["unknown","up","down"],VG=[...GG,"relay_legacy"],WG=["idle","installing","starting","verifying","ready","degraded","error"],YG="remote.markus.global",Zx=[{kind:"cloudflare_quick",recommended:!1,barrier:"low",stability:"low",needsAccount:!1,needsDomain:!1,binary:"cloudflared",reachesHub:!0},{kind:"cloudflare_named",recommended:!0,barrier:"medium",stability:"high",needsAccount:!0,needsDomain:!0,binary:"cloudflared",reachesHub:!0},{kind:"tailscale_funnel",recommended:!1,barrier:"low",stability:"high",needsAccount:!0,needsDomain:!1,binary:"tailscale",reachesHub:!0},{kind:"tailscale_serve",recommended:!1,barrier:"low",stability:"high",needsAccount:!0,needsDomain:!1,binary:"tailscale",reachesHub:!1},{kind:"custom",recommended:!1,barrier:"high",stability:"medium",needsAccount:!1,needsDomain:!1,binary:null,reachesHub:!0}];function xle(e){return Zx.find(t=>t.kind===e)??Zx[0]}const QG=8056;function wle(e,t,n=QG){const a=n;switch(e){case"cloudflare_quick":return{install:t==="macos"?"brew install cloudflared":t==="linux"?"curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared && chmod +x /usr/local/bin/cloudflared":"winget install --id Cloudflare.cloudflared",run:`cloudflared tunnel --url http://localhost:${a}`};case"cloudflare_named":return{install:t==="macos"?"brew install cloudflared":t==="linux"?"curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared && chmod +x /usr/local/bin/cloudflared":"winget install --id Cloudflare.cloudflared",run:`cloudflared tunnel login && cloudflared tunnel run --url http://localhost:${a} markus`};case"tailscale_funnel":return{install:t==="macos"?"brew install tailscale":t==="linux"?"curl -fsSL https://tailscale.com/install.sh | sh":"winget install --id Tailscale.Tailscale",run:`tailscale up && tailscale funnel ${a}`};case"tailscale_serve":return{install:t==="macos"?"brew install tailscale":t==="linux"?"curl -fsSL https://tailscale.com/install.sh | sh":"winget install --id Tailscale.Tailscale",run:`tailscale up && tailscale serve ${a}`};case"custom":return{install:"# Install your own reverse proxy / FRP client (see the guide)",run:`# Point your proxy at http://localhost:${a} and expose it over HTTPS`}}}const Ui={status:"/settings/remote",detect:"/settings/remote/detect",tunnelRestart:"/settings/remote/tunnel/restart",tunnelRotate:"/settings/remote/tunnel/rotate",tunnelStop:"/settings/remote/tunnel/stop",tunnelRegister:"/settings/remote/tunnel/register",agentSetup:"/settings/remote/agent-setup",agentSetupTargets:"/settings/remote/agent-setup/targets"},XG=["install","start","resolve","register","verify","ready"],L4={path:null,kind:null,phase:"idle",remoteState:null,entryUrl:null,publicUrl:null,health:"unknown",latencyMs:null,message:null,verifyFailure:null,wasReady:!1,agentId:null,handedToChat:!1,agentContract:null};function JG(e,t){switch(e){case"idle":return"idle";case"installing":return"install";case"starting":return t.entryUrl?"verify":t.publicUrl?"register":"start";case"verifying":return"verify";case"ready":case"degraded":return"ready";case"error":return"error"}}function kle(e){return XG.indexOf(e)}function Sle(e){return e?.enabled&&e.publicUrl?{type:"addressResolved",publicUrl:e.publicUrl}:{type:"processStarted"}}function Cle(e,t){switch(t.type){case"selectKind":return{...e,kind:t.kind};case"choosePath":return{...e,path:t.path};case"selectAgent":return{...e,agentId:t.agentId};case"handedToChat":return{...e,path:"agent",handedToChat:!0,agentContract:t.contract??e.agentContract,message:null,verifyFailure:null};case"beginInstall":return{...e,phase:"install",message:null,verifyFailure:null};case"installSucceeded":return{...e,phase:"start",message:null};case"installFailed":return{...e,phase:"error",message:t.message};case"processStarted":return{...e,phase:"resolve",message:null};case"addressResolved":return{...e,publicUrl:t.publicUrl,phase:"register",health:"up",message:null};case"registered":return{...e,entryUrl:t.entryUrl??e.entryUrl,phase:"verify",message:null};case"verifyStarted":return{...e,phase:"verify",message:null};case"verifyFailed":return{...e,phase:"error",verifyFailure:t.reason,message:t.message??null};case"ready":return{...e,phase:"ready",wasReady:!0,verifyFailure:null,message:null,health:"up"};case"degraded":return{...e,phase:"ready",wasReady:!0,message:t.message??e.message};case"disconnected":return e.wasReady?{...e,phase:"reconnecting",publicUrl:null,health:"down"}:{...e,phase:"error",health:"down",message:t.message??null};case"userError":return{...e,phase:"error",message:t.message};case"reset":return{...L4,kind:e.kind,path:e.path};case"status":return ZG(e,t.status)}}function ZG(e,t){if(!t.enabled)return{...L4,kind:e.kind,path:e.path};const n={...e,remoteState:t.state,entryUrl:t.entryUrl??e.entryUrl,publicUrl:t.publicUrl??e.publicUrl,health:t.health,latencyMs:t.latencyMs??null,message:t.message??null};return t.state==="ready"||t.state==="degraded"?{...n,phase:"ready",wasReady:!0,verifyFailure:null}:t.state==="error"?{...n,phase:"error"}:e.phase==="ready"||e.phase==="reconnecting"?{...n,phase:"reconnecting",wasReady:!0}:{...n,phase:JG(t.state,n)}}const jf=(e,t)=>typeof t=="string"&&e.includes(t);function eK(e){if(!e||typeof e!="object")return null;const t=e;if(jf(VG,t.mode)&&jf(WG,t.state))return{enabled:t.enabled===!0,mode:t.mode,state:t.state,entryUrl:typeof t.entryUrl=="string"?t.entryUrl:null,publicUrl:typeof t.publicUrl=="string"?t.publicUrl:null,health:jf(KG,t.health)?t.health:"unknown",latencyMs:typeof t.latencyMs=="number"?t.latencyMs:void 0,message:typeof t.message=="string"?t.message:void 0};if(typeof t.enabled=="boolean"||typeof t.state=="string"){const n=t.connected===!0,a=typeof t.state=="string"?t.state:"idle";return{enabled:t.enabled===!0,mode:"relay_legacy",state:tK(a,n),entryUrl:null,publicUrl:typeof t.remoteUrl=="string"?t.remoteUrl:null,health:n?"up":"unknown"}}return null}function tK(e,t){switch(e){case"registering":case"connecting":return"starting";case"connected":return"ready";case"disconnected":return t?"ready":"error";default:return"idle"}}function Ale(e){return e?`https://${e}.${YG}`:null}function Tle(e){const t=e.toLowerCase();return t.includes("mac")||t.includes("darwin")?"macos":t.includes("win")?"windows":"linux"}const Rs="/api";class P4 extends Error{code;status;constructor(t,n,a){super(t),this.code=n,this.status=a}}const $h="markus:auth-expired";function Ele(e){return e instanceof P4&&(e.code==="AUTH_REQUIRED"||e.status===401&&e.code!==void 0)}let qh=!1;function nK(){qh||(qh=!0,window.dispatchEvent(new CustomEvent($h)))}function e2(){qh=!1}const Qi=new Map,aK=3e3;function rK(e){if(!e){Qi.clear();return}for(const t of Qi.keys())t.startsWith(e)&&Qi.delete(t)}async function G(e,t){const a=(t?.method?.toUpperCase()??"GET")==="GET"&&!t?.body;if(a){const l=Qi.get(e);if(l&&Date.now()-l.ts<aK)return l.promise}else{const l=e.replace(/\/[^/]+$/,"");for(const c of Qi.keys())(c===e||c.startsWith(l))&&Qi.delete(c)}const i=(async()=>{const l=await fetch(`${Rs}${e}`,{headers:{"Content-Type":"application/json"},credentials:"include",...t,body:t?.body?typeof t.body=="string"?t.body:JSON.stringify(t.body):void 0});if(!l.ok){let c="",u;try{const m=await l.json();c=m.error??m.message??"",u=m.code}catch{}throw l.status===401&&!e.startsWith("/auth")&&nK(),new P4(c||`API error: ${l.status}`,u,l.status)}return l.json()})();return a&&(Qi.set(e,{promise:i,ts:Date.now()}),i.catch(()=>Qi.delete(e))),i}function t2(e,t){if(e.onThinking){e.onThinking(t);return}e.onChunk?.(`<think>${t}</think>`)}const Te={agents:{list:e=>G(`/agents${e?.lean?"?lean=1":""}`).then(t=>({...t,agents:t.agents.filter(n=>n.name)})),get:e=>G(`/agents/${e}`),create:(e,t,n,a)=>G("/agents",{method:"POST",body:JSON.stringify({name:e,...t?{roleName:t}:{},agentRole:n,teamId:a})}),start:e=>G(`/agents/${e}/start`,{method:"POST"}),stop:e=>G(`/agents/${e}/stop`,{method:"POST"}),cancelProcessing:(e,t)=>G(`/agents/${e}/cancel-processing`,{method:"POST",body:t?JSON.stringify(t):void 0,headers:t?{"Content-Type":"application/json"}:void 0}),dropMailboxItem:(e,t,n)=>G(`/agents/${e}/mailbox/${encodeURIComponent(t)}/drop`,{method:"POST",body:JSON.stringify({reason:n}),headers:{"Content-Type":"application/json"}}),recoverStaleMailbox:e=>G(`/agents/${e}/mailbox/recover-stale`,{method:"POST"}),evolveFromMessage:(e,t)=>G(`/agents/${e}/evolve-from-message`,{method:"POST",body:JSON.stringify(t)}),remove:(e,t)=>G(`/agents/${e}${t?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,t)=>G(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(t)}),getMemory:e=>G(`/agents/${e}/memory`),getMemorySession:(e,t)=>G(`/agents/${e}/memory/sessions/${encodeURIComponent(t)}`),updateDailyMemory:(e,t)=>G(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:t})}),updateLongTermMemory:(e,t,n)=>G(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:t,content:n})}),getFiles:e=>G(`/agents/${e}/files`),getFilesMap:e=>G(`/agents/${e}/files`),updateFile:(e,t,n)=>G(`/agents/${e}/files/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:n})}),updateSystemPrompt:(e,t)=>G(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:t})}),roleStatus:e=>G(`/agents/${e}/role-status`),roleDiff:(e,t="ROLE.md")=>G(`/agents/${e}/role-diff?file=${encodeURIComponent(t)}`),roleSync:(e,t)=>G(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(t?{files:t}:{})}),roleSmartSync:(e,t)=>G(`/agents/${e}/role-smart-sync`,{method:"POST",body:JSON.stringify({file:t})}),roleUpdates:()=>G("/agents/role-updates"),addSkill:(e,t)=>G(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:t})}),removeSkill:(e,t)=>G(`/agents/${e}/skills/${encodeURIComponent(t)}`,{method:"DELETE"}),getHeartbeat:e=>G(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>G(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),cancelWakeup:(e,t)=>G(`/agents/${e}/wakeups/${t}`,{method:"DELETE"}),getRecentActivities:e=>G(`/agents/${e}/recent-activities`),getActivityLogs:(e,t)=>G(`/agents/${e}/activity-logs?activityId=${encodeURIComponent(t)}`),getActivities:(e,t)=>{const n=new URLSearchParams;t?.type&&n.set("type",t.type),t?.limit&&n.set("limit",String(t.limit)),t?.before&&n.set("before",t.before),t?.taskId&&n.set("taskId",t.taskId);const a=n.toString();return G(`/agents/${e}/activities${a?"?"+a:""}`)},getMindState:e=>G(`/agents/${e}/mind`),sendCommand:(e,t,n)=>G(`/agents/${e}/command`,{method:"POST",body:JSON.stringify({command:t,args:n})}),getMailbox:(e,t)=>{const n=new URLSearchParams;t?.limit&&n.set("limit",String(t.limit)),t?.offset&&n.set("offset",String(t.offset)),t?.category&&n.set("category",t.category),t?.sourceType&&n.set("sourceType",t.sourceType),t?.status&&n.set("status",t.status);const a=n.toString();return G(`/agents/${e}/mailbox${a?"?"+a:""}`)},getDecisions:(e,t=50)=>G(`/agents/${e}/decisions?limit=${t}`),messageStream:(e,t,n,a)=>new Promise(async(i,l)=>{const{signal:c,images:u,sessionId:m,isRetry:f,isResume:g,fileNames:h,replyTo:v,titleSource:y,chips:w,userMessageId:T,assistantMessageId:C}=a??{};let A=!1,M="",I,B,K,j=null;try{const z=await fetch(`${Rs}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:t,stream:!0,images:u,fileNames:h,sessionId:m??void 0,isRetry:f||void 0,isResume:g||void 0,replyTo:v||void 0,titleSource:y||void 0,chips:w&&w.length>0?w:void 0,userMessageId:T||void 0,assistantMessageId:C||void 0}),signal:c});if(!z.ok){l(new Error(`API error: ${z.status}`));return}const U=z.body?.getReader();if(!U){l(new Error("No reader"));return}const Y=new TextDecoder;let $="";for(c&&(j=Jx({signal:c,onStall:()=>{U.cancel().catch(()=>{})}}));;){const{done:D,value:W}=await U.read();if(j?.bump(),D)break;$+=Y.decode(W,{stream:!0});const X=$.split(`
|
|
518
518
|
`);$=X.pop()??"";for(const H of X){const se=H.trim();if(se.startsWith("data: "))try{const R=JSON.parse(se.slice(6));if(R.type==="session_start"&&R.sessionId){I=R.sessionId;const re=R.userMessageId;n.onCommit?.({type:"session_start",content:"",createdAt:new Date().toISOString(),sessionId:R.sessionId,userMessageId:re})}else if(R.type==="text_delta"&&R.text)M+=R.text,n.onChunk?.(R.text);else if(R.type==="thinking_delta"&&R.thinking)t2(n,R.thinking);else if(R.type==="done"){A=!0,M=R.content||M,R.sessionId&&(I=R.sessionId);{const V=R.messageId??R.assistantMessageId??R.agentMessageId;typeof V=="string"&&V&&(K=V)}const re=R.segments;re&&(B=re);const ue=!!R.merged,Ce=!!R.cancelled,q=!!R.emptyReply;i({content:M,sessionId:I,segments:B,merged:ue,cancelled:Ce,emptyReply:q,messageId:K}),U.cancel().catch(()=>{}),j?.stop();return}else if(R.type==="error"){const re=R;re.sessionId&&(I=re.sessionId);const ue=new Error(re.message??re.error??"Unknown stream error");ue.sessionId=re.sessionId,l(ue),U.cancel().catch(()=>{}),j?.stop();return}else R.type==="thinking_commit"&&R.thinking?n.onCommit?.({type:"thinking_commit",content:R.thinking,createdAt:R.createdAt??new Date().toISOString()}):R.type==="text_commit"&&R.text?n.onCommit?.({type:"text_commit",content:R.text,createdAt:R.createdAt??new Date().toISOString()}):R.type==="tool_call_start"&&R.toolCall?.name?n.onActivity?.({tool:R.toolCall.name,phase:"start"}):R.type==="agent_tool"&&R.tool&&R.phase?R.phase==="start"?n.onActivity?.({tool:R.tool,phase:"start",arguments:R.arguments}):R.phase==="end"&&n.onActivity?.({tool:R.tool,phase:"end",success:R.success,arguments:R.arguments,result:R.result,error:R.error,durationMs:R.durationMs}):R.type==="tool_output"&&R.tool?n.onActivity?.({tool:R.tool,phase:"output",output:R.text}):R.type==="subagent_progress"&&R.tool?n.onActivity?.({tool:R.tool,phase:"subagent_progress",subagentEvent:R.subagentEvent}):R.type==="heartbeat"&&n.onActivity?.({tool:"",phase:"heartbeat"})}catch{}}}j?.stop(),i({content:M,sessionId:I,segments:B,messageId:K,softDisconnected:!A})}catch(z){j?.stop(),z instanceof Error&&z.name==="AbortError"?i({content:M,sessionId:I,segments:B,messageId:K,softDisconnected:!A}):l(z)}})},roles:{list:()=>G("/roles")},teams:{list:e=>G(`/teams?orgId=${e??"default"}`),create:(e,t)=>G("/teams",{method:"POST",body:JSON.stringify({name:e,description:t})}),update:(e,t)=>G(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:(e,t,n)=>G(`/teams/${e}?deleteMembers=${t?"true":"false"}${n?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,t,n)=>G(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n})}),removeMember:(e,t)=>G(`/teams/${e}/members/${t}`,{method:"DELETE"}),startAll:e=>G(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>G(`/teams/${e}/stop`,{method:"POST"}),status:e=>G(`/teams/${e}/status`),getFiles:e=>G(`/teams/${e}/files`),getFile:(e,t)=>G(`/teams/${e}/files/${encodeURIComponent(t)}`),updateFile:(e,t,n)=>G(`/teams/${e}/files/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:n})}),exportTeam:e=>G(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>G(`/teams/${e}/export`)},externalAgents:{list:e=>G(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const t=new URLSearchParams;e?.lean&&t.set("lean","1"),e?.assignedAgentId&&t.set("assignedAgentId",e.assignedAgentId),e?.status&&t.set("status",e.status),e?.projectId&&t.set("projectId",e.projectId),e?.requirementId&&t.set("requirementId",e.requirementId),e?.priority&&t.set("priority",e.priority),e?.search&&t.set("search",e.search),e?.sortBy&&t.set("sortBy",e.sortBy),e?.sortOrder&&t.set("sortOrder",e.sortOrder),e?.page!==null&&e?.page!==void 0&&t.set("page",String(e.page)),e?.pageSize!==null&&e?.pageSize!==void 0&&t.set("pageSize",String(e.pageSize));const n=t.toString();return G(`/tasks${n?`?${n}`:""}`).then(a=>({...a,tasks:(a.tasks??[]).map(Mf)}))},get:e=>G(`/tasks/${e}`).then(t=>({...t,task:Mf(t.task)})),create:(e,t,n,a,i,l,c,u,m,f,g)=>G("/tasks",{method:"POST",body:JSON.stringify({title:e,description:t,assignedAgentId:n,reviewerId:a,priority:i,projectId:l,blockedBy:c,requirementId:u,taskType:m,scheduleConfig:f,reviewerType:g})}),update:(e,t)=>G(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),updateStatus:(e,t)=>G(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:t})}),assign:(e,t)=>G(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:t})}),approve:(e,t)=>G(`/tasks/${e}/approve`,{method:"POST",body:JSON.stringify({runNow:t??void 0})}),reject:e=>G(`/tasks/${e}/reject`,{method:"POST"}),requestApproval:e=>G(`/tasks/${e}/request-approval`,{method:"POST"}),cancel:(e,t=!1)=>G(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:t})}),getDependentCount:e=>G(`/tasks/${e}/dependents`),board:e=>{const t=new URLSearchParams;e?.projectId&&t.set("projectId",e.projectId);const n=t.toString();return G(`/taskboard${n?`?${n}`:""}`).then(a=>({...a,board:Object.fromEntries(Object.entries(a.board??{}).map(([i,l])=>[i,(l??[]).map(Mf)]))}))},boardSummary:e=>{const t=new URLSearchParams;e?.projectId&&t.set("projectId",e.projectId);const n=t.toString();return G(`/taskboard/summary${n?`?${n}`:""}`)},listSubtasks:e=>G(`/tasks/${e}/subtasks`),createSubtask:(e,t)=>G(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:t})}),completeSubtask:(e,t)=>G(`/tasks/${e}/subtasks/${t}/complete`,{method:"POST"}),cancelSubtask:(e,t)=>G(`/tasks/${e}/subtasks/${t}/cancel`,{method:"POST"}),deleteSubtask:(e,t)=>G(`/tasks/${e}/subtasks/${t}`,{method:"DELETE"}),run:e=>G(`/tasks/${e}/run`,{method:"POST"}),getLogs:(e,t)=>G(`/tasks/${e}/logs${t!=null?`?round=${t}`:""}`),getLogsSummary:e=>G(`/tasks/${e}/logs/summary`),accept:(e,t)=>G(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerId:t??"human"})}),revision:(e,t,n)=>G(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:t,reviewerId:n??"human"})}),archive:e=>G(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>G(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>G(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>G(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>G(`/tasks/${e}/comments`),getHistory:e=>G(`/tasks/${e}/history`),addComment:(e,t,n,a,i,l,c)=>G(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:t,authorId:i??"human",authorName:n??"User",authorType:"human",attachments:a,mentions:l,replyTo:c})}),pauseSchedule:e=>G(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>G(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>G(`/tasks/${e}/schedule/run-now`,{method:"POST"}),updateSchedule:(e,t)=>G(`/tasks/${e}/schedule`,{method:"PUT",body:JSON.stringify(t)}),deliverables:e=>{const t=e?`?projectId=${encodeURIComponent(e)}`:"";return G(`/tasks/deliverables${t}`)}},files:{preview:e=>G(`/files/preview?path=${encodeURIComponent(e)}`),streamUrl:e=>`${Rs}/files/stream?path=${encodeURIComponent(e)}`,stat:e=>G(`/files/stat?path=${encodeURIComponent(e)}`),reveal:e=>G("/files/reveal",{method:"POST",body:JSON.stringify({path:e})}),check:e=>G("/files/check",{method:"POST",body:JSON.stringify({paths:e})}),write:(e,t)=>G("/files/write",{method:"POST",body:JSON.stringify({path:e,content:t})})},requirements:{list:e=>{const t=new URLSearchParams;e?.orgId&&t.set("orgId",e.orgId),e?.status&&t.set("status",e.status),e?.source&&t.set("source",e.source),e?.projectId&&t.set("projectId",e.projectId),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset)),e?.lean&&t.set("lean","1");const n=t.toString();return G(`/requirements${n?`?${n}`:""}`).then(a=>({...a,requirements:(a.requirements??[]).map(nu)}))},get:e=>G(`/requirements/${e}`).then(t=>({...t,requirement:nu(t.requirement)})),create:e=>G("/requirements",{method:"POST",body:JSON.stringify(e)}).then(t=>({...t,requirement:nu(t.requirement)})),update:(e,t)=>G(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(t)}).then(n=>({...n,requirement:nu(n.requirement)})),updateStatus:(e,t)=>G(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:t})}),approve:e=>G(`/requirements/${e}/approve`,{method:"POST"}),approveTasksBulk:(e,t)=>G(`/requirements/${e}/tasks/approve-bulk`,{method:"POST",body:JSON.stringify({dryRun:t?.dryRun===!0,runNow:t?.runNow!==!1})}),reject:(e,t)=>G(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:t})}),requestApproval:e=>G(`/requirements/${e}/request-approval`,{method:"POST"}),cancel:e=>G(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>G(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>G(`/requirements/${e}/comments`),getHistory:e=>G(`/requirements/${e}/history`),addComment:(e,t,n,a,i,l,c)=>G(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:t,authorId:i??"human",authorName:n??"User",authorType:"human",attachments:a,mentions:l,replyTo:c})})},users:{list:e=>G(`/users?orgId=${e??"default"}`),create:(e,t,n,a,i,l)=>G("/users",{method:"POST",body:JSON.stringify({name:e,role:t,orgId:n,email:a,password:i,teamId:l})}),update:(e,t)=>G(`/users/${e}`,{method:"PATCH",body:JSON.stringify(t)}),resetPassword:(e,t)=>G(`/users/${e}/reset-password`,{method:"POST",body:JSON.stringify({password:t})}),reinvite:e=>G(`/users/${e}/reinvite`,{method:"POST"}),remove:e=>G(`/users/${e}`,{method:"DELETE"})},teamTemplates:{list:e=>{const t=e?`?q=${encodeURIComponent(e)}`:"";return G(`/team-templates${t}`)},get:e=>G(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>G(`/ops/dashboard?period=${e}`)},agentMetrics:(e,t="24h")=>G(`/agents/${e}/metrics?period=${t}`),usage:{summary:(e="default",t)=>{const n=new URLSearchParams({orgId:e});return t&&n.set("period",t),G(`/usage?${n}`)},agents:(e="default")=>G(`/usage/agents?orgId=${e}`)},cu:{status:()=>G("/cu/status")},health:()=>G("/health"),system:{openPath:e=>G("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>G("/system/storage"),info:()=>G("/system/info"),orphans:()=>G("/system/storage/orphans"),purgeOrphans:e=>G("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},browser:{tabOwnership:()=>G("/browser/tab-ownership")},terminal:{sessionOwnership:()=>G("/terminal/session-ownership")},settings:{getLlm:()=>G("/settings/llm"),getOrg:()=>G("/settings/org"),updateOrg:e=>G("/settings/org",{method:"PUT",body:JSON.stringify({name:e})}),syncOpenRouter:()=>G("/settings/llm/sync-openrouter",{method:"POST",body:JSON.stringify({})}),getRouting:()=>G("/settings/llm/routing"),updateRouting:e=>G("/settings/llm",{method:"POST",body:JSON.stringify(e)}),getAgent:()=>G("/settings/agent"),updateAgent:e=>G("/settings/agent",{method:"POST",body:JSON.stringify(e)}),getBrowser:()=>G("/settings/browser"),updateBrowser:e=>G("/settings/browser",{method:"POST",body:JSON.stringify(e)}),testAutoClick:()=>G("/settings/browser/test-auto-click",{method:"POST"}),downloadExtensionZip:()=>{const e=`${Rs}/settings/browser/extension.zip`,t={},n=localStorage.getItem("markus_token");return n&&(t.Authorization=`Bearer ${n}`),fetch(e,{headers:t}).then(a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.blob()}).then(a=>{const i=document.createElement("a");i.href=URL.createObjectURL(a),i.download="markus-browser-extension.zip",i.click(),URL.revokeObjectURL(i.href)})},openExtensionsPage:()=>G("/settings/browser/open-extensions-page",{method:"POST"}),testConcurrentBrowserQuick:()=>G("/settings/browser/test-concurrent",{method:"POST",body:JSON.stringify({mode:"quick"})}),testConcurrentBrowserChaos:async(e,t)=>{const n={"Content-Type":"application/json"},a=localStorage.getItem("markus_token");a&&(n.Authorization=`Bearer ${a}`);const i=await fetch(`${Rs}/settings/browser/test-concurrent`,{method:"POST",headers:n,body:JSON.stringify({mode:"chaos",durationSec:e.durationSec??120,agents:e.agents??3})});if(!i.ok)throw new Error(`HTTP ${i.status}`);const l=i.body.getReader(),c=new TextDecoder;let u="";for(;;){const{done:m,value:f}=await l.read();if(m)break;u+=c.decode(f,{stream:!0});const g=u.split(`
|
|
519
519
|
`);u=g.pop()??"";let h="";for(const v of g)if(v.startsWith("event: "))h=v.slice(7).trim();else if(v.startsWith("data: ")){try{t({type:h||"unknown",...JSON.parse(v.slice(6))})}catch{}h=""}}},stopConcurrentBrowserTest:()=>G("/settings/browser/test-concurrent",{method:"DELETE"}),getSearch:()=>G("/settings/search"),updateSearch:e=>G("/settings/search",{method:"POST",body:JSON.stringify(e)}),testSearch:(e,t)=>G("/settings/search/test",{method:"POST",body:JSON.stringify({provider:e,...t})}),getRemote:()=>G("/settings/remote"),enableRemote:()=>G("/settings/remote/enable",{method:"POST"}),disableRemote:()=>G("/settings/remote/disable",{method:"POST"}),getRemoteV2:async()=>eK(await G(Ui.status)),remoteDetect:()=>G(Ui.detect),remoteTunnelRestart:()=>G(Ui.tunnelRestart,{method:"POST"}),remoteTunnelRotate:()=>G(Ui.tunnelRotate,{method:"POST"}),remoteTunnelStop:()=>G(Ui.tunnelStop,{method:"POST"}),remoteTunnelRegister:e=>G(Ui.tunnelRegister,{method:"POST",body:JSON.stringify(e)}),remoteAgentSetup:e=>G(Ui.agentSetup,{method:"POST",body:JSON.stringify(e)}),remoteSetupTargets:()=>G(Ui.agentSetupTargets),sendFeishuTestMessage:e=>G("/settings/integrations/feishu/test-message",{method:"POST",body:JSON.stringify(e)}),listFeishuChats:()=>G("/settings/integrations/feishu/chats"),registerFeishuApp:e=>G("/settings/integrations/feishu/register",{method:"POST",body:JSON.stringify(e??{})}),getFeishuRegisterStatus:()=>G("/settings/integrations/feishu/register/status"),listIntegrations:()=>G("/settings/integrations"),getIntegration:e=>G(`/settings/integrations/${encodeURIComponent(e)}`),saveIntegration:(e,t)=>G(`/settings/integrations/${encodeURIComponent(e)}`,{method:"POST",body:JSON.stringify(t)}),deleteIntegration:e=>G(`/settings/integrations/${encodeURIComponent(e)}`,{method:"DELETE"}),testIntegration:(e,t)=>G(`/settings/integrations/${encodeURIComponent(e)}/test`,{method:"POST",body:JSON.stringify(t??{})}),listInstances:()=>G("/settings/integrations/instances"),createInstance:(e,t)=>G("/settings/integrations/instances",{method:"POST",body:JSON.stringify({platform:e,label:t})}),saveInstance:(e,t)=>G(`/settings/integrations/instances/${encodeURIComponent(e)}`,{method:"POST",body:JSON.stringify(t)}),deleteInstance:e=>G(`/settings/integrations/instances/${encodeURIComponent(e)}`,{method:"DELETE"}),testInstance:(e,t)=>G(`/settings/integrations/instances/${encodeURIComponent(e)}/test`,{method:"POST",body:JSON.stringify(t??{})}),startConnectionTest:(e,t)=>G(`/settings/integrations/instances/${encodeURIComponent(e)}/connection-test`,{method:"POST",body:JSON.stringify(t??{})}),getConnectionTest:e=>G(`/settings/integrations/instances/${encodeURIComponent(e)}/connection-test`),listInstanceChannels:e=>G(`/settings/integrations/instances/${encodeURIComponent(e)}/channels`),saveInstanceChannels:(e,t)=>G(`/settings/integrations/instances/${encodeURIComponent(e)}/channels`,{method:"PUT",body:JSON.stringify({channels:t})}),getCodingTools:()=>G("/settings/coding-tools"),updateCodingTools:e=>G("/settings/coding-tools",{method:"POST",body:JSON.stringify(e)}),detectCodingTools:()=>G("/settings/coding-tools/detect"),detectCodingTool:e=>G(`/settings/coding-tools/detect/${e}`),authCodingTool:(e,t,n)=>G(`/settings/coding-tools/${e}/auth`,{method:"POST",body:JSON.stringify({method:t,apiKey:n})}),listCodingToolModels:e=>G(`/settings/coding-tools/${e}/models`),testCodingTool:e=>G(`/settings/coding-tools/${e}/test`,{method:"POST"})},modelCatalog:{getByProvider:e=>G(`/models/catalog/${e}`),getLive:e=>G(`/models/live/${e}`),getAll:e=>{const t=e?`?provider=${e}`:"";return G(`/models/catalog${t}`)},getStatus:()=>G("/models/catalog/status"),providerCatalog:()=>G("/llm/provider-catalog"),refresh:()=>G("/models/catalog/refresh",{method:"POST"}),validateKey:(e,t,n)=>G("/models/validate-key",{method:"POST",body:JSON.stringify({provider:e,apiKey:t,baseUrl:n})})},skills:{list:()=>G("/skills"),builtin:()=>G("/skills/builtin"),updates:()=>G("/skills/updates"),registry:e=>G(`/skills/registry${e?`?source=${e}`:""}`),registrySkillhub:e=>{const t=new URLSearchParams;e?.q&&t.set("q",e.q),e?.category&&t.set("category",e.category),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit)),e?.sort&&t.set("sort",e.sort);const n=t.toString();return G(`/skills/registry/skillhub${n?`?${n}`:""}`)},registrySkillssh:e=>G(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,t,n,a)=>G("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:t,description:n,category:a})}),install:e=>G("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>G(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>G(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>G("/builder/artifacts"),get:(e,t)=>G(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`),save:(e,t)=>G("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:t})}),import:(e,t,n,a,i)=>G("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:t,files:n,source:a,version:i})}),install:(e,t)=>G(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/install`,{method:"POST"}),uninstall:(e,t)=>G(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/uninstall`,{method:"POST"}),delete:(e,t)=>G(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`,{method:"DELETE"}),ensureSlug:(e,t)=>G(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/ensure-slug`,{method:"POST"}),ensureSlugSafe:async(e,t,n)=>{const a=Tc(t);if(a&&a===t)return{converted:!1,type:e,name:t,slug:a,displayName:n,path:""};try{return await Te.builder.artifacts.ensureSlug(e,t)}catch(i){if(a)return{converted:!1,type:e,name:a,slug:a,displayName:n,path:""};throw i}},installed:()=>G("/builder/artifacts/installed")}},auth:{status:()=>G("/auth/status"),init:(e,t,n)=>G("/auth/init",{method:"POST",body:JSON.stringify({name:e,email:t,password:n})}),login:(e,t)=>G("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})}),hubLogin:(e,t)=>G("/auth/hub-login",{method:"POST",body:JSON.stringify({hubToken:e,hubUser:t})}),logout:()=>G("/auth/logout",{method:"POST"}),me:()=>G("/auth/me"),changePassword:(e,t)=>G("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:t})}),updateProfile:(e,t)=>G("/auth/profile",{method:"PUT",body:JSON.stringify({name:e,email:t})}),updatePreferences:e=>G("/auth/me/preferences",{method:"PUT",body:JSON.stringify(e)}),setup:(e,t)=>G("/auth/setup",{method:"POST",body:JSON.stringify({token:e,password:t})}),inviteInfo:e=>G(`/auth/invite-info?token=${encodeURIComponent(e)}`),uploadAvatar:(e,t="user",n)=>G("/avatars/upload",{method:"POST",body:JSON.stringify({image:e,type:t,id:n})})},license:{get:()=>G("/license"),refresh:()=>G("/license/refresh",{method:"POST"}),activate:e=>G("/license/activate",{method:"POST",body:JSON.stringify({licenseKey:e})}),trial:()=>G("/license/trial",{method:"POST"})},sessions:{hasAny:()=>G("/sessions/has-any"),create:e=>G(`/agents/${e}/sessions`,{method:"POST"}),listByAgent:(e,t=10,n=1)=>G(`/agents/${e}/sessions?page=${n}&limit=${t}`),renameTitle:(e,t)=>G(`/sessions/${e}/title`,{method:"PATCH",body:JSON.stringify({title:t})}),getMessages:(e,t=30,n)=>G(`/sessions/${e}/messages?limit=${t}${n?`&before=${n}`:""}`),getMessageDetail:(e,t)=>G(`/sessions/${e}/messages/${encodeURIComponent(t)}`),delete:e=>G(`/sessions/${e}`,{method:"DELETE"}),setModelOverride:(e,t)=>G(`/sessions/${e}/model-override`,{method:"PUT",body:JSON.stringify(t??{provider:"",model:""})}),streamStatus:(e,t)=>G(`/agents/${e}/sessions/${t}/stream/status`),streamStatusBatch:(e,t)=>G("/sessions/stream/status",{method:"POST",body:JSON.stringify({agentId:e,sessionIds:t}),headers:{"Content-Type":"application/json"}}),reattachStream:(e,t,n,a,i=0)=>new Promise(async(l,c)=>{let u="",m=t,f,g,h=null;try{const v=await fetch(`${Rs}/agents/${e}/sessions/${t}/stream?afterSeq=${i}`,{method:"GET",credentials:"include",signal:a});if(v.status===204){l({content:"",sessionId:t,attached:!1,terminal:!1});return}if(!v.ok){c(new Error(`API error: ${v.status}`));return}const y=v.body?.getReader();if(!y){c(new Error("No reader"));return}const w=new TextDecoder;let T="",C=!1;for(a&&(h=Jx({signal:a,onStall:()=>{y.cancel().catch(()=>{})}}));;){const{done:A,value:M}=await y.read();if(h?.bump(),A)break;T+=w.decode(M,{stream:!0});const I=T.split(`
|
|
520
|
-
`);T=I.pop()??"";for(const B of I){const K=B.trim();if(K.startsWith("data: "))try{const j=JSON.parse(K.slice(6)),z=j.type;if(z==="snapshot"){const U=j.segments??[],Y=typeof j.content=="string"?j.content:"";u=Y,U.length&&(f=U),n.onSnapshot?.({content:Y,segments:U})}else if(z==="text_delta"&&typeof j.text=="string")u+=j.text,n.onChunk?.(j.text);else if(z==="thinking_delta"&&typeof j.thinking=="string")t2(n,j.thinking);else if(z==="done"){u=j.content||u,typeof j.sessionId=="string"&&(m=j.sessionId),typeof j.messageId=="string"&&(g=j.messageId);const U=j.segments;U&&(f=U),C=!0,l({content:u,sessionId:m,segments:f,messageId:g,attached:!0,terminal:!0}),y.cancel().catch(()=>{}),h?.stop();return}else if(z==="error"){c(new Error(j.message??j.error??"Stream error")),y.cancel().catch(()=>{}),h?.stop();return}else z==="thinking_commit"&&typeof j.thinking=="string"?n.onCommit?.({type:"thinking_commit",content:j.thinking,createdAt:j.createdAt??new Date().toISOString()}):z==="text_commit"&&typeof j.text=="string"?n.onCommit?.({type:"text_commit",content:j.text,createdAt:j.createdAt??new Date().toISOString()}):z==="agent_tool"&&j.tool&&j.phase?j.phase==="start"?n.onActivity?.({tool:j.tool,phase:"start",arguments:j.arguments}):j.phase==="end"&&n.onActivity?.({tool:j.tool,phase:"end",success:j.success,arguments:j.arguments,result:j.result,error:j.error,durationMs:j.durationMs}):z==="subagent_progress"&&j.tool?n.onActivity?.({tool:j.tool,phase:"subagent_progress",subagentEvent:j.subagentEvent}):z==="heartbeat"&&n.onActivity?.({tool:"",phase:"heartbeat"})}catch{}}}h?.stop(),l({content:u,sessionId:m,segments:f,messageId:g,attached:!0,terminal:C})}catch(v){h?.stop(),c(v)}})},channels:{getMessages:(e,t=30,n)=>G(`/channels/${encodeURIComponent(e)}/messages?limit=${t}${n?`&before=${n}`:""}`),sendMessage:(e,t)=>G(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(t)})},governance:{getSystemStatus:()=>G("/system/status"),emergencyStop:e=>G("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>G("/system/announcements"),createAnnouncement:e=>G("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>G("/governance/policy"),setPolicy:e=>G("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:(e,t)=>{const n=new URLSearchParams;e&&n.set("status",e),t?.limit!==void 0&&n.set("limit",String(t.limit)),t?.offset!==void 0&&n.set("offset",String(t.offset));const a=n.toString();return G(`/approvals${a?`?${a}`:""}`)},respond:(e,t,n,a,i,l)=>G(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:t,respondedBy:n,comment:a,selectedOption:i,answers:l})})},notifications:{list:(e,t,n)=>{const a=new URLSearchParams;return e&&a.set("userId",e),t&&a.set("unread","true"),n?.type&&a.set("type",n.type),n?.limit&&a.set("limit",String(n.limit)),n?.offset&&a.set("offset",String(n.offset)),G(`/notifications?${a}`)},create:e=>G("/notifications",{method:"POST",body:JSON.stringify(e)}),markRead:e=>G(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>G("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},unread:{getCounts:()=>G("/unread"),markRead:(e,t,n)=>G("/unread/mark-read",{method:"POST",body:JSON.stringify({conversationKey:e,lastReadAt:t,lastReadId:n})}),markReadBatch:e=>G("/unread/mark-read-batch",{method:"POST",body:JSON.stringify({items:e})}),markAllRead:()=>G("/unread/mark-all-read",{method:"POST"})},messages:{search:(e,t)=>{const n=new URLSearchParams({q:e});return t?.scope&&n.set("scope",t.scope),t?.channel&&n.set("channel",t.channel),t?.limit&&n.set("limit",String(t.limit)),G(`/messages/search?${n}`)}},activity:{list:e=>{const t=new URLSearchParams;e?.limit&&t.set("limit",String(e.limit)),e?.type&&t.set("type",e.type);const n=t.toString();return G(`/activity${n?`?${n}`:""}`)}},projects:{list:e=>{const t=e?`?orgId=${e}`:"";return G(`/projects${t}`)},get:e=>G(`/projects/${e}`),create:e=>G("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>G(`/projects/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>G(`/projects/${e}`,{method:"DELETE"}),syncKnowledge:(e,t)=>G(`/projects/${e}/knowledge/sync`,{method:"POST",body:JSON.stringify({knowledgeRoots:t})})},knowledge:{search:(e,t,n)=>{const a=new URLSearchParams;return e&&a.set("query",e),t&&a.set("scope",t),n&&a.set("category",n),G(`/knowledge/search?${a}`)},contribute:e=>G("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,t)=>G(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:t})}),verify:e=>G(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>G(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const t=new URLSearchParams;return e?.q&&t.set("q",e.q),e?.projectId&&t.set("projectId",e.projectId),e?.agentId&&t.set("agentId",e.agentId),e?.taskId&&t.set("taskId",e.taskId),e?.type&&t.set("type",e.type),e?.status&&t.set("status",e.status),e?.artifactType&&t.set("artifactType",e.artifactType),e?.source&&t.set("source",e.source),e?.offset&&t.set("offset",String(e.offset)),e?.limit&&t.set("limit",String(e.limit)),G(`/deliverables?${t}`)},get:e=>G(`/deliverables/${e}`).then(t=>({...t,deliverable:UG(t.deliverable)})),create:e=>G("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>G(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(t)}),remove:e=>G(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>G(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})}),checkHealth:e=>{const t=new URLSearchParams;return e&&t.set("agentId",e),G(`/deliverables/health?${t}`)}},codeReviews:{list:(e,t=20)=>{const n=new URLSearchParams;return e&&n.set("taskId",e),n.set("limit",String(t)),G(`/reviews?${n}`)},get:e=>G(`/reviews/${e}`),run:e=>G("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>G("/reports"),get:e=>G(`/reports/${e}`),generate:e=>G("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,t)=>G(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(t)}),rejectPlan:(e,t)=>G(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(t)}),addFeedback:(e,t)=>G(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(t)}),getFeedback:e=>G(`/reports/${e}/feedback`)},executionLogs:{get:(e,t)=>G(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(t)}`)},groupChats:{list:()=>G("/group-chats"),create:e=>G("/group-chats",{method:"POST",body:JSON.stringify(e)}),getById:e=>G(`/group-chats/${e}`),update:(e,t)=>G(`/group-chats/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>G(`/group-chats/${e}`,{method:"DELETE"}),addMember:(e,t,n,a)=>G(`/group-chats/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n,memberName:a})}),removeMember:(e,t)=>G(`/group-chats/${e}/members/${t}`,{method:"DELETE"})},uploads:{upload:(e,t)=>G("/uploads",{method:"POST",body:JSON.stringify({files:e,prefix:t})})},hubOrgs:{mine:()=>Ut("/orgs/mine"),get:e=>Ut(`/orgs/${e}`),update:(e,t)=>Ut(`/orgs/${e}`,{method:"PUT",body:JSON.stringify(t)}),create:e=>Ut("/orgs",{method:"POST",body:JSON.stringify({name:e})}),members:e=>Ut(`/orgs/${e}/members`),invite:(e,t)=>Ut(`/orgs/${e}/members`,{method:"POST",body:JSON.stringify(t)}),removeMember:(e,t)=>Ut(`/orgs/${e}/members/${t}`,{method:"DELETE"}),updateMemberRole:(e,t,n)=>Ut(`/orgs/${e}/members/${t}`,{method:"PATCH",body:JSON.stringify({role:n})}),invitations:()=>Ut("/orgs/invitations"),acceptInvitation:e=>Ut(`/orgs/${e}/members/accept`,{method:"POST"}),leave:e=>Ut(`/orgs/${e}/leave`,{method:"POST"})},workflows:{list:e=>G(`/teams/${e}/workflows`),get:(e,t)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}`),create:(e,t,n)=>G(`/teams/${e}/workflows`,{method:"POST",body:JSON.stringify({name:t,yaml:n})}),update:(e,t,n)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({yaml:n})}),remove:(e,t)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),roles:(e,t)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}/roles`),listRuns:(e,t,n)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs${n?`?limit=${n}`:""}`),startRun:(e,t,n,a,i)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs`,{method:"POST",body:JSON.stringify({projectId:n,params:a,roleMapping:i})}),getRun:e=>G(`/workflow-runs/${e}`),cancelRun:e=>G(`/workflow-runs/${e}`,{method:"DELETE"}),pauseRun:e=>G(`/workflow-runs/${e}/pause`,{method:"POST"}),resumeRun:e=>G(`/workflow-runs/${e}/resume`,{method:"POST"})}};function Nle(e){return{id:e.id,sourceType:"task",sourceId:e.taskId,agentId:e.agentId,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,executionRound:e.executionRound,createdAt:e.createdAt}}function Mle(e,t,n){return e.type==="llm_request"?null:{id:`alog_${t}_${e.seq}`,sourceType:"activity",sourceId:t,agentId:n,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,createdAt:e.createdAt}}class uc{ws=null;handlers=new Map;reconnectTimer=null;heartbeatTimer=null;intentionalClose=!1;currentUserId;reconnectAttempts=0;lastEventTimestamp=null;static BACKOFF_BASE=1e3;static BACKOFF_MAX=3e4;static HEARTBEAT_INTERVAL=25e3;connect(t){if(t!==void 0&&(this.currentUserId=t),this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN))if(t!==void 0&&this.ws.url&&!this.ws.url.includes(`userId=${t}`))this.ws.onclose=null,this.ws.close(),this.ws=null;else return;this.intentionalClose=!1;const n=window.location.protocol==="https:"?"wss:":"ws:",a=new URLSearchParams;this.currentUserId&&a.set("userId",this.currentUserId),this.lastEventTimestamp&&a.set("since",this.lastEventTimestamp);const i=a.toString(),l=`${n}//${window.location.host}/ws${i?`?${i}`:""}`,c=new WebSocket(l);this.ws=c,c.onopen=()=>{this.reconnectAttempts=0,this.startHeartbeat(c)},c.onmessage=u=>{if(this.ws===c)try{const m=JSON.parse(u.data);if(m.timestamp&&(this.lastEventTimestamp=m.timestamp),m.type==="pong")return;const f=this.handlers.get(m.type);if(f)for(const h of f)h(m);const g=this.handlers.get("*");if(g)for(const h of g)h(m)}catch{}},c.onclose=()=>{if(this.stopHeartbeat(),this.intentionalClose)return;const u=Math.min(uc.BACKOFF_BASE*Math.pow(2,this.reconnectAttempts),uc.BACKOFF_MAX);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(this.currentUserId),u)},c.onerror=()=>{c.close()}}startHeartbeat(t){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"ping"}))},uc.HEARTBEAT_INTERVAL)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}disconnect(){this.intentionalClose=!0,this.stopHeartbeat(),this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>this.handlers.get(t)?.delete(n)}}const _s=new uc;let Um=typeof window<"u"?window.__MARKUS_HUB_URL__??"https://markus.global":"https://markus.global",Fu=null;async function Fh(){if(!kn())return null;try{const e=await Ut("/auth/me");if(e?.user?.id){const t=kn();return dm(t,e.user),e.user}}catch{}return mr()}async function O4(){if(!window.__MARKUS_PREVIEW__)try{const e=await G("/settings/hub");e.hubUrl&&(Um=e.hubUrl)}catch{}}function iK(){return Fu||(Fu=O4().finally(()=>{})),Fu}window.__MARKUS_PREVIEW__||(Fu=O4().then(async()=>{const e=localStorage.getItem("markus_hub_token");if(e)G("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{}),Fh();else try{await Te.auth.me();const t=await G("/settings/hub-token");t.token&&(localStorage.setItem("markus_hub_token",t.token),await Fh())}catch{}}).catch(()=>{}));const Ac="markus_hub_token",lm="markus_hub_user";function kn(){return localStorage.getItem(Ac)}async function sK(){const e=kn();if(e)return e;try{await Te.auth.me()}catch{return null}try{const t=await G("/settings/hub-token");if(t.token)return localStorage.setItem(Ac,t.token),Fh(),t.token}catch{}return null}function mr(){try{const e=localStorage.getItem(lm);return e?JSON.parse(e):null}catch{return null}}function cm(e,t){if(e.purchasedByCurrentUser||t?.has(e.id))return!0;const n=mr();if(!n?.id)return!1;const a=e.author?.id??e.authorId;return!!a&&a===n.id}function Ls(){localStorage.removeItem(Ac),localStorage.removeItem(lm),z4(null),window.dispatchEvent(new CustomEvent("markus:hub-auth"))}function dm(e,t){const n=localStorage.getItem(Ac),a=localStorage.getItem(lm),i=JSON.stringify(t);n===e&&a===i||(localStorage.setItem(Ac,e),localStorage.setItem(lm,i),z4(e),window.dispatchEvent(new CustomEvent("markus:hub-auth")))}function z4(e){G("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}async function oK(e){e.openrouter?.key&&await G("/settings/subscription-key",{method:"POST",body:JSON.stringify({openrouter:e.openrouter})}).catch(()=>{})}async function Gg(e){try{return await G(`/auth/hub-connect-status?session=${encodeURIComponent(e)}&_t=${Date.now()}`)}catch{return null}}async function Kg(e){!e.token||!e.user||(dm(e.token,e.user),e.openrouter?.key&&await oK({openrouter:e.openrouter}),lK())}async function lK(){if(kn())try{const{org:e}=await G("/settings/org"),t=e?.name?.trim();if(!t||t==="My Organization")return;const a=((await Ut("/orgs/mine")).orgs??[]).find(i=>i.role==="owner");if(!a||a.name===t)return;await Ut(`/orgs/${a.id}`,{method:"PUT",body:JSON.stringify({name:t})})}catch{}}function H4(){return window.markusDesktop}async function cK(e,t=12e4){const n=Date.now()+t;for(;Date.now()<n;){const a=await Gg(e);if(a?.ready&&a.token&&a.user)return await Kg(a),!0;await new Promise(i=>setTimeout(i,1200))}return!1}let Uu=null;H4()?.onDeepLinkAuth?.(e=>{Uu?.(e?.session??"")});let um=null;function dK(){um?.(),Ms=null}function uK(e,t,n){return new Promise((a,i)=>{let l=!1,c=!1;const u=(T,C)=>{l||(l=!0,um=null,clearInterval(y),clearTimeout(w),window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",h),Uu===f&&(Uu=null),T?(n.focusWindow?.(),a()):i(C))};um=()=>u(!1,new Error("Hub login cancelled"));const m=async()=>{if(!(l||c)){c=!0;try{const T=await Gg(e);T?.ready&&T.token&&T.user&&(await Kg(T),u(!0))}finally{c=!1}}},f=T=>{(!T||T===e)&&m()};Uu=f;const g=()=>{m()},h=()=>{document.visibilityState==="visible"&&m()};window.addEventListener("focus",g),document.addEventListener("visibilitychange",h);let v=`${Um}/auth/connect?session=${encodeURIComponent(e)}&redirect=${encodeURIComponent("markus://auth")}`;t&&(v+=`&method=${encodeURIComponent(t)}`),Promise.resolve(n.openExternal(v)).then(()=>{m()}).catch(T=>{u(!1,T instanceof Error?T:new Error("Failed to open browser"))});const y=setInterval(()=>{m()},1500),w=setTimeout(()=>u(!1,new Error("Hub login timed out")),5*6e4)})}function mK(e,t){return new Promise((n,a)=>{let i=`${Um}/auth/connect?session=${encodeURIComponent(e)}`;t&&(i+=`&method=${encodeURIComponent(t)}`);const l=460,c=580,u=Math.round(window.screenX+(window.outerWidth-l)/2),m=Math.round(window.screenY+(window.outerHeight-c)/2),f=window.open(i,"markus_hub_auth",`popup=yes,width=${l},height=${c},left=${u},top=${m}`);if(!f){a(new Error("Popup blocked by browser. Please allow popups for this site."));return}let g=!1,h=null;const v=()=>{clearInterval(w),clearInterval(C),h&&clearInterval(h),document.removeEventListener("visibilitychange",T)},y=async()=>{if(g)return;const A=await Gg(e);A?.ready&&A.token&&A.user&&(g=!0,await Kg(A),v(),f?.close(),n())},w=setInterval(()=>{y()},1500),T=()=>{!g&&document.visibilityState==="visible"&&y()};document.addEventListener("visibilitychange",T);const C=setInterval(()=>{if(!g&&f?.closed){clearInterval(C);let A=0;h=setInterval(async()=>{if(g){clearInterval(h);return}A++,await y(),A>=5&&!g&&(g=!0,v(),kn()?n():a(new Error("Hub login cancelled")))},1e3)}},500)})}let Ms=null;function Ia(e){const t=typeof e=="string"?{method:e}:e??{};if(t.force)um?.(),Ms=null,(kn()||mr())&&Ls();else if(kn())return Promise.resolve();if(Ms)return Ms;const n=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`,a=H4(),i=(async()=>{await iK(),a?await uK(n,t.method,a):await mK(n,t.method)})();return Ms=i,i.catch(()=>{}).finally(()=>{Ms===i&&(Ms=null)}),i}async function Ut(e,t){const n=kn(),a={"Content-Type":"application/json",...t?.headers};n&&(a.Authorization=`Bearer ${n}`);const i=await fetch(`${Rs}/hub${e}`,{...t,headers:a,credentials:"include"}),l=await i.json();if(i.status===401&&n&&Ls(),!i.ok){const c=new Error(l.error??`Hub HTTP ${i.status}`);throw c.code=typeof l.code=="string"?l.code:void 0,c.retryAfterSeconds=typeof l.retryAfterSeconds=="number"?l.retryAfterSeconds:void 0,c.status=i.status,c}return l}async function B4(){if(!kn())return!1;try{return await Ut("/user/plan"),!0}catch{return!1}}const nt={getUrl:()=>Um,isAuthenticated:()=>!!kn(),getUser:mr,logout:()=>{Ls()},ensureAuth:Ia,validateSession:B4,login:async(e,t)=>{const n=await Ut("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})});return dm(n.token,n.user),n},register:async(e,t,n)=>{const a=await Ut("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:t,password:n})});return dm(a.token,a.user),a},search:e=>{const t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.subtype&&t.set("subtype",e.subtype),e?.q&&t.set("q",e.q),e?.category&&t.set("category",e.category),e?.sort&&t.set("sort",e.sort),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit));const n=t.toString();return Ut(`/items${n?`?${n}`:""}`)},getItem:e=>Ut(`/items/${e}`),download:async e=>{await Ia();try{return await Ut(`/items/${e}/download`,{method:"POST"})}catch(t){if(!kn())return await Ia(),Ut(`/items/${e}/download`,{method:"POST"});throw t}},publish:async e=>{await Ia();try{return await Ut("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!kn())return await Ia(),Ut("/items",{method:"POST",body:JSON.stringify(e)});throw t}},uploadImage:async e=>{await Ia();try{const t=new FormData;t.append("file",e);const n=await fetch("/api/hub/upload",{method:"POST",credentials:"include",headers:{Authorization:`Bearer ${kn()}`},body:t});return n.ok?await n.json():null}catch{return null}},uploadMediaBatch:async e=>{await Ia();try{const t=await fetch("/api/hub/deliverables/media",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${kn()}`},body:JSON.stringify({files:e})});return t.ok?await t.json():{files:[],errors:[{filename:"batch",error:`HTTP ${t.status}`}]}}catch(t){return{files:[],errors:[{filename:"batch",error:String(t)}]}}},publishViaProxy:async e=>{await Ia();try{return await Ut("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!kn())return await Ia(),Ut("/items",{method:"POST",body:JSON.stringify(e)});throw t}},updateItem:async(e,t)=>(await Ia(),Ut(`/items/${e}`,{method:"PUT",body:JSON.stringify(t)})),myItems:async()=>kn()?Ut("/items/mine"):{items:[]},browseItems:async e=>{const t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.orgId&&t.set("orgId",e.orgId),e?.q&&t.set("q",e.q),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit??50));const n=t.toString();return Ut(`/items${n?`?${n}`:""}`)},myOrgs:async()=>kn()?Ut("/orgs/mine").then(e=>({memberships:(e.orgs??[]).map(t=>({id:t.id,name:t.name,slug:t.slug,role:t.role}))})):{memberships:[]},deleteItem:async e=>(await Ia(),Ut(`/items/${e}`,{method:"DELETE"})),purchases:{checkout:e=>Ut("/purchases/checkout",{method:"POST",body:JSON.stringify({itemId:e})}),payWithEarnings:e=>Ut("/purchases/pay-with-earnings",{method:"POST",body:JSON.stringify({itemId:e})}),mine:()=>Ut("/purchases/mine")},creator:{getBalance:()=>Ut("/creator/balance")},feedback:{create:e=>Ut("/feedback",{method:"POST",body:JSON.stringify(e)})},user:{plan:()=>Ut("/user/plan"),cuStats:(e=30,t="day")=>Ut(`/user/cu/stats?days=${e}&granularity=${t}`),claimFreeCreditsStatus:()=>Ut("/user/claim-free-credits"),claimFreeCredits:()=>Ut("/user/claim-free-credits",{method:"POST"}),referral:()=>Ut("/user/referral")}},pK=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function $4(e){return typeof e=="string"&&e.length>=2&&e.length<=64&&pK.test(e)}function Tc(e){const t=e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-+|-+$/g,"");return $4(t)?t:null}function mm(e,t){const n=Tc(e);if(n)return n;if(t){const i=Tc(t);if(i)return i;if($4(t))return t}let a=0;for(let i=0;i<e.length;i++)a=(a<<5)-a+e.charCodeAt(i)|0;return`pkg-${Math.abs(a).toString(36)}`}let n2=null,au=me.HOME;const yt={setHandler(e){n2=e},navigate(e,t){t&&Object.entries(t).forEach(([n,a])=>localStorage.setItem(`markus_nav_${n}`,a)),n2?.(e,t),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:t}}))},setSettingsReturnPage(e){e!==me.SETTINGS&&(au=e)},getSettingsReturnPage(){return au},leaveSettings(){const e=au!==me.SETTINGS?au:me.HOME;this.navigate(e)}};let q4=Sc();const Uh=new Set;function a2(){q4=Sc(),Uh.forEach(e=>e())}typeof window<"u"&&(window.addEventListener("hashchange",a2),window.addEventListener("popstate",a2));function fK(e){return Uh.add(e),()=>Uh.delete(e)}function hK(e){return k.useSyncExternalStore(fK,()=>q4===e,()=>!1)}var Lc=f4();function Fs(e){k.useEffect(()=>wG(),[e])}function vr({title:e,message:t,confirmLabel:n,cancelLabel:a,variant:i="danger",alertOnly:l=!1,checkboxes:c,onConfirm:u,onCancel:m,onCancelClick:f}){const{t:g}=xt("common");Fs(!0);const[h,v]=k.useState(()=>{const T={};for(const C of c??[])T[C.id]=C.defaultChecked??!1;return T}),y=i==="primary",w=y?"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors":"px-4 py-1.5 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors";return Lc.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:m,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[360px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[o.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center shrink-0 ${y?"bg-brand-500/15":"bg-red-500/15"}`,children:y?o.jsxs("svg",{className:"w-5 h-5 text-brand-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M12 16v-4"}),o.jsx("path",{d:"M12 8h.01"})]}):o.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),o.jsxs("div",{className:"min-w-0 pt-0.5",children:[o.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:e}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:t})]})]}),c&&c.length>0&&o.jsx("div",{className:"mb-4 space-y-2",children:c.map(T=>o.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:h[T.id]??!1,onChange:C=>v(A=>({...A,[T.id]:C.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),T.label]},T.id))}),o.jsxs("div",{className:"flex justify-end gap-2",children:[!l&&o.jsx("button",{type:"button",onClick:()=>{f?f(c?h:void 0):m()},className:"px-4 py-1.5 text-sm border border-border-default rounded-lg text-fg-primary hover:bg-surface-elevated transition-colors",children:a??g("cancel")}),o.jsx("button",{type:"button",onClick:()=>u(c?h:void 0),className:w,children:n??g(l?"ok":"confirm")})]})]})}),document.body)}function F4(e,t){const n=e||t||null;if(!n)return null;if(n.startsWith("http")||n.startsWith("data:")||n.startsWith("/api/"))return n;if(n.startsWith("/")){const a=nt.getUrl()?.replace(/\/$/,"")||"";return a?`${a}${n}`:n}return n}function U4({size:e,className:t=""}){const n=Math.max(12,Math.round(e*.55));return o.jsx("div",{className:`rounded-full bg-surface-overlay text-fg-secondary flex items-center justify-center shrink-0 border border-border-default/70 ${t}`,style:{width:e,height:e},"aria-hidden":!0,children:o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),o.jsx("circle",{cx:"12",cy:"7",r:"4"})]})})}function Fo({name:e,avatarUrl:t,size:n=28,className:a="",bgClass:i="bg-brand-600 text-on-brand",fallback:l="initials"}){const[c,u]=k.useState(!1);if(k.useEffect(()=>{u(!1)},[t]),!!t&&!c)return o.jsx("img",{src:t,alt:e??"",className:`rounded-full object-cover shrink-0 ${a}`,style:{width:n,height:n},onError:()=>u(!0)});if(l==="icon")return o.jsx(U4,{size:n,className:a});const f=e?.[0]?.toUpperCase()??"?",g=n<=20?"text-[8px]":n<=28?"text-xs":n<=40?"text-sm":"text-lg",h=/\btext-(?!white\b)/.test(i);return o.jsx("div",{className:`rounded-full ${i} flex items-center justify-center ${h?"":"text-white"} ${g} font-bold shrink-0 ${a}`,style:{width:n,height:n},children:f})}function G4({currentUrl:e,name:t,size:n=64,targetType:a="user",targetId:i,onUploaded:l}){const{t:c}=xt("common"),[u,m]=k.useState(null),[f,g]=k.useState(!1),[h,v]=k.useState(!1),[y,w]=k.useState(null),T=k.useRef(null),C=u??e;k.useEffect(()=>{v(!1)},[C]);const A=!!C&&!h,M=k.useCallback(async I=>{if(!I.type.startsWith("image/"))return;if(I.size>2*1024*1024){w(c("imageTooLarge"));return}const B=new FileReader;B.onload=async()=>{const K=B.result;m(K),v(!1),g(!0);try{const{avatarUrl:j}=await Te.auth.uploadAvatar(K,a,i);l?.(j)}catch{m(null)}finally{g(!1)}},B.readAsDataURL(I)},[a,i,l,c]);return o.jsxs("div",{className:"relative inline-block group",children:[o.jsx("input",{ref:T,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden",onChange:I=>{const B=I.target.files?.[0];B&&M(B)}}),o.jsxs("button",{type:"button",onClick:()=>T.current?.click(),className:"relative rounded-full overflow-hidden focus:outline-none focus:ring-2 focus:ring-brand-500/50",style:{width:n,height:n},title:c("clickToSetAvatar",{defaultValue:"Click to set avatar"}),"aria-busy":f,children:[A?o.jsx("img",{src:C,alt:t??"",className:"w-full h-full object-cover",onError:()=>v(!0)}):o.jsx(U4,{size:n}),o.jsx("div",{className:`absolute inset-0 bg-black/45 flex items-center justify-center transition-opacity ${f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:f?o.jsx("div",{className:"w-5 h-5 border-2 border-white/60 border-t-white rounded-full animate-spin"}):o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),o.jsx("circle",{cx:"12",cy:"13",r:"4"})]})})]}),y&&o.jsx(vr,{alertOnly:!0,variant:"danger",title:c("error",{defaultValue:"Error"}),message:y,onConfirm:()=>w(null),onCancel:()=>w(null)})]})}const gK={total:0,used:0,remaining:0,pct:0,personalLimit:!1};function bK(e){return e?"billing":"login"}function yK(e,t){return e?t?"sidebar.hubConnectedAs":"sidebar.hubConnected":"sidebar.hubDisconnected"}function Mo(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function vK(e,t){const n=e?.memberCuLimit;return n==null||n<=0,!1}function xK(e,t){if(!e)return gK;const n=vK(e),a=e.memberCuLimit!==null&&e.memberCuLimit!==void 0&&e.memberCuLimit>0,i=Mo(e.monthlyQuotaCu)+Mo(e.bonusCu)+Mo(e.purchasedCu),l=n?Mo(e.memberCuLimit):e.creditsBudgetCu??(a?Mo(e.memberCuLimit):i),c=n?Mo(e.memberCuUsed):e.totalConsumedThisPeriod??e.cuUsed??e.memberCuUsed??0,u=Math.max(0,l-c),m=l>0?Math.min(100,Math.round(c/l*100)):0;return{total:l,used:c,remaining:u,pct:m,personalLimit:n}}function K4(e){const[t,n]=k.useState(()=>nt.isAuthenticated()),[a,i]=k.useState(()=>mr()),[l,c]=k.useState(null),u=k.useCallback(m=>{if(i(mr()),!nt.isAuthenticated()){n(!1),c(null);return}if(!m?.validate){n(!0);return}B4().then(f=>{n(f),i(mr())})},[]);return k.useEffect(()=>{u({validate:!0});const m=()=>u(),f=()=>u({validate:!0});return window.addEventListener("markus:hub-auth",m),window.addEventListener("focus",f),()=>{window.removeEventListener("markus:hub-auth",m),window.removeEventListener("focus",f)}},[u]),k.useEffect(()=>{if(!e||!nt.isAuthenticated())return;let m=!1;return nt.user.plan().then(f=>{m||c(xK(f))}).catch(()=>{m||c(null)}),()=>{m=!0}},[e,t]),{connected:t,user:a,credits:l,refresh:u}}function Uo(){return!!window.markusDesktop}function Or(e){window.markusDesktop?window.markusDesktop.openExternal(e):window.open(e,"_blank","noopener,noreferrer")}function wK({authUser:e,onNavigate:t,onLogout:n}){const{t:a}=xt(["settings","common","nav"]),[i,l]=k.useState(!1),[c,u]=k.useState(!1),{connected:m,user:f,credits:g}=K4(i);k.useEffect(()=>{const T=()=>l(!0);return window.addEventListener("markus:open-drawer",T),()=>window.removeEventListener("markus:open-drawer",T)},[]),k.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i]);const h=T=>{if(l(!1),T==="__edit_profile"){window.dispatchEvent(new CustomEvent("markus:open-edit-profile"));return}t(T)},v=()=>{if(l(!1),bK(m)==="login"){Ia().catch(()=>{});return}Or(`${nt.getUrl().replace(/\/$/,"")}/settings?tab=billing`)},y=()=>{l(!1),yt.navigate(me.SETTINGS,{tab:"account"})};if(!i)return null;const w=a(`nav:${yK(m,!!f?.username)}`,{username:f?.username??""});return o.jsxs("div",{className:"fixed inset-0 z-[100]",children:[o.jsx("div",{className:"absolute inset-0 bg-black/40 animate-fadeIn",onClick:()=>l(!1)}),o.jsxs("aside",{className:"absolute inset-y-0 left-0 w-72 bg-surface-secondary shadow-2xl flex flex-col animate-slideInLeft",children:[o.jsx("div",{className:"px-5 pt-6 pb-4 border-b border-border-default",children:e?o.jsxs("button",{onClick:()=>h("__edit_profile"),className:"flex items-center gap-3 w-full text-left",children:[o.jsx(Fo,{name:e.name||"User",avatarUrl:e.avatarUrl,size:40}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:e.name||a("common:userPlaceholder")}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:e.email||e.role})]}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]}):o.jsx("div",{className:"text-sm text-fg-tertiary",children:a("common:loading")})}),o.jsxs("div",{className:"px-3 pt-3 pb-1 border-b border-border-default space-y-0.5",children:[o.jsxs("button",{onClick:v,title:m?a("common:creditBalanceOpenHub"):void 0,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-surface-overlay active:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:"w-[18px] h-[18px] flex items-center justify-center shrink-0 text-fg-tertiary",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),o.jsx("path",{d:"M12.5 5.5v13",strokeDasharray:"2 2.5"})]})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-secondary truncate",children:a("common:creditBalance")}),o.jsx("span",{className:"text-sm font-medium text-fg-primary shrink-0 tabular-nums",children:m?g!==null?g.remaining.toLocaleString():"—":a("nav:sidebar.hubLoginShort")}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]}),o.jsxs("button",{onClick:y,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:"w-[18px] h-[18px] flex items-center justify-center shrink-0",children:o.jsx("span",{className:`w-2 h-2 rounded-full ${m?"bg-emerald-500":"bg-fg-muted"}`})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-secondary truncate",children:w}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]})]}),o.jsxs("nav",{className:"flex-1 overflow-y-auto py-3 px-3 space-y-1",children:[o.jsx(Rf,{icon:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),o.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),label:a("common:home",{defaultValue:"Home"}),onClick:()=>h(me.HOME)}),o.jsx(Rf,{icon:o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:Fm[me.BUILDER]})}),label:a("nav:builder"),onClick:()=>h(me.BUILDER)}),o.jsx(Rf,{icon:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.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-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-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 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 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 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),label:a("settings:title"),onClick:()=>h(me.SETTINGS)})]})]}),c&&n&&o.jsx(vr,{title:a("common:signOutConfirmTitle"),message:a("common:signOutConfirmMessage"),confirmLabel:a("common:signOut"),variant:"primary",onConfirm:()=>{u(!1),l(!1),n()},onCancel:()=>u(!1)})]})}function Rf({icon:e,label:t,onClick:n}){return o.jsxs("button",{onClick:n,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm text-fg-secondary hover:text-fg-primary hover:bg-surface-overlay transition-colors",children:[e,o.jsx("span",{children:t})]})}function kK(){window.dispatchEvent(new CustomEvent("markus:open-drawer"))}function V4({className:e=""}){return o.jsx("button",{onClick:kK,className:`p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 ${e}`,"aria-label":"Menu",children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),o.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),o.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})})}function SK({onClose:e,onClaimed:t}){const{t:n}=xt(["home","common"]);Fs(!0);const[a,i]=k.useState("loading"),[l,c]=k.useState(1e3),[u,m]=k.useState(""),f=k.useRef(t);f.current=t;const g=k.useRef(!1),h=()=>`${nt.getUrl().replace(/\/$/,"")}/settings?tab=overview&claim=1`,v=k.useCallback(async()=>{i("loading"),m("");try{kn()||await Ia();const w=await nt.user.claimFreeCreditsStatus();if(typeof w.amountCu=="number"&&w.amountCu>0&&c(w.amountCu),w.claimed){i("already"),f.current();return}i("open_hub")}catch(w){m(w instanceof Error?w.message:n("claim.loadFailed")),i("error")}},[n]);k.useEffect(()=>{g.current||(g.current=!0,v())},[v]);const y=()=>{const w=h();Uo()?Or(w):window.open(w,"_blank","noopener,noreferrer")};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60] p-4",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-6 w-full max-w-md shadow-2xl",onClick:w=>w.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold text-lg text-fg-primary",children:n("claim.title")}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:n("claim.subtitle")})]}),o.jsx("button",{type:"button",onClick:e,className:"text-fg-tertiary hover:text-fg-primary text-lg leading-none",children:"×"})]}),a==="loading"&&o.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:n("claim.loading")}),a==="already"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-emerald-400",children:n("claim.success",{amount:l.toLocaleString()})}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("claim.startUsing")}),o.jsx("button",{type:"button",onClick:e,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-on-brand hover:bg-brand-600",children:n("common:close")})]}),a==="open_hub"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:n("claim.openHubHint",{amount:l.toLocaleString()})}),o.jsx("button",{type:"button",onClick:y,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-on-brand hover:bg-brand-600",children:n("claim.openHub")})]}),a==="error"&&o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-red-400",children:u}),o.jsx("button",{type:"button",onClick:()=>{v()},className:"w-full py-2 text-sm rounded-xl border border-border-default",children:n("claim.retry")})]})]})})}function r2(e){return e.includes(":")?e:`common:${e}`}const Dr=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar",labelKey:"shortcuts.toggleLeft",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",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:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"new-conversation",group:"team",keys:["N"],label:"New conversation",labelKey:"shortcuts.newConversation",page:"team"},{id:"cycle-session-tab",group:"team",keys:["Ctrl","Tab"],label:"Next conversation tab",labelKey:"shortcuts.cycleSessionTab",page:"team"},{id:"cycle-session-tab-prev",group:"team",keys:["Ctrl","Shift","Tab"],label:"Previous conversation tab",labelKey:"shortcuts.cycleSessionTabPrev",page:"team"}];function W4(e){return`markus_shortcut_lesson_${e}`}function pm(e){try{const t=localStorage.getItem(W4(e));if(!t)return[];const n=JSON.parse(t);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function fm(e,t){try{localStorage.setItem(W4(e),JSON.stringify(t.filter(Boolean)))}catch{}}function Vg(e){const t=new Set(pm(e));return Dr.every(n=>t.has(n.id))}function CK(e,t,n){const a=Dr.find(l=>Y4(e,l.id,n));if(!a)return Vg(t);const i=new Set(pm(t));return i.add(a.id),fm(t,[...i]),Dr.every(l=>i.has(l.id))}function AK(e){fm(e,Dr.map(t=>t.id))}function Y4(e,t,n){const a=n?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey,i=e.key.toLowerCase();switch(t){case"toggle-left":return a&&!e.altKey&&!e.shiftKey&&i==="b";case"nav-l0-jk":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&(i==="j"||i==="k");case"nav-l0-l":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="l";case"nav-l0-h":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="h";case"search":return a&&!e.altKey&&!e.shiftKey&&i==="p";case"help":return a&&!e.altKey&&(i==="/"||!e.shiftKey&&(e.code==="Slash"||i==="/"));case"new-conversation":return a&&!e.altKey&&!e.shiftKey&&i==="n";case"cycle-session-tab":return e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"&&!e.shiftKey;case"cycle-session-tab-prev":return e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"&&e.shiftKey;default:return!1}}const TK=[{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:"new-conversation",group:"team",keys:["N"],label:"New conversation",labelKey:"shortcuts.newConversation",page:"team"},{id:"cycle-session-tab",group:"team",keys:["Ctrl","Tab"],label:"Next conversation tab",labelKey:"shortcuts.cycleSessionTab",page:"team"},{id:"cycle-session-tab-prev",group:"team",keys:["Ctrl","Shift","Tab"],label:"Previous conversation tab",labelKey:"shortcuts.cycleSessionTabPrev",page:"team"},{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 Q4(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 i2(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 s2(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const EK=["layout","navigation","search","help","team"];function NK(e,t){return t&&e.startsWith("⌘")?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-[15px] font-semibold leading-none",children:"⌘"}),o.jsx("span",{className:"text-[13px]",children:e.slice(1)})]}):o.jsx("span",{className:"text-[13px]",children:e})}function MK({open:e,userId:t,onClose:n,onCompleted:a}){const{t:i}=xt(["home","common"]),l=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),[c,u]=k.useState(()=>new Set(t?pm(t):[]));k.useEffect(()=>{e&&t&&u(new Set(pm(t)))},[e,t]);const m=Dr.every(y=>c.has(y.id)),f=c.size;k.useEffect(()=>{!e||!t||m&&Vg(t)&&a()},[e,t,m]);const g=k.useMemo(()=>EK.map(y=>({group:y,items:Dr.filter(w=>w.group===y)})).filter(y=>y.items.length>0),[]);if(k.useEffect(()=>{if(!e||!t)return;const y=w=>{if(w.key==="Escape"){n();return}const T={key:w.key,code:w.code,metaKey:w.metaKey,ctrlKey:w.ctrlKey,altKey:w.altKey,shiftKey:w.shiftKey},C=Dr.find(A=>Y4(T,A.id,l));C&&((w.metaKey||w.ctrlKey||w.altKey)&&w.preventDefault(),w.stopPropagation(),u(A=>{if(A.has(C.id))return A;const M=new Set(A);return M.add(C.id),t&&fm(t,[...M]),M}))};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[e,t,l,n]),!e)return null;const h=y=>{t&&u(w=>{const T=new Set(w);return T.has(y)?T.delete(y):T.add(y),fm(t,[...T]),T})},v=()=>{t&&(AK(t),u(new Set(Dr.map(y=>y.id))),a())};return o.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:y=>{y.target===y.currentTarget&&n()},role:"dialog","aria-modal":"true","aria-label":i("home:checklist.shortcutLesson.title"),children:o.jsxs("div",{className:"w-full max-w-md max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[o.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:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:i("checklist.shortcutLesson.title")}),o.jsx("button",{type:"button",onClick:n,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":i("common:shortcuts.close"),children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"px-4 py-3",children:[o.jsx("p",{className:"text-xs text-fg-secondary mb-3",children:i("checklist.shortcutLesson.subtitle")}),m?o.jsxs("div",{className:"flex items-center gap-2 bg-green-500/10 border border-green-500/30 rounded-xl px-4 py-3 mb-4",children:[o.jsx("span",{className:"text-green-600 text-base",children:"✓"}),o.jsx("span",{className:"text-sm font-medium text-green-600",children:i("checklist.shortcutLesson.allDone")})]}):o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-300",style:{width:`${f/Dr.length*100}%`}})}),o.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:i("checklist.progress",{done:f,total:Dr.length})})]}),o.jsx("div",{className:"space-y-4",children:g.map(({group:y,items:w})=>o.jsxs("section",{children:[o.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:i(r2(`shortcuts.groups.${y}`),{defaultValue:y})}),o.jsx("ul",{className:"space-y-1",children:w.map(T=>{const C=c.has(T.id);return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>h(T.id),className:"w-full flex items-center justify-between gap-3 rounded-lg px-2 py-2 text-left hover:bg-surface-elevated/60 transition-colors",children:[o.jsxs("span",{className:"flex items-center gap-2.5 min-w-0",children:[o.jsx("span",{className:`shrink-0 w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${C?"bg-green-500 border-green-500":"border-border-default"}`,children:C&&o.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),o.jsx("span",{className:`text-sm min-w-0 ${C?"text-fg-tertiary line-through":"text-fg-primary"}`,children:i(r2(T.labelKey))})]}),o.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default font-medium leading-none text-fg-primary font-mono",children:NK(Q4(T.keys,l,T.bare),l)})]})},T.id)})})]},y))})]}),o.jsxs("div",{className:"sticky bottom-0 border-t border-border-default bg-surface-primary px-4 py-3 flex items-center justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:v,className:"px-3 py-2 text-sm rounded-xl border border-border-default text-fg-secondary hover:bg-surface-elevated hover:text-fg-primary transition-colors font-medium",children:i("checklist.shortcutLesson.markAllLearned")}),o.jsx("button",{type:"button",onClick:n,className:`px-4 py-2 text-sm rounded-xl transition-colors font-medium ${m?"bg-green-600 hover:bg-green-500 text-on-brand":"bg-brand-600 hover:bg-brand-500 text-on-brand"}`,children:i(m?"checklist.shortcutLesson.done":"common:close")})]})]})})}function X4(e){if(!e||e.status&&e.status!=="pending"||e.type!=="action"||Array.isArray(e.questions)&&e.questions.length>0)return!1;const t=e.details?.toolName;return typeof t=="string"&&t.length>0}function jK(e){return e.details?.agentId??e.agentId}function RK(e){const t=e.details??{};return[t.chatSessionId,t.sessionId].filter(n=>typeof n=="string"&&n.length>0)}function jle(e,t){const n=e.filter(l=>X4(l)&&jK(l)===t.agentId);if(!t.sessionId)return n;const a=[],i=[];for(const l of n)(RK(l).includes(t.sessionId)?a:i).push(l);return[...a,...i]}function _K(e){return Array.isArray(e.questions)&&e.questions.length>0}function Gh(e){if(!e)return null;try{const t=JSON.parse(e);return t&&typeof t=="object"?t:null}catch{return null}}function o2(e){const t={},n=e.split("?")[1];if(!n)return t;for(const[a,i]of new URLSearchParams(n).entries())t[a]=i;return t}function DK(e){if(e.actionType==="open_chat"||e.actionType==="navigate")return!0;const t=e.metadata??{};return!!(t.agentId||t.taskId||t.requirementId||t.projectId||t.channel||t.senderId||t.approvalId||t.sessionId)}function Kh(e,t={}){if(_K(e)){if(t.onOpenApproval){t.onOpenApproval(e);return}const a=e.details?.sessionId,i={};e.agentId&&(i.agentId=e.agentId),a&&(i.sessionId=a),yt.navigate(me.TEAM,Object.keys(i).length>0?i:void 0);return}const n=e.details;if(X4(e)&&e.agentId)return void yt.navigate(me.TEAM,{agentId:e.agentId});if(n?.taskId)return void yt.navigate(me.WORK,{openTask:n.taskId});if(n?.requirementId)return void yt.navigate(me.WORK,{openRequirement:n.requirementId});if(e.agentId)return void yt.navigate(me.TEAM,{agentId:e.agentId,preferMain:"1"});yt.navigate(me.WORK)}function J4(e){const t=e.metadata??{},n=a=>typeof a=="string"&&a.length>0?a:void 0;if(e.actionType==="open_chat"){const a=n(t.taskId),i=n(t.requirementId);if(a)return{page:"WORK",params:{openTask:a}};if(i)return{page:"WORK",params:{openRequirement:i}};const l=Gh(e.actionTarget),c=n(l?.agentId);if(c){const u={agentId:c},m=n(l?.sessionId);return m&&(u.sessionId=m),{page:"TEAM",params:u}}}if(e.actionType==="navigate"){const a=Gh(e.actionTarget),i=n(a?.path);if(i){if(i.startsWith("/team"))return{page:"TEAM",params:o2(i)};if(i.startsWith("/work"))return{page:"WORK",params:o2(i)};if(i.startsWith("/approvals/"))return null}}switch(e.type){case"approval_request":return null;case"task_completed":case"task_created":case"task_review":case"task_failed":{const a=n(t.taskId);return{page:"WORK",params:a?{openTask:a}:{}}}case"requirement_created":case"requirement_decision":{const a=n(t.requirementId);return{page:"WORK",params:a?{openRequirement:a}:{}}}case"agent_report":case"system":{if(t.creditExhausted||t.templateUpdates)return null;const a=n(t.agentId),i={};a&&(i.agentId=a);const l=n(t.sessionId);return l?i.sessionId=l:a&&(i.preferMain="1"),{page:"TEAM",params:i}}case"direct_message":{const a=n(t.senderId);return{page:"TEAM",params:a?{dm:a}:{}}}case"group_message":{const a=n(t.channel);return{page:"TEAM",params:a?{channel:a}:{}}}default:{const a=n(t.taskId);if(a)return{page:"WORK",params:{openTask:a}};const i=n(t.requirementId);if(i)return{page:"WORK",params:{openRequirement:i}};const l=n(t.projectId);if(l)return{page:"WORK",params:{projectId:l}};const c=n(t.agentId);return c?{page:"TEAM",params:{agentId:c}}:{page:"WORK",params:{}}}}}function IK(e,t={}){const n=J4(e);if(n){const l=Object.keys(n.params).length>0?n.params:void 0;return void yt.navigate(n.page==="WORK"?me.WORK:me.TEAM,l)}const a=e.metadata??{},i=l=>typeof l=="string"&&l.length>0?l:void 0;if(e.actionType==="navigate"){const l=Gh(e.actionTarget),c=i(l?.path);if(c?.startsWith("/approvals/")){const u=c.split("?")[0].split("/")[2],m=u?t.approvals?.find(f=>f.id===u):void 0;if(m)return Kh(m,t)}}if(e.type==="approval_request"){const l=i(a.approvalId),c=l?t.approvals?.find(g=>g.id===l):void 0;if(c)return Kh(c,t);const u=i(a.taskId);if(u)return void yt.navigate(me.WORK,{openTask:u});const m=i(a.requirementId);if(m)return void yt.navigate(me.WORK,{openRequirement:m});const f=i(a.agentId);return f?void yt.navigate(me.TEAM,{agentId:f,preferMain:"1"}):void yt.navigate(me.WORK)}if(a.creditExhausted){t.onCreditExhausted?.();return}if(a.templateUpdates){t.onTemplateUpdates?.();return}yt.navigate(me.WORK)}function l2(e){const t=e.metadata??{};return e.type==="agent_report"&&!t.creditExhausted&&!t.templateUpdates&&(e.actionType==="open_chat"||!!t.agentId&&e.actionType!=="navigate")}function c2(e){const t=e.metadata??{},n=l=>typeof l=="string"&&l.length>0?l:void 0,a=n(t.taskId),i=n(t.requirementId);return a?`task:${a}`:i?`req:${i}`:null}function Z4(e,t){const n=new Set,a=c2(e),i=a?t.filter(l=>!l.read&&c2(l)===a):[e];for(const l of i)l.read||l2(l)||n.add(l.id);!e.read&&!l2(e)&&n.add(e.id);for(const l of n)Te.notifications.markRead(l).catch(()=>{});return n.size>0&&window.dispatchEvent(new CustomEvent("markus:notifications-changed")),n}async function LK(e){const t=await Te.notifications.markAllRead(e);return rK("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),t?.count??0}const d2=6e4,u2=36e5,m2=864e5;function PK(e){if(!Number.isFinite(e))return"";const t=Date.now()-e;if(t<0||t<d2)return"刚刚";if(t<u2)return`${Math.floor(t/d2)} 分钟前`;if(t<m2)return`${Math.floor(t/u2)} 小时前`;const n=Math.floor(t/m2);return n===1?"昨天":`${n} 天前`}function OK(e){return typeof e=="number"?e:e?new Date(e).getTime():Number.NaN}function p2(e){return PK(OK(e))}function e5(e,t){if(e.blockedReason==="deps"||e.blockedReason==="hold"||e.blockedReason==="workflow")return e.blockedReason;const n=e.blockedBy??[];return n.length===0||t&&n.every(i=>t(i)?.status==="completed")?"hold":"deps"}function Rle(e,t){return e5(e,t)==="hold"}function Vh(e){return Array.isArray(e?.questions)&&e.questions.length>0}const f2={agent_question:0,approval_request:1,blocked_hold:2,task_failed:3,requirement_approval:4,task_review:5,unread_message:6},zK={urgent:0,high:1,medium:2,low:3};function h2(e){return zK[(e??"").toLowerCase()]??4}function Cs(e,t){return e&&e.length>0?e:t}function Ql(e,t){return t?e>t:!1}function g2(e){if(e.page!=="WORK")return[];const t=[],n=e.params.openTask,a=e.params.openRequirement;return n&&t.push(`task:${n}`),a&&t.push(`requirement:${a}`),t}function HK(e){const{tasks:t,requirements:n,approvals:a,notifications:i,taskById:l,lastSeenAt:c=null,includeUnread:u=!0,notifyTitle:m}=e,f=new Date(0).toISOString(),g=[],h=new Set;for(const y of a){if(y.status!=="pending")continue;const w=y.details??{},T={};let C="TEAM";w.taskId?(C="WORK",T.openTask=w.taskId,h.add(`task:${w.taskId}`)):w.requirementId&&(C="WORK",T.openRequirement=w.requirementId),y.agentId&&(T.agentId=y.agentId),C==="TEAM"&&(T.preferMain="1"),g.push({id:`approval:${y.id}`,kind:Vh(y)?"agent_question":"approval_request",title:y.title,priority:"none",waitingSince:Cs(y.requestedAt,f),waitingBasis:"requested",target:{page:C,params:T},isNew:Ql(Cs(y.requestedAt,f),c),...y.agentName?{meta:y.agentName}:{}})}for(const y of n){if(y.status!=="pending")continue;const w=Cs(y.createdAt,f);g.push({id:`requirement:${y.id}`,kind:"requirement_approval",title:y.title,priority:y.priority??"none",waitingSince:w,waitingBasis:"created",target:{page:"WORK",params:{openRequirement:y.id}},isNew:Ql(w,c)})}for(const y of t){if(y.status==="review"&&y.reviewerType==="human"){if(h.has(`task:${y.id}`))continue;const w=y.statusChangedAt,T=Cs(w??y.updatedAt??y.createdAt,f);g.push({id:`task:${y.id}`,kind:"task_review",title:y.title,priority:y.priority??"none",waitingSince:T,waitingBasis:w?"status":"approximate",target:{page:"WORK",params:{openTask:y.id}},isNew:Ql(T,c)});continue}if(y.status==="blocked"){if(e5(y,A=>l?.(A))!=="hold")continue;const T=y.statusChangedAt,C=Cs(T??y.updatedAt??y.createdAt,f);g.push({id:`blocked:${y.id}`,kind:"blocked_hold",title:y.title,priority:y.priority??"none",waitingSince:C,waitingBasis:T?"status":"approximate",target:{page:"WORK",params:{openTask:y.id}},isNew:Ql(C,c)});continue}if(y.status==="failed"){const w=y.statusChangedAt,T=Cs(w??y.updatedAt??y.createdAt,f);g.push({id:`failed:${y.id}`,kind:"task_failed",title:y.title,priority:y.priority??"none",waitingSince:T,waitingBasis:w?"status":"approximate",target:{page:"WORK",params:{openTask:y.id}},isNew:Ql(T,c)})}}const v=new Map;for(const y of g)for(const w of g2(y.target))v.has(w)||v.set(w,y);if(u)for(const y of i){if(y.read)continue;const w=Cs(y.createdAt,f),T=y.metadata??{},C=J4(y);let A;if(C)A=C;else{const K={},j=typeof T.agentId=="string"?T.agentId:void 0,z=typeof T.sessionId=="string"?T.sessionId:void 0;j&&(K.agentId=j),z?K.sessionId=z:j&&(K.preferMain="1"),A={page:"TEAM",params:K}}const M=g2(A),I=M.map(K=>v.get(K)).find(K=>!!K);if(I){I.notices=[...I.notices??[],y];continue}const B={id:`notice:${y.id}`,kind:"unread_message",title:m?m(y):y.title,priority:y.priority??"none",waitingSince:w,waitingBasis:"created",target:A,isNew:!0,notices:[y]};g.push(B);for(const K of M)v.set(K,B)}return g.sort((y,w)=>{if(y.waitingSince!==w.waitingSince)return y.waitingSince<w.waitingSince?-1:1;const T=h2(y.priority)-h2(w.priority);if(T!==0)return T;const C=f2[y.kind]-f2[w.kind];return C!==0?C:y.id<w.id?-1:y.id>w.id?1:0})}function BK(e){return e.filter(t=>t.kind!=="unread_message").length}function t5(e,t=Date.now()){const n=Date.parse(e.waitingSince);if(!Number.isFinite(n))return"—";const a=Math.max(0,t-n),i=Math.floor(a/6e4),l=Math.floor(i/60),c=Math.floor(l/24);let u;return i<1?u="<1 分钟":i<60?u=`${i} 分钟`:l<24?u=`${l} 小时`:c<30?u=l%24>0?`${c} 天 ${l%24} 小时`:`${c} 天`:u=">30 天",e.waitingBasis==="approximate"?`约 ${u}`:u}const b2={approved:{label:"已批准",dot:"bg-fg-muted/30",chip:"bg-green-500/8 text-green-600/70"},rejected:{label:"已拒绝",dot:"bg-fg-muted/30",chip:"bg-red-500/8 text-red-500/70"},cancelled:{label:"已取消",dot:"bg-fg-muted/25",chip:"bg-surface-overlay text-fg-tertiary"},expired:{label:"已过期",dot:"bg-fg-muted/25",chip:"bg-amber-500/8 text-amber-600/70"}},y2=15,n5="markus_history_ui";function v2(){try{const e=localStorage.getItem(n5);if(!e)return{tab:"all",scrollTop:0};const t=JSON.parse(e);return{tab:t.tab==="approvals"||t.tab==="notices"?t.tab:"all",scrollTop:typeof t.scrollTop=="number"&&t.scrollTop>=0?t.scrollTop:0}}catch{return{tab:"all",scrollTop:0}}}function $K(e){try{localStorage.setItem(n5,JSON.stringify(e))}catch{}}const x2=200;function qK(e){k.useEffect(()=>{if(!e)return;const t=[document.documentElement,document.body,document.querySelector("[data-app-scroll]")].filter(l=>!!l),n=t.map(l=>l.style.overflow),a=t.map(l=>l.style.paddingRight),i=window.innerWidth-document.documentElement.clientWidth;return t.forEach((l,c)=>{l.style.overflow="hidden",c===0&&i>0&&(l.style.paddingRight=`${i}px`),a[c]}),()=>{t.forEach((l,c)=>{l.style.overflow=n[c]??"",l.style.paddingRight=a[c]??""})}},[e])}function FK(e){return e.actionUrl&&!e.actionType?()=>window.open(e.actionUrl,"_blank","noopener"):DK(e)?()=>IK(e):null}function UK({open:e,onClose:t,userId:n}){const[a,i]=k.useState(()=>v2().tab),l=k.useRef(v2().scrollTop),[c,u]=k.useState([]),m=k.useRef(null),f=k.useRef(null),[g,h]=k.useState(0),[v,y]=k.useState(null),[w,T]=k.useState("loading"),[C,A]=k.useState("loading"),[M,I]=k.useState(0),[B,K]=k.useState([]),[j,z]=k.useState(!1),[U,Y]=k.useState(!1),[$,D]=k.useState(null),{t:W}=xt(["team"]),[X,H]=k.useState(!1),[se,R]=k.useState(!1),[re,ue]=k.useState(null),Ce=k.useRef(null),q=k.useRef({loading:!1,done:!1,count:0});q.current={loading:X,done:se,count:c.length};const V=k.useCallback(async Re=>{if(n){H(!0);try{const Xe=await Te.notifications.list(n,!1,{limit:y2,offset:Re}),wt=Xe.notifications??[];u(kt=>{const lt=new Set(kt.map(Dt=>Dt.id));return[...kt,...wt.filter(Dt=>!lt.has(Dt.id))].slice(0,x2)}),h(Xe.totalCount??0);const mt=Xe.unreadCount;y(typeof mt=="number"?mt:null),T(typeof mt=="number"?"ok":"error"),(wt.length===0||wt.length<y2||q.current.count+wt.length>=x2)&&R(!0),ue(null)}catch(Xe){ue(Xe instanceof Error?Xe.message:"读取失败"),T("error")}finally{H(!1)}}},[n]);k.useEffect(()=>{if(!e||!n)return;const Re=()=>{V(0),Te.approvals.list().then(Xe=>{K((Xe.approvals??[]).filter(wt=>wt.status==="pending")),A("ok")}).catch(()=>A("error"))};return window.addEventListener("markus:notifications-changed",Re),window.addEventListener("markus:data-changed",Re),()=>{window.removeEventListener("markus:notifications-changed",Re),window.removeEventListener("markus:data-changed",Re)}},[e,n,V]);const ce=k.useCallback(()=>{ue(null),T("loading"),A("loading"),I(Re=>Re+1)},[]),P=k.useCallback(async()=>{if(!(!n||U)){Y(!0),D(null);try{await LK(n),u(Re=>Re.map(Xe=>Xe.read?Xe:{...Xe,read:!0})),y(0),T("ok")}catch(Re){D(Re instanceof Error?Re.message:String(Re))}finally{Y(!1)}}},[n,U]);k.useEffect(()=>{!e||!n||(u([]),h(0),R(!1),ue(null),T("loading"),A("loading"),V(0),Te.approvals.list(void 0,{limit:100}).then(Re=>{K((Re.approvals??[]).filter(Xe=>Xe.status!=="pending")),A("ok")}).catch(()=>A("error")))},[e,n,V,M]),k.useEffect(()=>{if(!e)return;const Re=Ce.current;if(!Re||typeof IntersectionObserver>"u")return;const Xe=new IntersectionObserver(wt=>{const mt=q.current;!wt[0]?.isIntersecting||mt.loading||mt.done||V(mt.count)},{rootMargin:"120px"});return Xe.observe(Re),()=>Xe.disconnect()},[e,V,c.length]);const Ee=k.useMemo(()=>{const Re=B.map(mt=>({kind:"approval",at:mt.respondedAt??mt.requestedAt,approval:mt})),Xe=c.map(mt=>({kind:"notice",at:mt.createdAt,notice:mt})),wt=[...Re,...Xe].sort((mt,kt)=>(kt.at??"").localeCompare(mt.at??""));return j?wt.filter(mt=>mt.kind==="notice"&&!mt.notice.read):a==="approvals"?wt.filter(mt=>mt.kind==="approval"):a==="notices"?wt.filter(mt=>mt.kind==="notice"):wt},[B,c,a,j]),$e=B.length,qe=w==="ok"?v:null,Ze=Ee.length===0&&!X&&!re&&C!=="error"&&w!=="error",Qe=j&&w==="ok"&&qe===0&&(g>0||c.length>0);return qK(e),k.useEffect(()=>{if(!e)return;const Re=window.setTimeout(()=>{const Xe=m.current;Xe&&(Xe.scrollTop=l.current)},60);return()=>window.clearTimeout(Re)},[e,a]),e?o.jsx("div",{ref:f,className:"fixed inset-0 z-50 flex items-start justify-center bg-black/40 p-4 sm:p-6 overflow-hidden overscroll-none",onClick:t,children:o.jsxs("div",{className:"w-full max-w-lg h-[78vh] bg-surface-elevated rounded-2xl shadow-xl overflow-hidden flex flex-col mt-4",onClick:Re=>Re.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 pt-3.5 pb-2 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:"历史"}),w==="error"&&o.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded-full bg-rose-500/10 text-rose-600",children:"未读数未知(读取失败)"}),w==="loading"&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:"未读…"}),qe!==null&&qe>0&&o.jsxs("button",{onClick:()=>z(Re=>!Re),"aria-pressed":j,title:j?"显示全部":"只看未读",className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full tabular-nums transition-colors ${j?"bg-brand-500 text-on-brand":"text-brand-400 bg-brand-500/10 hover:bg-brand-500/20"}`,children:[qe," 条未读"]}),qe!==null&&j&&qe===0&&o.jsx("button",{onClick:()=>z(!1),className:"text-[10px] font-semibold text-fg-tertiary bg-surface-overlay px-1.5 py-0.5 rounded-full",children:"已全部读完·看全部"}),qe!==null&&qe>0&&o.jsx("button",{onClick:()=>{P()},disabled:U,"data-mark-all-read":!0,className:"text-[10px] font-medium text-fg-tertiary hover:text-fg-primary px-1.5 py-0.5 rounded-full hover:bg-surface-overlay transition-colors disabled:opacity-50",children:U?"…":W("team:notifications.markAllRead")})]}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay text-fg-tertiary","aria-label":"关闭",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"px-4 pb-2.5 shrink-0 flex items-center gap-1",children:[{id:"all",label:"全部",count:$e+c.length},{id:"approvals",label:"审批结果",count:$e},{id:"notices",label:"通知",count:c.length}].map(Re=>{const Xe=a===Re.id;return o.jsxs("button",{onClick:()=>i(Re.id),className:`px-2.5 py-1 rounded-full text-[11px] font-medium transition-colors flex items-center gap-1 ${Xe?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:[Re.label,Re.count>0&&o.jsx("span",{className:"tabular-nums text-fg-muted",children:Re.count})]},Re.id)})}),o.jsxs("div",{ref:m,onScroll:Re=>$K({tab:a,scrollTop:Re.currentTarget.scrollTop}),className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-thin px-2 pb-2",children:[$&&o.jsxs("div",{"data-mark-all-error":!0,className:"mx-1 mb-2 rounded-lg bg-rose-500/10 text-rose-600 text-[11px] px-3 py-2 flex items-center gap-2",children:[o.jsx("span",{className:"flex-1",children:W("team:notifications.markAllReadFailed")}),o.jsx("button",{onClick:()=>{P()},disabled:U,className:"shrink-0 rounded bg-rose-500/15 px-2 py-0.5 font-semibold hover:bg-rose-500/25 disabled:opacity-50",children:"重试"})]}),(re||C==="error")&&o.jsxs("div",{className:"mx-1 mb-2 rounded-lg bg-rose-500/10 text-rose-600 text-[11px] px-3 py-2 flex items-center gap-2",children:[o.jsx("span",{className:"flex-1",children:[re?`通知读取失败:${re}(这不等于「没有历史」)。`:null,C==="error"?"审批历史读取失败(不等于「没有审批」)。":null].filter(Boolean).join(" ")}),o.jsx("button",{onClick:ce,className:"shrink-0 rounded bg-rose-500/15 px-2 py-0.5 font-semibold hover:bg-rose-500/25",children:"重试"})]}),Ze&&(Qe?o.jsxs("div",{"data-empty-unread":!0,className:"px-3 py-10 text-center",children:[o.jsx("div",{className:"text-[12px] text-fg-secondary",children:W("team:notifications.noUnread")}),o.jsx("button",{onClick:()=>z(!1),className:"mt-2 rounded-full bg-surface-overlay px-2.5 py-1 text-[11px] text-fg-tertiary hover:text-fg-primary transition-colors",children:W("team:notifications.filterAll")})]}):o.jsxs("div",{className:"px-3 py-10 text-center",children:[o.jsx("div",{className:"text-[12px] text-fg-secondary",children:"还没有历史记录"}),o.jsx("div",{className:"text-[11px] text-fg-muted mt-1",children:"团队开始工作后,审批和通知会出现在这里"})]})),Ee.map(Re=>Re.kind==="approval"?(()=>{const Xe=b2[Re.approval.status]??b2.cancelled,wt=Re.approval.respondedAt??Re.approval.requestedAt;return o.jsxs("div",{onClick:()=>{t(),Kh(Re.approval)},title:"打开对应的任务 / 需求 / 会话",className:"flex items-center gap-2.5 px-2.5 py-2.5 rounded-xl hover:bg-surface-overlay/50 transition-colors cursor-pointer",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Xe.dot}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded shrink-0 ${Xe.chip}`,children:Xe.label}),o.jsx("span",{className:"text-xs text-fg-secondary truncate",children:Re.approval.title})]}),o.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5 truncate",children:[Re.approval.agentName," · ",Re.approval.status==="approved"?Vh(Re.approval)?"已答复":"已批准":Re.approval.status==="rejected"?Vh(Re.approval)?"未答复":"已拒绝":Xe.label," ","于 ",p2(wt),Re.approval.respondedAt&&Re.approval.requestedAt&&o.jsxs(o.Fragment,{children:[" · 等了 ",t5({waitingSince:Re.approval.requestedAt,waitingBasis:"requested"},Date.parse(Re.approval.respondedAt))]})]})]})]},`a:${Re.approval.id}`)})():(()=>{const Xe=FK(Re.notice);return o.jsxs("div",{title:Xe?void 0:"这条通知没有关联的任务 / 需求 / 会话,仅作告知",className:`flex items-start gap-2.5 px-2.5 py-2.5 rounded-xl transition-colors ${Xe?"hover:bg-surface-overlay/50 cursor-pointer":""}`,onClick:Xe?()=>{const wt=Z4(Re.notice,c);u(mt=>mt.map(kt=>wt.has(kt.id)?{...kt,read:!0}:kt)),t(),Xe()}:void 0,children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 ${Re.notice.read?"bg-fg-muted/40":"bg-brand-500"}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:`text-xs truncate ${Re.notice.read?"text-fg-tertiary":"text-fg-primary font-medium"}`,children:[Re.notice.title,!Xe&&o.jsx("span",{className:"ml-1.5 align-middle text-[10px] font-normal text-fg-muted",children:"仅告知"})]}),Re.notice.body&&o.jsx("div",{className:"text-[11px] text-fg-muted mt-0.5 line-clamp-2 leading-relaxed",children:Re.notice.body}),o.jsx("div",{className:"text-[10px] text-fg-muted mt-1",children:p2(Re.notice.createdAt)})]})]},`n:${Re.notice.id}`)})()),o.jsxs("div",{ref:Ce,className:"h-8 flex items-center justify-center",children:[X&&o.jsx("span",{className:"text-[11px] text-fg-muted",children:"加载中…"}),!X&&se&&c.length>0&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:"没有更早的记录了"})]})]})]})}):null}const a5="markus_attention_count",hm="markus:attention-count",r5="markus_attention_last_seen";function GK(){try{return localStorage.getItem(r5)}catch{return null}}function KK(e){try{localStorage.setItem(r5,e)}catch{}}function VK(e){try{localStorage.setItem(a5,String(e))}catch{}window.dispatchEvent(new CustomEvent(hm,{detail:{count:e}}))}function Gm(){return w2(a5)+w2(i5)}const i5="markus_unread_count";function w2(e){try{const t=localStorage.getItem(e),n=t===null?0:Number(t);return Number.isFinite(n)&&n>0?n:0}catch{return 0}}function WK(e){try{localStorage.setItem(i5,String(Math.max(0,e)))}catch{}window.dispatchEvent(new CustomEvent(hm,{detail:{count:Gm()}}))}function s5(e){const t=n=>{const a=n.detail;e(typeof a?.count=="number"?a.count:Gm())};return window.addEventListener(hm,t),()=>window.removeEventListener(hm,t)}function o5(e){const t=e.metadata;if(!(!t||typeof t.i18n!="object"||!t.i18n))return t.i18n}function YK(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function QK(e,t){const n=o5(e);if(!n?.titleKey)return e.title;const a={...n.titleParams??{}};return t(`team:${n.titleKey}`,{...a,defaultValue:e.title})}function _le(e,t){const n=o5(e);if(!n?.bodyKey)return e.body;const a={};for(const[i,l]of Object.entries(n.bodyParams??{}))if(i==="priority")a[i]=t(`common:priority.${l}`,{defaultValue:l});else if(i==="status"||i==="statusKey"){const c=YK(l);a[i]=t(`common:status.${l}`,{defaultValue:c===l?l:t(`common:status.${c}`,{defaultValue:l})})}else a[i]=l;return t(`team:${n.bodyKey}`,{...a,defaultValue:e.body})}const l5={code:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"16 18 22 12 16 6"}),o.jsx("polyline",{points:"8 6 2 12 8 18"})]}),search:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("path",{d:"m21 21-4.3-4.3"})]}),clipboard:o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),o.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":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]}),server:o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),o.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),o.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),o.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),"file-text":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),o.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),o.jsx("path",{d:"M10 9H8"}),o.jsx("path",{d:"M16 13H8"}),o.jsx("path",{d:"M16 17H8"})]}),"book-open":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 7v14"}),o.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:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),o.jsx("circle",{cx:"9",cy:"7",r:"4"}),o.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),o.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"dollar-sign":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"}),o.jsx("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]}),megaphone:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m3 11 18-5v12L3 14v-3z"}),o.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]}),edit:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 20h9"}),o.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),headphones:o.jsx(o.Fragment,{children:o.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:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),target:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("circle",{cx:"12",cy:"12",r:"6"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),zap:o.jsx(o.Fragment,{children:o.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),terminal:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"4 17 10 11 4 5"}),o.jsx("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]}),sparkles:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"M20 3v4"}),o.jsx("path",{d:"M22 5h-4"})]}),wrench:o.jsx(o.Fragment,{children:o.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:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),o.jsx("path",{d:"M2 12h20"})]}),link:o.jsxs(o.Fragment,{children:[o.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"}),o.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:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 8V4H8"}),o.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),o.jsx("path",{d:"M2 14h2"}),o.jsx("path",{d:"M20 14h2"}),o.jsx("path",{d:"M15 13v2"}),o.jsx("path",{d:"M9 13v2"})]}),"message-square":o.jsx(o.Fragment,{children:o.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:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"M18 14h-8"}),o.jsx("path",{d:"M15 18h-5"}),o.jsx("path",{d:"M10 6h8v4h-8V6Z"})]}),layers:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}),o.jsx("path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"})]}),"bar-chart":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),o.jsx("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),o.jsx("line",{x1:"6",x2:"6",y1:"20",y2:"16"})]}),folder:o.jsx(o.Fragment,{children:o.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":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),o.jsx("circle",{cx:"18",cy:"6",r:"3"}),o.jsx("circle",{cx:"6",cy:"18",r:"3"}),o.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),save:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),o.jsx("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]}),camera:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),clock:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),database:o.jsxs(o.Fragment,{children:[o.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),o.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),o.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]}),lightbulb:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"M9 18h6"}),o.jsx("path",{d:"M10 22h4"})]}),"alert-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),o.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),"square-terminal":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m7 11 2-2-2-2"}),o.jsx("path",{d:"M11 13h4"}),o.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]}),package:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m7.5 4.27 9 5.15"}),o.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"}),o.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),o.jsx("path",{d:"M12 22V12"})]}),inbox:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),o.jsx("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]}),"circle-pause":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"10",x2:"10",y1:"15",y2:"9"}),o.jsx("line",{x1:"14",x2:"14",y1:"15",y2:"9"})]}),"circle-x":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"m15 9-6 6"}),o.jsx("path",{d:"m9 9 6 6"})]}),"clipboard-check":o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),o.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"}),o.jsx("path",{d:"m9 14 2 2 4-4"})]}),"file-check":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),o.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),o.jsx("path",{d:"m9 15 2 2 4-4"})]}),bell:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),o.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]}),"help-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),o.jsx("path",{d:"M12 17h.01"})]})};function XK(e){return!!e&&e in l5}function c5({name:e,size:t=24,className:n=""}){const a=l5[e];return a?o.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":!0,children:a}):null}const k2={"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"},S2={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Gu(e,t){const n=(e||"").toLowerCase();return k2[n]?k2[n]:t&&S2[t]?S2[t]:"layers"}const Tn={attention:{chip:"bg-violet-500/15 text-violet-500",dot:"bg-violet-500",solid:"bg-violet-500",text:"text-violet-500",border:"border-violet-500/40",surface:"bg-violet-500/[0.06]",btn:"bg-violet-500/10 text-violet-500 hover:bg-violet-500/20",hex:"#8b5cf6"},active:{chip:"bg-blue-500/15 text-blue-500",dot:"bg-blue-500",solid:"bg-blue-500",text:"text-blue-500",border:"border-blue-500/40",surface:"bg-blue-500/[0.06]",btn:"bg-blue-500/10 text-blue-500 hover:bg-blue-500/20",hex:"#3b82f6"},blocked:{chip:"bg-orange-500/15 text-orange-500",dot:"bg-orange-500",solid:"bg-orange-500",text:"text-orange-500",border:"border-orange-500/40",surface:"bg-orange-500/[0.06]",btn:"bg-orange-500/10 text-orange-500 hover:bg-orange-500/20",hex:"#f97316"},success:{chip:"bg-green-500/15 text-green-600",dot:"bg-green-500",solid:"bg-green-500",text:"text-green-600",border:"border-green-500/30",surface:"bg-green-500/[0.06]",btn:"bg-green-500/10 text-green-600 hover:bg-green-500/20",hex:"#22c55e"},danger:{chip:"bg-red-500/15 text-red-500",dot:"bg-red-500",solid:"bg-red-500",text:"text-red-500",border:"border-red-500/40",surface:"bg-red-500/[0.06]",btn:"bg-red-500/10 text-red-500 hover:bg-red-500/20",hex:"#ef4444"},neutral:{chip:"bg-gray-500/15 text-fg-tertiary",dot:"bg-gray-400",solid:"bg-gray-500",text:"text-fg-tertiary",border:"border-border-default/60",surface:"bg-surface-elevated/60",btn:"bg-surface-overlay text-fg-secondary hover:bg-surface-overlay/70",hex:"#6b7280"}};function Km(e,t){return t&&e[t]||"neutral"}const JK={pending:"neutral",in_progress:"active",blocked:"blocked",review:"attention",revision:"active",completed:"success",failed:"danger",rejected:"danger",cancelled:"neutral",archived:"neutral"},ZK={pending:"attention",in_progress:"active",completed:"success",rejected:"danger",cancelled:"neutral",archived:"neutral"},eV={active:"active",in_progress:"active",planning:"neutral",paused:"blocked",blocked:"blocked",completed:"success",archived:"neutral",cancelled:"neutral"},tV={draft:"neutral",pending:"neutral",submitted:"attention",in_review:"attention",review:"attention",approved:"success",published:"success",rejected:"danger",archived:"neutral"};function Pc(e){return Km(JK,e)}function nV(e){return Km(ZK,e)}function aV(e){return Km(eV,e)}function rV(e){return Km(tV,e)}function iV(e,t){switch(e){case"task":return Pc(t);case"requirement":return nV(t);case"project":return aV(t);case"deliverable":return rV(t);default:return"neutral"}}const sV={pending:"pending",in_progress:"inProgress",blocked:"blocked",review:"review",completed:"completed",failed:"failed",rejected:"rejected",cancelled:"cancelled",archived:"archived"};function d5(e){return e==="hold"?"hold":e==="workflow"?"workflow":"deps"}const oV={deps:"waitingDeps",hold:"onHold",workflow:"workflowPaused"},lV={deps:{chip:Tn.neutral.chip,dot:Tn.neutral.dot,bar:Tn.neutral.dot,card:`${Tn.neutral.surface} border-border-default/60`},hold:{chip:Tn.blocked.chip,dot:Tn.blocked.dot,bar:Tn.blocked.dot,card:`${Tn.blocked.surface} border-orange-500/30 ring-1 ring-orange-500/15`},workflow:{chip:Tn.neutral.chip,dot:Tn.neutral.dot,bar:Tn.neutral.dot,card:`${Tn.neutral.surface} border-border-default/60`}};function Wh(e,t,n){if(!e)return"—";if(e==="blocked"&&n!==void 0&&n!==null)return t(`common:taskStatus.${oV[d5(n)]}`);const a=sV[e];return a?t(`common:taskStatus.${a}`):e}function cV(e,t,n){const a=Wh(e,t,n);return e==="blocked"&&n!==void 0&&n!==null?{label:a,tone:lV[d5(n)]}:{label:a,tone:null}}function Dle(e,t){return t(`agent:profilePage.mind.attention.${e}`)}const dV={idle:"idle",working:"working",online:"online",offline:"offline",paused:"paused",error:"error"};function Ile(e,t){const n=dV[e];return n?t(`common:processStatus.${n}`):e}function u5(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function gm(e){return e.toLocaleString(void 0,{maximumFractionDigits:0})}function uV(e,t,n){const[a,i]=k.useState([]),[l,c]=k.useState(null),[u,m]=k.useState(null),[f,g]=k.useState(nt.isAuthenticated()),h=k.useCallback(async()=>{try{const w=await Te.usage.agents();i(w.agents)}catch{}},[]),v=k.useCallback(async()=>{if(!nt.isAuthenticated()){g(!1),m(null);return}g(!0);try{const[w,T]=await Promise.all([nt.user.plan(),Te.hubOrgs.mine().catch(()=>null)]);c(w);const C=T?.orgs?.find(A=>A.id===w.orgId)??T?.orgs?.[0];m(C?{role:C.role,memberCount:C.memberCount??1}:null)}catch{}},[]);return k.useEffect(()=>{if(!e)return;h(),v();const w=setInterval(h,3e4),T={at:0},C=15e3,A=()=>{const M=Date.now();M-T.at<C||(T.at=M,h(),v())};return window.addEventListener("markus:data-changed",A),()=>{clearInterval(w),window.removeEventListener("markus:data-changed",A)}},[e,h,v]),{contributors:k.useMemo(()=>{const w=[],T=new Map;for(const A of n)for(const M of A.members)T.set(M.id,A.name);const C=new Map((t?.agentEfficiency??[]).map(A=>[A.agentId,A]));for(const A of a){const M=C.get(A.agentId),I=A.cuUsed??0,B=A.totalTokens,K=M?.taskMetrics.completed??0,j=B>0?K/B*1e3:K>0?1/0:0;w.push({id:A.agentId,name:A.agentName,type:"agent",role:A.role,teamName:T.get(A.agentId),status:A.status,tasksCompleted:K,tasksFailed:M?.taskMetrics.failed??0,cuUsed:I,cuUsedToday:A.cuUsedToday??0,totalTokens:B,tokensToday:A.tokensUsedToday,requestCount:A.requestCount,toolCalls:A.toolCalls,healthScore:M?.healthScore??0,efficiency:j,provider:A.provider})}return w.sort((A,M)=>M.cuUsed+M.tasksCompleted*100-(A.cuUsed+A.tasksCompleted*100)===0?M.totalTokens-A.totalTokens:M.cuUsed+M.tasksCompleted*100-(A.cuUsed+A.tasksCompleted*100)),w},[a,t,n]),hubPlan:l,hubOrgMeta:u,hubConnected:f}}function Yh({title:e,badge:t,children:n}){const{t:a}=xt("home"),[i,l]=k.useState(!1);return o.jsxs("section",{className:`bg-surface-elevated shadow-sm rounded-2xl ${i?"overflow-visible":"overflow-hidden"}`,children:[o.jsxs("button",{type:"button",onClick:()=>l(c=>!c),className:"w-full px-4 sm:px-5 py-3.5 flex items-center justify-between gap-3 hover:bg-surface-overlay/40 transition-colors text-left rounded-2xl","aria-expanded":i,children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate",children:e}),t]}),o.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-fg-tertiary shrink-0",children:[o.jsx("span",{className:"hidden sm:inline",children:a(i?"usage.trends.collapse":"usage.trends.expand")}),o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${i?"rotate-180":""}`,children:o.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),i&&o.jsx("div",{className:"rounded-b-2xl overflow-visible",children:n})]})}function mV({hubConnected:e,hubPlan:t,hubOrgMeta:n}){const{t:a}=xt("home"),i=mr();if(!e)return o.jsxs("div",{className:"px-4 sm:px-5 pb-4 flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-500 shrink-0"}),o.jsx("span",{className:"text-sm text-fg-tertiary",children:a("usage.quota.notConnected")})]}),o.jsx("button",{onClick:()=>nt.ensureAuth().catch(()=>{}),className:"px-3 py-1.5 text-xs font-medium bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors shrink-0",children:a("usage.quota.connect")})]});if(!t)return o.jsx("div",{className:"px-4 sm:px-5 pb-4 text-sm text-fg-tertiary",children:a("usage.trends.noData")});const l=t.memberCuLimit!=null&&t.memberCuLimit>0,c=!n||n.role==="owner"||n.role==="admin"||n.memberCount<=1,u=l&&!c,m=(t.monthlyQuotaCu??0)+(t.bonusCu??0)+(t.purchasedCu??0),f=u?t.memberCuLimit:t.creditsBudgetCu??(l?t.memberCuLimit:m),g=u?t.memberCuUsed??0:t.totalConsumedThisPeriod??t.memberCuUsed??0,h=f>0?Math.min(100,Math.round(g/f*100)):0,v=h>90?"bg-red-500":h>70?"bg-amber-500":"bg-brand-500",y=()=>{Or(`${nt.getUrl().replace(/\/$/,"")}/settings?tab=billing`)};return o.jsxs("div",{className:"px-4 sm:px-5 pb-4",children:[u&&o.jsx("div",{className:"mb-2 px-3 py-1.5 rounded-lg text-[10px] bg-amber-500/8 text-amber-500/80 border border-amber-500/15",children:a("usage.quota.personalLimit")}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:a(l&&!c?"usage.quota.personalLimitLabel":"usage.quota.title")}),o.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] font-medium bg-brand-500/10 text-brand-500 uppercase shrink-0",children:t.planType}),i?.username&&o.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:a("usage.quota.connectedAs",{username:i.username})})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 text-[10px] text-fg-tertiary",children:[o.jsx("span",{children:t.cuResetAt?a("usage.quota.resetsAt",{date:new Date(t.cuResetAt).toLocaleDateString()}):""}),o.jsx("button",{type:"button",className:"px-2 py-1 bg-brand-600 text-on-brand rounded hover:bg-brand-500 transition-colors font-medium",onClick:w=>{w.stopPropagation(),y()},children:a("usage.quota.topUp")})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex-1 h-2 bg-surface-overlay rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full transition-all ${v}`,style:{width:`${h}%`}})}),o.jsxs("span",{className:"text-xs text-fg-secondary tabular-nums shrink-0",children:[gm(g)," / ",gm(f)]})]})]})}function pV({contributors:e}){const{t}=xt("home"),[n,a]=k.useState("totalTokens"),[i,l]=k.useState(!0),[c,u]=k.useState(!1),m=10,f=A=>{n===A?l(!i):(a(A),l(!0))},g=k.useMemo(()=>[...e].sort((A,M)=>{const I=A[n]===1/0?999999:A[n],B=M[n]===1/0?999999:M[n];return i?B-I:I-B}),[e,n,i]),h=c?g:g.slice(0,m),v=Math.max(1,...e.map(A=>A.totalTokens)),y=e.some(A=>A.cuUsed>0),w=new Set(e.filter(A=>A.provider).map(A=>A.provider)),C=w.size>1||w.size===1&&!w.has("markus")?o.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-overlay px-2 py-0.5 rounded shrink-0",children:t("usage.agents.mixedProviders")}):void 0;return e.length===0?o.jsx(Yh,{title:t("usage.agents.title"),children:o.jsx("div",{className:"px-4 sm:px-5 pb-6 text-center",children:o.jsx("p",{className:"text-sm text-fg-tertiary",children:t("usage.agents.noData")})})}):o.jsxs(Yh,{title:t("usage.agents.title"),badge:C,children:[o.jsx("div",{className:"overflow-x-auto scrollbar-thin border-t border-border-default",children:o.jsxs("table",{className:"w-full min-w-[520px]",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium w-8",children:"#"}),o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium",children:t("usage.agents.name")}),o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium hidden sm:table-cell",children:t("usage.agents.team")}),o.jsx(ru,{label:t("usage.agents.tasks"),col:"tasksCompleted",current:n,desc:i,onSort:f}),o.jsx(ru,{label:t("usage.agents.tokens"),col:"totalTokens",current:n,desc:i,onSort:f}),y&&o.jsx(ru,{label:t("usage.agents.cuUsed"),col:"cuUsed",current:n,desc:i,onSort:f}),o.jsx(ru,{label:t("usage.agents.efficiency"),col:"efficiency",current:n,desc:i,onSort:f,align:"right"})]})}),o.jsx("tbody",{children:h.map((A,M)=>o.jsx(fV,{contributor:A,rank:M+1,maxTokens:v,showCu:y},A.id))}),o.jsx("tfoot",{children:o.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[o.jsx("td",{colSpan:2,className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary sm:hidden",children:t("usage.agents.total",{count:e.length})}),o.jsx("td",{colSpan:3,className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary hidden sm:table-cell",children:t("usage.agents.total",{count:e.length})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:e.reduce((A,M)=>A+M.tasksCompleted,0)}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:u5(e.reduce((A,M)=>A+M.totalTokens,0))}),y&&o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:gm(e.reduce((A,M)=>A+M.cuUsed,0))}),o.jsx("td",{})]})})]})}),g.length>m&&o.jsx("button",{type:"button",onClick:()=>u(A=>!A),className:"w-full px-4 py-2.5 text-xs font-medium text-brand-500 hover:bg-surface-overlay/40 border-t border-border-default transition-colors",children:c?t("usage.agents.showLess"):t("usage.agents.showAll",{count:g.length})})]})}function fV({contributor:e,rank:t,maxTokens:n,showCu:a}){const i=n>0?Math.min(100,e.totalTokens/n*100):0,l=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="error"?"bg-red-500":"bg-gray-500",c=e.tasksCompleted===0?"—":e.totalTokens>0?`${e.efficiency.toFixed(1)}`:"∞",u=t<=3?`${t===1?"text-amber-500":t===2?"text-gray-400":"text-amber-700"} font-bold`:"text-fg-tertiary",m=e.provider==="markus"?"":e.provider??"";return o.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>yt.navigate(me.TEAM,{selectAgent:e.id}),children:[o.jsx("td",{className:`px-3 sm:px-4 py-3 text-sm tabular-nums ${u}`,children:t}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("div",{className:`w-2 h-2 rounded-full ${l} shrink-0`}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:e.name}),m&&o.jsx("span",{className:"px-1 py-0.5 rounded text-[8px] font-medium bg-surface-overlay text-fg-tertiary shrink-0",children:m})]}),o.jsxs("div",{className:"text-[10px] text-fg-tertiary truncate",children:[e.role,o.jsx("span",{className:"sm:hidden",children:e.teamName?` · ${e.teamName}`:""})]})]})]})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-xs text-fg-tertiary hidden sm:table-cell",children:e.teamName||"—"}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:e.tasksCompleted}),e.tasksFailed>0&&o.jsxs("span",{className:"text-[10px] text-red-500 tabular-nums",children:["(",e.tasksFailed,")"]})]})}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-overlay rounded-full overflow-hidden max-w-[80px] hidden md:block",children:o.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${i}%`}})}),o.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:u5(e.totalTokens)})]})}),a&&o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.cuUsed>0?gm(e.cuUsed):o.jsx("span",{className:"text-fg-tertiary",children:"—"})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-right",children:o.jsx("span",{className:`text-sm font-medium tabular-nums ${e.tasksCompleted===0?"text-fg-tertiary":e.efficiency>5?"text-green-500":e.efficiency>1?"text-fg-secondary":"text-amber-500"}`,children:c})})]})}function ru({label:e,col:t,current:n,desc:a,onSort:i,align:l}){const c=n===t?a?"↓":"↑":"↕",u=n===t?"text-brand-500":"text-fg-muted";return o.jsxs("th",{className:`px-3 sm:px-4 py-3 ${l==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>i(t),children:[e,o.jsx("span",{className:`ml-1 ${u}`,children:c})]})}function hV({contributors:e,hubPlan:t,hubOrgMeta:n,hubConnected:a,showMarkusUsage:i}){const{t:l}=xt("home");return o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-tertiary px-0.5",children:l("usage.sectionTitle")}),i&&o.jsx(Yh,{title:l("usage.creditsTitle"),children:o.jsx(mV,{hubConnected:a,hubPlan:t,hubOrgMeta:n})}),o.jsx(pV,{contributors:e})]})}const gV="(max-width: 767px)";let _f=null;function m5(){return _f||(_f=window.matchMedia(gV)),_f}function bV(e){const t=m5();return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function yV(){return m5().matches}function vV(){return!1}const xV=k.createContext(!1);function Yo(){const e=k.useContext(xV),t=k.useSyncExternalStore(bV,yV,vV);return e?!1:t}const wV="markus_onboarded";function Wg(e){return`markus_onboarded_${e}`}function p5(e){return`markus_checklist_dismissed_${e}`}function Qh(e){try{return localStorage.getItem(Wg(e))!==null?!0:localStorage.getItem(wV)!==null}catch{return!1}}function Xh(e){try{localStorage.setItem(Wg(e),"1")}catch{}}function C2(e){try{localStorage.removeItem(Wg(e))}catch{}}function kV(e){try{return localStorage.getItem(p5(e))==="true"}catch{return!1}}function SV(e){try{localStorage.setItem(p5(e),"true")}catch{}}function A2(e){return{configured:Object.values(e.providers).some(t=>t.configured),markus:!!e.providers.markus?.configured,providerLabel:e.providers[e.defaultProvider]?.displayName??e.defaultProvider??""}}const CV=Object.fromEntries(["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"].map(e=>[e,Tn[Pc(e)].hex])),AV=e=>Tn[Pc(e)].dot,f5=["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"],Df={agent_question:{tone:"attention",iconName:"help-circle"},approval_request:{tone:"attention",iconName:"check-circle"},requirement_approval:{tone:"attention",iconName:"file-check"},task_review:{tone:"attention",iconName:"clipboard-check"},blocked_hold:{tone:"blocked",iconName:"circle-pause"},task_failed:{tone:"danger",iconName:"circle-x"},unread_message:{tone:"neutral",iconName:"message-square"}},T2={urgent:Tn.danger.chip,high:"bg-surface-overlay text-fg-secondary font-semibold",medium:"bg-surface-overlay text-fg-secondary",low:"bg-surface-overlay text-fg-tertiary",none:"bg-surface-overlay text-fg-tertiary"},TV=Object.fromEntries(["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"].map(e=>[e,Tn[Pc(e)].chip])),E2={"Heartbeat check-in":"agentFocus.heartbeatCheckIn","Heartbeat check-in (idle skip)":"agentFocus.heartbeatSkip"},EV={thinking:`${Tn.active.dot} animate-pulse`,running:`${Tn.active.dot} animate-pulse`,"waiting-dependency":`${Tn.blocked.dot} animate-pulse`,blocked:`${Tn.danger.dot} animate-pulse`,degraded:`${Tn.danger.dot} animate-pulse`,error:"bg-red-500 animate-pulse",idle:"bg-green-400",offline:"bg-gray-400"},N2={thinking:"agentFocus.phaseThinking",running:"agentFocus.phaseRunning","waiting-dependency":"agentFocus.phaseWaitingDep",blocked:"agentFocus.phaseBlocked",degraded:"agentFocus.phaseDegraded",error:"agentFocus.phaseError"};function M2({authUser:e,previewMode:t,previewData:n}={}){const{t:a}=xt(["home","common","team"]),i=Yo(),l=hK(me.HOME),[c,u]=k.useState(!1);k.useEffect(()=>qG(()=>u(!0)),[]);const[m,f]=k.useState(n?.agents??[]),[g,h]=k.useState(n?.teams??[]),[v,y]=k.useState(n?.board??{}),[w,T]=k.useState(n?.boardCounts??{}),[C,A]=k.useState(n?.ops??null),M="7d",[I,B]=k.useState(n?.requirements??[]),[K,j]=k.useState(n?.projects??[]),[z,U]=k.useState(n?.deliverableTotal??0),[Y,$]=k.useState([]),[D,W]=k.useState(n?.storageInfo??null),[X,H]=k.useState(n?.usageInfo??null),[se,R]=k.useState(null),[re,ue]=k.useState(!1),[Ce,q]=k.useState(!1),[V,ce]=k.useState(!1),[P,Ee]=k.useState(null),[$e,qe]=k.useState(!1),[Ze,Qe]=k.useState(""),[Re,Xe]=k.useState(!1),[wt,mt]=k.useState(null),[kt,lt]=k.useState(!1),Dt=k.useRef(!1);Dt.current=kt;const[ht,Oe]=k.useState(!1),[Nt,Gt]=k.useState(()=>e?.id?Vg(e.id):!1),ie=e?.id,[et,at]=k.useState(()=>e?.id?Qh(e.id)||e.preferences?.guideHidden===!0:!0),[,ye]=k.useState(0),Ne=ie?kV(ie):!1,[De,te]=k.useState(!1),[F,ae]=k.useState(!1),we=k.useRef(null);k.useEffect(()=>{const J=()=>Gt(!0);return window.addEventListener("markus:shortcut-lesson-complete",J),()=>window.removeEventListener("markus:shortcut-lesson-complete",J)},[Gt]);const Le=k.useCallback(()=>{Xe(!0),Te.cu.status().then(R).catch(()=>{}),Te.settings.getLlm().then(J=>{const xe=A2(J);Ee(xe.configured),qe(xe.markus),Qe(xe.providerLabel)}).catch(()=>{}),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("markus:data-changed"))},800)},[]);k.useEffect(()=>{if(!re)return;const J=xe=>{we.current&&!we.current.contains(xe.target)&&ue(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[re]),k.useEffect(()=>{!t||!n||(n.agents&&f(n.agents),n.teams&&h(n.teams),n.board&&y(n.board),n.boardCounts&&T(n.boardCounts),A(n.ops??null),B(n.requirements??[]),j(n.projects??[]),U(n.deliverableTotal??0),n.storageInfo&&W(n.storageInfo),n.usageInfo&&H(n.usageInfo))},[t,n]);const He=k.useCallback(()=>{const J=Te.agents.list().then(Rt=>{f(Rt.agents);const Ht=Rt.agents.find(on=>on.role==="secretary")??Rt.agents.find(on=>on.name?.toLowerCase().includes("secretary"));Ht&&Te.sessions.listByAgent(Ht.id,20).then(async on=>{if(on.sessions.length===0){te(!1);return}const Zn=ie?on.sessions.filter(Ar=>Ar.userId===ie):on.sessions;if(Zn.length===0){te(!1);return}const da=await Te.sessions.getMessages(Zn[0].id,1);te(da.messages.length>0)}).catch(()=>{})}).catch(()=>{}),xe=Te.teams.list().then(Rt=>h(Rt.teams)).catch(()=>{});Te.tasks.boardSummary().then(Rt=>{y(Rt.board),T(Rt.counts)}).catch(()=>{}),Te.ops.dashboard(M).then(A).catch(()=>{});const st=Te.requirements.list({lean:!0}).then(Rt=>B(Rt.requirements)).catch(()=>{}),Mt=Te.projects.list().then(Rt=>j(Rt.projects)).catch(()=>{});Te.deliverables.search({limit:18}).then(Rt=>{U(Rt.total);const Ht=new Map;for(const on of Rt.results){const Zn=on.reference,da=Ht.get(Zn);(!da||on.updatedAt>da.updatedAt)&&Ht.set(Zn,on)}$([...Ht.values()].sort((on,Zn)=>Zn.updatedAt.localeCompare(on.updatedAt)).slice(0,6))}).catch(()=>{}),Te.usage.summary().then(Rt=>H(Rt.usage)).catch(()=>{}),Te.cu.status().then(R).catch(()=>{});const en=Te.settings.getLlm().then(Rt=>{const Ht=A2(Rt);Ee(Ht.configured),qe(Ht.markus),Qe(Ht.providerLabel)}).catch(()=>{}),Sn=Te.settings.getBrowser().then(Rt=>{mt(Rt.extensionConnected)}).catch(()=>{}),zn=sK().then(Rt=>{if(!Rt&&!kn()){Xe(!1);return}return nt.user.claimFreeCreditsStatus().then(Ht=>Xe(!!Ht.claimed)).catch(()=>{})}).catch(()=>{});Promise.race([Promise.allSettled([J,xe,st,Mt,en,Sn,zn]),new Promise(Rt=>setTimeout(Rt,8e3))]).then(()=>{ae(!0)})},[M,ie]);k.useEffect(()=>{!V||D||Te.system.storage().then(W).catch(()=>{})},[V,D]);const de=k.useCallback(()=>{ie&&(Xh(ie),at(!0),Te.auth.updatePreferences({guideHidden:!0}).catch(()=>{}))},[ie]),fe=k.useCallback(J=>{const xe=m.find(st=>st.role==="secretary")??m.find(st=>st.name?.toLowerCase().includes("secretary"));yt.navigate(me.TEAM,{...xe?{agentId:xe.id}:{},prefillMessage:J})},[m]),ct=!!kn()||$e,We=P===!0||$e,ut=[...ct?[{id:"claim",done:Re,isSetup:!0,label:a("checklist.setup.claim"),desc:a("checklist.setup.claimDesc"),action:a("checklist.setup.claimAction"),onClick:()=>{lt(!0)}}]:[],{id:"llm",done:We,isSetup:!0,label:a("checklist.setup.llm"),desc:We&&Ze?a("checklist.setup.llmDescConfigured",{provider:Ze}):a(ct?"checklist.setup.llmDescHub":"checklist.setup.llmDesc"),action:a("checklist.setup.llmAction"),onClick:()=>{window.location.hash="#settings/providers"}},{id:"browser",done:wt===!0,isSetup:!0,optional:!0,label:a("checklist.setup.browser"),desc:a("checklist.setup.browserDesc"),action:a("checklist.setup.browserAction"),onClick:()=>{window.location.hash="#settings/browser"}}],Ft=[{id:"greet",done:De,label:a("checklist.explore.greet"),desc:a("checklist.explore.greetDesc"),action:a("checklist.explore.greetAction"),onClick:()=>fe("你好!我是新用户,请简单介绍一下你能帮我做什么?")},{id:"project",done:ie?K.some(J=>J.createdBy===ie):K.length>0,label:a("checklist.explore.project"),desc:a("checklist.explore.projectDesc"),action:a("checklist.explore.projectAction"),onClick:()=>fe("帮我创建一个名为「Markus探索」的项目,用于了解和体验Markus的各项能力")},{id:"requirements",done:ie?I.some(J=>J.createdBy===ie):I.length>0,label:a("checklist.explore.requirements"),desc:a("checklist.explore.requirementsDesc"),action:a("checklist.explore.requirementsAction"),onClick:()=>fe("在「Markus探索」项目中创建两个需求:1. 了解Markus开源项目的架构和设计理念 2. 探索Markus智能体的能力和使用方式")},{id:"team",done:g.length>0,label:a("checklist.explore.team"),desc:a("checklist.explore.teamDesc"),action:a("checklist.explore.teamAction"),onClick:()=>fe("帮我组建一个名为「科技前沿智库」的团队,成员包括4位科技领袖角色的智能体:埃隆·马斯克(关注太空、电动车、AI安全)、史蒂夫·乔布斯(关注产品设计与用户体验)、山姆·奥特曼(关注AGI与AI创业生态)、黄仁勋(关注GPU、AI算力与数据中心)。团队目标是从不同视角分析科技前沿趋势。")},{id:"shortcuts",done:Nt,label:a("checklist.explore.shortcuts"),desc:a("checklist.explore.shortcutsDesc"),action:a("checklist.explore.shortcutsAction"),onClick:()=>Oe(!0)}],ln=[...ut,...Ft],Pt=ln.filter(J=>J.done).length,Ae=ln.length,je=ut.filter(J=>!J.optional).every(J=>J.done)&&Ft.every(J=>J.done),_e=ut.some(J=>!J.optional&&!J.done),Q=()=>{ie&&(SV(ie),_e?ye(J=>J+1):de())};k.useEffect(()=>{!F||et||je&&de()},[F,et,je,de]),k.useEffect(()=>{if(t||!l)return;He();const J=setInterval(He,6e4),xe={at:0},st=15e3,Mt=()=>{const Sn=Date.now();Sn-xe.at<st||(xe.at=Sn,He())},en=()=>{if(Dt.current){nt.user.claimFreeCreditsStatus().then(Sn=>Xe(!!Sn.claimed)).catch(()=>{});return}He()};return window.addEventListener("markus:data-changed",Mt),window.addEventListener("markus:hub-auth",en),()=>{clearInterval(J),window.removeEventListener("markus:data-changed",Mt),window.removeEventListener("markus:hub-auth",en)}},[t,M,l,He]);const he={},Se=Object.keys(w).length>0?w:Object.fromEntries(Object.entries(v).map(([J,xe])=>[J,xe.length]));for(const[J,xe]of Object.entries(Se))J!=="archived"&&xe>0&&(he[J]=xe);const Ye=he.completed??0,bt=Object.values(he).reduce((J,xe)=>J+xe,0),it=m.filter(J=>{const xe=J.runtime?.phase;return xe?xe!=="idle"&&xe!=="offline":J.status==="working"}).length,tt=K.filter(J=>J.status==="active").length,St=bt>0?Math.round(Ye/bt*100):0,gn=f5.filter(J=>(he[J]??0)>0).map(J=>({status:J,count:he[J]})),bn=k.useMemo(()=>{const J={};return I.forEach(xe=>{J[xe.status]=(J[xe.status]??0)+1}),J},[I]),Qn=k.useMemo(()=>{const J=new Map(m.map(xe=>[xe.id,xe]));return g.map(xe=>{const st=xe.members.filter(Mt=>Mt.type==="agent").map(Mt=>J.get(Mt.id)).filter(Mt=>!!Mt);return{team:xe,agents:st,working:st.filter(Mt=>Mt.status==="working").length,total:st.length}})},[g,m]),ha=m.filter(J=>{const xe=J.runtime?.phase;return xe?xe!=="idle"&&xe!=="offline":J.status==="working"}),bi=!(P===!0&&!$e),ga=uV(!t&&l,C,g);t||yt.navigate;const En=k.useMemo(()=>{const J=new Map;for(const xe of Object.values(v))for(const st of xe)J.set(st.id,st);return J},[v]),[Xn,wr]=k.useState([]),[kr,Vs]=k.useState([]),[qr]=k.useState(()=>GK());k.useEffect(()=>{if(t||!l)return;let J=!0;const xe=()=>{Te.approvals.list().then(st=>{J&&wr((st.approvals??[]).filter(Mt=>Mt.status==="pending"))}).catch(()=>{}),e?.id&&Te.notifications.list(e.id,!0,{limit:20}).then(st=>{J&&Vs(st.notifications??[])}).catch(()=>{})};return xe(),window.addEventListener("markus:notifications-changed",xe),()=>{J=!1,window.removeEventListener("markus:notifications-changed",xe)}},[t,l,e?.id]);const is=k.useMemo(()=>Object.values(v).flat(),[v]),Jn=k.useMemo(()=>HK({tasks:is,requirements:I,approvals:Xn,notifications:kr,taskById:J=>En.get(J),lastSeenAt:qr,notifyTitle:J=>QK(J,a)}),[is,I,Xn,kr,En,qr,a]),yi=k.useMemo(()=>BK(Jn),[Jn]),aa=k.useMemo(()=>Jn.filter(J=>J.isNew).length,[Jn]),[hr,Sr]=k.useState(()=>Date.now());k.useEffect(()=>{const J=window.setInterval(()=>Sr(Date.now()),6e4);return()=>window.clearInterval(J)},[]),k.useEffect(()=>{t||VK(yi)},[yi,t]),k.useEffect(()=>{if(t||!l)return;const J=window.setTimeout(()=>KK(new Date().toISOString()),3e3);return()=>window.clearTimeout(J)},[t,l,Jn.length]);const Cr=k.useCallback(J=>{const xe=J.notices?.[0];xe&&Z4(xe,kr),yt.navigate(J.target.page==="WORK"?me.WORK:me.TEAM,J.target.params)},[kr]);k.useEffect(()=>{if(t||!l)return;let J=!0;const xe=()=>{Te.notifications.list(e?.id,!0,{limit:1}).then(st=>{J&&WK(st.unreadCount??0)}).catch(()=>{})};return xe(),window.addEventListener("markus:notifications-changed",xe),()=>{J=!1,window.removeEventListener("markus:notifications-changed",xe)}},[t,l,e?.id]);const In=k.useMemo(()=>{const J=new Map;for(const xe of Object.values(v))for(const st of xe)st.priority&&J.set(st.id,st.priority);return J},[v]),ss=k.useMemo(()=>{const J=new Map;for(const xe of m)J.set(xe.id,xe.name);return J},[m]),{activityLimit:Fr,teamsLimit:Ba}=k.useMemo(()=>{const J=(K.length>0?1:0)+(I.length>0?1:0)+(z>0?1:0),xe=bt>0?6+J:0,st=xe>0?2:0,en=xe+st+2,Sn=Qn.length>0?2+Qn.length:0,zn=Math.max(Sn,4),Rt=ha.length,Ht=Rt>0?8:12,on=Math.max(0,zn-en);let Zn=Rt>0?Math.max(Rt,on):on;Zn=Math.max(3,Math.min(Ht,Zn));const da=en+Math.max(Rt,Zn);let Ar=Qn.length;if(zn>da+2){const Tr=zn-da;Ar=Math.max(2,Qn.length-Tr)}else if(da>zn+2){const Tr=da-zn;Zn=Math.max(3,Zn-Tr)}return{activityLimit:Zn,teamsLimit:Ar}},[Qn,bt,K,I,z,ha]);return o.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:[o.jsxs("div",{"data-electron-drag":!0,className:`flex items-center justify-between px-4 sm:px-6 lg:px-8 h-14 sm:h-16 ${t?"":"max-w-7xl mx-auto"} w-full`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[i&&o.jsx(V4,{}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-base sm:text-lg font-bold",children:a("title")}),o.jsx("p",{className:"text-xs text-fg-tertiary hidden sm:block",children:a("subtitle")})]})]}),o.jsxs("div",{"data-no-drag":!0,className:"flex items-center gap-1.5",children:[o.jsx("button",{onClick:()=>t?void 0:i?yt.navigate(me.SEARCH):window.dispatchEvent(new CustomEvent("markus:open-search")),className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":"Search",children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),o.jsx(LV,{ref:we,show:re,onToggle:()=>ue(!re),onClose:()=>ue(!1),t:a,isMobile:i})]})]}),o.jsxs("div",{className:`px-4 sm:px-6 lg:px-8 pb-8 space-y-6 ${t?"":"max-w-7xl mx-auto"} w-full`,children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(iu,{label:a("metricCards.working"),value:String(it),sub:`/${m.length}`,icon:o.jsx(su,{type:"working"}),pulse:it>0,onClick:()=>q(!0)}),o.jsx(iu,{label:a("metricCards.tasksDone"),value:`${Ye}`,sub:`/${bt}`,icon:o.jsx(su,{type:"tasks"}),onClick:()=>yt.navigate(me.WORK)}),o.jsx(iu,{label:a("metricCards.projects"),value:String(tt),icon:o.jsx(su,{type:"projects"}),onClick:()=>yt.navigate(me.WORK)}),o.jsx(iu,{label:a("metricCards.health"),value:`${P===!1?100:C?.systemHealth.overallScore??"—"}`,sub:P===!1||C?"%":void 0,icon:o.jsx(su,{type:"health"}),color:P===!1?"green":C?C.systemHealth.overallScore>=80?"green":C.systemHealth.overallScore>=50?"amber":"red":void 0,onClick:()=>ce(!0)})]}),!t&&o.jsxs("div",{className:"bg-gradient-to-r from-amber-500/5 via-surface-elevated to-surface-elevated border border-amber-500/20 rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-4 pb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 shrink-0"}),o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("attention.title")}),Jn.length>0&&o.jsx("span",{className:"text-[11px] text-fg-tertiary tabular-nums",children:Jn.length}),aa>0&&o.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-brand-500/15 text-brand-500 shrink-0",children:a("attention.newCount",{count:aa})})]}),o.jsx("button",{onClick:()=>u(!0),className:"text-[11px] font-medium text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",children:a("attention.history")})]}),Jn.length===0?o.jsx("div",{className:"px-5 pb-4 text-xs text-fg-tertiary",children:a("attention.allClear")}):o.jsxs("div",{className:"px-3 pb-2 space-y-1",children:[Jn.slice(0,5).map(J=>o.jsxs("button",{onClick:()=>Cr(J),className:"w-full flex items-start gap-2.5 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 transition-colors text-left",children:[o.jsx("span",{className:`w-1 self-stretch rounded-full shrink-0 ${J.isNew?"bg-brand-500":"bg-transparent"}`}),o.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${Tn[Df[J.kind].tone].chip}`,children:o.jsx(c5,{name:Df[J.kind].iconName,size:15})}),o.jsxs("span",{className:"flex-1 min-w-0",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:J.title}),J.priority!=="none"&&o.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${T2[J.priority]??T2.none}`,children:J.priority})]}),o.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"shrink-0",children:a(`attention.kind.${J.kind}`)}),o.jsx("span",{children:"·"}),o.jsx("span",{className:"tabular-nums shrink-0",children:t5(J,hr)}),J.meta&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsx("span",{className:"truncate",children:J.meta})]})]})]}),o.jsx("span",{className:`shrink-0 text-[11px] font-medium px-2.5 py-1 rounded-lg transition-colors ${Tn[Df[J.kind].tone].btn}`,children:a(`attention.act.${J.kind}`)})]},J.id)),Jn.length>5&&o.jsx("button",{onClick:()=>u(!0),className:"w-full text-[11px] text-fg-tertiary hover:text-fg-primary px-3 py-2 text-left",children:a("attention.more",{count:Jn.length-5})})]})]}),!t&&o.jsx(UK,{open:c,onClose:()=>u(!1),userId:e?.id}),Y.length>0&&o.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("recentDeliverables.title")}),o.jsx("button",{onClick:()=>yt.navigate(me.DELIVERABLES),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsx("div",{className:"px-3 pb-3",children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-1",children:Y.map(J=>o.jsxs("div",{className:"flex items-start gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(me.DELIVERABLES,{openDeliverable:J.id}),children:[o.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 ${J.artifactType?"bg-brand-500/10":J.type==="directory"?"bg-blue-500/10":"bg-green-500/10"}`,children:o.jsx(_V,{type:J.type,artifactType:J.artifactType})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:J.title}),o.jsx("div",{className:"text-[11px] text-fg-tertiary truncate mt-0.5",children:J.summary}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[J.agentId&&ss.get(J.agentId)&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:ss.get(J.agentId)}),o.jsx("span",{className:"text-[10px] text-fg-muted",children:R2(J.updatedAt,a)}),J.status==="verified"&&o.jsx("span",{className:"text-[10px] text-blue-500 font-medium",children:"Verified"})]})]}),J.diffStats&&o.jsxs("div",{className:"text-[10px] text-fg-muted shrink-0 mt-1 tabular-nums",children:[o.jsxs("span",{className:"text-green-500",children:["+",J.diffStats.additions]})," ",o.jsxs("span",{className:"text-red-500",children:["-",J.diffStats.deletions]})]})]},J.id))})})]}),F&&!et&&!je&&(()=>{if(Ne&&!_e)return null;const J=xe=>o.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg hover:bg-surface-elevated/50 transition-colors group",children:[o.jsx("div",{className:`mt-0.5 shrink-0 w-5 h-5 rounded-full flex items-center justify-center ${xe.done?"bg-green-500":"border-2 border-border-default"}`,children:xe.done&&o.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`text-xs font-medium ${xe.done?"text-fg-tertiary line-through":"text-fg-primary"}`,children:xe.label}),"optional"in xe&&xe.optional&&o.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-fg-muted font-medium",children:a("checklist.setup.optional")})]}),o.jsx("p",{className:`text-[11px] mt-0.5 ${xe.done?"text-fg-muted":"text-fg-tertiary"}`,children:xe.desc})]}),xe.done&&xe.isSetup?o.jsx("button",{onClick:xe.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg border border-border-default hover:bg-surface-elevated text-fg-secondary font-medium transition-colors opacity-0 group-hover:opacity-100",children:a("checklist.setup.update")}):xe.done?null:o.jsx("button",{onClick:xe.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand font-medium transition-colors opacity-80 group-hover:opacity-100",children:xe.action})]},xe.id);return o.jsxs("div",{className:"bg-gradient-to-br from-brand-600/10 via-surface-secondary to-surface-secondary border border-brand-500/20 rounded-2xl p-5 sm:p-6",children:[o.jsxs("div",{className:"flex items-start justify-between mb-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:a("checklist.title")}),o.jsx("p",{className:"text-xs text-fg-secondary",children:a("checklist.subtitle")})]}),o.jsx("button",{onClick:Q,className:"text-fg-muted hover:text-fg-secondary transition-colors p-1 -mr-1 -mt-1",title:"Dismiss",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-500",style:{width:`${Pt/Ae*100}%`}})}),o.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:a("checklist.progress",{done:Pt,total:Ae})})]}),o.jsxs("div",{className:"mb-4",children:[o.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:a("checklist.setup.title")}),o.jsx("div",{className:"space-y-0.5",children:ut.map(J)})]}),o.jsx("div",{className:"border-t border-border-default/50 my-3"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:a("checklist.explore.title")}),o.jsx("div",{className:"space-y-0.5",children:Ft.map(J)})]})]})})(),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[bt>0&&o.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("globalOverview.title")}),o.jsx("button",{onClick:()=>yt.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsxs("div",{className:"px-5 py-4 flex flex-col sm:flex-row items-center gap-6 border-t border-border-subtle/50",children:[o.jsx(MV,{statusCounts:he,total:bt,completionRate:St,completed:Ye}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"grid grid-cols-2 gap-x-5 gap-y-2.5",children:gn.map(({status:J,count:xe})=>o.jsxs("button",{onClick:()=>yt.navigate(me.WORK,{statusFilter:J}),className:"flex items-center gap-2 group cursor-pointer text-left",children:[o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${AV(J)}`}),o.jsx("span",{className:"text-xs text-fg-tertiary group-hover:text-fg-secondary transition-colors",children:Wh(J,a)}),o.jsx("span",{className:"text-sm font-semibold text-fg-primary ml-auto tabular-nums",children:xe})]},J))})})]}),o.jsxs("div",{className:"divide-y divide-border-subtle/50",children:[K.length>0&&o.jsx(If,{icon:"folder",label:a("globalOverview.projects"),value:K.length,onClick:()=>yt.navigate(me.WORK),children:o.jsxs(j2,{children:[tt," ",a("globalOverview.active")]})}),I.length>0&&o.jsx(If,{icon:"edit",label:a("globalOverview.requirements"),value:I.length,onClick:()=>yt.navigate(me.WORK),children:["in_progress","pending","completed"].map(J=>(bn[J]??0)>0&&o.jsxs(j2,{children:[bn[J]," ",Wh(J,a)]},J))}),z>0&&o.jsx(If,{icon:"book",label:a("globalOverview.deliverables"),value:z,onClick:()=>yt.navigate(me.DELIVERABLES)})]})]}),(ha.length>0||C&&C.taskKPI.recentActivity.length>0)&&o.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:o.jsxs("div",{className:`grid grid-cols-1 ${ha.length>0&&C&&C.taskKPI.recentActivity.length>0?"sm:grid-cols-2 divide-y sm:divide-y-0 sm:divide-x divide-border-subtle/50":""}`,children:[ha.length>0&&o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),o.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:a("liveActivity.whosWorking")})]}),o.jsx("div",{className:"space-y-1",children:ha.map(J=>{const xe=J.runtime,st=xe?.phase??(J.status==="idle"?"idle":J.status==="offline"?"offline":"running"),Mt=EV[st]??"bg-blue-400 animate-pulse";return o.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(me.TEAM,{agentId:J.id}),children:[o.jsx(Fo,{name:J.name,avatarUrl:J.avatarUrl,size:24,bgClass:"bg-brand-600/30 text-brand-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Mt}`}),o.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:J.name}),N2[st]&&o.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:a(N2[st])}),xe?.stall?.stalled&&o.jsx("span",{title:xe.stall.stuckReason,className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full shrink-0 ${xe.stall.stallKind==="dead-dependency"?"bg-amber-500/20 text-amber-400 border border-amber-500/30":"bg-sky-500/15 text-sky-300 border border-sky-500/25"}`,children:xe.stall.stallKind==="dead-dependency"?a("agentFocus.stallDeadBadge"):a("agentFocus.stallStaleBadge")}),xe?.dirty?.dirty&&(()=>{const en=xe.dirty.recovery==="human-review";return o.jsx("span",{className:`inline-flex items-center px-1.5 py-px rounded text-[9px] font-medium shrink-0 ${en?"bg-amber-500/15 text-amber-300":"bg-emerald-500/15 text-emerald-300"}`,children:a(en?"liveActivity.dirtyNeedsHuman":"liveActivity.dirtyRecovered")})})()]}),o.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:OV(J,a)})]})]},J.id)})})]}),C&&C.taskKPI.recentActivity.length>0&&o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:a("liveActivity.recentChanges")}),o.jsx("button",{onClick:()=>yt.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsx("div",{className:`${ha.length>0?"":"grid grid-cols-1 sm:grid-cols-2 gap-x-4"}`,children:C.taskKPI.recentActivity.slice(0,Fr).map(J=>{const xe=In.get(J.taskId);return o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(me.WORK,{openTask:J.taskId}),children:[o.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${TV[J.status]??"bg-gray-500/15"}`,children:o.jsx(jV,{status:J.status})}),o.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1",children:J.title}),(xe==="urgent"||xe==="high")&&o.jsx(RV,{priority:xe}),o.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:R2(J.updatedAt,a)})]},J.taskId)})})]})]})})]}),o.jsx("div",{className:"space-y-6",children:Qn.length>0&&o.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("teamOverview.title")}),o.jsx("button",{onClick:()=>yt.navigate(me.TEAM),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsxs("div",{className:"space-y-0.5",children:[Qn.slice(0,Ba).map(J=>o.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(me.TEAM,{selectTeam:J.team.id}),children:[o.jsx("div",{className:"w-7 h-7 rounded-md bg-brand-600/15 flex items-center justify-center text-[10px] font-bold text-brand-400 shrink-0",children:J.team.name.charAt(0)}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:J.team.name})}),o.jsx("div",{className:"flex items-center -space-x-1 shrink-0",children:J.agents.slice(0,3).map(xe=>o.jsx(Fo,{name:xe.name,avatarUrl:xe.avatarUrl,size:18,bgClass:"bg-surface-overlay text-fg-secondary ring-1 ring-surface-elevated"},xe.id))}),J.working>0&&o.jsxs("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:[J.working,"/",J.total]})]},J.team.id)),Ba<Qn.length&&o.jsxs("button",{onClick:()=>yt.navigate(me.TEAM),className:"w-full text-center text-[11px] text-brand-400 hover:text-brand-300 font-medium py-1.5",children:["+",Qn.length-Ba," more"]})]})]})})})]}),!t&&P!==null&&o.jsx(hV,{contributors:ga.contributors,hubPlan:ga.hubPlan,hubOrgMeta:ga.hubOrgMeta,hubConnected:ga.hubConnected,showMarkusUsage:bi})]}),Ce&&o.jsx(DV,{workingAgents:ha,onClose:()=>q(!1),t:a}),V&&o.jsx(IV,{ops:C,completed:Ye,totalRootTasks:bt,workingAgents:it,totalAgents:m.length,usageInfo:X,storageInfo:D,cuQuota:se,onClose:()=>ce(!1),t:a}),kt&&o.jsx(SK,{onClose:()=>lt(!1),onClaimed:Le}),o.jsx(MK,{open:ht,userId:ie,onClose:()=>Oe(!1),onCompleted:()=>{Gt(!0),Oe(!1)}})]})}function iu({label:e,value:t,sub:n,icon:a,pulse:i,color:l,badge:c,onClick:u}){const m=l==="green"?"text-green-500":l==="amber"?"text-amber-500":l==="red"?"text-red-500":"text-fg-primary";return o.jsxs("div",{onClick:u,className:"bg-surface-elevated shadow-sm rounded-2xl p-4 sm:p-5 flex items-start justify-between cursor-pointer hover:shadow-md transition-shadow",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-[11px] text-fg-tertiary mb-2",children:e}),o.jsxs("div",{className:"flex items-baseline gap-0.5",children:[o.jsx("span",{className:`text-2xl sm:text-3xl font-bold ${m} leading-none`,children:t}),n&&o.jsx("span",{className:"text-sm text-fg-muted font-medium",children:n})]}),c&&o.jsx("div",{className:"text-[10px] text-amber-500 font-medium mt-1.5",children:c})]}),o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-overlay/60 flex items-center justify-center text-fg-tertiary",children:a}),i&&o.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 rounded-full bg-green-500 animate-pulse"})]})]})}function su({type:e}){const t={working:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})}),tasks:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),o.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),projects:o.jsx(o.Fragment,{children:o.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"})}),health:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})};return o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:t[e]})}function If({icon:e,label:t,value:n,onClick:a,children:i}){return o.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 hover:bg-surface-overlay/30 cursor-pointer transition-colors",onClick:a,children:[o.jsx("span",{className:"text-fg-muted",children:o.jsx(NV,{type:e})}),o.jsx("span",{className:"text-xs text-fg-secondary",children:t}),o.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:n}),o.jsx("div",{className:"flex items-center gap-2 ml-auto text-[11px] text-fg-tertiary",children:i})]})}function j2({children:e}){return o.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-overlay/60 text-[11px] text-fg-secondary",children:e})}function NV({type:e}){const t={folder:"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",edit:"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",book:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20 M4 19.5A2.5 2.5 0 0 0 6.5 22H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15z"};return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:t[e]})})}function MV({statusCounts:e,total:t,completionRate:n,completed:a}){const u=2*Math.PI*42,m=f5.filter(h=>(e[h]??0)>0).map(h=>({status:h,value:e[h],color:CV[h]??"#6b7280"}));let f=0;const g=m.map(h=>{const v=h.value/t*u,y={len:Math.max(v-.8,.5),offset:f,color:h.color,status:h.status};return f+=v,y});return o.jsxs("div",{className:"relative shrink-0",style:{width:120,height:120},children:[o.jsx("svg",{width:120,height:120,viewBox:"0 0 120 120",children:g.map((h,v)=>o.jsx("circle",{cx:"60",cy:"60",r:42,fill:"none",stroke:h.color,strokeWidth:12,strokeDasharray:`${h.len} ${u-h.len}`,strokeDashoffset:-h.offset,transform:"rotate(-90 60 60)",className:"transition-all duration-500 cursor-pointer",onClick:()=>yt.navigate(me.WORK,{statusFilter:h.status})},v))}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsxs("span",{className:"text-2xl font-bold text-fg-primary leading-none",children:[n,"%"]}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[a,"/",t]})]})]})}function jV({status:e}){const n={completed:"#22c55e",in_progress:"#8b5cf6",pending:"#f59e0b",review:"#3b82f6",failed:"#ef4444",blocked:"#f59e0b",rejected:"#ef4444",cancelled:"#6b7280"}[e]??"#6b7280";return o.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e==="completed"&&o.jsx("polyline",{points:"20 6 9 17 4 12"}),e==="in_progress"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e==="pending"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),o.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e==="review"&&o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),(e==="failed"||e==="rejected")&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),e==="blocked"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})]}),e==="cancelled"&&o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})]})}function RV({priority:e}){return e==="urgent"?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-red-500/15 text-red-500 shrink-0 uppercase tracking-wide",children:"!"}):e==="high"?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-amber-500/15 text-amber-600 shrink-0 uppercase tracking-wide",children:"H"}):null}function _V({type:e,artifactType:t}){if(t){const a=t==="agent"?"#8b5cf6":t==="team"?"#3b82f6":"#f59e0b";return o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),o.jsx("path",{d:"M2 17l10 5 10-5"}),o.jsx("path",{d:"M2 12l10 5 10-5"})]})}const n=e==="directory"?"#3b82f6":"#22c55e";return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:e==="directory"?o.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"}):o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"})]})})}function DV({workingAgents:e,onClose:t,t:n}){return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:o.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[420px] max-w-[90vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between shrink-0",children:[o.jsx("h3",{className:"text-sm font-semibold",children:n("ranking.workingNow")}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"overflow-y-auto flex-1 scrollbar-thin px-5 py-4",children:e.length>0?o.jsx("div",{className:"space-y-0.5",children:e.map(a=>o.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>{t(),yt.navigate(me.TEAM,{agentId:a.id})},children:[o.jsx(Fo,{name:a.name,avatarUrl:a.avatarUrl,size:26,bgClass:"bg-brand-600/30 text-brand-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:a.name}),o.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:a.currentActivity?.label??"—"})]}),o.jsx("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:"Working"})]},a.id))}):o.jsx("div",{className:"py-8 text-center text-xs text-fg-tertiary",children:n("ranking.noData")})})]})})}function IV({ops:e,completed:t,totalRootTasks:n,workingAgents:a,totalAgents:i,usageInfo:l,storageInfo:c,cuQuota:u,onClose:m,t:f}){return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:m,children:o.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] overflow-hidden",onClick:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-semibold",children:f("systemHealth.title")}),o.jsx("button",{onClick:m,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"p-5 space-y-4",children:[e&&o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.successRate")}),o.jsxs("span",{className:"text-sm font-bold text-fg-primary",children:[Math.round(e.taskKPI.successRate),"%"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-green-500 transition-all duration-500",style:{width:`${Math.round(e.taskKPI.successRate)}%`}})})]}),e&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("metricCards.health")}),o.jsxs("span",{className:`text-sm font-bold ${e.systemHealth.overallScore>=80?"text-green-500":e.systemHealth.overallScore>=50?"text-amber-500":"text-red-500"}`,children:[e.systemHealth.overallScore,"%"]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.tasksTotal")}),o.jsxs("span",{className:"text-xs font-semibold text-fg-primary",children:[t,"/",n]})]}),l&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.tokenUsage")}),o.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:lu(l.llmTokens)})]}),u?.available&&u.cuLimit>0&&(()=>{const g=u.cuLimit-u.cuRemaining,h=Math.min(100,Math.round(g/u.cuLimit*100)),v=h>=95?"text-red-500":h>=80?"text-amber-500":"text-green-500",y=h>=95?"bg-red-500":h>=80?"bg-amber-500":"bg-green-500";return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:"CU Quota"}),o.jsxs("span",{className:`text-xs font-semibold ${v}`,children:[lu(g)," / ",lu(u.cuLimit)," (",h,"%)"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full ${y} transition-all duration-500`,style:{width:`${h}%`}})}),u.cuUsedToday!=null&&u.cuUsedToday>0&&o.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[o.jsx("span",{className:"text-xs text-fg-tertiary",children:"Today's CU Used"}),o.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:lu(u.cuUsedToday)})]})]})})(),a>0&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.currentWorking")}),o.jsxs("span",{className:"text-xs font-semibold text-green-500",children:[a,"/",i]})]}),c&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.storage")}),o.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:zV(c.totalSize)})]})]})]})})}const LV=k.forwardRef(({show:e,onToggle:t,onClose:n,t:a,isMobile:i},l)=>o.jsxs("div",{ref:l,className:"relative",children:[o.jsx("button",{onClick:t,className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":"Create",children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),o.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e&&o.jsx("div",{className:"absolute right-0 top-full mt-2 bg-surface-elevated border border-border-default rounded-xl shadow-xl z-50 overflow-hidden w-48 animate-fadeIn",children:o.jsxs("div",{className:"py-1",children:[o.jsx(ou,{onClick:()=>{n(),yt.navigate(me.BUILDER,i?{storeTab:"builder"}:void 0)},icon:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M19 8v6 M22 11h-6",children:a("home:createMenu.agent")}),o.jsx(ou,{onClick:()=>{n(),yt.navigate(me.BUILDER)},icon:"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",children:a("home:createMenu.team")}),o.jsx(ou,{onClick:()=>{n(),yt.navigate(me.BUILDER)},icon:"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",children:a("home:createMenu.skill")}),o.jsx("div",{className:"border-t border-border-default my-1"}),o.jsx(ou,{onClick:()=>{n(),yt.navigate(me.STORE)},icon:"M6 2L3 7v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-3-5z M3 7h18 M16 11a4 4 0 0 1-8 0",children:a("home:createMenu.discover")})]})})]}));function ou({onClick:e,icon:t,children:n}){return o.jsxs("button",{onClick:e,className:"w-full flex items-center gap-2.5 px-4 py-2.5 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:t})}),n]})}function R2(e,t){const n=Date.now()-new Date(e).getTime(),a=Math.floor(n/6e4);if(a<1)return t("common:time.now");if(a<60)return t("common:time.minutesAgo",{count:a});const i=Math.floor(a/60);return i<24?t("common:time.hoursAgo",{count:i}):t("common:time.daysAgo",{count:Math.floor(i/24)})}function _2(e,t){return e?E2[e]?t(E2[e]):e:null}function PV(e,t=""){if(!e)return t;const n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function OV(e,t){const n=e.runtime,a=[];if(n){if(n.stall?.stalled)if(n.stall.stallKind==="dead-dependency")a.push(t("agentFocus.stallDeadDep",{title:n.stall.stuckOnTitle??n.stall.stuckOnTaskId??""}));else{const i=n.stall.lastActivityAgoMin;a.push(t("agentFocus.stallStale",{minutes:typeof i=="number"?i:0}))}else n.blockedBy&&n.blockedBy.length>0?a.push(t("agentFocus.blockedBy",{title:n.blockedBy[0].title})):n.phase==="idle"||n.phase==="offline"||(n.activityLabel?a.push(_2(n.activityLabel,t)??n.activityLabel):n.activityType==="heartbeat"&&a.push(t("agentFocus.heartbeatCheckIn")));return typeof n.runningMinutes=="number"&&n.runningMinutes>=1&&a.push(t("agentFocus.runningFor",{n:n.runningMinutes})),(n.lastActivityAt||n.lastHeartbeat)&&a.push(t("agentFocus.lastActivity",{time:PV(n.lastActivityAt??n.lastHeartbeat)})),n.lastError&&a.push(n.lastError),a.join(" · ")}return _2(e.currentActivity?.label,t)??t("agentFocus.working")}function lu(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function zV(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n>0?1:0)} ${t[n]}`}class HV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!BV(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 BV(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 bm=5,h5=5*1024*1024,$V=["image/png","image/jpeg","image/webp","image/gif"];function qV(e,t){const n=[],a=[],i=$V;let l=t;for(const c of e){if(!i.includes(c.type)){a.push({name:c.name,reason:"not_image"});continue}if(c.size>h5){a.push({name:c.name,reason:"too_large"});continue}if(l>=bm){a.push({name:c.name,reason:"too_many"});continue}n.push(c),l+=1}return{accepted:n,rejected:a}}function FV(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB"],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024))),a=e/1024**n;return`${a>=10||n===0?Math.round(a):Math.round(a*10)/10} ${t[n]}`}function UV(e){return e.title.trim()?null:"title_required"}function GV(e,t){return t==="not_image"?e("feedback.rejectNotImage"):t==="too_large"?e("feedback.rejectTooLarge",{size:FV(h5)}):e("feedback.rejectTooMany",{max:bm})}function KV({defaultContact:e,onClose:t}){const{t:n}=xt("common");Fs(!0);const[a,i]=k.useState(""),[l,c]=k.useState(""),[u,m]=k.useState(e),[f,g]=k.useState([]),[h,v]=k.useState([]),[y,w]=k.useState(""),[T,C]=k.useState(!1),[A,M]=k.useState(!1),[I,B]=k.useState(!1),K=k.useRef(null),j=k.useRef([]);j.current=f;const z=nt.isAuthenticated();k.useEffect(()=>()=>{for(const D of j.current)URL.revokeObjectURL(D.previewUrl)},[]),k.useEffect(()=>{const D=W=>{W.key==="Escape"&&!T&&t()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[T,t]);const U=k.useCallback(D=>{if(!D)return;const W=Array.from(D);if(W.length===0)return;const{accepted:X,rejected:H}=qV(W,j.current.length);H.length?v(H.map(se=>`${se.name}:${GV(n,se.reason)}`)):v([]),X.length&&g(se=>[...se,...X.map(R=>({id:`${R.name}-${R.size}-${Math.random().toString(36).slice(2)}`,file:R,previewUrl:URL.createObjectURL(R)}))])},[n]),Y=D=>{g(W=>{const X=W.find(H=>H.id===D);return X&&URL.revokeObjectURL(X.previewUrl),W.filter(H=>H.id!==D)}),v([])},$=async D=>{if(D.preventDefault(),w(""),UV({title:a})){w(n("feedback.titleRequired"));return}C(!0);try{const W=[];for(const X of f){const H=await nt.uploadImage(X.file);if(!H?.url)throw new Error("upload_failed");W.push(H.url)}await nt.feedback.create({title:a.trim(),content:l.trim()||void 0,contact:u.trim()||void 0,images:W.length?W:void 0,appVersion:"0.12.3-rc.3",platform:typeof navigator<"u"?navigator.platform:void 0,locale:typeof navigator<"u"?navigator.language:void 0}),M(!0)}catch(W){const X=W.status,H=W instanceof Error?W.message:String(W);w(n(X===404?"feedback.hubUnsupported":H==="upload_failed"?"feedback.uploadFailed":"feedback.submitFailed"))}finally{C(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000] p-4",onClick:()=>{T||t()},children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[540px] max-w-full max-h-[calc(100vh-2rem)] overflow-y-auto shadow-2xl",onClick:D=>D.stopPropagation(),onDragOver:D=>{D.preventDefault(),z&&B(!0)},onDragLeave:()=>B(!1),onDrop:D=>{D.preventDefault(),B(!1),z&&U(D.dataTransfer.files)},children:A?o.jsxs("div",{className:"p-6 text-center",children:[o.jsx("div",{className:"text-3xl mb-3",children:"✅"}),o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:n("feedback.successTitle")}),o.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:n("feedback.successDesc")}),o.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg",children:n("feedback.successClose")})]}):o.jsxs("form",{onSubmit:$,className:"p-6",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:n("feedback.modalTitle")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-4",children:n("feedback.modalSubtitle")}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:[n("feedback.fieldTitle")," ",o.jsx("span",{className:"text-red-400",children:"*"})]}),o.jsx("input",{value:a,onChange:D=>i(D.target.value),maxLength:120,autoFocus:!0,placeholder:n("feedback.titlePlaceholder"),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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:n("feedback.fieldContent")}),o.jsx("textarea",{value:l,onChange:D=>c(D.target.value),maxLength:4e3,rows:5,placeholder:n("feedback.contentPlaceholder"),onPaste:D=>{if(!z)return;const W=Array.from(D.clipboardData?.files??[]);W.length&&(D.preventDefault(),U(W))},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 resize-y"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:n("feedback.fieldImages",{max:bm})}),z?o.jsxs("div",{className:`rounded-lg border border-dashed p-3 transition-colors ${I?"border-brand-500 bg-brand-500/5":"border-border-default"}`,children:[o.jsxs("div",{className:"flex flex-wrap gap-2",children:[f.map(D=>o.jsxs("div",{className:"relative group",children:[o.jsx("img",{src:D.previewUrl,alt:D.file.name,className:"w-20 h-16 object-cover rounded-md border border-border-default"}),o.jsx("button",{type:"button",onClick:()=>Y(D.id),title:n("remove"),className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-black/70 text-white text-[11px] leading-none opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},D.id)),f.length<bm&&o.jsx("button",{type:"button",onClick:()=>K.current?.click(),className:"w-20 h-16 rounded-md border border-dashed border-border-default text-fg-muted hover:text-fg-secondary hover:border-brand-500 transition-colors text-lg",children:"+"})]}),o.jsx("p",{className:"text-[10px] text-fg-muted mt-2",children:n("feedback.dropHint")}),o.jsx("input",{ref:K,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,className:"hidden",onChange:D=>{U(D.target.files),D.target.value=""}})]}):o.jsx("p",{className:"text-[11px] text-amber-500/90 bg-amber-500/10 border border-amber-500/30 rounded-lg px-3 py-2",children:n("feedback.loginForImages")}),h.length>0&&o.jsx("ul",{className:"mt-1.5 space-y-0.5",children:h.map((D,W)=>o.jsx("li",{className:"text-[11px] text-red-400",children:D},W))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:n("feedback.fieldContact")}),o.jsx("input",{value:u,onChange:D=>m(D.target.value),placeholder:n("feedback.contactPlaceholder"),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"})]}),y&&o.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:y})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:t,disabled:T,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated disabled:opacity-50",children:n("cancel")}),o.jsx("button",{type:"submit",disabled:T,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand rounded-lg",children:n(T?"feedback.submitting":"feedback.submit")})]})]})})})}function Lf({label:e,value:t}){return o.jsxs("div",{className:"rounded-lg px-2 py-2.5 text-center bg-surface-elevated",children:[o.jsx("div",{className:"text-lg font-semibold tabular-nums text-fg-primary",children:t.toLocaleString()}),o.jsx("div",{className:"text-[10px] uppercase tracking-wider mt-0.5 text-fg-muted",children:e})]})}function VV({onClose:e}){const{t}=xt("common");Fs(!0);const[n,a]=k.useState(null),[i,l]=k.useState(!0),[c,u]=k.useState(""),[m,f]=k.useState(null),g=nt.isAuthenticated(),h=k.useCallback(async()=>{if(!g){l(!1);return}l(!0),u("");try{const y=await nt.user.referral();a({code:y.code,shareUrl:y.shareUrl,invitedCount:y.invitedCount,paidCount:y.paidCount,rewardCuTotal:y.rewardCuTotal,rewardCuPerPaid:y.rewardCuPerPaid,claimBonusCu:y.claimBonusCu})}catch(y){u(y.status===404?t("ambassador.unsupported"):t("ambassador.loadFailed"))}finally{l(!1)}},[g,t]);k.useEffect(()=>{h()},[h]),k.useEffect(()=>{const y=w=>{w.key==="Escape"&&e()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[e]);const v=async y=>{if(n)try{await navigator.clipboard.writeText(y==="code"?n.code:n.shareUrl),f(y),setTimeout(()=>f(null),2e3)}catch{}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000] p-4",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[460px] max-w-full max-h-[calc(100vh-2rem)] overflow-y-auto shadow-2xl p-6",onClick:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[o.jsx("span",{className:"text-xl leading-none",children:"🎁"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:t("ambassador.title")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1 leading-relaxed",children:n?t("ambassador.desc",{claimAmount:n.claimBonusCu.toLocaleString(),rewardAmount:n.rewardCuPerPaid.toLocaleString()}):t("ambassador.descGeneric")})]})]}),g?i?o.jsx("p",{className:"text-sm text-fg-tertiary py-6 text-center",children:t("ambassador.loading")}):c?o.jsx("p",{className:"text-xs text-red-400 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:c}):n?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:t("ambassador.codeLabel")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"flex-1 px-3 py-2 rounded-lg text-sm font-mono tracking-widest bg-surface-elevated text-fg-primary select-all",children:n.code}),o.jsx("button",{type:"button",onClick:()=>{v("code")},className:"px-3 py-2 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand shrink-0",children:t(m==="code"?"ambassador.copied":"ambassador.copyCode")})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsx(Lf,{label:t("ambassador.statInvited"),value:n.invitedCount}),o.jsx(Lf,{label:t("ambassador.statPaid"),value:n.paidCount}),o.jsx(Lf,{label:t("ambassador.statReward"),value:n.rewardCuTotal})]}),o.jsx("button",{type:"button",onClick:()=>{v("link")},className:"w-full px-3 py-2 text-xs border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:t(m==="link"?"ambassador.copied":"ambassador.copyLink")})]}):null:o.jsxs("div",{className:"rounded-lg border border-border-default p-4 text-center",children:[o.jsx("p",{className:"text-sm text-fg-secondary mb-3",children:t("ambassador.loginPrompt")}),o.jsx("button",{type:"button",onClick:()=>{nt.ensureAuth().then(()=>h()).catch(()=>{})},className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg",children:t("ambassador.login")})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[g&&n&&o.jsx("button",{type:"button",onClick:()=>{const y=nt.getUrl().replace(/\/$/,"");Or(`${y}/settings`)},className:"px-3 py-2 text-xs border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:t("ambassador.openHub")}),o.jsx("button",{type:"button",onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("close")})]})]})})}function jo({d:e,size:t=14}){return o.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:o.jsx("path",{d:e})})}const Pf=200;function WV({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:a=!1,collapsed:i=!1,showVersion:l=!1}){const{t:c}=xt(["nav","common"]),[u,m]=k.useState(!1),[f,g]=k.useState(!1),[h,v]=k.useState(!1),[y,w]=k.useState(!1),[T,C]=k.useState({top:0,left:0}),A=k.useRef(null),M=k.useRef(null),{connected:I,user:B,credits:K,refresh:j}=K4(u),z=k.useCallback(()=>{if(!A.current)return;const R=A.current.getBoundingClientRect(),re=window.innerWidth,ue=window.innerHeight,Ce=M.current?.offsetHeight??220;let q=R.right+8;q+Pf>re-8&&(q=Math.max(8,R.left-Pf-8));let V=R.top-Ce-8;V<8&&(V=Math.min(R.bottom+8,ue-Ce-8)),C({top:Math.max(8,V),left:q})},[]);k.useLayoutEffect(()=>{if(!u)return;z();const R=requestAnimationFrame(()=>z());return()=>cancelAnimationFrame(R)},[u,z,i]),k.useEffect(()=>{if(!u)return;const R=ue=>{const Ce=ue.target;A.current?.contains(Ce)||M.current?.contains(Ce)||m(!1)},re=()=>z();return document.addEventListener("mousedown",R),window.addEventListener("resize",re),window.addEventListener("scroll",re,!0),()=>{document.removeEventListener("mousedown",R),window.removeEventListener("resize",re),window.removeEventListener("scroll",re,!0)}},[u,z]);const U=e?.name||B?.displayName||B?.username||c("common:userPlaceholder"),Y=e?.email||B?.email||"",$=F4(e?.avatarUrl,B?.avatarUrl),D=I?"bg-emerald-500":"bg-fg-muted",W=I?B?.username?c("sidebar.hubConnectedAs",{username:B.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),X=!!(I&&B?.username&&e?.name&&B.username.toLowerCase()!==e.name.toLowerCase()&&B.email?.toLowerCase()!==e.email?.toLowerCase()),H=()=>{m(!1),j({validate:!0}),yt.navigate(me.SETTINGS,{tab:"account"})},se=u&&Lc.createPortal(o.jsxs("div",{ref:M,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:T.top,left:T.left,width:Pf},children:[o.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:U}),Y&&o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:Y}),K!==null&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),Or(`${nt.getUrl().replace(/\/$/,"")}/settings?tab=billing`)},title:c("common:creditBalanceOpenHub"),className:"text-xs text-fg-secondary mt-0.5 -mx-1 px-1 max-w-full flex items-center gap-1 rounded transition-colors hover:text-brand-500 hover:bg-surface-overlay",children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[o.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),o.jsx("path",{d:"M12.5 5.5v13",strokeDasharray:"2 2.5"})]}),o.jsxs("span",{className:"truncate",children:[c("common:creditBalance"),": ",K.remaining.toLocaleString()]})]})]}),n&&o.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:o.jsx(jo,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),o.jsxs("button",{type:"button",onClick:H,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${D}`}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:W}),X&&B?.username&&o.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:B.username})})]}),o.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:o.jsx("path",{d:"m9 18 6-6-6-6"})})]}),o.jsxs("div",{className:"py-1",children:[o.jsxs("button",{type:"button",onClick:()=>{m(!1),v(!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:[o.jsx(jo,{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5Z"}),c("common:feedback.entry")]}),o.jsxs("button",{type:"button",onClick:()=>{m(!1),w(!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:[o.jsx(jo,{d:"M20 12v10H4V12M2 7h20v5H2zM12 22V7M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7ZM12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7Z"}),c("common:ambassador.entry")]}),a&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),yt.navigate(me.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:[o.jsx(jo,{d:Fm[me.SETTINGS]}),c("settings")]}),window.markusDesktop&&o.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:[o.jsx(jo,{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&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),g(!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:[o.jsx(jo,{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 o.jsxs("div",{className:`relative ${i?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[o.jsxs("button",{ref:A,type:"button",onClick:()=>m(R=>!R),title:U,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${i?"p-0.5":""}`,children:[o.jsx(Fo,{name:U,avatarUrl:$,size:i?28:32,fallback:"icon"}),o.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${D}`,title:W})]}),l&&!i&&o.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.12.3-rc.3"]}),se,h&&o.jsx(KV,{defaultContact:Y,onClose:()=>v(!1)}),y&&o.jsx(VV,{onClose:()=>w(!1)}),f&&t&&o.jsx(vr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{g(!1),t()},onCancel:()=>g(!1)})]})}function YV({d:e,size:t=18}){return o.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:o.jsx("path",{d:e})})}function QV({currentPage:e,onNavigate:t,authUser:n,collapsed:a,onToggleCollapse:i,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:u}){const{t:m}=xt(["nav","common"]),[f,g]=k.useState(Gm);return k.useEffect(()=>s5(g),[]),o.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[o.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${a?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:o.jsxs("button",{"data-no-drag":!0,onClick:i,title:m(a?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!a&&o.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),o.jsx("nav",{className:`${a?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:yG.map((h,v)=>{const y=M4.filter(T=>T.section===h.key);if(y.length===0)return null;const w=m(`sections.${h.key}`);return o.jsx("div",{children:o.jsxs("div",{className:v>0?"mt-3":"",children:[!a&&w&&o.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:w}),a&&v>0&&o.jsx("div",{className:"my-3"}),y.map(T=>{const C=e===T.id,A=u&&c===T.id;return o.jsxs("button",{"data-l0-page-id":T.id,onClick:()=>t(T.id),title:a?m(T.id):void 0,className:`relative w-full flex items-center ${a?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${A?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":C?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[o.jsx(YV,{d:Fm[T.id]??"",size:a?16:18}),a?o.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(T.id)}):o.jsx("span",{className:"truncate",children:m(T.id)}),T.id===me.HOME&&f>0&&(a?o.jsx("span",{className:"absolute top-0.5 right-1.5 min-w-[13px] h-[13px] px-[3px] rounded-full bg-red-500 text-white text-[8px] font-bold flex items-center justify-center tabular-nums",children:f>9?"9+":f}):o.jsx("span",{className:"ml-auto shrink-0 text-[10px] px-1.5 py-0.5 rounded-full bg-red-500 text-white font-semibold tabular-nums",children:f>99?"99+":f}))]},T.id)})]})},h.key)})}),o.jsx("div",{className:`shrink-0 border-t border-border-subtle ${a?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:o.jsx(WV,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const XV=100;function JV(e,t){const n=XV,a=((f,g)=>setTimeout(f,g)),i=(f=>clearTimeout(f)),l=new Map;let c=null,u=!1;function m(){if(c=null,u=!1,l.size===0)return;const f=[];for(const[g,h]of l)f.push({conversationKey:g,lastReadAt:h});l.clear(),e(f)}return{queue(f,g){let h=!1;for(const v of f)v&&(l.set(v,g),h=!0);h&&(u||(u=!0,c=a(m,n)))},flushNow(){u&&(i(c),u=!1,c=null),m()},pendingCount(){return l.size}}}const ZV=6e4,eW=2e3;let cr={},Wi={};const Jh=new Set,ym=new Set;let g5=0;const Zh=new Map;let mc=null,cu=0,Ku=null;function Ec(){for(const e of Jh)e()}function D2(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const a of n)if(e[a]!==t[a])return!1;return!0}function tW(e,t){const n={},a=[];for(const[i,l]of Object.entries(e)){if(t.has(i)){l>0&&a.push(i);continue}n[i]=l}return{counts:n,staleActiveKeys:a}}function nW(e,t){vm([e],t)}function aW(e,t,n,a){const i=[];for(const l of e){const c=t.get(l)??0;!a?.force&&n-c<eW||i.push(l)}return i}const b5=JV(e=>{(e.length===1?Te.unread.markRead(e[0].conversationKey,e[0].lastReadAt):Te.unread.markReadBatch(e)).catch(()=>{})});typeof window<"u"&&typeof window.addEventListener=="function"&&window.addEventListener("pagehide",()=>b5.flushNow(),{passive:!0});function vm(e,t){const n=Date.now(),a=aW(e,Zh,n,t);let i=!1;for(const l of a)Zh.set(l,n),l in cr&&(delete cr[l],i=!0);i&&Ec(),a.length!==0&&b5.queue(a,new Date(n).toISOString())}async function eg(){try{const e=await Te.unread.getCounts(),{counts:t,staleActiveKeys:n}=tW(e.counts??{},ym);cr=t,Wi=e.sessionAgentMap??{},Ec(),vm(n)}catch{}}function rW(){mc||(eg(),mc=setInterval(eg,ZV),Ku=_s.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(ym.has(t)){nW(t);return}Date.now()>g5&&(cr[t]=(cr[t]??0)+1,Ec())}}))}function iW(){mc&&(clearInterval(mc),mc=null),Ku&&(Ku(),Ku=null)}function sW(e){const t=e?.enabled??!0,[n,a]=k.useState(cr),[i,l]=k.useState(Wi),c=k.useCallback(async()=>{await eg()},[]),u=k.useCallback(async C=>{if(C.length===0)return;let A=!1;for(const M of C)M in cr&&(delete cr[M],A=!0);A&&Ec(),vm(C,{force:!0})},[]),m=k.useCallback(async C=>{await u([C])},[u]),f=k.useCallback(async()=>{cr={},Ec();try{await Te.unread.markAllRead()}catch{}},[]),g=k.useCallback(C=>{ym.add(C)},[]),h=k.useCallback(C=>{if(C.length!==0){for(const A of C)ym.delete(A),Zh.delete(A);g5=Date.now()+150,vm(C,{force:!0})}},[]),v=k.useCallback(C=>{h([C])},[h]);k.useEffect(()=>{if(!t)return;cu++,rW();let C=Wi;const A=()=>{a(M=>D2(M,cr)?M:{...cr}),C!==Wi&&(C=Wi,l(M=>D2(M,Wi)?M:{...Wi}))};return Jh.add(A),a({...cr}),l({...Wi}),()=>{Jh.delete(A),cu--,cu<=0&&(cu=0,iW())}},[t]);const y=k.useMemo(()=>Object.values(n).reduce((C,A)=>C+A,0),[n]),w=k.useCallback(C=>n[`session:${C}`]??0,[n]),T=k.useCallback(C=>n[`channel:${C}`]??0,[n]);return{counts:n,totalUnread:y,sessionAgentMap:i,getSessionUnread:w,getChannelUnread:T,markRead:m,markReadMany:u,markAllRead:f,refresh:c,setActiveKey:g,clearActiveKey:v,clearActiveKeys:h}}function Lle(e,t){return k.useMemo(()=>{const n=new Map;for(const[a,i]of Object.entries(t))if(a.startsWith("session:")){const l=a.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+i)}return n},[e,t])}function oW(e){return e.startsWith("channel:dm:a2a:")}function lW(e,t){let n=0;for(const[a,i]of Object.entries(e))if(a.startsWith("session:")){const l=a.slice(8);t[l]&&(n+=i)}else if(a.startsWith("channel:")){if(oW(a))continue;n+=i}return n}const cW=6,dW=56;function uW({currentPage:e,onNavigate:t}){const{t:n}=xt("nav"),[a,i]=k.useState(Gm);k.useEffect(()=>s5(i),[]);const[l,c]=k.useState(!1),u=k.useRef(!1),m=k.useCallback(v=>{u.current!==v&&(u.current=v,c(v))},[]);k.useEffect(()=>{let v=window.scrollY,y=0;const w=()=>{y||(y=requestAnimationFrame(()=>{y=0;const T=window.scrollY,C=T-v;if(v=T,T<=dW){m(!1);return}C>cW?m(!0):C<-6&&m(!1)}))};return window.addEventListener("scroll",w,{passive:!0}),()=>{window.removeEventListener("scroll",w),y&&cancelAnimationFrame(y)}},[m]),k.useEffect(()=>{m(!1)},[e,m]);const{counts:f,sessionAgentMap:g}=sW({enabled:!0}),h=k.useMemo(()=>lW(f,g),[f,g]);return o.jsx("nav",{"data-mobile-bottom-nav":!0,className:`fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom transition-transform duration-300 ease-out will-change-transform ${l?"translate-y-[calc(100%+1px)]":"translate-y-0"}`,children:xG.map(v=>{const y=v.group.includes(e),w=v.id===me.HOME,T=v.id===me.TEAM;return o.jsxs("button",{onClick:()=>t(v.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${y?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[o.jsxs("div",{className:"relative",children:[o.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:y?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:o.jsx("path",{d:Fm[v.id]})}),w&&a>0&&o.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:a>99?"99+":a}),T&&h>0&&o.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:h>99?"99+":h})]}),o.jsx("span",{className:`text-[10px] leading-tight ${y?"font-semibold":""}`,children:n(v.id)})]},v.id)})})}const xm=new Map;function As(e,t){xm.has(e)||xm.set(e,t().catch(()=>{}))}function Ps(e){const t=xm.get(e);return xm.delete(e),t}const La={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function I2(e){const t=[],n=String(e||"");let a=n.indexOf(","),i=0,l=!1;for(;!l;){a===-1&&(a=n.length,l=!0);const c=n.slice(i,a).trim();(c||!l)&&t.push(c),i=a+1,a=n.indexOf(",",i)}return t}function mW(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const pW=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hW={};function L2(e,t){return(hW.jsx?fW:pW).test(e)}const gW=/[ \t\n\f\r]/g;function bW(e){return typeof e=="object"?e.type==="text"?P2(e.value):!1:P2(e)}function P2(e){return e.replace(gW,"")===""}class Oc{constructor(t,n,a){this.normal=n,this.property=t,a&&(this.space=a)}}Oc.prototype.normal={};Oc.prototype.property={};Oc.prototype.space=void 0;function y5(e,t){const n={},a={};for(const i of e)Object.assign(n,i.property),Object.assign(a,i.normal);return new Oc(n,a,t)}function Nc(e){return e.toLowerCase()}class Ha{constructor(t,n){this.attribute=n,this.property=t}}Ha.prototype.attribute="";Ha.prototype.booleanish=!1;Ha.prototype.boolean=!1;Ha.prototype.commaOrSpaceSeparated=!1;Ha.prototype.commaSeparated=!1;Ha.prototype.defined=!1;Ha.prototype.mustUseProperty=!1;Ha.prototype.number=!1;Ha.prototype.overloadedBoolean=!1;Ha.prototype.property="";Ha.prototype.spaceSeparated=!1;Ha.prototype.space=void 0;let yW=0;const $t=Us(),Kn=Us(),tg=Us(),Ke=Us(),wn=Us(),Bo=Us(),Wa=Us();function Us(){return 2**++yW}const ng=Object.freeze(Object.defineProperty({__proto__:null,boolean:$t,booleanish:Kn,commaOrSpaceSeparated:Wa,commaSeparated:Bo,number:Ke,overloadedBoolean:tg,spaceSeparated:wn},Symbol.toStringTag,{value:"Module"})),Of=Object.keys(ng);class Yg extends Ha{constructor(t,n,a,i){let l=-1;if(super(t,n),O2(this,"space",i),typeof a=="number")for(;++l<Of.length;){const c=Of[l];O2(this,Of[l],(a&ng[c])===ng[c])}}}Yg.prototype.defined=!0;function O2(e,t,n){n&&(e[t]=n)}function Qo(e){const t={},n={};for(const[a,i]of Object.entries(e.properties)){const l=new Yg(a,e.transform(e.attributes||{},a),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(l.mustUseProperty=!0),t[a]=l,n[Nc(a)]=a,n[Nc(l.attribute)]=a}return new Oc(t,n,e.space)}const v5=Qo({properties:{ariaActiveDescendant:null,ariaAtomic:Kn,ariaAutoComplete:null,ariaBusy:Kn,ariaChecked:Kn,ariaColCount:Ke,ariaColIndex:Ke,ariaColSpan:Ke,ariaControls:wn,ariaCurrent:null,ariaDescribedBy:wn,ariaDetails:null,ariaDisabled:Kn,ariaDropEffect:wn,ariaErrorMessage:null,ariaExpanded:Kn,ariaFlowTo:wn,ariaGrabbed:Kn,ariaHasPopup:null,ariaHidden:Kn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wn,ariaLevel:Ke,ariaLive:null,ariaModal:Kn,ariaMultiLine:Kn,ariaMultiSelectable:Kn,ariaOrientation:null,ariaOwns:wn,ariaPlaceholder:null,ariaPosInSet:Ke,ariaPressed:Kn,ariaReadOnly:Kn,ariaRelevant:null,ariaRequired:Kn,ariaRoleDescription:wn,ariaRowCount:Ke,ariaRowIndex:Ke,ariaRowSpan:Ke,ariaSelected:Kn,ariaSetSize:Ke,ariaSort:null,ariaValueMax:Ke,ariaValueMin:Ke,ariaValueNow:Ke,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function x5(e,t){return t in e?e[t]:t}function w5(e,t){return x5(e,t.toLowerCase())}const vW=Qo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Bo,acceptCharset:wn,accessKey:wn,action:null,allow:null,allowFullScreen:$t,allowPaymentRequest:$t,allowUserMedia:$t,alt:null,as:null,async:$t,autoCapitalize:null,autoComplete:wn,autoFocus:$t,autoPlay:$t,blocking:wn,capture:null,charSet:null,checked:$t,cite:null,className:wn,cols:Ke,colSpan:null,content:null,contentEditable:Kn,controls:$t,controlsList:wn,coords:Ke|Bo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$t,defer:$t,dir:null,dirName:null,disabled:$t,download:tg,draggable:Kn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$t,formTarget:null,headers:wn,height:Ke,hidden:tg,high:Ke,href:null,hrefLang:null,htmlFor:wn,httpEquiv:wn,id:null,imageSizes:null,imageSrcSet:null,inert:$t,inputMode:null,integrity:null,is:null,isMap:$t,itemId:null,itemProp:wn,itemRef:wn,itemScope:$t,itemType:wn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$t,low:Ke,manifest:null,max:null,maxLength:Ke,media:null,method:null,min:null,minLength:Ke,multiple:$t,muted:$t,name:null,nonce:null,noModule:$t,noValidate:$t,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:$t,optimum:Ke,pattern:null,ping:wn,placeholder:null,playsInline:$t,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$t,referrerPolicy:null,rel:wn,required:$t,reversed:$t,rows:Ke,rowSpan:Ke,sandbox:wn,scope:null,scoped:$t,seamless:$t,selected:$t,shadowRootClonable:$t,shadowRootDelegatesFocus:$t,shadowRootMode:null,shape:null,size:Ke,sizes:null,slot:null,span:Ke,spellCheck:Kn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ke,step:null,style:null,tabIndex:Ke,target:null,title:null,translate:null,type:null,typeMustMatch:$t,useMap:null,value:Kn,width:Ke,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wn,axis:null,background:null,bgColor:null,border:Ke,borderColor:null,bottomMargin:Ke,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$t,declare:$t,event:null,face:null,frame:null,frameBorder:null,hSpace:Ke,leftMargin:Ke,link:null,longDesc:null,lowSrc:null,marginHeight:Ke,marginWidth:Ke,noResize:$t,noHref:$t,noShade:$t,noWrap:$t,object:null,profile:null,prompt:null,rev:null,rightMargin:Ke,rules:null,scheme:null,scrolling:Kn,standby:null,summary:null,text:null,topMargin:Ke,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ke,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:$t,disableRemotePlayback:$t,prefix:null,property:null,results:Ke,security:null,unselectable:null},space:"html",transform:w5}),xW=Qo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Wa,accentHeight:Ke,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ke,amplitude:Ke,arabicForm:null,ascent:Ke,attributeName:null,attributeType:null,azimuth:Ke,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ke,by:null,calcMode:null,capHeight:Ke,className:wn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ke,diffuseConstant:Ke,direction:null,display:null,dur:null,divisor:Ke,dominantBaseline:null,download:$t,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ke,enableBackground:null,end:null,event:null,exponent:Ke,externalResourcesRequired:null,fill:null,fillOpacity:Ke,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Bo,g2:Bo,glyphName:Bo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ke,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ke,horizOriginX:Ke,horizOriginY:Ke,id:null,ideographic:Ke,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ke,k:Ke,k1:Ke,k2:Ke,k3:Ke,k4:Ke,kernelMatrix:Wa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ke,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ke,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ke,overlineThickness:Ke,paintOrder:null,panose1:null,path:null,pathLength:Ke,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:wn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ke,pointsAtY:Ke,pointsAtZ:Ke,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Wa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Wa,rev:Wa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Wa,requiredFeatures:Wa,requiredFonts:Wa,requiredFormats:Wa,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ke,specularExponent:Ke,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ke,strikethroughThickness:Ke,string:null,stroke:null,strokeDashArray:Wa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ke,strokeOpacity:Ke,strokeWidth:null,style:null,surfaceScale:Ke,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Wa,tabIndex:Ke,tableValues:null,target:null,targetX:Ke,targetY:Ke,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Wa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ke,underlineThickness:Ke,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ke,values:null,vAlphabetic:Ke,vMathematical:Ke,vectorEffect:null,vHanging:Ke,vIdeographic:Ke,version:null,vertAdvY:Ke,vertOriginX:Ke,vertOriginY:Ke,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ke,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:x5}),k5=Qo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),S5=Qo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:w5}),C5=Qo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),wW={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},kW=/[A-Z]/g,z2=/-[a-z]/g,SW=/^data[-\w.:]+$/i;function A5(e,t){const n=Nc(t);let a=t,i=Ha;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&SW.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(z2,AW);a="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!z2.test(l)){let c=l.replace(kW,CW);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}i=Yg}return new i(a,t)}function CW(e){return"-"+e.toLowerCase()}function AW(e){return e.charAt(1).toUpperCase()}const T5=y5([v5,vW,k5,S5,C5],"html"),Vm=y5([v5,xW,k5,S5,C5],"svg");function H2(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function TW(e){return e.join(" ").trim()}var Ro={},zf,B2;function EW(){if(B2)return zf;B2=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,m=`
|
|
520
|
+
`);T=I.pop()??"";for(const B of I){const K=B.trim();if(K.startsWith("data: "))try{const j=JSON.parse(K.slice(6)),z=j.type;if(z==="snapshot"){const U=j.segments??[],Y=typeof j.content=="string"?j.content:"";u=Y,U.length&&(f=U),n.onSnapshot?.({content:Y,segments:U})}else if(z==="text_delta"&&typeof j.text=="string")u+=j.text,n.onChunk?.(j.text);else if(z==="thinking_delta"&&typeof j.thinking=="string")t2(n,j.thinking);else if(z==="done"){u=j.content||u,typeof j.sessionId=="string"&&(m=j.sessionId),typeof j.messageId=="string"&&(g=j.messageId);const U=j.segments;U&&(f=U),C=!0,l({content:u,sessionId:m,segments:f,messageId:g,attached:!0,terminal:!0}),y.cancel().catch(()=>{}),h?.stop();return}else if(z==="error"){c(new Error(j.message??j.error??"Stream error")),y.cancel().catch(()=>{}),h?.stop();return}else z==="thinking_commit"&&typeof j.thinking=="string"?n.onCommit?.({type:"thinking_commit",content:j.thinking,createdAt:j.createdAt??new Date().toISOString()}):z==="text_commit"&&typeof j.text=="string"?n.onCommit?.({type:"text_commit",content:j.text,createdAt:j.createdAt??new Date().toISOString()}):z==="agent_tool"&&j.tool&&j.phase?j.phase==="start"?n.onActivity?.({tool:j.tool,phase:"start",arguments:j.arguments}):j.phase==="end"&&n.onActivity?.({tool:j.tool,phase:"end",success:j.success,arguments:j.arguments,result:j.result,error:j.error,durationMs:j.durationMs}):z==="subagent_progress"&&j.tool?n.onActivity?.({tool:j.tool,phase:"subagent_progress",subagentEvent:j.subagentEvent}):z==="heartbeat"&&n.onActivity?.({tool:"",phase:"heartbeat"})}catch{}}}h?.stop(),l({content:u,sessionId:m,segments:f,messageId:g,attached:!0,terminal:C})}catch(v){h?.stop(),c(v)}})},channels:{getMessages:(e,t=30,n)=>G(`/channels/${encodeURIComponent(e)}/messages?limit=${t}${n?`&before=${n}`:""}`),sendMessage:(e,t)=>G(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(t)})},governance:{getSystemStatus:()=>G("/system/status"),emergencyStop:e=>G("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>G("/system/announcements"),createAnnouncement:e=>G("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>G("/governance/policy"),setPolicy:e=>G("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:(e,t)=>{const n=new URLSearchParams;e&&n.set("status",e),t?.limit!==void 0&&n.set("limit",String(t.limit)),t?.offset!==void 0&&n.set("offset",String(t.offset));const a=n.toString();return G(`/approvals${a?`?${a}`:""}`)},respond:(e,t,n,a,i,l)=>G(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:t,respondedBy:n,comment:a,selectedOption:i,answers:l})})},notifications:{list:(e,t,n)=>{const a=new URLSearchParams;return e&&a.set("userId",e),t&&a.set("unread","true"),n?.type&&a.set("type",n.type),n?.limit&&a.set("limit",String(n.limit)),n?.offset&&a.set("offset",String(n.offset)),G(`/notifications?${a}`)},create:e=>G("/notifications",{method:"POST",body:JSON.stringify(e)}),markRead:e=>G(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>G("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},unread:{getCounts:()=>G("/unread"),markRead:(e,t,n)=>G("/unread/mark-read",{method:"POST",body:JSON.stringify({conversationKey:e,lastReadAt:t,lastReadId:n})}),markReadBatch:e=>G("/unread/mark-read-batch",{method:"POST",body:JSON.stringify({items:e})}),markAllRead:()=>G("/unread/mark-all-read",{method:"POST"})},messages:{search:(e,t)=>{const n=new URLSearchParams({q:e});return t?.scope&&n.set("scope",t.scope),t?.channel&&n.set("channel",t.channel),t?.limit&&n.set("limit",String(t.limit)),G(`/messages/search?${n}`)}},activity:{list:e=>{const t=new URLSearchParams;e?.limit&&t.set("limit",String(e.limit)),e?.type&&t.set("type",e.type);const n=t.toString();return G(`/activity${n?`?${n}`:""}`)}},projects:{list:e=>{const t=e?`?orgId=${e}`:"";return G(`/projects${t}`)},get:e=>G(`/projects/${e}`),create:e=>G("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>G(`/projects/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>G(`/projects/${e}`,{method:"DELETE"}),syncKnowledge:(e,t)=>G(`/projects/${e}/knowledge/sync`,{method:"POST",body:JSON.stringify({knowledgeRoots:t})})},knowledge:{search:(e,t,n)=>{const a=new URLSearchParams;return e&&a.set("query",e),t&&a.set("scope",t),n&&a.set("category",n),G(`/knowledge/search?${a}`)},contribute:e=>G("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,t)=>G(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:t})}),verify:e=>G(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>G(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const t=new URLSearchParams;return e?.q&&t.set("q",e.q),e?.projectId&&t.set("projectId",e.projectId),e?.agentId&&t.set("agentId",e.agentId),e?.taskId&&t.set("taskId",e.taskId),e?.type&&t.set("type",e.type),e?.status&&t.set("status",e.status),e?.artifactType&&t.set("artifactType",e.artifactType),e?.source&&t.set("source",e.source),e?.offset&&t.set("offset",String(e.offset)),e?.limit&&t.set("limit",String(e.limit)),G(`/deliverables?${t}`)},get:e=>G(`/deliverables/${e}`).then(t=>({...t,deliverable:UG(t.deliverable)})),create:e=>G("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>G(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(t)}),remove:e=>G(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>G(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})}),checkHealth:e=>{const t=new URLSearchParams;return e&&t.set("agentId",e),G(`/deliverables/health?${t}`)}},codeReviews:{list:(e,t=20)=>{const n=new URLSearchParams;return e&&n.set("taskId",e),n.set("limit",String(t)),G(`/reviews?${n}`)},get:e=>G(`/reviews/${e}`),run:e=>G("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>G("/reports"),get:e=>G(`/reports/${e}`),generate:e=>G("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,t)=>G(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(t)}),rejectPlan:(e,t)=>G(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(t)}),addFeedback:(e,t)=>G(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(t)}),getFeedback:e=>G(`/reports/${e}/feedback`)},executionLogs:{get:(e,t)=>G(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(t)}`)},groupChats:{list:()=>G("/group-chats"),create:e=>G("/group-chats",{method:"POST",body:JSON.stringify(e)}),getById:e=>G(`/group-chats/${e}`),update:(e,t)=>G(`/group-chats/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>G(`/group-chats/${e}`,{method:"DELETE"}),addMember:(e,t,n,a)=>G(`/group-chats/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n,memberName:a})}),removeMember:(e,t)=>G(`/group-chats/${e}/members/${t}`,{method:"DELETE"})},uploads:{upload:(e,t)=>G("/uploads",{method:"POST",body:JSON.stringify({files:e,prefix:t})})},hubOrgs:{mine:()=>Ut("/orgs/mine"),get:e=>Ut(`/orgs/${e}`),update:(e,t)=>Ut(`/orgs/${e}`,{method:"PUT",body:JSON.stringify(t)}),create:e=>Ut("/orgs",{method:"POST",body:JSON.stringify({name:e})}),members:e=>Ut(`/orgs/${e}/members`),invite:(e,t)=>Ut(`/orgs/${e}/members`,{method:"POST",body:JSON.stringify(t)}),removeMember:(e,t)=>Ut(`/orgs/${e}/members/${t}`,{method:"DELETE"}),updateMemberRole:(e,t,n)=>Ut(`/orgs/${e}/members/${t}`,{method:"PATCH",body:JSON.stringify({role:n})}),invitations:()=>Ut("/orgs/invitations"),acceptInvitation:e=>Ut(`/orgs/${e}/members/accept`,{method:"POST"}),leave:e=>Ut(`/orgs/${e}/leave`,{method:"POST"})},workflows:{list:e=>G(`/teams/${e}/workflows`),get:(e,t)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}`),create:(e,t,n)=>G(`/teams/${e}/workflows`,{method:"POST",body:JSON.stringify({name:t,yaml:n})}),update:(e,t,n)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({yaml:n})}),remove:(e,t)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),roles:(e,t)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}/roles`),listRuns:(e,t,n)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs${n?`?limit=${n}`:""}`),startRun:(e,t,n,a,i)=>G(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs`,{method:"POST",body:JSON.stringify({projectId:n,params:a,roleMapping:i})}),getRun:e=>G(`/workflow-runs/${e}`),cancelRun:e=>G(`/workflow-runs/${e}`,{method:"DELETE"}),pauseRun:e=>G(`/workflow-runs/${e}/pause`,{method:"POST"}),resumeRun:e=>G(`/workflow-runs/${e}/resume`,{method:"POST"})}};function Nle(e){return{id:e.id,sourceType:"task",sourceId:e.taskId,agentId:e.agentId,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,executionRound:e.executionRound,createdAt:e.createdAt}}function Mle(e,t,n){return e.type==="llm_request"?null:{id:`alog_${t}_${e.seq}`,sourceType:"activity",sourceId:t,agentId:n,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,createdAt:e.createdAt}}class uc{ws=null;handlers=new Map;reconnectTimer=null;heartbeatTimer=null;intentionalClose=!1;currentUserId;reconnectAttempts=0;lastEventTimestamp=null;static BACKOFF_BASE=1e3;static BACKOFF_MAX=3e4;static HEARTBEAT_INTERVAL=25e3;connect(t){if(t!==void 0&&(this.currentUserId=t),this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN))if(t!==void 0&&this.ws.url&&!this.ws.url.includes(`userId=${t}`))this.ws.onclose=null,this.ws.close(),this.ws=null;else return;this.intentionalClose=!1;const n=window.location.protocol==="https:"?"wss:":"ws:",a=new URLSearchParams;this.currentUserId&&a.set("userId",this.currentUserId),this.lastEventTimestamp&&a.set("since",this.lastEventTimestamp);const i=a.toString(),l=`${n}//${window.location.host}/ws${i?`?${i}`:""}`,c=new WebSocket(l);this.ws=c,c.onopen=()=>{this.reconnectAttempts=0,this.startHeartbeat(c)},c.onmessage=u=>{if(this.ws===c)try{const m=JSON.parse(u.data);if(m.timestamp&&(this.lastEventTimestamp=m.timestamp),m.type==="pong")return;const f=this.handlers.get(m.type);if(f)for(const h of f)h(m);const g=this.handlers.get("*");if(g)for(const h of g)h(m)}catch{}},c.onclose=()=>{if(this.stopHeartbeat(),this.intentionalClose)return;const u=Math.min(uc.BACKOFF_BASE*Math.pow(2,this.reconnectAttempts),uc.BACKOFF_MAX);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(this.currentUserId),u)},c.onerror=()=>{c.close()}}startHeartbeat(t){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"ping"}))},uc.HEARTBEAT_INTERVAL)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}disconnect(){this.intentionalClose=!0,this.stopHeartbeat(),this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>this.handlers.get(t)?.delete(n)}}const _s=new uc;let Um=typeof window<"u"?window.__MARKUS_HUB_URL__??"https://markus.global":"https://markus.global",Fu=null;async function Fh(){if(!kn())return null;try{const e=await Ut("/auth/me");if(e?.user?.id){const t=kn();return dm(t,e.user),e.user}}catch{}return mr()}async function O4(){if(!window.__MARKUS_PREVIEW__)try{const e=await G("/settings/hub");e.hubUrl&&(Um=e.hubUrl)}catch{}}function iK(){return Fu||(Fu=O4().finally(()=>{})),Fu}window.__MARKUS_PREVIEW__||(Fu=O4().then(async()=>{const e=localStorage.getItem("markus_hub_token");if(e)G("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{}),Fh();else try{await Te.auth.me();const t=await G("/settings/hub-token");t.token&&(localStorage.setItem("markus_hub_token",t.token),await Fh())}catch{}}).catch(()=>{}));const Ac="markus_hub_token",lm="markus_hub_user";function kn(){return localStorage.getItem(Ac)}async function sK(){const e=kn();if(e)return e;try{await Te.auth.me()}catch{return null}try{const t=await G("/settings/hub-token");if(t.token)return localStorage.setItem(Ac,t.token),Fh(),t.token}catch{}return null}function mr(){try{const e=localStorage.getItem(lm);return e?JSON.parse(e):null}catch{return null}}function cm(e,t){if(e.purchasedByCurrentUser||t?.has(e.id))return!0;const n=mr();if(!n?.id)return!1;const a=e.author?.id??e.authorId;return!!a&&a===n.id}function Ls(){localStorage.removeItem(Ac),localStorage.removeItem(lm),z4(null),window.dispatchEvent(new CustomEvent("markus:hub-auth"))}function dm(e,t){const n=localStorage.getItem(Ac),a=localStorage.getItem(lm),i=JSON.stringify(t);n===e&&a===i||(localStorage.setItem(Ac,e),localStorage.setItem(lm,i),z4(e),window.dispatchEvent(new CustomEvent("markus:hub-auth")))}function z4(e){G("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}async function oK(e){e.openrouter?.key&&await G("/settings/subscription-key",{method:"POST",body:JSON.stringify({openrouter:e.openrouter})}).catch(()=>{})}async function Gg(e){try{return await G(`/auth/hub-connect-status?session=${encodeURIComponent(e)}&_t=${Date.now()}`)}catch{return null}}async function Kg(e){!e.token||!e.user||(dm(e.token,e.user),e.openrouter?.key&&await oK({openrouter:e.openrouter}),lK())}async function lK(){if(kn())try{const{org:e}=await G("/settings/org"),t=e?.name?.trim();if(!t||t==="My Organization")return;const a=((await Ut("/orgs/mine")).orgs??[]).find(i=>i.role==="owner");if(!a||a.name===t)return;await Ut(`/orgs/${a.id}`,{method:"PUT",body:JSON.stringify({name:t})})}catch{}}function H4(){return window.markusDesktop}async function cK(e,t=12e4){const n=Date.now()+t;for(;Date.now()<n;){const a=await Gg(e);if(a?.ready&&a.token&&a.user)return await Kg(a),!0;await new Promise(i=>setTimeout(i,1200))}return!1}let Uu=null;H4()?.onDeepLinkAuth?.(e=>{Uu?.(e?.session??"")});let um=null;function dK(){um?.(),Ms=null}function uK(e,t,n){return new Promise((a,i)=>{let l=!1,c=!1;const u=(T,C)=>{l||(l=!0,um=null,clearInterval(y),clearTimeout(w),window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",h),Uu===f&&(Uu=null),T?(n.focusWindow?.(),a()):i(C))};um=()=>u(!1,new Error("Hub login cancelled"));const m=async()=>{if(!(l||c)){c=!0;try{const T=await Gg(e);T?.ready&&T.token&&T.user&&(await Kg(T),u(!0))}finally{c=!1}}},f=T=>{(!T||T===e)&&m()};Uu=f;const g=()=>{m()},h=()=>{document.visibilityState==="visible"&&m()};window.addEventListener("focus",g),document.addEventListener("visibilitychange",h);let v=`${Um}/auth/connect?session=${encodeURIComponent(e)}&redirect=${encodeURIComponent("markus://auth")}`;t&&(v+=`&method=${encodeURIComponent(t)}`),Promise.resolve(n.openExternal(v)).then(()=>{m()}).catch(T=>{u(!1,T instanceof Error?T:new Error("Failed to open browser"))});const y=setInterval(()=>{m()},1500),w=setTimeout(()=>u(!1,new Error("Hub login timed out")),5*6e4)})}function mK(e,t){return new Promise((n,a)=>{let i=`${Um}/auth/connect?session=${encodeURIComponent(e)}`;t&&(i+=`&method=${encodeURIComponent(t)}`);const l=460,c=580,u=Math.round(window.screenX+(window.outerWidth-l)/2),m=Math.round(window.screenY+(window.outerHeight-c)/2),f=window.open(i,"markus_hub_auth",`popup=yes,width=${l},height=${c},left=${u},top=${m}`);if(!f){a(new Error("Popup blocked by browser. Please allow popups for this site."));return}let g=!1,h=null;const v=()=>{clearInterval(w),clearInterval(C),h&&clearInterval(h),document.removeEventListener("visibilitychange",T)},y=async()=>{if(g)return;const A=await Gg(e);A?.ready&&A.token&&A.user&&(g=!0,await Kg(A),v(),f?.close(),n())},w=setInterval(()=>{y()},1500),T=()=>{!g&&document.visibilityState==="visible"&&y()};document.addEventListener("visibilitychange",T);const C=setInterval(()=>{if(!g&&f?.closed){clearInterval(C);let A=0;h=setInterval(async()=>{if(g){clearInterval(h);return}A++,await y(),A>=5&&!g&&(g=!0,v(),kn()?n():a(new Error("Hub login cancelled")))},1e3)}},500)})}let Ms=null;function Ia(e){const t=typeof e=="string"?{method:e}:e??{};if(t.force)um?.(),Ms=null,(kn()||mr())&&Ls();else if(kn())return Promise.resolve();if(Ms)return Ms;const n=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`,a=H4(),i=(async()=>{await iK(),a?await uK(n,t.method,a):await mK(n,t.method)})();return Ms=i,i.catch(()=>{}).finally(()=>{Ms===i&&(Ms=null)}),i}async function Ut(e,t){const n=kn(),a={"Content-Type":"application/json",...t?.headers};n&&(a.Authorization=`Bearer ${n}`);const i=await fetch(`${Rs}/hub${e}`,{...t,headers:a,credentials:"include"}),l=await i.json();if(i.status===401&&n&&Ls(),!i.ok){const c=new Error(l.error??`Hub HTTP ${i.status}`);throw c.code=typeof l.code=="string"?l.code:void 0,c.retryAfterSeconds=typeof l.retryAfterSeconds=="number"?l.retryAfterSeconds:void 0,c.status=i.status,c}return l}async function B4(){if(!kn())return!1;try{return await Ut("/user/plan"),!0}catch{return!1}}const nt={getUrl:()=>Um,isAuthenticated:()=>!!kn(),getUser:mr,logout:()=>{Ls()},ensureAuth:Ia,validateSession:B4,login:async(e,t)=>{const n=await Ut("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})});return dm(n.token,n.user),n},register:async(e,t,n)=>{const a=await Ut("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:t,password:n})});return dm(a.token,a.user),a},search:e=>{const t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.subtype&&t.set("subtype",e.subtype),e?.q&&t.set("q",e.q),e?.category&&t.set("category",e.category),e?.sort&&t.set("sort",e.sort),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit));const n=t.toString();return Ut(`/items${n?`?${n}`:""}`)},getItem:e=>Ut(`/items/${e}`),download:async e=>{await Ia();try{return await Ut(`/items/${e}/download`,{method:"POST"})}catch(t){if(!kn())return await Ia(),Ut(`/items/${e}/download`,{method:"POST"});throw t}},publish:async e=>{await Ia();try{return await Ut("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!kn())return await Ia(),Ut("/items",{method:"POST",body:JSON.stringify(e)});throw t}},uploadImage:async e=>{await Ia();try{const t=new FormData;t.append("file",e);const n=await fetch("/api/hub/upload",{method:"POST",credentials:"include",headers:{Authorization:`Bearer ${kn()}`},body:t});return n.ok?await n.json():null}catch{return null}},uploadMediaBatch:async e=>{await Ia();try{const t=await fetch("/api/hub/deliverables/media",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Authorization:`Bearer ${kn()}`},body:JSON.stringify({files:e})});return t.ok?await t.json():{files:[],errors:[{filename:"batch",error:`HTTP ${t.status}`}]}}catch(t){return{files:[],errors:[{filename:"batch",error:String(t)}]}}},publishViaProxy:async e=>{await Ia();try{return await Ut("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!kn())return await Ia(),Ut("/items",{method:"POST",body:JSON.stringify(e)});throw t}},updateItem:async(e,t)=>(await Ia(),Ut(`/items/${e}`,{method:"PUT",body:JSON.stringify(t)})),myItems:async()=>kn()?Ut("/items/mine"):{items:[]},browseItems:async e=>{const t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.orgId&&t.set("orgId",e.orgId),e?.q&&t.set("q",e.q),e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit??50));const n=t.toString();return Ut(`/items${n?`?${n}`:""}`)},myOrgs:async()=>kn()?Ut("/orgs/mine").then(e=>({memberships:(e.orgs??[]).map(t=>({id:t.id,name:t.name,slug:t.slug,role:t.role}))})):{memberships:[]},deleteItem:async e=>(await Ia(),Ut(`/items/${e}`,{method:"DELETE"})),purchases:{checkout:e=>Ut("/purchases/checkout",{method:"POST",body:JSON.stringify({itemId:e})}),payWithEarnings:e=>Ut("/purchases/pay-with-earnings",{method:"POST",body:JSON.stringify({itemId:e})}),mine:()=>Ut("/purchases/mine")},creator:{getBalance:()=>Ut("/creator/balance")},feedback:{create:e=>Ut("/feedback",{method:"POST",body:JSON.stringify(e)})},user:{plan:()=>Ut("/user/plan"),cuStats:(e=30,t="day")=>Ut(`/user/cu/stats?days=${e}&granularity=${t}`),claimFreeCreditsStatus:()=>Ut("/user/claim-free-credits"),claimFreeCredits:()=>Ut("/user/claim-free-credits",{method:"POST"}),referral:()=>Ut("/user/referral")}},pK=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function $4(e){return typeof e=="string"&&e.length>=2&&e.length<=64&&pK.test(e)}function Tc(e){const t=e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-+|-+$/g,"");return $4(t)?t:null}function mm(e,t){const n=Tc(e);if(n)return n;if(t){const i=Tc(t);if(i)return i;if($4(t))return t}let a=0;for(let i=0;i<e.length;i++)a=(a<<5)-a+e.charCodeAt(i)|0;return`pkg-${Math.abs(a).toString(36)}`}let n2=null,au=me.HOME;const yt={setHandler(e){n2=e},navigate(e,t){t&&Object.entries(t).forEach(([n,a])=>localStorage.setItem(`markus_nav_${n}`,a)),n2?.(e,t),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:t}}))},setSettingsReturnPage(e){e!==me.SETTINGS&&(au=e)},getSettingsReturnPage(){return au},leaveSettings(){const e=au!==me.SETTINGS?au:me.HOME;this.navigate(e)}};let q4=Sc();const Uh=new Set;function a2(){q4=Sc(),Uh.forEach(e=>e())}typeof window<"u"&&(window.addEventListener("hashchange",a2),window.addEventListener("popstate",a2));function fK(e){return Uh.add(e),()=>Uh.delete(e)}function hK(e){return k.useSyncExternalStore(fK,()=>q4===e,()=>!1)}var Lc=f4();function Fs(e){k.useEffect(()=>wG(),[e])}function vr({title:e,message:t,confirmLabel:n,cancelLabel:a,variant:i="danger",alertOnly:l=!1,checkboxes:c,onConfirm:u,onCancel:m,onCancelClick:f}){const{t:g}=xt("common");Fs(!0);const[h,v]=k.useState(()=>{const T={};for(const C of c??[])T[C.id]=C.defaultChecked??!1;return T}),y=i==="primary",w=y?"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors":"px-4 py-1.5 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors";return Lc.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:m,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[360px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[o.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center shrink-0 ${y?"bg-brand-500/15":"bg-red-500/15"}`,children:y?o.jsxs("svg",{className:"w-5 h-5 text-brand-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M12 16v-4"}),o.jsx("path",{d:"M12 8h.01"})]}):o.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),o.jsxs("div",{className:"min-w-0 pt-0.5",children:[o.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:e}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:t})]})]}),c&&c.length>0&&o.jsx("div",{className:"mb-4 space-y-2",children:c.map(T=>o.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:h[T.id]??!1,onChange:C=>v(A=>({...A,[T.id]:C.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),T.label]},T.id))}),o.jsxs("div",{className:"flex justify-end gap-2",children:[!l&&o.jsx("button",{type:"button",onClick:()=>{f?f(c?h:void 0):m()},className:"px-4 py-1.5 text-sm border border-border-default rounded-lg text-fg-primary hover:bg-surface-elevated transition-colors",children:a??g("cancel")}),o.jsx("button",{type:"button",onClick:()=>u(c?h:void 0),className:w,children:n??g(l?"ok":"confirm")})]})]})}),document.body)}function F4(e,t){const n=e||t||null;if(!n)return null;if(n.startsWith("http")||n.startsWith("data:")||n.startsWith("/api/"))return n;if(n.startsWith("/")){const a=nt.getUrl()?.replace(/\/$/,"")||"";return a?`${a}${n}`:n}return n}function U4({size:e,className:t=""}){const n=Math.max(12,Math.round(e*.55));return o.jsx("div",{className:`rounded-full bg-surface-overlay text-fg-secondary flex items-center justify-center shrink-0 border border-border-default/70 ${t}`,style:{width:e,height:e},"aria-hidden":!0,children:o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),o.jsx("circle",{cx:"12",cy:"7",r:"4"})]})})}function Fo({name:e,avatarUrl:t,size:n=28,className:a="",bgClass:i="bg-brand-600 text-on-brand",fallback:l="initials"}){const[c,u]=k.useState(!1);if(k.useEffect(()=>{u(!1)},[t]),!!t&&!c)return o.jsx("img",{src:t,alt:e??"",className:`rounded-full object-cover shrink-0 ${a}`,style:{width:n,height:n},onError:()=>u(!0)});if(l==="icon")return o.jsx(U4,{size:n,className:a});const f=e?.[0]?.toUpperCase()??"?",g=n<=20?"text-[8px]":n<=28?"text-xs":n<=40?"text-sm":"text-lg",h=/\btext-(?!white\b)/.test(i);return o.jsx("div",{className:`rounded-full ${i} flex items-center justify-center ${h?"":"text-white"} ${g} font-bold shrink-0 ${a}`,style:{width:n,height:n},children:f})}function G4({currentUrl:e,name:t,size:n=64,targetType:a="user",targetId:i,onUploaded:l}){const{t:c}=xt("common"),[u,m]=k.useState(null),[f,g]=k.useState(!1),[h,v]=k.useState(!1),[y,w]=k.useState(null),T=k.useRef(null),C=u??e;k.useEffect(()=>{v(!1)},[C]);const A=!!C&&!h,M=k.useCallback(async I=>{if(!I.type.startsWith("image/"))return;if(I.size>2*1024*1024){w(c("imageTooLarge"));return}const B=new FileReader;B.onload=async()=>{const K=B.result;m(K),v(!1),g(!0);try{const{avatarUrl:j}=await Te.auth.uploadAvatar(K,a,i);l?.(j)}catch{m(null)}finally{g(!1)}},B.readAsDataURL(I)},[a,i,l,c]);return o.jsxs("div",{className:"relative inline-block group",children:[o.jsx("input",{ref:T,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden",onChange:I=>{const B=I.target.files?.[0];B&&M(B)}}),o.jsxs("button",{type:"button",onClick:()=>T.current?.click(),className:"relative rounded-full overflow-hidden focus:outline-none focus:ring-2 focus:ring-brand-500/50",style:{width:n,height:n},title:c("clickToSetAvatar",{defaultValue:"Click to set avatar"}),"aria-busy":f,children:[A?o.jsx("img",{src:C,alt:t??"",className:"w-full h-full object-cover",onError:()=>v(!0)}):o.jsx(U4,{size:n}),o.jsx("div",{className:`absolute inset-0 bg-black/45 flex items-center justify-center transition-opacity ${f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:f?o.jsx("div",{className:"w-5 h-5 border-2 border-white/60 border-t-white rounded-full animate-spin"}):o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),o.jsx("circle",{cx:"12",cy:"13",r:"4"})]})})]}),y&&o.jsx(vr,{alertOnly:!0,variant:"danger",title:c("error",{defaultValue:"Error"}),message:y,onConfirm:()=>w(null),onCancel:()=>w(null)})]})}const gK={total:0,used:0,remaining:0,pct:0,personalLimit:!1};function bK(e){return e?"billing":"login"}function yK(e,t){return e?t?"sidebar.hubConnectedAs":"sidebar.hubConnected":"sidebar.hubDisconnected"}function Mo(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function vK(e,t){const n=e?.memberCuLimit;return n==null||n<=0,!1}function xK(e,t){if(!e)return gK;const n=vK(e),a=e.memberCuLimit!==null&&e.memberCuLimit!==void 0&&e.memberCuLimit>0,i=Mo(e.monthlyQuotaCu)+Mo(e.bonusCu)+Mo(e.purchasedCu),l=n?Mo(e.memberCuLimit):e.creditsBudgetCu??(a?Mo(e.memberCuLimit):i),c=n?Mo(e.memberCuUsed):e.totalConsumedThisPeriod??e.cuUsed??e.memberCuUsed??0,u=Math.max(0,l-c),m=l>0?Math.min(100,Math.round(c/l*100)):0;return{total:l,used:c,remaining:u,pct:m,personalLimit:n}}function K4(e){const[t,n]=k.useState(()=>nt.isAuthenticated()),[a,i]=k.useState(()=>mr()),[l,c]=k.useState(null),u=k.useCallback(m=>{if(i(mr()),!nt.isAuthenticated()){n(!1),c(null);return}if(!m?.validate){n(!0);return}B4().then(f=>{n(f),i(mr())})},[]);return k.useEffect(()=>{u({validate:!0});const m=()=>u(),f=()=>u({validate:!0});return window.addEventListener("markus:hub-auth",m),window.addEventListener("focus",f),()=>{window.removeEventListener("markus:hub-auth",m),window.removeEventListener("focus",f)}},[u]),k.useEffect(()=>{if(!e||!nt.isAuthenticated())return;let m=!1;return nt.user.plan().then(f=>{m||c(xK(f))}).catch(()=>{m||c(null)}),()=>{m=!0}},[e,t]),{connected:t,user:a,credits:l,refresh:u}}function Uo(){return!!window.markusDesktop}function Or(e){window.markusDesktop?window.markusDesktop.openExternal(e):window.open(e,"_blank","noopener,noreferrer")}function wK({authUser:e,onNavigate:t,onLogout:n}){const{t:a}=xt(["settings","common","nav"]),[i,l]=k.useState(!1),[c,u]=k.useState(!1),{connected:m,user:f,credits:g}=K4(i);k.useEffect(()=>{const T=()=>l(!0);return window.addEventListener("markus:open-drawer",T),()=>window.removeEventListener("markus:open-drawer",T)},[]),k.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i]);const h=T=>{if(l(!1),T==="__edit_profile"){window.dispatchEvent(new CustomEvent("markus:open-edit-profile"));return}t(T)},v=()=>{if(l(!1),bK(m)==="login"){Ia().catch(()=>{});return}Or(`${nt.getUrl().replace(/\/$/,"")}/settings?tab=billing`)},y=()=>{l(!1),yt.navigate(me.SETTINGS,{tab:"account"})};if(!i)return null;const w=a(`nav:${yK(m,!!f?.username)}`,{username:f?.username??""});return o.jsxs("div",{className:"fixed inset-0 z-[100]",children:[o.jsx("div",{className:"absolute inset-0 bg-black/40 animate-fadeIn",onClick:()=>l(!1)}),o.jsxs("aside",{className:"absolute inset-y-0 left-0 w-72 bg-surface-secondary shadow-2xl flex flex-col animate-slideInLeft",children:[o.jsx("div",{className:"px-5 pt-6 pb-4 border-b border-border-default",children:e?o.jsxs("button",{onClick:()=>h("__edit_profile"),className:"flex items-center gap-3 w-full text-left",children:[o.jsx(Fo,{name:e.name||"User",avatarUrl:e.avatarUrl,size:40}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:e.name||a("common:userPlaceholder")}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:e.email||e.role})]}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]}):o.jsx("div",{className:"text-sm text-fg-tertiary",children:a("common:loading")})}),o.jsxs("div",{className:"px-3 pt-3 pb-1 border-b border-border-default space-y-0.5",children:[o.jsxs("button",{onClick:v,title:m?a("common:creditBalanceOpenHub"):void 0,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-surface-overlay active:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:"w-[18px] h-[18px] flex items-center justify-center shrink-0 text-fg-tertiary",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),o.jsx("path",{d:"M12.5 5.5v13",strokeDasharray:"2 2.5"})]})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-secondary truncate",children:a("common:creditBalance")}),o.jsx("span",{className:"text-sm font-medium text-fg-primary shrink-0 tabular-nums",children:m?g!==null?g.remaining.toLocaleString():"—":a("nav:sidebar.hubLoginShort")}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]}),o.jsxs("button",{onClick:y,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:"w-[18px] h-[18px] flex items-center justify-center shrink-0",children:o.jsx("span",{className:`w-2 h-2 rounded-full ${m?"bg-emerald-500":"bg-fg-muted"}`})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-secondary truncate",children:w}),o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:o.jsx("polyline",{points:"9 18 15 12 9 6"})})]})]}),o.jsxs("nav",{className:"flex-1 overflow-y-auto py-3 px-3 space-y-1",children:[o.jsx(Rf,{icon:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),o.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),label:a("common:home",{defaultValue:"Home"}),onClick:()=>h(me.HOME)}),o.jsx(Rf,{icon:o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:Fm[me.BUILDER]})}),label:a("nav:builder"),onClick:()=>h(me.BUILDER)}),o.jsx(Rf,{icon:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.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-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-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 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 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 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),label:a("settings:title"),onClick:()=>h(me.SETTINGS)})]})]}),c&&n&&o.jsx(vr,{title:a("common:signOutConfirmTitle"),message:a("common:signOutConfirmMessage"),confirmLabel:a("common:signOut"),variant:"primary",onConfirm:()=>{u(!1),l(!1),n()},onCancel:()=>u(!1)})]})}function Rf({icon:e,label:t,onClick:n}){return o.jsxs("button",{onClick:n,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm text-fg-secondary hover:text-fg-primary hover:bg-surface-overlay transition-colors",children:[e,o.jsx("span",{children:t})]})}function kK(){window.dispatchEvent(new CustomEvent("markus:open-drawer"))}function V4({className:e=""}){return o.jsx("button",{onClick:kK,className:`p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 ${e}`,"aria-label":"Menu",children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),o.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),o.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})})}function SK({onClose:e,onClaimed:t}){const{t:n}=xt(["home","common"]);Fs(!0);const[a,i]=k.useState("loading"),[l,c]=k.useState(1e3),[u,m]=k.useState(""),f=k.useRef(t);f.current=t;const g=k.useRef(!1),h=()=>`${nt.getUrl().replace(/\/$/,"")}/settings?tab=overview&claim=1`,v=k.useCallback(async()=>{i("loading"),m("");try{kn()||await Ia();const w=await nt.user.claimFreeCreditsStatus();if(typeof w.amountCu=="number"&&w.amountCu>0&&c(w.amountCu),w.claimed){i("already"),f.current();return}i("open_hub")}catch(w){m(w instanceof Error?w.message:n("claim.loadFailed")),i("error")}},[n]);k.useEffect(()=>{g.current||(g.current=!0,v())},[v]);const y=()=>{const w=h();Uo()?Or(w):window.open(w,"_blank","noopener,noreferrer")};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60] p-4",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-6 w-full max-w-md shadow-2xl",onClick:w=>w.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold text-lg text-fg-primary",children:n("claim.title")}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:n("claim.subtitle")})]}),o.jsx("button",{type:"button",onClick:e,className:"text-fg-tertiary hover:text-fg-primary text-lg leading-none",children:"×"})]}),a==="loading"&&o.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:n("claim.loading")}),a==="already"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-emerald-400",children:n("claim.success",{amount:l.toLocaleString()})}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("claim.startUsing")}),o.jsx("button",{type:"button",onClick:e,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-on-brand hover:bg-brand-600",children:n("common:close")})]}),a==="open_hub"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:n("claim.openHubHint",{amount:l.toLocaleString()})}),o.jsx("button",{type:"button",onClick:y,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-on-brand hover:bg-brand-600",children:n("claim.openHub")})]}),a==="error"&&o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-red-400",children:u}),o.jsx("button",{type:"button",onClick:()=>{v()},className:"w-full py-2 text-sm rounded-xl border border-border-default",children:n("claim.retry")})]})]})})}function r2(e){return e.includes(":")?e:`common:${e}`}const Dr=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar",labelKey:"shortcuts.toggleLeft",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",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:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"new-conversation",group:"team",keys:["N"],label:"New conversation",labelKey:"shortcuts.newConversation",page:"team"},{id:"cycle-session-tab",group:"team",keys:["Ctrl","Tab"],label:"Next conversation tab",labelKey:"shortcuts.cycleSessionTab",page:"team"},{id:"cycle-session-tab-prev",group:"team",keys:["Ctrl","Shift","Tab"],label:"Previous conversation tab",labelKey:"shortcuts.cycleSessionTabPrev",page:"team"}];function W4(e){return`markus_shortcut_lesson_${e}`}function pm(e){try{const t=localStorage.getItem(W4(e));if(!t)return[];const n=JSON.parse(t);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function fm(e,t){try{localStorage.setItem(W4(e),JSON.stringify(t.filter(Boolean)))}catch{}}function Vg(e){const t=new Set(pm(e));return Dr.every(n=>t.has(n.id))}function CK(e,t,n){const a=Dr.find(l=>Y4(e,l.id,n));if(!a)return Vg(t);const i=new Set(pm(t));return i.add(a.id),fm(t,[...i]),Dr.every(l=>i.has(l.id))}function AK(e){fm(e,Dr.map(t=>t.id))}function Y4(e,t,n){const a=n?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey,i=e.key.toLowerCase();switch(t){case"toggle-left":return a&&!e.altKey&&!e.shiftKey&&i==="b";case"nav-l0-jk":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&(i==="j"||i==="k");case"nav-l0-l":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="l";case"nav-l0-h":return!e.metaKey&&!e.ctrlKey&&!e.altKey&&i==="h";case"search":return a&&!e.altKey&&!e.shiftKey&&i==="p";case"help":return a&&!e.altKey&&(i==="/"||!e.shiftKey&&(e.code==="Slash"||i==="/"));case"new-conversation":return a&&!e.altKey&&!e.shiftKey&&i==="n";case"cycle-session-tab":return e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"&&!e.shiftKey;case"cycle-session-tab-prev":return e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"&&e.shiftKey;default:return!1}}const TK=[{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:"new-conversation",group:"team",keys:["N"],label:"New conversation",labelKey:"shortcuts.newConversation",page:"team"},{id:"cycle-session-tab",group:"team",keys:["Ctrl","Tab"],label:"Next conversation tab",labelKey:"shortcuts.cycleSessionTab",page:"team"},{id:"cycle-session-tab-prev",group:"team",keys:["Ctrl","Shift","Tab"],label:"Previous conversation tab",labelKey:"shortcuts.cycleSessionTabPrev",page:"team"},{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 Q4(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 i2(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 s2(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const EK=["layout","navigation","search","help","team"];function NK(e,t){return t&&e.startsWith("⌘")?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-[15px] font-semibold leading-none",children:"⌘"}),o.jsx("span",{className:"text-[13px]",children:e.slice(1)})]}):o.jsx("span",{className:"text-[13px]",children:e})}function MK({open:e,userId:t,onClose:n,onCompleted:a}){const{t:i}=xt(["home","common"]),l=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),[c,u]=k.useState(()=>new Set(t?pm(t):[]));k.useEffect(()=>{e&&t&&u(new Set(pm(t)))},[e,t]);const m=Dr.every(y=>c.has(y.id)),f=c.size;k.useEffect(()=>{!e||!t||m&&Vg(t)&&a()},[e,t,m]);const g=k.useMemo(()=>EK.map(y=>({group:y,items:Dr.filter(w=>w.group===y)})).filter(y=>y.items.length>0),[]);if(k.useEffect(()=>{if(!e||!t)return;const y=w=>{if(w.key==="Escape"){n();return}const T={key:w.key,code:w.code,metaKey:w.metaKey,ctrlKey:w.ctrlKey,altKey:w.altKey,shiftKey:w.shiftKey},C=Dr.find(A=>Y4(T,A.id,l));C&&((w.metaKey||w.ctrlKey||w.altKey)&&w.preventDefault(),w.stopPropagation(),u(A=>{if(A.has(C.id))return A;const M=new Set(A);return M.add(C.id),t&&fm(t,[...M]),M}))};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[e,t,l,n]),!e)return null;const h=y=>{t&&u(w=>{const T=new Set(w);return T.has(y)?T.delete(y):T.add(y),fm(t,[...T]),T})},v=()=>{t&&(AK(t),u(new Set(Dr.map(y=>y.id))),a())};return o.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:y=>{y.target===y.currentTarget&&n()},role:"dialog","aria-modal":"true","aria-label":i("home:checklist.shortcutLesson.title"),children:o.jsxs("div",{className:"w-full max-w-md max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[o.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:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:i("checklist.shortcutLesson.title")}),o.jsx("button",{type:"button",onClick:n,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":i("common:shortcuts.close"),children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"px-4 py-3",children:[o.jsx("p",{className:"text-xs text-fg-secondary mb-3",children:i("checklist.shortcutLesson.subtitle")}),m?o.jsxs("div",{className:"flex items-center gap-2 bg-green-500/10 border border-green-500/30 rounded-xl px-4 py-3 mb-4",children:[o.jsx("span",{className:"text-green-600 text-base",children:"✓"}),o.jsx("span",{className:"text-sm font-medium text-green-600",children:i("checklist.shortcutLesson.allDone")})]}):o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-300",style:{width:`${f/Dr.length*100}%`}})}),o.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:i("checklist.progress",{done:f,total:Dr.length})})]}),o.jsx("div",{className:"space-y-4",children:g.map(({group:y,items:w})=>o.jsxs("section",{children:[o.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:i(r2(`shortcuts.groups.${y}`),{defaultValue:y})}),o.jsx("ul",{className:"space-y-1",children:w.map(T=>{const C=c.has(T.id);return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>h(T.id),className:"w-full flex items-center justify-between gap-3 rounded-lg px-2 py-2 text-left hover:bg-surface-elevated/60 transition-colors",children:[o.jsxs("span",{className:"flex items-center gap-2.5 min-w-0",children:[o.jsx("span",{className:`shrink-0 w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${C?"bg-green-500 border-green-500":"border-border-default"}`,children:C&&o.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),o.jsx("span",{className:`text-sm min-w-0 ${C?"text-fg-tertiary line-through":"text-fg-primary"}`,children:i(r2(T.labelKey))})]}),o.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default font-medium leading-none text-fg-primary font-mono",children:NK(Q4(T.keys,l,T.bare),l)})]})},T.id)})})]},y))})]}),o.jsxs("div",{className:"sticky bottom-0 border-t border-border-default bg-surface-primary px-4 py-3 flex items-center justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:v,className:"px-3 py-2 text-sm rounded-xl border border-border-default text-fg-secondary hover:bg-surface-elevated hover:text-fg-primary transition-colors font-medium",children:i("checklist.shortcutLesson.markAllLearned")}),o.jsx("button",{type:"button",onClick:n,className:`px-4 py-2 text-sm rounded-xl transition-colors font-medium ${m?"bg-green-600 hover:bg-green-500 text-on-brand":"bg-brand-600 hover:bg-brand-500 text-on-brand"}`,children:i(m?"checklist.shortcutLesson.done":"common:close")})]})]})})}function X4(e){if(!e||e.status&&e.status!=="pending"||e.type!=="action"||Array.isArray(e.questions)&&e.questions.length>0)return!1;const t=e.details?.toolName;return typeof t=="string"&&t.length>0}function jK(e){return e.details?.agentId??e.agentId}function RK(e){const t=e.details??{};return[t.chatSessionId,t.sessionId].filter(n=>typeof n=="string"&&n.length>0)}function jle(e,t){const n=e.filter(l=>X4(l)&&jK(l)===t.agentId);if(!t.sessionId)return n;const a=[],i=[];for(const l of n)(RK(l).includes(t.sessionId)?a:i).push(l);return[...a,...i]}function _K(e){return Array.isArray(e.questions)&&e.questions.length>0}function Gh(e){if(!e)return null;try{const t=JSON.parse(e);return t&&typeof t=="object"?t:null}catch{return null}}function o2(e){const t={},n=e.split("?")[1];if(!n)return t;for(const[a,i]of new URLSearchParams(n).entries())t[a]=i;return t}function DK(e){if(e.actionType==="open_chat"||e.actionType==="navigate")return!0;const t=e.metadata??{};return!!(t.agentId||t.taskId||t.requirementId||t.projectId||t.channel||t.senderId||t.approvalId||t.sessionId)}function Kh(e,t={}){if(_K(e)){if(t.onOpenApproval){t.onOpenApproval(e);return}const a=e.details?.sessionId,i={};e.agentId&&(i.agentId=e.agentId),a&&(i.sessionId=a),yt.navigate(me.TEAM,Object.keys(i).length>0?i:void 0);return}const n=e.details;if(X4(e)&&e.agentId)return void yt.navigate(me.TEAM,{agentId:e.agentId});if(n?.taskId)return void yt.navigate(me.WORK,{openTask:n.taskId});if(n?.requirementId)return void yt.navigate(me.WORK,{openRequirement:n.requirementId});if(e.agentId)return void yt.navigate(me.TEAM,{agentId:e.agentId,preferMain:"1"});yt.navigate(me.WORK)}function J4(e){const t=e.metadata??{},n=a=>typeof a=="string"&&a.length>0?a:void 0;if(e.actionType==="open_chat"){const a=n(t.taskId),i=n(t.requirementId);if(a)return{page:"WORK",params:{openTask:a}};if(i)return{page:"WORK",params:{openRequirement:i}};const l=Gh(e.actionTarget),c=n(l?.agentId);if(c){const u={agentId:c},m=n(l?.sessionId);return m&&(u.sessionId=m),{page:"TEAM",params:u}}}if(e.actionType==="navigate"){const a=Gh(e.actionTarget),i=n(a?.path);if(i){if(i.startsWith("/team"))return{page:"TEAM",params:o2(i)};if(i.startsWith("/work"))return{page:"WORK",params:o2(i)};if(i.startsWith("/approvals/"))return null}}switch(e.type){case"approval_request":return null;case"task_completed":case"task_created":case"task_review":case"task_failed":{const a=n(t.taskId);return{page:"WORK",params:a?{openTask:a}:{}}}case"requirement_created":case"requirement_decision":{const a=n(t.requirementId);return{page:"WORK",params:a?{openRequirement:a}:{}}}case"agent_report":case"system":{if(t.creditExhausted||t.templateUpdates)return null;const a=n(t.agentId),i={};a&&(i.agentId=a);const l=n(t.sessionId);return l?i.sessionId=l:a&&(i.preferMain="1"),{page:"TEAM",params:i}}case"direct_message":{const a=n(t.senderId);return{page:"TEAM",params:a?{dm:a}:{}}}case"group_message":{const a=n(t.channel);return{page:"TEAM",params:a?{channel:a}:{}}}default:{const a=n(t.taskId);if(a)return{page:"WORK",params:{openTask:a}};const i=n(t.requirementId);if(i)return{page:"WORK",params:{openRequirement:i}};const l=n(t.projectId);if(l)return{page:"WORK",params:{projectId:l}};const c=n(t.agentId);return c?{page:"TEAM",params:{agentId:c}}:{page:"WORK",params:{}}}}}function IK(e,t={}){const n=J4(e);if(n){const l=Object.keys(n.params).length>0?n.params:void 0;return void yt.navigate(n.page==="WORK"?me.WORK:me.TEAM,l)}const a=e.metadata??{},i=l=>typeof l=="string"&&l.length>0?l:void 0;if(e.actionType==="navigate"){const l=Gh(e.actionTarget),c=i(l?.path);if(c?.startsWith("/approvals/")){const u=c.split("?")[0].split("/")[2],m=u?t.approvals?.find(f=>f.id===u):void 0;if(m)return Kh(m,t)}}if(e.type==="approval_request"){const l=i(a.approvalId),c=l?t.approvals?.find(g=>g.id===l):void 0;if(c)return Kh(c,t);const u=i(a.taskId);if(u)return void yt.navigate(me.WORK,{openTask:u});const m=i(a.requirementId);if(m)return void yt.navigate(me.WORK,{openRequirement:m});const f=i(a.agentId);return f?void yt.navigate(me.TEAM,{agentId:f,preferMain:"1"}):void yt.navigate(me.WORK)}if(a.creditExhausted){t.onCreditExhausted?.();return}if(a.templateUpdates){t.onTemplateUpdates?.();return}yt.navigate(me.WORK)}function l2(e){const t=e.metadata??{};return e.type==="agent_report"&&!t.creditExhausted&&!t.templateUpdates&&(e.actionType==="open_chat"||!!t.agentId&&e.actionType!=="navigate")}function c2(e){const t=e.metadata??{},n=l=>typeof l=="string"&&l.length>0?l:void 0,a=n(t.taskId),i=n(t.requirementId);return a?`task:${a}`:i?`req:${i}`:null}function Z4(e,t){const n=new Set,a=c2(e),i=a?t.filter(l=>!l.read&&c2(l)===a):[e];for(const l of i)l.read||l2(l)||n.add(l.id);!e.read&&!l2(e)&&n.add(e.id);for(const l of n)Te.notifications.markRead(l).catch(()=>{});return n.size>0&&window.dispatchEvent(new CustomEvent("markus:notifications-changed")),n}async function LK(e){const t=await Te.notifications.markAllRead(e);return rK("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),t?.count??0}const d2=6e4,u2=36e5,m2=864e5;function PK(e){if(!Number.isFinite(e))return"";const t=Date.now()-e;if(t<0||t<d2)return"刚刚";if(t<u2)return`${Math.floor(t/d2)} 分钟前`;if(t<m2)return`${Math.floor(t/u2)} 小时前`;const n=Math.floor(t/m2);return n===1?"昨天":`${n} 天前`}function OK(e){return typeof e=="number"?e:e?new Date(e).getTime():Number.NaN}function p2(e){return PK(OK(e))}function e5(e,t){if(e.blockedReason==="deps"||e.blockedReason==="hold"||e.blockedReason==="workflow")return e.blockedReason;const n=e.blockedBy??[];return n.length===0||t&&n.every(i=>t(i)?.status==="completed")?"hold":"deps"}function Rle(e,t){return e5(e,t)==="hold"}function Vh(e){return Array.isArray(e?.questions)&&e.questions.length>0}const f2={agent_question:0,approval_request:1,blocked_hold:2,task_failed:3,requirement_approval:4,task_review:5,unread_message:6},zK={urgent:0,high:1,medium:2,low:3};function h2(e){return zK[(e??"").toLowerCase()]??4}function Cs(e,t){return e&&e.length>0?e:t}function Ql(e,t){return t?e>t:!1}function g2(e){if(e.page!=="WORK")return[];const t=[],n=e.params.openTask,a=e.params.openRequirement;return n&&t.push(`task:${n}`),a&&t.push(`requirement:${a}`),t}function HK(e){const{tasks:t,requirements:n,approvals:a,notifications:i,taskById:l,lastSeenAt:c=null,includeUnread:u=!0,notifyTitle:m}=e,f=new Date(0).toISOString(),g=[],h=new Set;for(const y of a){if(y.status!=="pending")continue;const w=y.details??{},T={};let C="TEAM";w.taskId?(C="WORK",T.openTask=w.taskId,h.add(`task:${w.taskId}`)):w.requirementId&&(C="WORK",T.openRequirement=w.requirementId),y.agentId&&(T.agentId=y.agentId),C==="TEAM"&&(T.preferMain="1"),g.push({id:`approval:${y.id}`,kind:Vh(y)?"agent_question":"approval_request",title:y.title,priority:"none",waitingSince:Cs(y.requestedAt,f),waitingBasis:"requested",target:{page:C,params:T},isNew:Ql(Cs(y.requestedAt,f),c),...y.agentName?{meta:y.agentName}:{}})}for(const y of n){if(y.status!=="pending")continue;const w=Cs(y.createdAt,f);g.push({id:`requirement:${y.id}`,kind:"requirement_approval",title:y.title,priority:y.priority??"none",waitingSince:w,waitingBasis:"created",target:{page:"WORK",params:{openRequirement:y.id}},isNew:Ql(w,c)})}for(const y of t){if(y.status==="review"&&y.reviewerType==="human"){if(h.has(`task:${y.id}`))continue;const w=y.statusChangedAt,T=Cs(w??y.updatedAt??y.createdAt,f);g.push({id:`task:${y.id}`,kind:"task_review",title:y.title,priority:y.priority??"none",waitingSince:T,waitingBasis:w?"status":"approximate",target:{page:"WORK",params:{openTask:y.id}},isNew:Ql(T,c)});continue}if(y.status==="blocked"){if(e5(y,A=>l?.(A))!=="hold")continue;const T=y.statusChangedAt,C=Cs(T??y.updatedAt??y.createdAt,f);g.push({id:`blocked:${y.id}`,kind:"blocked_hold",title:y.title,priority:y.priority??"none",waitingSince:C,waitingBasis:T?"status":"approximate",target:{page:"WORK",params:{openTask:y.id}},isNew:Ql(C,c)});continue}if(y.status==="failed"){const w=y.statusChangedAt,T=Cs(w??y.updatedAt??y.createdAt,f);g.push({id:`failed:${y.id}`,kind:"task_failed",title:y.title,priority:y.priority??"none",waitingSince:T,waitingBasis:w?"status":"approximate",target:{page:"WORK",params:{openTask:y.id}},isNew:Ql(T,c)})}}const v=new Map;for(const y of g)for(const w of g2(y.target))v.has(w)||v.set(w,y);if(u)for(const y of i){if(y.read)continue;const w=Cs(y.createdAt,f),T=y.metadata??{},C=J4(y);let A;if(C)A=C;else{const K={},j=typeof T.agentId=="string"?T.agentId:void 0,z=typeof T.sessionId=="string"?T.sessionId:void 0;j&&(K.agentId=j),z?K.sessionId=z:j&&(K.preferMain="1"),A={page:"TEAM",params:K}}const M=g2(A),I=M.map(K=>v.get(K)).find(K=>!!K);if(I){I.notices=[...I.notices??[],y];continue}const B={id:`notice:${y.id}`,kind:"unread_message",title:m?m(y):y.title,priority:y.priority??"none",waitingSince:w,waitingBasis:"created",target:A,isNew:!0,notices:[y]};g.push(B);for(const K of M)v.set(K,B)}return g.sort((y,w)=>{if(y.waitingSince!==w.waitingSince)return y.waitingSince<w.waitingSince?-1:1;const T=h2(y.priority)-h2(w.priority);if(T!==0)return T;const C=f2[y.kind]-f2[w.kind];return C!==0?C:y.id<w.id?-1:y.id>w.id?1:0})}function BK(e){return e.filter(t=>t.kind!=="unread_message").length}function t5(e,t=Date.now()){const n=Date.parse(e.waitingSince);if(!Number.isFinite(n))return"—";const a=Math.max(0,t-n),i=Math.floor(a/6e4),l=Math.floor(i/60),c=Math.floor(l/24);let u;return i<1?u="<1 分钟":i<60?u=`${i} 分钟`:l<24?u=`${l} 小时`:c<30?u=l%24>0?`${c} 天 ${l%24} 小时`:`${c} 天`:u=">30 天",e.waitingBasis==="approximate"?`约 ${u}`:u}const b2={approved:{label:"已批准",dot:"bg-fg-muted/30",chip:"bg-green-500/8 text-green-600/70"},rejected:{label:"已拒绝",dot:"bg-fg-muted/30",chip:"bg-red-500/8 text-red-500/70"},cancelled:{label:"已取消",dot:"bg-fg-muted/25",chip:"bg-surface-overlay text-fg-tertiary"},expired:{label:"已过期",dot:"bg-fg-muted/25",chip:"bg-amber-500/8 text-amber-600/70"}},y2=15,n5="markus_history_ui";function v2(){try{const e=localStorage.getItem(n5);if(!e)return{tab:"all",scrollTop:0};const t=JSON.parse(e);return{tab:t.tab==="approvals"||t.tab==="notices"?t.tab:"all",scrollTop:typeof t.scrollTop=="number"&&t.scrollTop>=0?t.scrollTop:0}}catch{return{tab:"all",scrollTop:0}}}function $K(e){try{localStorage.setItem(n5,JSON.stringify(e))}catch{}}const x2=200;function qK(e){k.useEffect(()=>{if(!e)return;const t=[document.documentElement,document.body,document.querySelector("[data-app-scroll]")].filter(l=>!!l),n=t.map(l=>l.style.overflow),a=t.map(l=>l.style.paddingRight),i=window.innerWidth-document.documentElement.clientWidth;return t.forEach((l,c)=>{l.style.overflow="hidden",c===0&&i>0&&(l.style.paddingRight=`${i}px`),a[c]}),()=>{t.forEach((l,c)=>{l.style.overflow=n[c]??"",l.style.paddingRight=a[c]??""})}},[e])}function FK(e){return e.actionUrl&&!e.actionType?()=>window.open(e.actionUrl,"_blank","noopener"):DK(e)?()=>IK(e):null}function UK({open:e,onClose:t,userId:n}){const[a,i]=k.useState(()=>v2().tab),l=k.useRef(v2().scrollTop),[c,u]=k.useState([]),m=k.useRef(null),f=k.useRef(null),[g,h]=k.useState(0),[v,y]=k.useState(null),[w,T]=k.useState("loading"),[C,A]=k.useState("loading"),[M,I]=k.useState(0),[B,K]=k.useState([]),[j,z]=k.useState(!1),[U,Y]=k.useState(!1),[$,D]=k.useState(null),{t:W}=xt(["team"]),[X,H]=k.useState(!1),[se,R]=k.useState(!1),[re,ue]=k.useState(null),Ce=k.useRef(null),q=k.useRef({loading:!1,done:!1,count:0});q.current={loading:X,done:se,count:c.length};const V=k.useCallback(async Re=>{if(n){H(!0);try{const Xe=await Te.notifications.list(n,!1,{limit:y2,offset:Re}),wt=Xe.notifications??[];u(kt=>{const lt=new Set(kt.map(Dt=>Dt.id));return[...kt,...wt.filter(Dt=>!lt.has(Dt.id))].slice(0,x2)}),h(Xe.totalCount??0);const mt=Xe.unreadCount;y(typeof mt=="number"?mt:null),T(typeof mt=="number"?"ok":"error"),(wt.length===0||wt.length<y2||q.current.count+wt.length>=x2)&&R(!0),ue(null)}catch(Xe){ue(Xe instanceof Error?Xe.message:"读取失败"),T("error")}finally{H(!1)}}},[n]);k.useEffect(()=>{if(!e||!n)return;const Re=()=>{V(0),Te.approvals.list().then(Xe=>{K((Xe.approvals??[]).filter(wt=>wt.status==="pending")),A("ok")}).catch(()=>A("error"))};return window.addEventListener("markus:notifications-changed",Re),window.addEventListener("markus:data-changed",Re),()=>{window.removeEventListener("markus:notifications-changed",Re),window.removeEventListener("markus:data-changed",Re)}},[e,n,V]);const ce=k.useCallback(()=>{ue(null),T("loading"),A("loading"),I(Re=>Re+1)},[]),P=k.useCallback(async()=>{if(!(!n||U)){Y(!0),D(null);try{await LK(n),u(Re=>Re.map(Xe=>Xe.read?Xe:{...Xe,read:!0})),y(0),T("ok")}catch(Re){D(Re instanceof Error?Re.message:String(Re))}finally{Y(!1)}}},[n,U]);k.useEffect(()=>{!e||!n||(u([]),h(0),R(!1),ue(null),T("loading"),A("loading"),V(0),Te.approvals.list(void 0,{limit:100}).then(Re=>{K((Re.approvals??[]).filter(Xe=>Xe.status!=="pending")),A("ok")}).catch(()=>A("error")))},[e,n,V,M]),k.useEffect(()=>{if(!e)return;const Re=Ce.current;if(!Re||typeof IntersectionObserver>"u")return;const Xe=new IntersectionObserver(wt=>{const mt=q.current;!wt[0]?.isIntersecting||mt.loading||mt.done||V(mt.count)},{rootMargin:"120px"});return Xe.observe(Re),()=>Xe.disconnect()},[e,V,c.length]);const Ee=k.useMemo(()=>{const Re=B.map(mt=>({kind:"approval",at:mt.respondedAt??mt.requestedAt,approval:mt})),Xe=c.map(mt=>({kind:"notice",at:mt.createdAt,notice:mt})),wt=[...Re,...Xe].sort((mt,kt)=>(kt.at??"").localeCompare(mt.at??""));return j?wt.filter(mt=>mt.kind==="notice"&&!mt.notice.read):a==="approvals"?wt.filter(mt=>mt.kind==="approval"):a==="notices"?wt.filter(mt=>mt.kind==="notice"):wt},[B,c,a,j]),$e=B.length,qe=w==="ok"?v:null,Ze=Ee.length===0&&!X&&!re&&C!=="error"&&w!=="error",Qe=j&&w==="ok"&&qe===0&&(g>0||c.length>0);return qK(e),k.useEffect(()=>{if(!e)return;const Re=window.setTimeout(()=>{const Xe=m.current;Xe&&(Xe.scrollTop=l.current)},60);return()=>window.clearTimeout(Re)},[e,a]),e?o.jsx("div",{ref:f,className:"fixed inset-0 z-50 flex items-start justify-center bg-black/40 p-4 sm:p-6 overflow-hidden overscroll-none",onClick:t,children:o.jsxs("div",{className:"w-full max-w-lg h-[78vh] bg-surface-elevated rounded-2xl shadow-xl overflow-hidden flex flex-col mt-4",onClick:Re=>Re.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 pt-3.5 pb-2 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:"历史"}),w==="error"&&o.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded-full bg-rose-500/10 text-rose-600",children:"未读数未知(读取失败)"}),w==="loading"&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:"未读…"}),qe!==null&&qe>0&&o.jsxs("button",{onClick:()=>z(Re=>!Re),"aria-pressed":j,title:j?"显示全部":"只看未读",className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full tabular-nums transition-colors ${j?"bg-brand-500 text-on-brand":"text-brand-400 bg-brand-500/10 hover:bg-brand-500/20"}`,children:[qe," 条未读"]}),qe!==null&&j&&qe===0&&o.jsx("button",{onClick:()=>z(!1),className:"text-[10px] font-semibold text-fg-tertiary bg-surface-overlay px-1.5 py-0.5 rounded-full",children:"已全部读完·看全部"}),qe!==null&&qe>0&&o.jsx("button",{onClick:()=>{P()},disabled:U,"data-mark-all-read":!0,className:"text-[10px] font-medium text-fg-tertiary hover:text-fg-primary px-1.5 py-0.5 rounded-full hover:bg-surface-overlay transition-colors disabled:opacity-50",children:U?"…":W("team:notifications.markAllRead")})]}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay text-fg-tertiary","aria-label":"关闭",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"px-4 pb-2.5 shrink-0 flex items-center gap-1",children:[{id:"all",label:"全部",count:$e+c.length},{id:"approvals",label:"审批结果",count:$e},{id:"notices",label:"通知",count:c.length}].map(Re=>{const Xe=a===Re.id;return o.jsxs("button",{onClick:()=>i(Re.id),className:`px-2.5 py-1 rounded-full text-[11px] font-medium transition-colors flex items-center gap-1 ${Xe?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:[Re.label,Re.count>0&&o.jsx("span",{className:"tabular-nums text-fg-muted",children:Re.count})]},Re.id)})}),o.jsxs("div",{ref:m,onScroll:Re=>$K({tab:a,scrollTop:Re.currentTarget.scrollTop}),className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-thin px-2 pb-2",children:[$&&o.jsxs("div",{"data-mark-all-error":!0,className:"mx-1 mb-2 rounded-lg bg-rose-500/10 text-rose-600 text-[11px] px-3 py-2 flex items-center gap-2",children:[o.jsx("span",{className:"flex-1",children:W("team:notifications.markAllReadFailed")}),o.jsx("button",{onClick:()=>{P()},disabled:U,className:"shrink-0 rounded bg-rose-500/15 px-2 py-0.5 font-semibold hover:bg-rose-500/25 disabled:opacity-50",children:"重试"})]}),(re||C==="error")&&o.jsxs("div",{className:"mx-1 mb-2 rounded-lg bg-rose-500/10 text-rose-600 text-[11px] px-3 py-2 flex items-center gap-2",children:[o.jsx("span",{className:"flex-1",children:[re?`通知读取失败:${re}(这不等于「没有历史」)。`:null,C==="error"?"审批历史读取失败(不等于「没有审批」)。":null].filter(Boolean).join(" ")}),o.jsx("button",{onClick:ce,className:"shrink-0 rounded bg-rose-500/15 px-2 py-0.5 font-semibold hover:bg-rose-500/25",children:"重试"})]}),Ze&&(Qe?o.jsxs("div",{"data-empty-unread":!0,className:"px-3 py-10 text-center",children:[o.jsx("div",{className:"text-[12px] text-fg-secondary",children:W("team:notifications.noUnread")}),o.jsx("button",{onClick:()=>z(!1),className:"mt-2 rounded-full bg-surface-overlay px-2.5 py-1 text-[11px] text-fg-tertiary hover:text-fg-primary transition-colors",children:W("team:notifications.filterAll")})]}):o.jsxs("div",{className:"px-3 py-10 text-center",children:[o.jsx("div",{className:"text-[12px] text-fg-secondary",children:"还没有历史记录"}),o.jsx("div",{className:"text-[11px] text-fg-muted mt-1",children:"团队开始工作后,审批和通知会出现在这里"})]})),Ee.map(Re=>Re.kind==="approval"?(()=>{const Xe=b2[Re.approval.status]??b2.cancelled,wt=Re.approval.respondedAt??Re.approval.requestedAt;return o.jsxs("div",{onClick:()=>{t(),Kh(Re.approval)},title:"打开对应的任务 / 需求 / 会话",className:"flex items-center gap-2.5 px-2.5 py-2.5 rounded-xl hover:bg-surface-overlay/50 transition-colors cursor-pointer",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Xe.dot}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded shrink-0 ${Xe.chip}`,children:Xe.label}),o.jsx("span",{className:"text-xs text-fg-secondary truncate",children:Re.approval.title})]}),o.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5 truncate",children:[Re.approval.agentName," · ",Re.approval.status==="approved"?Vh(Re.approval)?"已答复":"已批准":Re.approval.status==="rejected"?Vh(Re.approval)?"未答复":"已拒绝":Xe.label," ","于 ",p2(wt),Re.approval.respondedAt&&Re.approval.requestedAt&&o.jsxs(o.Fragment,{children:[" · 等了 ",t5({waitingSince:Re.approval.requestedAt,waitingBasis:"requested"},Date.parse(Re.approval.respondedAt))]})]})]})]},`a:${Re.approval.id}`)})():(()=>{const Xe=FK(Re.notice);return o.jsxs("div",{title:Xe?void 0:"这条通知没有关联的任务 / 需求 / 会话,仅作告知",className:`flex items-start gap-2.5 px-2.5 py-2.5 rounded-xl transition-colors ${Xe?"hover:bg-surface-overlay/50 cursor-pointer":""}`,onClick:Xe?()=>{const wt=Z4(Re.notice,c);u(mt=>mt.map(kt=>wt.has(kt.id)?{...kt,read:!0}:kt)),t(),Xe()}:void 0,children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 ${Re.notice.read?"bg-fg-muted/40":"bg-brand-500"}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:`text-xs truncate ${Re.notice.read?"text-fg-tertiary":"text-fg-primary font-medium"}`,children:[Re.notice.title,!Xe&&o.jsx("span",{className:"ml-1.5 align-middle text-[10px] font-normal text-fg-muted",children:"仅告知"})]}),Re.notice.body&&o.jsx("div",{className:"text-[11px] text-fg-muted mt-0.5 line-clamp-2 leading-relaxed",children:Re.notice.body}),o.jsx("div",{className:"text-[10px] text-fg-muted mt-1",children:p2(Re.notice.createdAt)})]})]},`n:${Re.notice.id}`)})()),o.jsxs("div",{ref:Ce,className:"h-8 flex items-center justify-center",children:[X&&o.jsx("span",{className:"text-[11px] text-fg-muted",children:"加载中…"}),!X&&se&&c.length>0&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:"没有更早的记录了"})]})]})]})}):null}const a5="markus_attention_count",hm="markus:attention-count",r5="markus_attention_last_seen";function GK(){try{return localStorage.getItem(r5)}catch{return null}}function KK(e){try{localStorage.setItem(r5,e)}catch{}}function VK(e){try{localStorage.setItem(a5,String(e))}catch{}window.dispatchEvent(new CustomEvent(hm,{detail:{count:e}}))}function Gm(){return w2(a5)+w2(i5)}const i5="markus_unread_count";function w2(e){try{const t=localStorage.getItem(e),n=t===null?0:Number(t);return Number.isFinite(n)&&n>0?n:0}catch{return 0}}function WK(e){try{localStorage.setItem(i5,String(Math.max(0,e)))}catch{}window.dispatchEvent(new CustomEvent(hm,{detail:{count:Gm()}}))}function s5(e){const t=n=>{const a=n.detail;e(typeof a?.count=="number"?a.count:Gm())};return window.addEventListener(hm,t),()=>window.removeEventListener(hm,t)}function o5(e){const t=e.metadata;if(!(!t||typeof t.i18n!="object"||!t.i18n))return t.i18n}function YK(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function QK(e,t){const n=o5(e);if(!n?.titleKey)return e.title;const a={...n.titleParams??{}};return t(`team:${n.titleKey}`,{...a,defaultValue:e.title})}function _le(e,t){const n=o5(e);if(!n?.bodyKey)return e.body;const a={};for(const[i,l]of Object.entries(n.bodyParams??{}))if(i==="priority")a[i]=t(`common:priority.${l}`,{defaultValue:l});else if(i==="status"||i==="statusKey"){const c=YK(l);a[i]=t(`common:status.${l}`,{defaultValue:c===l?l:t(`common:status.${c}`,{defaultValue:l})})}else a[i]=l;return t(`team:${n.bodyKey}`,{...a,defaultValue:e.body})}const l5={code:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"16 18 22 12 16 6"}),o.jsx("polyline",{points:"8 6 2 12 8 18"})]}),search:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("path",{d:"m21 21-4.3-4.3"})]}),clipboard:o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),o.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":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]}),server:o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),o.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),o.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),o.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),"file-text":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),o.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),o.jsx("path",{d:"M10 9H8"}),o.jsx("path",{d:"M16 13H8"}),o.jsx("path",{d:"M16 17H8"})]}),"book-open":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 7v14"}),o.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:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),o.jsx("circle",{cx:"9",cy:"7",r:"4"}),o.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),o.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"dollar-sign":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"}),o.jsx("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]}),megaphone:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m3 11 18-5v12L3 14v-3z"}),o.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]}),edit:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 20h9"}),o.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),headphones:o.jsx(o.Fragment,{children:o.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:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),target:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("circle",{cx:"12",cy:"12",r:"6"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),zap:o.jsx(o.Fragment,{children:o.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),terminal:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"4 17 10 11 4 5"}),o.jsx("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]}),sparkles:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"M20 3v4"}),o.jsx("path",{d:"M22 5h-4"})]}),wrench:o.jsx(o.Fragment,{children:o.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:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),o.jsx("path",{d:"M2 12h20"})]}),link:o.jsxs(o.Fragment,{children:[o.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"}),o.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:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 8V4H8"}),o.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),o.jsx("path",{d:"M2 14h2"}),o.jsx("path",{d:"M20 14h2"}),o.jsx("path",{d:"M15 13v2"}),o.jsx("path",{d:"M9 13v2"})]}),"message-square":o.jsx(o.Fragment,{children:o.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:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"M18 14h-8"}),o.jsx("path",{d:"M15 18h-5"}),o.jsx("path",{d:"M10 6h8v4h-8V6Z"})]}),layers:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}),o.jsx("path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"})]}),"bar-chart":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),o.jsx("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),o.jsx("line",{x1:"6",x2:"6",y1:"20",y2:"16"})]}),folder:o.jsx(o.Fragment,{children:o.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":o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),o.jsx("circle",{cx:"18",cy:"6",r:"3"}),o.jsx("circle",{cx:"6",cy:"18",r:"3"}),o.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),save:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),o.jsx("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]}),camera:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),clock:o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),database:o.jsxs(o.Fragment,{children:[o.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),o.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),o.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]}),lightbulb:o.jsxs(o.Fragment,{children:[o.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"}),o.jsx("path",{d:"M9 18h6"}),o.jsx("path",{d:"M10 22h4"})]}),"alert-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),o.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),"square-terminal":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m7 11 2-2-2-2"}),o.jsx("path",{d:"M11 13h4"}),o.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]}),package:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"m7.5 4.27 9 5.15"}),o.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"}),o.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),o.jsx("path",{d:"M12 22V12"})]}),inbox:o.jsxs(o.Fragment,{children:[o.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),o.jsx("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]}),"circle-pause":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"10",x2:"10",y1:"15",y2:"9"}),o.jsx("line",{x1:"14",x2:"14",y1:"15",y2:"9"})]}),"circle-x":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"m15 9-6 6"}),o.jsx("path",{d:"m9 9 6 6"})]}),"clipboard-check":o.jsxs(o.Fragment,{children:[o.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),o.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"}),o.jsx("path",{d:"m9 14 2 2 4-4"})]}),"file-check":o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),o.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),o.jsx("path",{d:"m9 15 2 2 4-4"})]}),bell:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),o.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]}),"help-circle":o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),o.jsx("path",{d:"M12 17h.01"})]})};function XK(e){return!!e&&e in l5}function c5({name:e,size:t=24,className:n=""}){const a=l5[e];return a?o.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":!0,children:a}):null}const k2={"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"},S2={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Gu(e,t){const n=(e||"").toLowerCase();return k2[n]?k2[n]:t&&S2[t]?S2[t]:"layers"}const Tn={attention:{chip:"bg-violet-500/15 text-violet-500",dot:"bg-violet-500",solid:"bg-violet-500",text:"text-violet-500",border:"border-violet-500/40",surface:"bg-violet-500/[0.06]",btn:"bg-violet-500/10 text-violet-500 hover:bg-violet-500/20",hex:"#8b5cf6"},active:{chip:"bg-blue-500/15 text-blue-500",dot:"bg-blue-500",solid:"bg-blue-500",text:"text-blue-500",border:"border-blue-500/40",surface:"bg-blue-500/[0.06]",btn:"bg-blue-500/10 text-blue-500 hover:bg-blue-500/20",hex:"#3b82f6"},blocked:{chip:"bg-orange-500/15 text-orange-500",dot:"bg-orange-500",solid:"bg-orange-500",text:"text-orange-500",border:"border-orange-500/40",surface:"bg-orange-500/[0.06]",btn:"bg-orange-500/10 text-orange-500 hover:bg-orange-500/20",hex:"#f97316"},success:{chip:"bg-green-500/15 text-green-600",dot:"bg-green-500",solid:"bg-green-500",text:"text-green-600",border:"border-green-500/30",surface:"bg-green-500/[0.06]",btn:"bg-green-500/10 text-green-600 hover:bg-green-500/20",hex:"#22c55e"},danger:{chip:"bg-red-500/15 text-red-500",dot:"bg-red-500",solid:"bg-red-500",text:"text-red-500",border:"border-red-500/40",surface:"bg-red-500/[0.06]",btn:"bg-red-500/10 text-red-500 hover:bg-red-500/20",hex:"#ef4444"},neutral:{chip:"bg-gray-500/15 text-fg-tertiary",dot:"bg-gray-400",solid:"bg-gray-500",text:"text-fg-tertiary",border:"border-border-default/60",surface:"bg-surface-elevated/60",btn:"bg-surface-overlay text-fg-secondary hover:bg-surface-overlay/70",hex:"#6b7280"}};function Km(e,t){return t&&e[t]||"neutral"}const JK={pending:"neutral",in_progress:"active",blocked:"blocked",review:"attention",revision:"active",completed:"success",failed:"danger",rejected:"danger",cancelled:"neutral",archived:"neutral"},ZK={pending:"attention",in_progress:"active",completed:"success",rejected:"danger",cancelled:"neutral",archived:"neutral"},eV={active:"active",in_progress:"active",planning:"neutral",paused:"blocked",blocked:"blocked",completed:"success",archived:"neutral",cancelled:"neutral"},tV={draft:"neutral",pending:"neutral",submitted:"attention",in_review:"attention",review:"attention",approved:"success",published:"success",rejected:"danger",archived:"neutral"};function Pc(e){return Km(JK,e)}function nV(e){return Km(ZK,e)}function aV(e){return Km(eV,e)}function rV(e){return Km(tV,e)}function iV(e,t){switch(e){case"task":return Pc(t);case"requirement":return nV(t);case"project":return aV(t);case"deliverable":return rV(t);default:return"neutral"}}const sV={pending:"pending",in_progress:"inProgress",blocked:"blocked",review:"review",completed:"completed",failed:"failed",rejected:"rejected",cancelled:"cancelled",archived:"archived"};function d5(e){return e==="hold"?"hold":e==="workflow"?"workflow":"deps"}const oV={deps:"waitingDeps",hold:"onHold",workflow:"workflowPaused"},lV={deps:{chip:Tn.neutral.chip,dot:Tn.neutral.dot,bar:Tn.neutral.dot,card:`${Tn.neutral.surface} border-border-default/60`},hold:{chip:Tn.blocked.chip,dot:Tn.blocked.dot,bar:Tn.blocked.dot,card:`${Tn.blocked.surface} border-orange-500/30 ring-1 ring-orange-500/15`},workflow:{chip:Tn.neutral.chip,dot:Tn.neutral.dot,bar:Tn.neutral.dot,card:`${Tn.neutral.surface} border-border-default/60`}};function Wh(e,t,n){if(!e)return"—";if(e==="blocked"&&n!==void 0&&n!==null)return t(`common:taskStatus.${oV[d5(n)]}`);const a=sV[e];return a?t(`common:taskStatus.${a}`):e}function cV(e,t,n){const a=Wh(e,t,n);return e==="blocked"&&n!==void 0&&n!==null?{label:a,tone:lV[d5(n)]}:{label:a,tone:null}}function Dle(e,t){return t(`agent:profilePage.mind.attention.${e}`)}const dV={idle:"idle",working:"working",online:"online",offline:"offline",paused:"paused",error:"error"};function Ile(e,t){const n=dV[e];return n?t(`common:processStatus.${n}`):e}function u5(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function gm(e){return e.toLocaleString(void 0,{maximumFractionDigits:0})}function uV(e,t,n){const[a,i]=k.useState([]),[l,c]=k.useState(null),[u,m]=k.useState(null),[f,g]=k.useState(nt.isAuthenticated()),h=k.useCallback(async()=>{try{const w=await Te.usage.agents();i(w.agents)}catch{}},[]),v=k.useCallback(async()=>{if(!nt.isAuthenticated()){g(!1),m(null);return}g(!0);try{const[w,T]=await Promise.all([nt.user.plan(),Te.hubOrgs.mine().catch(()=>null)]);c(w);const C=T?.orgs?.find(A=>A.id===w.orgId)??T?.orgs?.[0];m(C?{role:C.role,memberCount:C.memberCount??1}:null)}catch{}},[]);return k.useEffect(()=>{if(!e)return;h(),v();const w=setInterval(h,3e4),T={at:0},C=15e3,A=()=>{const M=Date.now();M-T.at<C||(T.at=M,h(),v())};return window.addEventListener("markus:data-changed",A),()=>{clearInterval(w),window.removeEventListener("markus:data-changed",A)}},[e,h,v]),{contributors:k.useMemo(()=>{const w=[],T=new Map;for(const A of n)for(const M of A.members)T.set(M.id,A.name);const C=new Map((t?.agentEfficiency??[]).map(A=>[A.agentId,A]));for(const A of a){const M=C.get(A.agentId),I=A.cuUsed??0,B=A.totalTokens,K=M?.taskMetrics.completed??0,j=B>0?K/B*1e3:K>0?1/0:0;w.push({id:A.agentId,name:A.agentName,type:"agent",role:A.role,teamName:T.get(A.agentId),status:A.status,tasksCompleted:K,tasksFailed:M?.taskMetrics.failed??0,cuUsed:I,cuUsedToday:A.cuUsedToday??0,totalTokens:B,tokensToday:A.tokensUsedToday,requestCount:A.requestCount,toolCalls:A.toolCalls,healthScore:M?.healthScore??0,efficiency:j,provider:A.provider})}return w.sort((A,M)=>M.cuUsed+M.tasksCompleted*100-(A.cuUsed+A.tasksCompleted*100)===0?M.totalTokens-A.totalTokens:M.cuUsed+M.tasksCompleted*100-(A.cuUsed+A.tasksCompleted*100)),w},[a,t,n]),hubPlan:l,hubOrgMeta:u,hubConnected:f}}function Yh({title:e,badge:t,children:n}){const{t:a}=xt("home"),[i,l]=k.useState(!1);return o.jsxs("section",{className:`bg-surface-elevated shadow-sm rounded-2xl ${i?"overflow-visible":"overflow-hidden"}`,children:[o.jsxs("button",{type:"button",onClick:()=>l(c=>!c),className:"w-full px-4 sm:px-5 py-3.5 flex items-center justify-between gap-3 hover:bg-surface-overlay/40 transition-colors text-left rounded-2xl","aria-expanded":i,children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate",children:e}),t]}),o.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-fg-tertiary shrink-0",children:[o.jsx("span",{className:"hidden sm:inline",children:a(i?"usage.trends.collapse":"usage.trends.expand")}),o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${i?"rotate-180":""}`,children:o.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),i&&o.jsx("div",{className:"rounded-b-2xl overflow-visible",children:n})]})}function mV({hubConnected:e,hubPlan:t,hubOrgMeta:n}){const{t:a}=xt("home"),i=mr();if(!e)return o.jsxs("div",{className:"px-4 sm:px-5 pb-4 flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-500 shrink-0"}),o.jsx("span",{className:"text-sm text-fg-tertiary",children:a("usage.quota.notConnected")})]}),o.jsx("button",{onClick:()=>nt.ensureAuth().catch(()=>{}),className:"px-3 py-1.5 text-xs font-medium bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors shrink-0",children:a("usage.quota.connect")})]});if(!t)return o.jsx("div",{className:"px-4 sm:px-5 pb-4 text-sm text-fg-tertiary",children:a("usage.trends.noData")});const l=t.memberCuLimit!=null&&t.memberCuLimit>0,c=!n||n.role==="owner"||n.role==="admin"||n.memberCount<=1,u=l&&!c,m=(t.monthlyQuotaCu??0)+(t.bonusCu??0)+(t.purchasedCu??0),f=u?t.memberCuLimit:t.creditsBudgetCu??(l?t.memberCuLimit:m),g=u?t.memberCuUsed??0:t.totalConsumedThisPeriod??t.memberCuUsed??0,h=f>0?Math.min(100,Math.round(g/f*100)):0,v=h>90?"bg-red-500":h>70?"bg-amber-500":"bg-brand-500",y=()=>{Or(`${nt.getUrl().replace(/\/$/,"")}/settings?tab=billing`)};return o.jsxs("div",{className:"px-4 sm:px-5 pb-4",children:[u&&o.jsx("div",{className:"mb-2 px-3 py-1.5 rounded-lg text-[10px] bg-amber-500/8 text-amber-500/80 border border-amber-500/15",children:a("usage.quota.personalLimit")}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:a(l&&!c?"usage.quota.personalLimitLabel":"usage.quota.title")}),o.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] font-medium bg-brand-500/10 text-brand-500 uppercase shrink-0",children:t.planType}),i?.username&&o.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:a("usage.quota.connectedAs",{username:i.username})})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 text-[10px] text-fg-tertiary",children:[o.jsx("span",{children:t.cuResetAt?a("usage.quota.resetsAt",{date:new Date(t.cuResetAt).toLocaleDateString()}):""}),o.jsx("button",{type:"button",className:"px-2 py-1 bg-brand-600 text-on-brand rounded hover:bg-brand-500 transition-colors font-medium",onClick:w=>{w.stopPropagation(),y()},children:a("usage.quota.topUp")})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex-1 h-2 bg-surface-overlay rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full transition-all ${v}`,style:{width:`${h}%`}})}),o.jsxs("span",{className:"text-xs text-fg-secondary tabular-nums shrink-0",children:[gm(g)," / ",gm(f)]})]})]})}function pV({contributors:e}){const{t}=xt("home"),[n,a]=k.useState("totalTokens"),[i,l]=k.useState(!0),[c,u]=k.useState(!1),m=10,f=A=>{n===A?l(!i):(a(A),l(!0))},g=k.useMemo(()=>[...e].sort((A,M)=>{const I=A[n]===1/0?999999:A[n],B=M[n]===1/0?999999:M[n];return i?B-I:I-B}),[e,n,i]),h=c?g:g.slice(0,m),v=Math.max(1,...e.map(A=>A.totalTokens)),y=e.some(A=>A.cuUsed>0),w=new Set(e.filter(A=>A.provider).map(A=>A.provider)),C=w.size>1||w.size===1&&!w.has("markus")?o.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-overlay px-2 py-0.5 rounded shrink-0",children:t("usage.agents.mixedProviders")}):void 0;return e.length===0?o.jsx(Yh,{title:t("usage.agents.title"),children:o.jsx("div",{className:"px-4 sm:px-5 pb-6 text-center",children:o.jsx("p",{className:"text-sm text-fg-tertiary",children:t("usage.agents.noData")})})}):o.jsxs(Yh,{title:t("usage.agents.title"),badge:C,children:[o.jsx("div",{className:"overflow-x-auto scrollbar-thin border-t border-border-default",children:o.jsxs("table",{className:"w-full min-w-[520px]",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium w-8",children:"#"}),o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium",children:t("usage.agents.name")}),o.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium hidden sm:table-cell",children:t("usage.agents.team")}),o.jsx(ru,{label:t("usage.agents.tasks"),col:"tasksCompleted",current:n,desc:i,onSort:f}),o.jsx(ru,{label:t("usage.agents.tokens"),col:"totalTokens",current:n,desc:i,onSort:f}),y&&o.jsx(ru,{label:t("usage.agents.cuUsed"),col:"cuUsed",current:n,desc:i,onSort:f}),o.jsx(ru,{label:t("usage.agents.efficiency"),col:"efficiency",current:n,desc:i,onSort:f,align:"right"})]})}),o.jsx("tbody",{children:h.map((A,M)=>o.jsx(fV,{contributor:A,rank:M+1,maxTokens:v,showCu:y},A.id))}),o.jsx("tfoot",{children:o.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[o.jsx("td",{colSpan:2,className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary sm:hidden",children:t("usage.agents.total",{count:e.length})}),o.jsx("td",{colSpan:3,className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary hidden sm:table-cell",children:t("usage.agents.total",{count:e.length})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:e.reduce((A,M)=>A+M.tasksCompleted,0)}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:u5(e.reduce((A,M)=>A+M.totalTokens,0))}),y&&o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:gm(e.reduce((A,M)=>A+M.cuUsed,0))}),o.jsx("td",{})]})})]})}),g.length>m&&o.jsx("button",{type:"button",onClick:()=>u(A=>!A),className:"w-full px-4 py-2.5 text-xs font-medium text-brand-500 hover:bg-surface-overlay/40 border-t border-border-default transition-colors",children:c?t("usage.agents.showLess"):t("usage.agents.showAll",{count:g.length})})]})}function fV({contributor:e,rank:t,maxTokens:n,showCu:a}){const i=n>0?Math.min(100,e.totalTokens/n*100):0,l=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="error"?"bg-red-500":"bg-gray-500",c=e.tasksCompleted===0?"—":e.totalTokens>0?`${e.efficiency.toFixed(1)}`:"∞",u=t<=3?`${t===1?"text-amber-500":t===2?"text-gray-400":"text-amber-700"} font-bold`:"text-fg-tertiary",m=e.provider==="markus"?"":e.provider??"";return o.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>yt.navigate(me.TEAM,{selectAgent:e.id}),children:[o.jsx("td",{className:`px-3 sm:px-4 py-3 text-sm tabular-nums ${u}`,children:t}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("div",{className:`w-2 h-2 rounded-full ${l} shrink-0`}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:e.name}),m&&o.jsx("span",{className:"px-1 py-0.5 rounded text-[8px] font-medium bg-surface-overlay text-fg-tertiary shrink-0",children:m})]}),o.jsxs("div",{className:"text-[10px] text-fg-tertiary truncate",children:[e.role,o.jsx("span",{className:"sm:hidden",children:e.teamName?` · ${e.teamName}`:""})]})]})]})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-xs text-fg-tertiary hidden sm:table-cell",children:e.teamName||"—"}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:e.tasksCompleted}),e.tasksFailed>0&&o.jsxs("span",{className:"text-[10px] text-red-500 tabular-nums",children:["(",e.tasksFailed,")"]})]})}),o.jsx("td",{className:"px-3 sm:px-4 py-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-overlay rounded-full overflow-hidden max-w-[80px] hidden md:block",children:o.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${i}%`}})}),o.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:u5(e.totalTokens)})]})}),a&&o.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.cuUsed>0?gm(e.cuUsed):o.jsx("span",{className:"text-fg-tertiary",children:"—"})}),o.jsx("td",{className:"px-3 sm:px-4 py-3 text-right",children:o.jsx("span",{className:`text-sm font-medium tabular-nums ${e.tasksCompleted===0?"text-fg-tertiary":e.efficiency>5?"text-green-500":e.efficiency>1?"text-fg-secondary":"text-amber-500"}`,children:c})})]})}function ru({label:e,col:t,current:n,desc:a,onSort:i,align:l}){const c=n===t?a?"↓":"↑":"↕",u=n===t?"text-brand-500":"text-fg-muted";return o.jsxs("th",{className:`px-3 sm:px-4 py-3 ${l==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>i(t),children:[e,o.jsx("span",{className:`ml-1 ${u}`,children:c})]})}function hV({contributors:e,hubPlan:t,hubOrgMeta:n,hubConnected:a,showMarkusUsage:i}){const{t:l}=xt("home");return o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-tertiary px-0.5",children:l("usage.sectionTitle")}),i&&o.jsx(Yh,{title:l("usage.creditsTitle"),children:o.jsx(mV,{hubConnected:a,hubPlan:t,hubOrgMeta:n})}),o.jsx(pV,{contributors:e})]})}const gV="(max-width: 767px)";let _f=null;function m5(){return _f||(_f=window.matchMedia(gV)),_f}function bV(e){const t=m5();return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function yV(){return m5().matches}function vV(){return!1}const xV=k.createContext(!1);function Yo(){const e=k.useContext(xV),t=k.useSyncExternalStore(bV,yV,vV);return e?!1:t}const wV="markus_onboarded";function Wg(e){return`markus_onboarded_${e}`}function p5(e){return`markus_checklist_dismissed_${e}`}function Qh(e){try{return localStorage.getItem(Wg(e))!==null?!0:localStorage.getItem(wV)!==null}catch{return!1}}function Xh(e){try{localStorage.setItem(Wg(e),"1")}catch{}}function C2(e){try{localStorage.removeItem(Wg(e))}catch{}}function kV(e){try{return localStorage.getItem(p5(e))==="true"}catch{return!1}}function SV(e){try{localStorage.setItem(p5(e),"true")}catch{}}function A2(e){return{configured:Object.values(e.providers).some(t=>t.configured),markus:!!e.providers.markus?.configured,providerLabel:e.providers[e.defaultProvider]?.displayName??e.defaultProvider??""}}const CV=Object.fromEntries(["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"].map(e=>[e,Tn[Pc(e)].hex])),AV=e=>Tn[Pc(e)].dot,f5=["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"],Df={agent_question:{tone:"attention",iconName:"help-circle"},approval_request:{tone:"attention",iconName:"check-circle"},requirement_approval:{tone:"attention",iconName:"file-check"},task_review:{tone:"attention",iconName:"clipboard-check"},blocked_hold:{tone:"blocked",iconName:"circle-pause"},task_failed:{tone:"danger",iconName:"circle-x"},unread_message:{tone:"neutral",iconName:"message-square"}},T2={urgent:Tn.danger.chip,high:"bg-surface-overlay text-fg-secondary font-semibold",medium:"bg-surface-overlay text-fg-secondary",low:"bg-surface-overlay text-fg-tertiary",none:"bg-surface-overlay text-fg-tertiary"},TV=Object.fromEntries(["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"].map(e=>[e,Tn[Pc(e)].chip])),E2={"Heartbeat check-in":"agentFocus.heartbeatCheckIn","Heartbeat check-in (idle skip)":"agentFocus.heartbeatSkip"},EV={thinking:`${Tn.active.dot} animate-pulse`,running:`${Tn.active.dot} animate-pulse`,"waiting-dependency":`${Tn.blocked.dot} animate-pulse`,blocked:`${Tn.danger.dot} animate-pulse`,degraded:`${Tn.danger.dot} animate-pulse`,error:"bg-red-500 animate-pulse",idle:"bg-green-400",offline:"bg-gray-400"},N2={thinking:"agentFocus.phaseThinking",running:"agentFocus.phaseRunning","waiting-dependency":"agentFocus.phaseWaitingDep",blocked:"agentFocus.phaseBlocked",degraded:"agentFocus.phaseDegraded",error:"agentFocus.phaseError"};function M2({authUser:e,previewMode:t,previewData:n}={}){const{t:a}=xt(["home","common","team"]),i=Yo(),l=hK(me.HOME),[c,u]=k.useState(!1);k.useEffect(()=>qG(()=>u(!0)),[]);const[m,f]=k.useState(n?.agents??[]),[g,h]=k.useState(n?.teams??[]),[v,y]=k.useState(n?.board??{}),[w,T]=k.useState(n?.boardCounts??{}),[C,A]=k.useState(n?.ops??null),M="7d",[I,B]=k.useState(n?.requirements??[]),[K,j]=k.useState(n?.projects??[]),[z,U]=k.useState(n?.deliverableTotal??0),[Y,$]=k.useState([]),[D,W]=k.useState(n?.storageInfo??null),[X,H]=k.useState(n?.usageInfo??null),[se,R]=k.useState(null),[re,ue]=k.useState(!1),[Ce,q]=k.useState(!1),[V,ce]=k.useState(!1),[P,Ee]=k.useState(null),[$e,qe]=k.useState(!1),[Ze,Qe]=k.useState(""),[Re,Xe]=k.useState(!1),[wt,mt]=k.useState(null),[kt,lt]=k.useState(!1),Dt=k.useRef(!1);Dt.current=kt;const[ht,Oe]=k.useState(!1),[Nt,Gt]=k.useState(()=>e?.id?Vg(e.id):!1),ie=e?.id,[et,at]=k.useState(()=>e?.id?Qh(e.id)||e.preferences?.guideHidden===!0:!0),[,ye]=k.useState(0),Ne=ie?kV(ie):!1,[De,te]=k.useState(!1),[F,ae]=k.useState(!1),we=k.useRef(null);k.useEffect(()=>{const J=()=>Gt(!0);return window.addEventListener("markus:shortcut-lesson-complete",J),()=>window.removeEventListener("markus:shortcut-lesson-complete",J)},[Gt]);const Le=k.useCallback(()=>{Xe(!0),Te.cu.status().then(R).catch(()=>{}),Te.settings.getLlm().then(J=>{const xe=A2(J);Ee(xe.configured),qe(xe.markus),Qe(xe.providerLabel)}).catch(()=>{}),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("markus:data-changed"))},800)},[]);k.useEffect(()=>{if(!re)return;const J=xe=>{we.current&&!we.current.contains(xe.target)&&ue(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[re]),k.useEffect(()=>{!t||!n||(n.agents&&f(n.agents),n.teams&&h(n.teams),n.board&&y(n.board),n.boardCounts&&T(n.boardCounts),A(n.ops??null),B(n.requirements??[]),j(n.projects??[]),U(n.deliverableTotal??0),n.storageInfo&&W(n.storageInfo),n.usageInfo&&H(n.usageInfo))},[t,n]);const He=k.useCallback(()=>{const J=Te.agents.list().then(Rt=>{f(Rt.agents);const Ht=Rt.agents.find(on=>on.role==="secretary")??Rt.agents.find(on=>on.name?.toLowerCase().includes("secretary"));Ht&&Te.sessions.listByAgent(Ht.id,20).then(async on=>{if(on.sessions.length===0){te(!1);return}const Zn=ie?on.sessions.filter(Ar=>Ar.userId===ie):on.sessions;if(Zn.length===0){te(!1);return}const da=await Te.sessions.getMessages(Zn[0].id,1);te(da.messages.length>0)}).catch(()=>{})}).catch(()=>{}),xe=Te.teams.list().then(Rt=>h(Rt.teams)).catch(()=>{});Te.tasks.boardSummary().then(Rt=>{y(Rt.board),T(Rt.counts)}).catch(()=>{}),Te.ops.dashboard(M).then(A).catch(()=>{});const st=Te.requirements.list({lean:!0}).then(Rt=>B(Rt.requirements)).catch(()=>{}),Mt=Te.projects.list().then(Rt=>j(Rt.projects)).catch(()=>{});Te.deliverables.search({limit:18}).then(Rt=>{U(Rt.total);const Ht=new Map;for(const on of Rt.results){const Zn=on.reference,da=Ht.get(Zn);(!da||on.updatedAt>da.updatedAt)&&Ht.set(Zn,on)}$([...Ht.values()].sort((on,Zn)=>Zn.updatedAt.localeCompare(on.updatedAt)).slice(0,6))}).catch(()=>{}),Te.usage.summary().then(Rt=>H(Rt.usage)).catch(()=>{}),Te.cu.status().then(R).catch(()=>{});const en=Te.settings.getLlm().then(Rt=>{const Ht=A2(Rt);Ee(Ht.configured),qe(Ht.markus),Qe(Ht.providerLabel)}).catch(()=>{}),Sn=Te.settings.getBrowser().then(Rt=>{mt(Rt.extensionConnected)}).catch(()=>{}),zn=sK().then(Rt=>{if(!Rt&&!kn()){Xe(!1);return}return nt.user.claimFreeCreditsStatus().then(Ht=>Xe(!!Ht.claimed)).catch(()=>{})}).catch(()=>{});Promise.race([Promise.allSettled([J,xe,st,Mt,en,Sn,zn]),new Promise(Rt=>setTimeout(Rt,8e3))]).then(()=>{ae(!0)})},[M,ie]);k.useEffect(()=>{!V||D||Te.system.storage().then(W).catch(()=>{})},[V,D]);const de=k.useCallback(()=>{ie&&(Xh(ie),at(!0),Te.auth.updatePreferences({guideHidden:!0}).catch(()=>{}))},[ie]),fe=k.useCallback(J=>{const xe=m.find(st=>st.role==="secretary")??m.find(st=>st.name?.toLowerCase().includes("secretary"));yt.navigate(me.TEAM,{...xe?{agentId:xe.id}:{},prefillMessage:J})},[m]),ct=!!kn()||$e,We=P===!0||$e,ut=[...ct?[{id:"claim",done:Re,isSetup:!0,label:a("checklist.setup.claim"),desc:a("checklist.setup.claimDesc"),action:a("checklist.setup.claimAction"),onClick:()=>{lt(!0)}}]:[],{id:"llm",done:We,isSetup:!0,label:a("checklist.setup.llm"),desc:We&&Ze?a("checklist.setup.llmDescConfigured",{provider:Ze}):a(ct?"checklist.setup.llmDescHub":"checklist.setup.llmDesc"),action:a("checklist.setup.llmAction"),onClick:()=>{window.location.hash="#settings/providers"}},{id:"browser",done:wt===!0,isSetup:!0,optional:!0,label:a("checklist.setup.browser"),desc:a("checklist.setup.browserDesc"),action:a("checklist.setup.browserAction"),onClick:()=>{window.location.hash="#settings/browser"}}],Ft=[{id:"greet",done:De,label:a("checklist.explore.greet"),desc:a("checklist.explore.greetDesc"),action:a("checklist.explore.greetAction"),onClick:()=>fe("你好!我是新用户,请简单介绍一下你能帮我做什么?")},{id:"project",done:ie?K.some(J=>J.createdBy===ie):K.length>0,label:a("checklist.explore.project"),desc:a("checklist.explore.projectDesc"),action:a("checklist.explore.projectAction"),onClick:()=>fe("帮我创建一个名为「Markus探索」的项目,用于了解和体验Markus的各项能力")},{id:"requirements",done:ie?I.some(J=>J.createdBy===ie):I.length>0,label:a("checklist.explore.requirements"),desc:a("checklist.explore.requirementsDesc"),action:a("checklist.explore.requirementsAction"),onClick:()=>fe("在「Markus探索」项目中创建两个需求:1. 了解Markus开源项目的架构和设计理念 2. 探索Markus智能体的能力和使用方式")},{id:"team",done:g.length>0,label:a("checklist.explore.team"),desc:a("checklist.explore.teamDesc"),action:a("checklist.explore.teamAction"),onClick:()=>fe("帮我组建一个名为「科技前沿智库」的团队,成员包括4位科技领袖角色的智能体:埃隆·马斯克(关注太空、电动车、AI安全)、史蒂夫·乔布斯(关注产品设计与用户体验)、山姆·奥特曼(关注AGI与AI创业生态)、黄仁勋(关注GPU、AI算力与数据中心)。团队目标是从不同视角分析科技前沿趋势。")},{id:"shortcuts",done:Nt,label:a("checklist.explore.shortcuts"),desc:a("checklist.explore.shortcutsDesc"),action:a("checklist.explore.shortcutsAction"),onClick:()=>Oe(!0)}],ln=[...ut,...Ft],Pt=ln.filter(J=>J.done).length,Ae=ln.length,je=ut.filter(J=>!J.optional).every(J=>J.done)&&Ft.every(J=>J.done),_e=ut.some(J=>!J.optional&&!J.done),Q=()=>{ie&&(SV(ie),_e?ye(J=>J+1):de())};k.useEffect(()=>{!F||et||je&&de()},[F,et,je,de]),k.useEffect(()=>{if(t||!l)return;He();const J=setInterval(He,6e4),xe={at:0},st=15e3,Mt=()=>{const Sn=Date.now();Sn-xe.at<st||(xe.at=Sn,He())},en=()=>{if(Dt.current){nt.user.claimFreeCreditsStatus().then(Sn=>Xe(!!Sn.claimed)).catch(()=>{});return}He()};return window.addEventListener("markus:data-changed",Mt),window.addEventListener("markus:hub-auth",en),()=>{clearInterval(J),window.removeEventListener("markus:data-changed",Mt),window.removeEventListener("markus:hub-auth",en)}},[t,M,l,He]);const he={},Se=Object.keys(w).length>0?w:Object.fromEntries(Object.entries(v).map(([J,xe])=>[J,xe.length]));for(const[J,xe]of Object.entries(Se))J!=="archived"&&xe>0&&(he[J]=xe);const Ye=he.completed??0,bt=Object.values(he).reduce((J,xe)=>J+xe,0),it=m.filter(J=>{const xe=J.runtime?.phase;return xe?xe!=="idle"&&xe!=="offline":J.status==="working"}).length,tt=K.filter(J=>J.status==="active").length,St=bt>0?Math.round(Ye/bt*100):0,gn=f5.filter(J=>(he[J]??0)>0).map(J=>({status:J,count:he[J]})),bn=k.useMemo(()=>{const J={};return I.forEach(xe=>{J[xe.status]=(J[xe.status]??0)+1}),J},[I]),Qn=k.useMemo(()=>{const J=new Map(m.map(xe=>[xe.id,xe]));return g.map(xe=>{const st=xe.members.filter(Mt=>Mt.type==="agent").map(Mt=>J.get(Mt.id)).filter(Mt=>!!Mt);return{team:xe,agents:st,working:st.filter(Mt=>Mt.status==="working").length,total:st.length}})},[g,m]),ha=m.filter(J=>{const xe=J.runtime?.phase;return xe?xe!=="idle"&&xe!=="offline":J.status==="working"}),bi=!(P===!0&&!$e),ga=uV(!t&&l,C,g);t||yt.navigate;const En=k.useMemo(()=>{const J=new Map;for(const xe of Object.values(v))for(const st of xe)J.set(st.id,st);return J},[v]),[Xn,wr]=k.useState([]),[kr,Vs]=k.useState([]),[qr]=k.useState(()=>GK());k.useEffect(()=>{if(t||!l)return;let J=!0;const xe=()=>{Te.approvals.list().then(st=>{J&&wr((st.approvals??[]).filter(Mt=>Mt.status==="pending"))}).catch(()=>{}),e?.id&&Te.notifications.list(e.id,!0,{limit:20}).then(st=>{J&&Vs(st.notifications??[])}).catch(()=>{})};return xe(),window.addEventListener("markus:notifications-changed",xe),()=>{J=!1,window.removeEventListener("markus:notifications-changed",xe)}},[t,l,e?.id]);const is=k.useMemo(()=>Object.values(v).flat(),[v]),Jn=k.useMemo(()=>HK({tasks:is,requirements:I,approvals:Xn,notifications:kr,taskById:J=>En.get(J),lastSeenAt:qr,notifyTitle:J=>QK(J,a)}),[is,I,Xn,kr,En,qr,a]),yi=k.useMemo(()=>BK(Jn),[Jn]),aa=k.useMemo(()=>Jn.filter(J=>J.isNew).length,[Jn]),[hr,Sr]=k.useState(()=>Date.now());k.useEffect(()=>{const J=window.setInterval(()=>Sr(Date.now()),6e4);return()=>window.clearInterval(J)},[]),k.useEffect(()=>{t||VK(yi)},[yi,t]),k.useEffect(()=>{if(t||!l)return;const J=window.setTimeout(()=>KK(new Date().toISOString()),3e3);return()=>window.clearTimeout(J)},[t,l,Jn.length]);const Cr=k.useCallback(J=>{const xe=J.notices?.[0];xe&&Z4(xe,kr),yt.navigate(J.target.page==="WORK"?me.WORK:me.TEAM,J.target.params)},[kr]);k.useEffect(()=>{if(t||!l)return;let J=!0;const xe=()=>{Te.notifications.list(e?.id,!0,{limit:1}).then(st=>{J&&WK(st.unreadCount??0)}).catch(()=>{})};return xe(),window.addEventListener("markus:notifications-changed",xe),()=>{J=!1,window.removeEventListener("markus:notifications-changed",xe)}},[t,l,e?.id]);const In=k.useMemo(()=>{const J=new Map;for(const xe of Object.values(v))for(const st of xe)st.priority&&J.set(st.id,st.priority);return J},[v]),ss=k.useMemo(()=>{const J=new Map;for(const xe of m)J.set(xe.id,xe.name);return J},[m]),{activityLimit:Fr,teamsLimit:Ba}=k.useMemo(()=>{const J=(K.length>0?1:0)+(I.length>0?1:0)+(z>0?1:0),xe=bt>0?6+J:0,st=xe>0?2:0,en=xe+st+2,Sn=Qn.length>0?2+Qn.length:0,zn=Math.max(Sn,4),Rt=ha.length,Ht=Rt>0?8:12,on=Math.max(0,zn-en);let Zn=Rt>0?Math.max(Rt,on):on;Zn=Math.max(3,Math.min(Ht,Zn));const da=en+Math.max(Rt,Zn);let Ar=Qn.length;if(zn>da+2){const Tr=zn-da;Ar=Math.max(2,Qn.length-Tr)}else if(da>zn+2){const Tr=da-zn;Zn=Math.max(3,Zn-Tr)}return{activityLimit:Zn,teamsLimit:Ar}},[Qn,bt,K,I,z,ha]);return o.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:[o.jsxs("div",{"data-electron-drag":!0,className:`flex items-center justify-between px-4 sm:px-6 lg:px-8 h-14 sm:h-16 ${t?"":"max-w-7xl mx-auto"} w-full`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[i&&o.jsx(V4,{}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-base sm:text-lg font-bold",children:a("title")}),o.jsx("p",{className:"text-xs text-fg-tertiary hidden sm:block",children:a("subtitle")})]})]}),o.jsxs("div",{"data-no-drag":!0,className:"flex items-center gap-1.5",children:[o.jsx("button",{onClick:()=>t?void 0:i?yt.navigate(me.SEARCH):window.dispatchEvent(new CustomEvent("markus:open-search")),className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":"Search",children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),o.jsx(LV,{ref:we,show:re,onToggle:()=>ue(!re),onClose:()=>ue(!1),t:a,isMobile:i})]})]}),o.jsxs("div",{className:`px-4 sm:px-6 lg:px-8 pb-8 space-y-6 ${t?"":"max-w-7xl mx-auto"} w-full`,children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(iu,{label:a("metricCards.working"),value:String(it),sub:`/${m.length}`,icon:o.jsx(su,{type:"working"}),pulse:it>0,onClick:()=>q(!0)}),o.jsx(iu,{label:a("metricCards.tasksDone"),value:`${Ye}`,sub:`/${bt}`,icon:o.jsx(su,{type:"tasks"}),onClick:()=>yt.navigate(me.WORK)}),o.jsx(iu,{label:a("metricCards.projects"),value:String(tt),icon:o.jsx(su,{type:"projects"}),onClick:()=>yt.navigate(me.WORK)}),o.jsx(iu,{label:a("metricCards.health"),value:`${P===!1?100:C?.systemHealth.overallScore??"—"}`,sub:P===!1||C?"%":void 0,icon:o.jsx(su,{type:"health"}),color:P===!1?"green":C?C.systemHealth.overallScore>=80?"green":C.systemHealth.overallScore>=50?"amber":"red":void 0,onClick:()=>ce(!0)})]}),!t&&o.jsxs("div",{className:"bg-gradient-to-r from-amber-500/5 via-surface-elevated to-surface-elevated border border-amber-500/20 rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-4 pb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 shrink-0"}),o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("attention.title")}),Jn.length>0&&o.jsx("span",{className:"text-[11px] text-fg-tertiary tabular-nums",children:Jn.length}),aa>0&&o.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-brand-500/15 text-brand-500 shrink-0",children:a("attention.newCount",{count:aa})})]}),o.jsx("button",{onClick:()=>u(!0),className:"text-[11px] font-medium text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",children:a("attention.history")})]}),Jn.length===0?o.jsx("div",{className:"px-5 pb-4 text-xs text-fg-tertiary",children:a("attention.allClear")}):o.jsxs("div",{className:"px-3 pb-2 space-y-1",children:[Jn.slice(0,5).map(J=>o.jsxs("button",{onClick:()=>Cr(J),className:"w-full flex items-start gap-2.5 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 transition-colors text-left",children:[o.jsx("span",{className:`w-1 self-stretch rounded-full shrink-0 ${J.isNew?"bg-brand-500":"bg-transparent"}`}),o.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${Tn[Df[J.kind].tone].chip}`,children:o.jsx(c5,{name:Df[J.kind].iconName,size:15})}),o.jsxs("span",{className:"flex-1 min-w-0",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:J.title}),J.priority!=="none"&&o.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${T2[J.priority]??T2.none}`,children:J.priority})]}),o.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"shrink-0",children:a(`attention.kind.${J.kind}`)}),o.jsx("span",{children:"·"}),o.jsx("span",{className:"tabular-nums shrink-0",children:t5(J,hr)}),J.meta&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsx("span",{className:"truncate",children:J.meta})]})]})]}),o.jsx("span",{className:`shrink-0 text-[11px] font-medium px-2.5 py-1 rounded-lg transition-colors ${Tn[Df[J.kind].tone].btn}`,children:a(`attention.act.${J.kind}`)})]},J.id)),Jn.length>5&&o.jsx("button",{onClick:()=>u(!0),className:"w-full text-[11px] text-fg-tertiary hover:text-fg-primary px-3 py-2 text-left",children:a("attention.more",{count:Jn.length-5})})]})]}),!t&&o.jsx(UK,{open:c,onClose:()=>u(!1),userId:e?.id}),Y.length>0&&o.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("recentDeliverables.title")}),o.jsx("button",{onClick:()=>yt.navigate(me.DELIVERABLES),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsx("div",{className:"px-3 pb-3",children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-1",children:Y.map(J=>o.jsxs("div",{className:"flex items-start gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(me.DELIVERABLES,{openDeliverable:J.id}),children:[o.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 ${J.artifactType?"bg-brand-500/10":J.type==="directory"?"bg-blue-500/10":"bg-green-500/10"}`,children:o.jsx(_V,{type:J.type,artifactType:J.artifactType})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:J.title}),o.jsx("div",{className:"text-[11px] text-fg-tertiary truncate mt-0.5",children:J.summary}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[J.agentId&&ss.get(J.agentId)&&o.jsx("span",{className:"text-[10px] text-fg-muted",children:ss.get(J.agentId)}),o.jsx("span",{className:"text-[10px] text-fg-muted",children:R2(J.updatedAt,a)}),J.status==="verified"&&o.jsx("span",{className:"text-[10px] text-blue-500 font-medium",children:"Verified"})]})]}),J.diffStats&&o.jsxs("div",{className:"text-[10px] text-fg-muted shrink-0 mt-1 tabular-nums",children:[o.jsxs("span",{className:"text-green-500",children:["+",J.diffStats.additions]})," ",o.jsxs("span",{className:"text-red-500",children:["-",J.diffStats.deletions]})]})]},J.id))})})]}),F&&!et&&!je&&(()=>{if(Ne&&!_e)return null;const J=xe=>o.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg hover:bg-surface-elevated/50 transition-colors group",children:[o.jsx("div",{className:`mt-0.5 shrink-0 w-5 h-5 rounded-full flex items-center justify-center ${xe.done?"bg-green-500":"border-2 border-border-default"}`,children:xe.done&&o.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`text-xs font-medium ${xe.done?"text-fg-tertiary line-through":"text-fg-primary"}`,children:xe.label}),"optional"in xe&&xe.optional&&o.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-fg-muted font-medium",children:a("checklist.setup.optional")})]}),o.jsx("p",{className:`text-[11px] mt-0.5 ${xe.done?"text-fg-muted":"text-fg-tertiary"}`,children:xe.desc})]}),xe.done&&xe.isSetup?o.jsx("button",{onClick:xe.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg border border-border-default hover:bg-surface-elevated text-fg-secondary font-medium transition-colors opacity-0 group-hover:opacity-100",children:a("checklist.setup.update")}):xe.done?null:o.jsx("button",{onClick:xe.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand font-medium transition-colors opacity-80 group-hover:opacity-100",children:xe.action})]},xe.id);return o.jsxs("div",{className:"bg-gradient-to-br from-brand-600/10 via-surface-secondary to-surface-secondary border border-brand-500/20 rounded-2xl p-5 sm:p-6",children:[o.jsxs("div",{className:"flex items-start justify-between mb-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:a("checklist.title")}),o.jsx("p",{className:"text-xs text-fg-secondary",children:a("checklist.subtitle")})]}),o.jsx("button",{onClick:Q,className:"text-fg-muted hover:text-fg-secondary transition-colors p-1 -mr-1 -mt-1",title:"Dismiss",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[o.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-500",style:{width:`${Pt/Ae*100}%`}})}),o.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:a("checklist.progress",{done:Pt,total:Ae})})]}),o.jsxs("div",{className:"mb-4",children:[o.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:a("checklist.setup.title")}),o.jsx("div",{className:"space-y-0.5",children:ut.map(J)})]}),o.jsx("div",{className:"border-t border-border-default/50 my-3"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:a("checklist.explore.title")}),o.jsx("div",{className:"space-y-0.5",children:Ft.map(J)})]})]})})(),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[bt>0&&o.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("globalOverview.title")}),o.jsx("button",{onClick:()=>yt.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsxs("div",{className:"px-5 py-4 flex flex-col sm:flex-row items-center gap-6 border-t border-border-subtle/50",children:[o.jsx(MV,{statusCounts:he,total:bt,completionRate:St,completed:Ye}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"grid grid-cols-2 gap-x-5 gap-y-2.5",children:gn.map(({status:J,count:xe})=>o.jsxs("button",{onClick:()=>yt.navigate(me.WORK,{statusFilter:J}),className:"flex items-center gap-2 group cursor-pointer text-left",children:[o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${AV(J)}`}),o.jsx("span",{className:"text-xs text-fg-tertiary group-hover:text-fg-secondary transition-colors",children:Wh(J,a)}),o.jsx("span",{className:"text-sm font-semibold text-fg-primary ml-auto tabular-nums",children:xe})]},J))})})]}),o.jsxs("div",{className:"divide-y divide-border-subtle/50",children:[K.length>0&&o.jsx(If,{icon:"folder",label:a("globalOverview.projects"),value:K.length,onClick:()=>yt.navigate(me.WORK),children:o.jsxs(j2,{children:[tt," ",a("globalOverview.active")]})}),I.length>0&&o.jsx(If,{icon:"edit",label:a("globalOverview.requirements"),value:I.length,onClick:()=>yt.navigate(me.WORK),children:["in_progress","pending","completed"].map(J=>(bn[J]??0)>0&&o.jsxs(j2,{children:[bn[J]," ",Wh(J,a)]},J))}),z>0&&o.jsx(If,{icon:"book",label:a("globalOverview.deliverables"),value:z,onClick:()=>yt.navigate(me.DELIVERABLES)})]})]}),(ha.length>0||C&&C.taskKPI.recentActivity.length>0)&&o.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:o.jsxs("div",{className:`grid grid-cols-1 ${ha.length>0&&C&&C.taskKPI.recentActivity.length>0?"sm:grid-cols-2 divide-y sm:divide-y-0 sm:divide-x divide-border-subtle/50":""}`,children:[ha.length>0&&o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),o.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:a("liveActivity.whosWorking")})]}),o.jsx("div",{className:"space-y-1",children:ha.map(J=>{const xe=J.runtime,st=xe?.phase??(J.status==="idle"?"idle":J.status==="offline"?"offline":"running"),Mt=EV[st]??"bg-blue-400 animate-pulse";return o.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(me.TEAM,{agentId:J.id}),children:[o.jsx(Fo,{name:J.name,avatarUrl:J.avatarUrl,size:24,bgClass:"bg-brand-600/30 text-brand-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Mt}`}),o.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:J.name}),N2[st]&&o.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:a(N2[st])}),xe?.stall?.stalled&&o.jsx("span",{title:xe.stall.stuckReason,className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full shrink-0 ${xe.stall.stallKind==="dead-dependency"?"bg-amber-500/20 text-amber-400 border border-amber-500/30":"bg-sky-500/15 text-sky-300 border border-sky-500/25"}`,children:xe.stall.stallKind==="dead-dependency"?a("agentFocus.stallDeadBadge"):a("agentFocus.stallStaleBadge")}),xe?.dirty?.dirty&&(()=>{const en=xe.dirty.recovery==="human-review";return o.jsx("span",{className:`inline-flex items-center px-1.5 py-px rounded text-[9px] font-medium shrink-0 ${en?"bg-amber-500/15 text-amber-300":"bg-emerald-500/15 text-emerald-300"}`,children:a(en?"liveActivity.dirtyNeedsHuman":"liveActivity.dirtyRecovered")})})()]}),o.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:OV(J,a)})]})]},J.id)})})]}),C&&C.taskKPI.recentActivity.length>0&&o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:a("liveActivity.recentChanges")}),o.jsx("button",{onClick:()=>yt.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsx("div",{className:`${ha.length>0?"":"grid grid-cols-1 sm:grid-cols-2 gap-x-4"}`,children:C.taskKPI.recentActivity.slice(0,Fr).map(J=>{const xe=In.get(J.taskId);return o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(me.WORK,{openTask:J.taskId}),children:[o.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${TV[J.status]??"bg-gray-500/15"}`,children:o.jsx(jV,{status:J.status})}),o.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1",children:J.title}),(xe==="urgent"||xe==="high")&&o.jsx(RV,{priority:xe}),o.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:R2(J.updatedAt,a)})]},J.taskId)})})]})]})})]}),o.jsx("div",{className:"space-y-6",children:Qn.length>0&&o.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:a("teamOverview.title")}),o.jsx("button",{onClick:()=>yt.navigate(me.TEAM),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:a("common:viewAll")})]}),o.jsxs("div",{className:"space-y-0.5",children:[Qn.slice(0,Ba).map(J=>o.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>yt.navigate(me.TEAM,{selectTeam:J.team.id}),children:[o.jsx("div",{className:"w-7 h-7 rounded-md bg-brand-600/15 flex items-center justify-center text-[10px] font-bold text-brand-400 shrink-0",children:J.team.name.charAt(0)}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:J.team.name})}),o.jsx("div",{className:"flex items-center -space-x-1 shrink-0",children:J.agents.slice(0,3).map(xe=>o.jsx(Fo,{name:xe.name,avatarUrl:xe.avatarUrl,size:18,bgClass:"bg-surface-overlay text-fg-secondary ring-1 ring-surface-elevated"},xe.id))}),J.working>0&&o.jsxs("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:[J.working,"/",J.total]})]},J.team.id)),Ba<Qn.length&&o.jsxs("button",{onClick:()=>yt.navigate(me.TEAM),className:"w-full text-center text-[11px] text-brand-400 hover:text-brand-300 font-medium py-1.5",children:["+",Qn.length-Ba," more"]})]})]})})})]}),!t&&P!==null&&o.jsx(hV,{contributors:ga.contributors,hubPlan:ga.hubPlan,hubOrgMeta:ga.hubOrgMeta,hubConnected:ga.hubConnected,showMarkusUsage:bi})]}),Ce&&o.jsx(DV,{workingAgents:ha,onClose:()=>q(!1),t:a}),V&&o.jsx(IV,{ops:C,completed:Ye,totalRootTasks:bt,workingAgents:it,totalAgents:m.length,usageInfo:X,storageInfo:D,cuQuota:se,onClose:()=>ce(!1),t:a}),kt&&o.jsx(SK,{onClose:()=>lt(!1),onClaimed:Le}),o.jsx(MK,{open:ht,userId:ie,onClose:()=>Oe(!1),onCompleted:()=>{Gt(!0),Oe(!1)}})]})}function iu({label:e,value:t,sub:n,icon:a,pulse:i,color:l,badge:c,onClick:u}){const m=l==="green"?"text-green-500":l==="amber"?"text-amber-500":l==="red"?"text-red-500":"text-fg-primary";return o.jsxs("div",{onClick:u,className:"bg-surface-elevated shadow-sm rounded-2xl p-4 sm:p-5 flex items-start justify-between cursor-pointer hover:shadow-md transition-shadow",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-[11px] text-fg-tertiary mb-2",children:e}),o.jsxs("div",{className:"flex items-baseline gap-0.5",children:[o.jsx("span",{className:`text-2xl sm:text-3xl font-bold ${m} leading-none`,children:t}),n&&o.jsx("span",{className:"text-sm text-fg-muted font-medium",children:n})]}),c&&o.jsx("div",{className:"text-[10px] text-amber-500 font-medium mt-1.5",children:c})]}),o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-overlay/60 flex items-center justify-center text-fg-tertiary",children:a}),i&&o.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 rounded-full bg-green-500 animate-pulse"})]})]})}function su({type:e}){const t={working:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})}),tasks:o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),o.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),projects:o.jsx(o.Fragment,{children:o.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"})}),health:o.jsx(o.Fragment,{children:o.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})};return o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:t[e]})}function If({icon:e,label:t,value:n,onClick:a,children:i}){return o.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 hover:bg-surface-overlay/30 cursor-pointer transition-colors",onClick:a,children:[o.jsx("span",{className:"text-fg-muted",children:o.jsx(NV,{type:e})}),o.jsx("span",{className:"text-xs text-fg-secondary",children:t}),o.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:n}),o.jsx("div",{className:"flex items-center gap-2 ml-auto text-[11px] text-fg-tertiary",children:i})]})}function j2({children:e}){return o.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-overlay/60 text-[11px] text-fg-secondary",children:e})}function NV({type:e}){const t={folder:"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",edit:"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",book:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20 M4 19.5A2.5 2.5 0 0 0 6.5 22H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15z"};return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:t[e]})})}function MV({statusCounts:e,total:t,completionRate:n,completed:a}){const u=2*Math.PI*42,m=f5.filter(h=>(e[h]??0)>0).map(h=>({status:h,value:e[h],color:CV[h]??"#6b7280"}));let f=0;const g=m.map(h=>{const v=h.value/t*u,y={len:Math.max(v-.8,.5),offset:f,color:h.color,status:h.status};return f+=v,y});return o.jsxs("div",{className:"relative shrink-0",style:{width:120,height:120},children:[o.jsx("svg",{width:120,height:120,viewBox:"0 0 120 120",children:g.map((h,v)=>o.jsx("circle",{cx:"60",cy:"60",r:42,fill:"none",stroke:h.color,strokeWidth:12,strokeDasharray:`${h.len} ${u-h.len}`,strokeDashoffset:-h.offset,transform:"rotate(-90 60 60)",className:"transition-all duration-500 cursor-pointer",onClick:()=>yt.navigate(me.WORK,{statusFilter:h.status})},v))}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsxs("span",{className:"text-2xl font-bold text-fg-primary leading-none",children:[n,"%"]}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[a,"/",t]})]})]})}function jV({status:e}){const n={completed:"#22c55e",in_progress:"#8b5cf6",pending:"#f59e0b",review:"#3b82f6",failed:"#ef4444",blocked:"#f59e0b",rejected:"#ef4444",cancelled:"#6b7280"}[e]??"#6b7280";return o.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e==="completed"&&o.jsx("polyline",{points:"20 6 9 17 4 12"}),e==="in_progress"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e==="pending"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),o.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e==="review"&&o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),(e==="failed"||e==="rejected")&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),e==="blocked"&&o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})]}),e==="cancelled"&&o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})]})}function RV({priority:e}){return e==="urgent"?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-red-500/15 text-red-500 shrink-0 uppercase tracking-wide",children:"!"}):e==="high"?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-amber-500/15 text-amber-600 shrink-0 uppercase tracking-wide",children:"H"}):null}function _V({type:e,artifactType:t}){if(t){const a=t==="agent"?"#8b5cf6":t==="team"?"#3b82f6":"#f59e0b";return o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),o.jsx("path",{d:"M2 17l10 5 10-5"}),o.jsx("path",{d:"M2 12l10 5 10-5"})]})}const n=e==="directory"?"#3b82f6":"#22c55e";return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:e==="directory"?o.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"}):o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"})]})})}function DV({workingAgents:e,onClose:t,t:n}){return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:o.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[420px] max-w-[90vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between shrink-0",children:[o.jsx("h3",{className:"text-sm font-semibold",children:n("ranking.workingNow")}),o.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"overflow-y-auto flex-1 scrollbar-thin px-5 py-4",children:e.length>0?o.jsx("div",{className:"space-y-0.5",children:e.map(a=>o.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>{t(),yt.navigate(me.TEAM,{agentId:a.id})},children:[o.jsx(Fo,{name:a.name,avatarUrl:a.avatarUrl,size:26,bgClass:"bg-brand-600/30 text-brand-300"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:a.name}),o.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:a.currentActivity?.label??"—"})]}),o.jsx("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:"Working"})]},a.id))}):o.jsx("div",{className:"py-8 text-center text-xs text-fg-tertiary",children:n("ranking.noData")})})]})})}function IV({ops:e,completed:t,totalRootTasks:n,workingAgents:a,totalAgents:i,usageInfo:l,storageInfo:c,cuQuota:u,onClose:m,t:f}){return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:m,children:o.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] overflow-hidden",onClick:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-semibold",children:f("systemHealth.title")}),o.jsx("button",{onClick:m,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"p-5 space-y-4",children:[e&&o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.successRate")}),o.jsxs("span",{className:"text-sm font-bold text-fg-primary",children:[Math.round(e.taskKPI.successRate),"%"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-green-500 transition-all duration-500",style:{width:`${Math.round(e.taskKPI.successRate)}%`}})})]}),e&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("metricCards.health")}),o.jsxs("span",{className:`text-sm font-bold ${e.systemHealth.overallScore>=80?"text-green-500":e.systemHealth.overallScore>=50?"text-amber-500":"text-red-500"}`,children:[e.systemHealth.overallScore,"%"]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.tasksTotal")}),o.jsxs("span",{className:"text-xs font-semibold text-fg-primary",children:[t,"/",n]})]}),l&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.tokenUsage")}),o.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:lu(l.llmTokens)})]}),u?.available&&u.cuLimit>0&&(()=>{const g=u.cuLimit-u.cuRemaining,h=Math.min(100,Math.round(g/u.cuLimit*100)),v=h>=95?"text-red-500":h>=80?"text-amber-500":"text-green-500",y=h>=95?"bg-red-500":h>=80?"bg-amber-500":"bg-green-500";return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:"CU Quota"}),o.jsxs("span",{className:`text-xs font-semibold ${v}`,children:[lu(g)," / ",lu(u.cuLimit)," (",h,"%)"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full ${y} transition-all duration-500`,style:{width:`${h}%`}})}),u.cuUsedToday!=null&&u.cuUsedToday>0&&o.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[o.jsx("span",{className:"text-xs text-fg-tertiary",children:"Today's CU Used"}),o.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:lu(u.cuUsedToday)})]})]})})(),a>0&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.currentWorking")}),o.jsxs("span",{className:"text-xs font-semibold text-green-500",children:[a,"/",i]})]}),c&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs text-fg-secondary",children:f("systemHealth.storage")}),o.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:zV(c.totalSize)})]})]})]})})}const LV=k.forwardRef(({show:e,onToggle:t,onClose:n,t:a,isMobile:i},l)=>o.jsxs("div",{ref:l,className:"relative",children:[o.jsx("button",{onClick:t,className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":"Create",children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),o.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e&&o.jsx("div",{className:"absolute right-0 top-full mt-2 bg-surface-elevated border border-border-default rounded-xl shadow-xl z-50 overflow-hidden w-48 animate-fadeIn",children:o.jsxs("div",{className:"py-1",children:[o.jsx(ou,{onClick:()=>{n(),yt.navigate(me.BUILDER,i?{storeTab:"builder"}:void 0)},icon:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M19 8v6 M22 11h-6",children:a("home:createMenu.agent")}),o.jsx(ou,{onClick:()=>{n(),yt.navigate(me.BUILDER)},icon:"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",children:a("home:createMenu.team")}),o.jsx(ou,{onClick:()=>{n(),yt.navigate(me.BUILDER)},icon:"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",children:a("home:createMenu.skill")}),o.jsx("div",{className:"border-t border-border-default my-1"}),o.jsx(ou,{onClick:()=>{n(),yt.navigate(me.STORE)},icon:"M6 2L3 7v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-3-5z M3 7h18 M16 11a4 4 0 0 1-8 0",children:a("home:createMenu.discover")})]})})]}));function ou({onClick:e,icon:t,children:n}){return o.jsxs("button",{onClick:e,className:"w-full flex items-center gap-2.5 px-4 py-2.5 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:t})}),n]})}function R2(e,t){const n=Date.now()-new Date(e).getTime(),a=Math.floor(n/6e4);if(a<1)return t("common:time.now");if(a<60)return t("common:time.minutesAgo",{count:a});const i=Math.floor(a/60);return i<24?t("common:time.hoursAgo",{count:i}):t("common:time.daysAgo",{count:Math.floor(i/24)})}function _2(e,t){return e?E2[e]?t(E2[e]):e:null}function PV(e,t=""){if(!e)return t;const n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function OV(e,t){const n=e.runtime,a=[];if(n){if(n.stall?.stalled)if(n.stall.stallKind==="dead-dependency")a.push(t("agentFocus.stallDeadDep",{title:n.stall.stuckOnTitle??n.stall.stuckOnTaskId??""}));else{const i=n.stall.lastActivityAgoMin;a.push(t("agentFocus.stallStale",{minutes:typeof i=="number"?i:0}))}else n.blockedBy&&n.blockedBy.length>0?a.push(t("agentFocus.blockedBy",{title:n.blockedBy[0].title})):n.phase==="idle"||n.phase==="offline"||(n.activityLabel?a.push(_2(n.activityLabel,t)??n.activityLabel):n.activityType==="heartbeat"&&a.push(t("agentFocus.heartbeatCheckIn")));return typeof n.runningMinutes=="number"&&n.runningMinutes>=1&&a.push(t("agentFocus.runningFor",{n:n.runningMinutes})),(n.lastActivityAt||n.lastHeartbeat)&&a.push(t("agentFocus.lastActivity",{time:PV(n.lastActivityAt??n.lastHeartbeat)})),n.lastError&&a.push(n.lastError),a.join(" · ")}return _2(e.currentActivity?.label,t)??t("agentFocus.working")}function lu(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function zV(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n>0?1:0)} ${t[n]}`}class HV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!BV(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 BV(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 bm=5,h5=5*1024*1024,$V=["image/png","image/jpeg","image/webp","image/gif"];function qV(e,t){const n=[],a=[],i=$V;let l=t;for(const c of e){if(!i.includes(c.type)){a.push({name:c.name,reason:"not_image"});continue}if(c.size>h5){a.push({name:c.name,reason:"too_large"});continue}if(l>=bm){a.push({name:c.name,reason:"too_many"});continue}n.push(c),l+=1}return{accepted:n,rejected:a}}function FV(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB"],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024))),a=e/1024**n;return`${a>=10||n===0?Math.round(a):Math.round(a*10)/10} ${t[n]}`}function UV(e){return e.title.trim()?null:"title_required"}function GV(e,t){return t==="not_image"?e("feedback.rejectNotImage"):t==="too_large"?e("feedback.rejectTooLarge",{size:FV(h5)}):e("feedback.rejectTooMany",{max:bm})}function KV({defaultContact:e,onClose:t}){const{t:n}=xt("common");Fs(!0);const[a,i]=k.useState(""),[l,c]=k.useState(""),[u,m]=k.useState(e),[f,g]=k.useState([]),[h,v]=k.useState([]),[y,w]=k.useState(""),[T,C]=k.useState(!1),[A,M]=k.useState(!1),[I,B]=k.useState(!1),K=k.useRef(null),j=k.useRef([]);j.current=f;const z=nt.isAuthenticated();k.useEffect(()=>()=>{for(const D of j.current)URL.revokeObjectURL(D.previewUrl)},[]),k.useEffect(()=>{const D=W=>{W.key==="Escape"&&!T&&t()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[T,t]);const U=k.useCallback(D=>{if(!D)return;const W=Array.from(D);if(W.length===0)return;const{accepted:X,rejected:H}=qV(W,j.current.length);H.length?v(H.map(se=>`${se.name}:${GV(n,se.reason)}`)):v([]),X.length&&g(se=>[...se,...X.map(R=>({id:`${R.name}-${R.size}-${Math.random().toString(36).slice(2)}`,file:R,previewUrl:URL.createObjectURL(R)}))])},[n]),Y=D=>{g(W=>{const X=W.find(H=>H.id===D);return X&&URL.revokeObjectURL(X.previewUrl),W.filter(H=>H.id!==D)}),v([])},$=async D=>{if(D.preventDefault(),w(""),UV({title:a})){w(n("feedback.titleRequired"));return}C(!0);try{const W=[];for(const X of f){const H=await nt.uploadImage(X.file);if(!H?.url)throw new Error("upload_failed");W.push(H.url)}await nt.feedback.create({title:a.trim(),content:l.trim()||void 0,contact:u.trim()||void 0,images:W.length?W:void 0,appVersion:"0.12.3",platform:typeof navigator<"u"?navigator.platform:void 0,locale:typeof navigator<"u"?navigator.language:void 0}),M(!0)}catch(W){const X=W.status,H=W instanceof Error?W.message:String(W);w(n(X===404?"feedback.hubUnsupported":H==="upload_failed"?"feedback.uploadFailed":"feedback.submitFailed"))}finally{C(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000] p-4",onClick:()=>{T||t()},children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[540px] max-w-full max-h-[calc(100vh-2rem)] overflow-y-auto shadow-2xl",onClick:D=>D.stopPropagation(),onDragOver:D=>{D.preventDefault(),z&&B(!0)},onDragLeave:()=>B(!1),onDrop:D=>{D.preventDefault(),B(!1),z&&U(D.dataTransfer.files)},children:A?o.jsxs("div",{className:"p-6 text-center",children:[o.jsx("div",{className:"text-3xl mb-3",children:"✅"}),o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:n("feedback.successTitle")}),o.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:n("feedback.successDesc")}),o.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg",children:n("feedback.successClose")})]}):o.jsxs("form",{onSubmit:$,className:"p-6",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:n("feedback.modalTitle")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-4",children:n("feedback.modalSubtitle")}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:[n("feedback.fieldTitle")," ",o.jsx("span",{className:"text-red-400",children:"*"})]}),o.jsx("input",{value:a,onChange:D=>i(D.target.value),maxLength:120,autoFocus:!0,placeholder:n("feedback.titlePlaceholder"),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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:n("feedback.fieldContent")}),o.jsx("textarea",{value:l,onChange:D=>c(D.target.value),maxLength:4e3,rows:5,placeholder:n("feedback.contentPlaceholder"),onPaste:D=>{if(!z)return;const W=Array.from(D.clipboardData?.files??[]);W.length&&(D.preventDefault(),U(W))},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 resize-y"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:n("feedback.fieldImages",{max:bm})}),z?o.jsxs("div",{className:`rounded-lg border border-dashed p-3 transition-colors ${I?"border-brand-500 bg-brand-500/5":"border-border-default"}`,children:[o.jsxs("div",{className:"flex flex-wrap gap-2",children:[f.map(D=>o.jsxs("div",{className:"relative group",children:[o.jsx("img",{src:D.previewUrl,alt:D.file.name,className:"w-20 h-16 object-cover rounded-md border border-border-default"}),o.jsx("button",{type:"button",onClick:()=>Y(D.id),title:n("remove"),className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-black/70 text-white text-[11px] leading-none opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},D.id)),f.length<bm&&o.jsx("button",{type:"button",onClick:()=>K.current?.click(),className:"w-20 h-16 rounded-md border border-dashed border-border-default text-fg-muted hover:text-fg-secondary hover:border-brand-500 transition-colors text-lg",children:"+"})]}),o.jsx("p",{className:"text-[10px] text-fg-muted mt-2",children:n("feedback.dropHint")}),o.jsx("input",{ref:K,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,className:"hidden",onChange:D=>{U(D.target.files),D.target.value=""}})]}):o.jsx("p",{className:"text-[11px] text-amber-500/90 bg-amber-500/10 border border-amber-500/30 rounded-lg px-3 py-2",children:n("feedback.loginForImages")}),h.length>0&&o.jsx("ul",{className:"mt-1.5 space-y-0.5",children:h.map((D,W)=>o.jsx("li",{className:"text-[11px] text-red-400",children:D},W))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:n("feedback.fieldContact")}),o.jsx("input",{value:u,onChange:D=>m(D.target.value),placeholder:n("feedback.contactPlaceholder"),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"})]}),y&&o.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:y})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:t,disabled:T,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated disabled:opacity-50",children:n("cancel")}),o.jsx("button",{type:"submit",disabled:T,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand rounded-lg",children:n(T?"feedback.submitting":"feedback.submit")})]})]})})})}function Lf({label:e,value:t}){return o.jsxs("div",{className:"rounded-lg px-2 py-2.5 text-center bg-surface-elevated",children:[o.jsx("div",{className:"text-lg font-semibold tabular-nums text-fg-primary",children:t.toLocaleString()}),o.jsx("div",{className:"text-[10px] uppercase tracking-wider mt-0.5 text-fg-muted",children:e})]})}function VV({onClose:e}){const{t}=xt("common");Fs(!0);const[n,a]=k.useState(null),[i,l]=k.useState(!0),[c,u]=k.useState(""),[m,f]=k.useState(null),g=nt.isAuthenticated(),h=k.useCallback(async()=>{if(!g){l(!1);return}l(!0),u("");try{const y=await nt.user.referral();a({code:y.code,shareUrl:y.shareUrl,invitedCount:y.invitedCount,paidCount:y.paidCount,rewardCuTotal:y.rewardCuTotal,rewardCuPerPaid:y.rewardCuPerPaid,claimBonusCu:y.claimBonusCu})}catch(y){u(y.status===404?t("ambassador.unsupported"):t("ambassador.loadFailed"))}finally{l(!1)}},[g,t]);k.useEffect(()=>{h()},[h]),k.useEffect(()=>{const y=w=>{w.key==="Escape"&&e()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[e]);const v=async y=>{if(n)try{await navigator.clipboard.writeText(y==="code"?n.code:n.shareUrl),f(y),setTimeout(()=>f(null),2e3)}catch{}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000] p-4",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[460px] max-w-full max-h-[calc(100vh-2rem)] overflow-y-auto shadow-2xl p-6",onClick:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[o.jsx("span",{className:"text-xl leading-none",children:"🎁"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:t("ambassador.title")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1 leading-relaxed",children:n?t("ambassador.desc",{claimAmount:n.claimBonusCu.toLocaleString(),rewardAmount:n.rewardCuPerPaid.toLocaleString()}):t("ambassador.descGeneric")})]})]}),g?i?o.jsx("p",{className:"text-sm text-fg-tertiary py-6 text-center",children:t("ambassador.loading")}):c?o.jsx("p",{className:"text-xs text-red-400 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:c}):n?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:t("ambassador.codeLabel")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"flex-1 px-3 py-2 rounded-lg text-sm font-mono tracking-widest bg-surface-elevated text-fg-primary select-all",children:n.code}),o.jsx("button",{type:"button",onClick:()=>{v("code")},className:"px-3 py-2 text-xs font-medium rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand shrink-0",children:t(m==="code"?"ambassador.copied":"ambassador.copyCode")})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsx(Lf,{label:t("ambassador.statInvited"),value:n.invitedCount}),o.jsx(Lf,{label:t("ambassador.statPaid"),value:n.paidCount}),o.jsx(Lf,{label:t("ambassador.statReward"),value:n.rewardCuTotal})]}),o.jsx("button",{type:"button",onClick:()=>{v("link")},className:"w-full px-3 py-2 text-xs border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:t(m==="link"?"ambassador.copied":"ambassador.copyLink")})]}):null:o.jsxs("div",{className:"rounded-lg border border-border-default p-4 text-center",children:[o.jsx("p",{className:"text-sm text-fg-secondary mb-3",children:t("ambassador.loginPrompt")}),o.jsx("button",{type:"button",onClick:()=>{nt.ensureAuth().then(()=>h()).catch(()=>{})},className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg",children:t("ambassador.login")})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[g&&n&&o.jsx("button",{type:"button",onClick:()=>{const y=nt.getUrl().replace(/\/$/,"");Or(`${y}/settings`)},className:"px-3 py-2 text-xs border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:t("ambassador.openHub")}),o.jsx("button",{type:"button",onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("close")})]})]})})}function jo({d:e,size:t=14}){return o.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:o.jsx("path",{d:e})})}const Pf=200;function WV({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:a=!1,collapsed:i=!1,showVersion:l=!1}){const{t:c}=xt(["nav","common"]),[u,m]=k.useState(!1),[f,g]=k.useState(!1),[h,v]=k.useState(!1),[y,w]=k.useState(!1),[T,C]=k.useState({top:0,left:0}),A=k.useRef(null),M=k.useRef(null),{connected:I,user:B,credits:K,refresh:j}=K4(u),z=k.useCallback(()=>{if(!A.current)return;const R=A.current.getBoundingClientRect(),re=window.innerWidth,ue=window.innerHeight,Ce=M.current?.offsetHeight??220;let q=R.right+8;q+Pf>re-8&&(q=Math.max(8,R.left-Pf-8));let V=R.top-Ce-8;V<8&&(V=Math.min(R.bottom+8,ue-Ce-8)),C({top:Math.max(8,V),left:q})},[]);k.useLayoutEffect(()=>{if(!u)return;z();const R=requestAnimationFrame(()=>z());return()=>cancelAnimationFrame(R)},[u,z,i]),k.useEffect(()=>{if(!u)return;const R=ue=>{const Ce=ue.target;A.current?.contains(Ce)||M.current?.contains(Ce)||m(!1)},re=()=>z();return document.addEventListener("mousedown",R),window.addEventListener("resize",re),window.addEventListener("scroll",re,!0),()=>{document.removeEventListener("mousedown",R),window.removeEventListener("resize",re),window.removeEventListener("scroll",re,!0)}},[u,z]);const U=e?.name||B?.displayName||B?.username||c("common:userPlaceholder"),Y=e?.email||B?.email||"",$=F4(e?.avatarUrl,B?.avatarUrl),D=I?"bg-emerald-500":"bg-fg-muted",W=I?B?.username?c("sidebar.hubConnectedAs",{username:B.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),X=!!(I&&B?.username&&e?.name&&B.username.toLowerCase()!==e.name.toLowerCase()&&B.email?.toLowerCase()!==e.email?.toLowerCase()),H=()=>{m(!1),j({validate:!0}),yt.navigate(me.SETTINGS,{tab:"account"})},se=u&&Lc.createPortal(o.jsxs("div",{ref:M,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:T.top,left:T.left,width:Pf},children:[o.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:U}),Y&&o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:Y}),K!==null&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),Or(`${nt.getUrl().replace(/\/$/,"")}/settings?tab=billing`)},title:c("common:creditBalanceOpenHub"),className:"text-xs text-fg-secondary mt-0.5 -mx-1 px-1 max-w-full flex items-center gap-1 rounded transition-colors hover:text-brand-500 hover:bg-surface-overlay",children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[o.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),o.jsx("path",{d:"M12.5 5.5v13",strokeDasharray:"2 2.5"})]}),o.jsxs("span",{className:"truncate",children:[c("common:creditBalance"),": ",K.remaining.toLocaleString()]})]})]}),n&&o.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:o.jsx(jo,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),o.jsxs("button",{type:"button",onClick:H,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${D}`}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:W}),X&&B?.username&&o.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:B.username})})]}),o.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:o.jsx("path",{d:"m9 18 6-6-6-6"})})]}),o.jsxs("div",{className:"py-1",children:[o.jsxs("button",{type:"button",onClick:()=>{m(!1),v(!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:[o.jsx(jo,{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5Z"}),c("common:feedback.entry")]}),o.jsxs("button",{type:"button",onClick:()=>{m(!1),w(!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:[o.jsx(jo,{d:"M20 12v10H4V12M2 7h20v5H2zM12 22V7M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7ZM12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7Z"}),c("common:ambassador.entry")]}),a&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),yt.navigate(me.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:[o.jsx(jo,{d:Fm[me.SETTINGS]}),c("settings")]}),window.markusDesktop&&o.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:[o.jsx(jo,{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&&o.jsxs("button",{type:"button",onClick:()=>{m(!1),g(!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:[o.jsx(jo,{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 o.jsxs("div",{className:`relative ${i?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[o.jsxs("button",{ref:A,type:"button",onClick:()=>m(R=>!R),title:U,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${i?"p-0.5":""}`,children:[o.jsx(Fo,{name:U,avatarUrl:$,size:i?28:32,fallback:"icon"}),o.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${D}`,title:W})]}),l&&!i&&o.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.12.3"]}),se,h&&o.jsx(KV,{defaultContact:Y,onClose:()=>v(!1)}),y&&o.jsx(VV,{onClose:()=>w(!1)}),f&&t&&o.jsx(vr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{g(!1),t()},onCancel:()=>g(!1)})]})}function YV({d:e,size:t=18}){return o.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:o.jsx("path",{d:e})})}function QV({currentPage:e,onNavigate:t,authUser:n,collapsed:a,onToggleCollapse:i,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:u}){const{t:m}=xt(["nav","common"]),[f,g]=k.useState(Gm);return k.useEffect(()=>s5(g),[]),o.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[o.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${a?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:o.jsxs("button",{"data-no-drag":!0,onClick:i,title:m(a?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!a&&o.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),o.jsx("nav",{className:`${a?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:yG.map((h,v)=>{const y=M4.filter(T=>T.section===h.key);if(y.length===0)return null;const w=m(`sections.${h.key}`);return o.jsx("div",{children:o.jsxs("div",{className:v>0?"mt-3":"",children:[!a&&w&&o.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:w}),a&&v>0&&o.jsx("div",{className:"my-3"}),y.map(T=>{const C=e===T.id,A=u&&c===T.id;return o.jsxs("button",{"data-l0-page-id":T.id,onClick:()=>t(T.id),title:a?m(T.id):void 0,className:`relative w-full flex items-center ${a?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${A?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":C?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[o.jsx(YV,{d:Fm[T.id]??"",size:a?16:18}),a?o.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(T.id)}):o.jsx("span",{className:"truncate",children:m(T.id)}),T.id===me.HOME&&f>0&&(a?o.jsx("span",{className:"absolute top-0.5 right-1.5 min-w-[13px] h-[13px] px-[3px] rounded-full bg-red-500 text-white text-[8px] font-bold flex items-center justify-center tabular-nums",children:f>9?"9+":f}):o.jsx("span",{className:"ml-auto shrink-0 text-[10px] px-1.5 py-0.5 rounded-full bg-red-500 text-white font-semibold tabular-nums",children:f>99?"99+":f}))]},T.id)})]})},h.key)})}),o.jsx("div",{className:`shrink-0 border-t border-border-subtle ${a?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:o.jsx(WV,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const XV=100;function JV(e,t){const n=XV,a=((f,g)=>setTimeout(f,g)),i=(f=>clearTimeout(f)),l=new Map;let c=null,u=!1;function m(){if(c=null,u=!1,l.size===0)return;const f=[];for(const[g,h]of l)f.push({conversationKey:g,lastReadAt:h});l.clear(),e(f)}return{queue(f,g){let h=!1;for(const v of f)v&&(l.set(v,g),h=!0);h&&(u||(u=!0,c=a(m,n)))},flushNow(){u&&(i(c),u=!1,c=null),m()},pendingCount(){return l.size}}}const ZV=6e4,eW=2e3;let cr={},Wi={};const Jh=new Set,ym=new Set;let g5=0;const Zh=new Map;let mc=null,cu=0,Ku=null;function Ec(){for(const e of Jh)e()}function D2(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const a of n)if(e[a]!==t[a])return!1;return!0}function tW(e,t){const n={},a=[];for(const[i,l]of Object.entries(e)){if(t.has(i)){l>0&&a.push(i);continue}n[i]=l}return{counts:n,staleActiveKeys:a}}function nW(e,t){vm([e],t)}function aW(e,t,n,a){const i=[];for(const l of e){const c=t.get(l)??0;!a?.force&&n-c<eW||i.push(l)}return i}const b5=JV(e=>{(e.length===1?Te.unread.markRead(e[0].conversationKey,e[0].lastReadAt):Te.unread.markReadBatch(e)).catch(()=>{})});typeof window<"u"&&typeof window.addEventListener=="function"&&window.addEventListener("pagehide",()=>b5.flushNow(),{passive:!0});function vm(e,t){const n=Date.now(),a=aW(e,Zh,n,t);let i=!1;for(const l of a)Zh.set(l,n),l in cr&&(delete cr[l],i=!0);i&&Ec(),a.length!==0&&b5.queue(a,new Date(n).toISOString())}async function eg(){try{const e=await Te.unread.getCounts(),{counts:t,staleActiveKeys:n}=tW(e.counts??{},ym);cr=t,Wi=e.sessionAgentMap??{},Ec(),vm(n)}catch{}}function rW(){mc||(eg(),mc=setInterval(eg,ZV),Ku=_s.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(ym.has(t)){nW(t);return}Date.now()>g5&&(cr[t]=(cr[t]??0)+1,Ec())}}))}function iW(){mc&&(clearInterval(mc),mc=null),Ku&&(Ku(),Ku=null)}function sW(e){const t=e?.enabled??!0,[n,a]=k.useState(cr),[i,l]=k.useState(Wi),c=k.useCallback(async()=>{await eg()},[]),u=k.useCallback(async C=>{if(C.length===0)return;let A=!1;for(const M of C)M in cr&&(delete cr[M],A=!0);A&&Ec(),vm(C,{force:!0})},[]),m=k.useCallback(async C=>{await u([C])},[u]),f=k.useCallback(async()=>{cr={},Ec();try{await Te.unread.markAllRead()}catch{}},[]),g=k.useCallback(C=>{ym.add(C)},[]),h=k.useCallback(C=>{if(C.length!==0){for(const A of C)ym.delete(A),Zh.delete(A);g5=Date.now()+150,vm(C,{force:!0})}},[]),v=k.useCallback(C=>{h([C])},[h]);k.useEffect(()=>{if(!t)return;cu++,rW();let C=Wi;const A=()=>{a(M=>D2(M,cr)?M:{...cr}),C!==Wi&&(C=Wi,l(M=>D2(M,Wi)?M:{...Wi}))};return Jh.add(A),a({...cr}),l({...Wi}),()=>{Jh.delete(A),cu--,cu<=0&&(cu=0,iW())}},[t]);const y=k.useMemo(()=>Object.values(n).reduce((C,A)=>C+A,0),[n]),w=k.useCallback(C=>n[`session:${C}`]??0,[n]),T=k.useCallback(C=>n[`channel:${C}`]??0,[n]);return{counts:n,totalUnread:y,sessionAgentMap:i,getSessionUnread:w,getChannelUnread:T,markRead:m,markReadMany:u,markAllRead:f,refresh:c,setActiveKey:g,clearActiveKey:v,clearActiveKeys:h}}function Lle(e,t){return k.useMemo(()=>{const n=new Map;for(const[a,i]of Object.entries(t))if(a.startsWith("session:")){const l=a.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+i)}return n},[e,t])}function oW(e){return e.startsWith("channel:dm:a2a:")}function lW(e,t){let n=0;for(const[a,i]of Object.entries(e))if(a.startsWith("session:")){const l=a.slice(8);t[l]&&(n+=i)}else if(a.startsWith("channel:")){if(oW(a))continue;n+=i}return n}const cW=6,dW=56;function uW({currentPage:e,onNavigate:t}){const{t:n}=xt("nav"),[a,i]=k.useState(Gm);k.useEffect(()=>s5(i),[]);const[l,c]=k.useState(!1),u=k.useRef(!1),m=k.useCallback(v=>{u.current!==v&&(u.current=v,c(v))},[]);k.useEffect(()=>{let v=window.scrollY,y=0;const w=()=>{y||(y=requestAnimationFrame(()=>{y=0;const T=window.scrollY,C=T-v;if(v=T,T<=dW){m(!1);return}C>cW?m(!0):C<-6&&m(!1)}))};return window.addEventListener("scroll",w,{passive:!0}),()=>{window.removeEventListener("scroll",w),y&&cancelAnimationFrame(y)}},[m]),k.useEffect(()=>{m(!1)},[e,m]);const{counts:f,sessionAgentMap:g}=sW({enabled:!0}),h=k.useMemo(()=>lW(f,g),[f,g]);return o.jsx("nav",{"data-mobile-bottom-nav":!0,className:`fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom transition-transform duration-300 ease-out will-change-transform ${l?"translate-y-[calc(100%+1px)]":"translate-y-0"}`,children:xG.map(v=>{const y=v.group.includes(e),w=v.id===me.HOME,T=v.id===me.TEAM;return o.jsxs("button",{onClick:()=>t(v.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${y?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[o.jsxs("div",{className:"relative",children:[o.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:y?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:o.jsx("path",{d:Fm[v.id]})}),w&&a>0&&o.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:a>99?"99+":a}),T&&h>0&&o.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:h>99?"99+":h})]}),o.jsx("span",{className:`text-[10px] leading-tight ${y?"font-semibold":""}`,children:n(v.id)})]},v.id)})})}const xm=new Map;function As(e,t){xm.has(e)||xm.set(e,t().catch(()=>{}))}function Ps(e){const t=xm.get(e);return xm.delete(e),t}const La={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function I2(e){const t=[],n=String(e||"");let a=n.indexOf(","),i=0,l=!1;for(;!l;){a===-1&&(a=n.length,l=!0);const c=n.slice(i,a).trim();(c||!l)&&t.push(c),i=a+1,a=n.indexOf(",",i)}return t}function mW(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const pW=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hW={};function L2(e,t){return(hW.jsx?fW:pW).test(e)}const gW=/[ \t\n\f\r]/g;function bW(e){return typeof e=="object"?e.type==="text"?P2(e.value):!1:P2(e)}function P2(e){return e.replace(gW,"")===""}class Oc{constructor(t,n,a){this.normal=n,this.property=t,a&&(this.space=a)}}Oc.prototype.normal={};Oc.prototype.property={};Oc.prototype.space=void 0;function y5(e,t){const n={},a={};for(const i of e)Object.assign(n,i.property),Object.assign(a,i.normal);return new Oc(n,a,t)}function Nc(e){return e.toLowerCase()}class Ha{constructor(t,n){this.attribute=n,this.property=t}}Ha.prototype.attribute="";Ha.prototype.booleanish=!1;Ha.prototype.boolean=!1;Ha.prototype.commaOrSpaceSeparated=!1;Ha.prototype.commaSeparated=!1;Ha.prototype.defined=!1;Ha.prototype.mustUseProperty=!1;Ha.prototype.number=!1;Ha.prototype.overloadedBoolean=!1;Ha.prototype.property="";Ha.prototype.spaceSeparated=!1;Ha.prototype.space=void 0;let yW=0;const $t=Us(),Kn=Us(),tg=Us(),Ke=Us(),wn=Us(),Bo=Us(),Wa=Us();function Us(){return 2**++yW}const ng=Object.freeze(Object.defineProperty({__proto__:null,boolean:$t,booleanish:Kn,commaOrSpaceSeparated:Wa,commaSeparated:Bo,number:Ke,overloadedBoolean:tg,spaceSeparated:wn},Symbol.toStringTag,{value:"Module"})),Of=Object.keys(ng);class Yg extends Ha{constructor(t,n,a,i){let l=-1;if(super(t,n),O2(this,"space",i),typeof a=="number")for(;++l<Of.length;){const c=Of[l];O2(this,Of[l],(a&ng[c])===ng[c])}}}Yg.prototype.defined=!0;function O2(e,t,n){n&&(e[t]=n)}function Qo(e){const t={},n={};for(const[a,i]of Object.entries(e.properties)){const l=new Yg(a,e.transform(e.attributes||{},a),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(l.mustUseProperty=!0),t[a]=l,n[Nc(a)]=a,n[Nc(l.attribute)]=a}return new Oc(t,n,e.space)}const v5=Qo({properties:{ariaActiveDescendant:null,ariaAtomic:Kn,ariaAutoComplete:null,ariaBusy:Kn,ariaChecked:Kn,ariaColCount:Ke,ariaColIndex:Ke,ariaColSpan:Ke,ariaControls:wn,ariaCurrent:null,ariaDescribedBy:wn,ariaDetails:null,ariaDisabled:Kn,ariaDropEffect:wn,ariaErrorMessage:null,ariaExpanded:Kn,ariaFlowTo:wn,ariaGrabbed:Kn,ariaHasPopup:null,ariaHidden:Kn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wn,ariaLevel:Ke,ariaLive:null,ariaModal:Kn,ariaMultiLine:Kn,ariaMultiSelectable:Kn,ariaOrientation:null,ariaOwns:wn,ariaPlaceholder:null,ariaPosInSet:Ke,ariaPressed:Kn,ariaReadOnly:Kn,ariaRelevant:null,ariaRequired:Kn,ariaRoleDescription:wn,ariaRowCount:Ke,ariaRowIndex:Ke,ariaRowSpan:Ke,ariaSelected:Kn,ariaSetSize:Ke,ariaSort:null,ariaValueMax:Ke,ariaValueMin:Ke,ariaValueNow:Ke,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function x5(e,t){return t in e?e[t]:t}function w5(e,t){return x5(e,t.toLowerCase())}const vW=Qo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Bo,acceptCharset:wn,accessKey:wn,action:null,allow:null,allowFullScreen:$t,allowPaymentRequest:$t,allowUserMedia:$t,alt:null,as:null,async:$t,autoCapitalize:null,autoComplete:wn,autoFocus:$t,autoPlay:$t,blocking:wn,capture:null,charSet:null,checked:$t,cite:null,className:wn,cols:Ke,colSpan:null,content:null,contentEditable:Kn,controls:$t,controlsList:wn,coords:Ke|Bo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$t,defer:$t,dir:null,dirName:null,disabled:$t,download:tg,draggable:Kn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$t,formTarget:null,headers:wn,height:Ke,hidden:tg,high:Ke,href:null,hrefLang:null,htmlFor:wn,httpEquiv:wn,id:null,imageSizes:null,imageSrcSet:null,inert:$t,inputMode:null,integrity:null,is:null,isMap:$t,itemId:null,itemProp:wn,itemRef:wn,itemScope:$t,itemType:wn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$t,low:Ke,manifest:null,max:null,maxLength:Ke,media:null,method:null,min:null,minLength:Ke,multiple:$t,muted:$t,name:null,nonce:null,noModule:$t,noValidate:$t,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:$t,optimum:Ke,pattern:null,ping:wn,placeholder:null,playsInline:$t,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$t,referrerPolicy:null,rel:wn,required:$t,reversed:$t,rows:Ke,rowSpan:Ke,sandbox:wn,scope:null,scoped:$t,seamless:$t,selected:$t,shadowRootClonable:$t,shadowRootDelegatesFocus:$t,shadowRootMode:null,shape:null,size:Ke,sizes:null,slot:null,span:Ke,spellCheck:Kn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ke,step:null,style:null,tabIndex:Ke,target:null,title:null,translate:null,type:null,typeMustMatch:$t,useMap:null,value:Kn,width:Ke,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wn,axis:null,background:null,bgColor:null,border:Ke,borderColor:null,bottomMargin:Ke,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$t,declare:$t,event:null,face:null,frame:null,frameBorder:null,hSpace:Ke,leftMargin:Ke,link:null,longDesc:null,lowSrc:null,marginHeight:Ke,marginWidth:Ke,noResize:$t,noHref:$t,noShade:$t,noWrap:$t,object:null,profile:null,prompt:null,rev:null,rightMargin:Ke,rules:null,scheme:null,scrolling:Kn,standby:null,summary:null,text:null,topMargin:Ke,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ke,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:$t,disableRemotePlayback:$t,prefix:null,property:null,results:Ke,security:null,unselectable:null},space:"html",transform:w5}),xW=Qo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Wa,accentHeight:Ke,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ke,amplitude:Ke,arabicForm:null,ascent:Ke,attributeName:null,attributeType:null,azimuth:Ke,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ke,by:null,calcMode:null,capHeight:Ke,className:wn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ke,diffuseConstant:Ke,direction:null,display:null,dur:null,divisor:Ke,dominantBaseline:null,download:$t,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ke,enableBackground:null,end:null,event:null,exponent:Ke,externalResourcesRequired:null,fill:null,fillOpacity:Ke,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Bo,g2:Bo,glyphName:Bo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ke,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ke,horizOriginX:Ke,horizOriginY:Ke,id:null,ideographic:Ke,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ke,k:Ke,k1:Ke,k2:Ke,k3:Ke,k4:Ke,kernelMatrix:Wa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ke,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ke,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ke,overlineThickness:Ke,paintOrder:null,panose1:null,path:null,pathLength:Ke,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:wn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ke,pointsAtY:Ke,pointsAtZ:Ke,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Wa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Wa,rev:Wa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Wa,requiredFeatures:Wa,requiredFonts:Wa,requiredFormats:Wa,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ke,specularExponent:Ke,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ke,strikethroughThickness:Ke,string:null,stroke:null,strokeDashArray:Wa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ke,strokeOpacity:Ke,strokeWidth:null,style:null,surfaceScale:Ke,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Wa,tabIndex:Ke,tableValues:null,target:null,targetX:Ke,targetY:Ke,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Wa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ke,underlineThickness:Ke,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ke,values:null,vAlphabetic:Ke,vMathematical:Ke,vectorEffect:null,vHanging:Ke,vIdeographic:Ke,version:null,vertAdvY:Ke,vertOriginX:Ke,vertOriginY:Ke,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ke,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:x5}),k5=Qo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),S5=Qo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:w5}),C5=Qo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),wW={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},kW=/[A-Z]/g,z2=/-[a-z]/g,SW=/^data[-\w.:]+$/i;function A5(e,t){const n=Nc(t);let a=t,i=Ha;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&SW.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(z2,AW);a="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!z2.test(l)){let c=l.replace(kW,CW);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}i=Yg}return new i(a,t)}function CW(e){return"-"+e.toLowerCase()}function AW(e){return e.charAt(1).toUpperCase()}const T5=y5([v5,vW,k5,S5,C5],"html"),Vm=y5([v5,xW,k5,S5,C5],"svg");function H2(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function TW(e){return e.join(" ").trim()}var Ro={},zf,B2;function EW(){if(B2)return zf;B2=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,m=`
|
|
521
521
|
`,f="/",g="*",h="",v="comment",y="declaration";function w(C,A){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];A=A||{};var M=1,I=1;function B(H){var se=H.match(t);se&&(M+=se.length);var R=H.lastIndexOf(m);I=~R?H.length-R:I+H.length}function K(){var H={line:M,column:I};return function(se){return se.position=new j(H),Y(),se}}function j(H){this.start=H,this.end={line:M,column:I},this.source=A.source}j.prototype.content=C;function z(H){var se=new Error(A.source+":"+M+":"+I+": "+H);if(se.reason=H,se.filename=A.source,se.line=M,se.column=I,se.source=C,!A.silent)throw se}function U(H){var se=H.exec(C);if(se){var R=se[0];return B(R),C=C.slice(R.length),se}}function Y(){U(n)}function $(H){var se;for(H=H||[];se=D();)se!==!1&&H.push(se);return H}function D(){var H=K();if(!(f!=C.charAt(0)||g!=C.charAt(1))){for(var se=2;h!=C.charAt(se)&&(g!=C.charAt(se)||f!=C.charAt(se+1));)++se;if(se+=2,h===C.charAt(se-1))return z("End of comment missing");var R=C.slice(2,se-2);return I+=2,B(R),C=C.slice(se),I+=2,H({type:v,comment:R})}}function W(){var H=K(),se=U(a);if(se){if(D(),!U(i))return z("property missing ':'");var R=U(l),re=H({type:y,property:T(se[0].replace(e,h)),value:R?T(R[0].replace(e,h)):h});return U(c),re}}function X(){var H=[];$(H);for(var se;se=W();)se!==!1&&(H.push(se),$(H));return H}return Y(),X()}function T(C){return C?C.replace(u,h):h}return zf=w,zf}var $2;function NW(){if($2)return Ro;$2=1;var e=Ro&&Ro.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Ro,"__esModule",{value:!0}),Ro.default=n;const t=e(EW());function n(a,i){let l=null;if(!a||typeof a!="string")return l;const c=(0,t.default)(a),u=typeof i=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:g}=m;u?i(f,g,m):g&&(l=l||{},l[f]=g)}),l}return Ro}var Xl={},q2;function MW(){if(q2)return Xl;q2=1,Object.defineProperty(Xl,"__esModule",{value:!0}),Xl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,l=function(f){return!f||n.test(f)||e.test(f)},c=function(f,g){return g.toUpperCase()},u=function(f,g){return"".concat(g,"-")},m=function(f,g){return g===void 0&&(g={}),l(f)?f:(f=f.toLowerCase(),g.reactCompat?f=f.replace(i,u):f=f.replace(a,u),f.replace(t,c))};return Xl.camelCase=m,Xl}var Jl,F2;function jW(){if(F2)return Jl;F2=1;var e=Jl&&Jl.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(NW()),n=MW();function a(i,l){var c={};return!i||typeof i!="string"||(0,t.default)(i,function(u,m){u&&m&&(c[(0,n.camelCase)(u,l)]=m)}),c}return a.default=a,Jl=a,Jl}var RW=jW();const _W=Ic(RW),E5=N5("end"),Qg=N5("start");function N5(e){return t;function t(n){const a=n&&n.position&&n.position[e]||{};if(typeof a.line=="number"&&a.line>0&&typeof a.column=="number"&&a.column>0)return{line:a.line,column:a.column,offset:typeof a.offset=="number"&&a.offset>-1?a.offset:void 0}}}function DW(e){const t=Qg(e),n=E5(e);if(t&&n)return{start:t,end:n}}function pc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?U2(e.position):"start"in e||"end"in e?U2(e):"line"in e||"column"in e?ag(e):""}function ag(e){return G2(e&&e.line)+":"+G2(e&&e.column)}function U2(e){return ag(e&&e.start)+"-"+ag(e&&e.end)}function G2(e){return e&&typeof e=="number"?e:1}class fa extends Error{constructor(t,n,a){super(),typeof n=="string"&&(a=n,n=void 0);let i="",l={},c=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?i=t:!l.cause&&t&&(c=!0,i=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof a=="string"){const m=a.indexOf(":");m===-1?l.ruleId=a:(l.source=a.slice(0,m),l.ruleId=a.slice(m+1))}if(!l.place&&l.ancestors&&l.ancestors){const m=l.ancestors[l.ancestors.length-1];m&&(l.place=m.position)}const u=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=u?u.line:void 0,this.name=pc(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=c&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}fa.prototype.file="";fa.prototype.name="";fa.prototype.reason="";fa.prototype.message="";fa.prototype.stack="";fa.prototype.column=void 0;fa.prototype.line=void 0;fa.prototype.ancestors=void 0;fa.prototype.cause=void 0;fa.prototype.fatal=void 0;fa.prototype.place=void 0;fa.prototype.ruleId=void 0;fa.prototype.source=void 0;const Xg={}.hasOwnProperty,IW=new Map,LW=/[A-Z]/g,PW=new Set(["table","tbody","thead","tfoot","tr"]),OW=new Set(["td","th"]),M5="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function zW(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let a;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=KW(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");a=GW(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:a,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Vm:T5,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=j5(i,e,void 0);return l&&typeof l!="string"?l:i.create(e,i.Fragment,{children:l||void 0},void 0)}function j5(e,t,n){if(t.type==="element")return HW(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return BW(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return qW(e,t,n);if(t.type==="mdxjsEsm")return $W(e,t);if(t.type==="root")return FW(e,t,n);if(t.type==="text")return UW(e,t)}function HW(e,t,n){const a=e.schema;let i=a;t.tagName.toLowerCase()==="svg"&&a.space==="html"&&(i=Vm,e.schema=i),e.ancestors.push(t);const l=_5(e,t.tagName,!1),c=VW(e,t);let u=Zg(e,t);return PW.has(t.tagName)&&(u=u.filter(function(m){return typeof m=="string"?!bW(m):!0})),R5(e,c,l,t),Jg(c,u),e.ancestors.pop(),e.schema=a,e.create(t,l,c,n)}function BW(e,t){if(t.data&&t.data.estree&&e.evaluater){const a=t.data.estree.body[0];return a.type,e.evaluater.evaluateExpression(a.expression)}Mc(e,t.position)}function $W(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Mc(e,t.position)}function qW(e,t,n){const a=e.schema;let i=a;t.name==="svg"&&a.space==="html"&&(i=Vm,e.schema=i),e.ancestors.push(t);const l=t.name===null?e.Fragment:_5(e,t.name,!0),c=WW(e,t),u=Zg(e,t);return R5(e,c,l,t),Jg(c,u),e.ancestors.pop(),e.schema=a,e.create(t,l,c,n)}function FW(e,t,n){const a={};return Jg(a,Zg(e,t)),e.create(t,e.Fragment,a,n)}function UW(e,t){return t.value}function R5(e,t,n,a){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=a)}function Jg(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function GW(e,t,n){return a;function a(i,l,c,u){const f=Array.isArray(c.children)?n:t;return u?f(l,c,u):f(l,c)}}function KW(e,t){return n;function n(a,i,l,c){const u=Array.isArray(l.children),m=Qg(a);return t(i,l,c,u,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function VW(e,t){const n={};let a,i;for(i in t.properties)if(i!=="children"&&Xg.call(t.properties,i)){const l=YW(e,i,t.properties[i]);if(l){const[c,u]=l;e.tableCellAlignToStyle&&c==="align"&&typeof u=="string"&&OW.has(t.tagName)?a=u:n[c]=u}}if(a){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return n}function WW(e,t){const n={};for(const a of t.attributes)if(a.type==="mdxJsxExpressionAttribute")if(a.data&&a.data.estree&&e.evaluater){const l=a.data.estree.body[0];l.type;const c=l.expression;c.type;const u=c.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else Mc(e,t.position);else{const i=a.name;let l;if(a.value&&typeof a.value=="object")if(a.value.data&&a.value.data.estree&&e.evaluater){const u=a.value.data.estree.body[0];u.type,l=e.evaluater.evaluateExpression(u.expression)}else Mc(e,t.position);else l=a.value===null?!0:a.value;n[i]=l}return n}function Zg(e,t){const n=[];let a=-1;const i=e.passKeys?new Map:IW;for(;++a<t.children.length;){const l=t.children[a];let c;if(e.passKeys){const m=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(m){const f=i.get(m)||0;c=m+"-"+f,i.set(m,f+1)}}const u=j5(e,l,c);u!==void 0&&n.push(u)}return n}function YW(e,t,n){const a=A5(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=a.commaSeparated?mW(n):TW(n)),a.property==="style"){let i=typeof n=="object"?n:QW(e,String(n));return e.stylePropertyNameCase==="css"&&(i=XW(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&a.space?wW[a.property]||a.property:a.attribute,n]}}function QW(e,t){try{return _W(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const a=n,i=new fa("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:a,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=M5+"#cannot-parse-style-attribute",i}}function _5(e,t,n){let a;if(!n)a={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let l=-1,c;for(;++l<i.length;){const u=L2(i[l])?{type:"Identifier",name:i[l]}:{type:"Literal",value:i[l]};c=c?{type:"MemberExpression",object:c,property:u,computed:!!(l&&u.type==="Literal"),optional:!1}:u}a=c}else a=L2(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(a.type==="Literal"){const i=a.value;return Xg.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(a);Mc(e)}function Mc(e,t){const n=new fa("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=M5+"#cannot-handle-mdx-estrees-without-createevaluater",n}function XW(e){const t={};let n;for(n in e)Xg.call(e,n)&&(t[JW(n)]=e[n]);return t}function JW(e){let t=e.replace(LW,ZW);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function ZW(e){return"-"+e.toLowerCase()}const Hf={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},eY={};function eb(e,t){const n=eY,a=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return D5(e,a,i)}function D5(e,t,n){if(tY(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return K2(e.children,t,n)}return Array.isArray(e)?K2(e,t,n):""}function K2(e,t,n){const a=[];let i=-1;for(;++i<e.length;)a[i]=D5(e[i],t,n);return a.join("")}function tY(e){return!!(e&&typeof e=="object")}const V2=document.createElement("i");function tb(e){const t="&"+e+";";V2.innerHTML=t;const n=V2.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ya(e,t,n,a){const i=e.length;let l=0,c;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,a.length<1e4)c=Array.from(a),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);l<a.length;)c=a.slice(l,l+1e4),c.unshift(t,0),e.splice(...c),l+=1e4,t+=1e4}function dr(e,t){return e.length>0?(Ya(e,e.length,0,t),e):t}const W2={}.hasOwnProperty;function I5(e){const t={};let n=-1;for(;++n<e.length;)nY(t,e[n]);return t}function nY(e,t){let n;for(n in t){const i=(W2.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let c;if(l)for(c in l){W2.call(i,c)||(i[c]=[]);const u=l[c];aY(i[c],Array.isArray(u)?u:u?[u]:[])}}}function aY(e,t){let n=-1;const a=[];for(;++n<t.length;)(t[n].add==="after"?e:a).push(t[n]);Ya(e,0,0,a)}function L5(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function xr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const wa=as(/[A-Za-z]/),ma=as(/[\dA-Za-z]/),rY=as(/[#-'*+\--9=?A-Z^-~]/);function wm(e){return e!==null&&(e<32||e===127)}const rg=as(/\d/),iY=as(/[\dA-Fa-f]/),sY=as(/[!-/:-@[-`{-~]/);function gt(e){return e!==null&&e<-2}function vn(e){return e!==null&&(e<0||e===32)}function Yt(e){return e===-2||e===-1||e===32}const Wm=as(new RegExp("\\p{P}|\\p{S}","u")),$s=as(/\s/);function as(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Xo(e){const t=[];let n=-1,a=0,i=0;for(;++n<e.length;){const l=e.charCodeAt(n);let c="";if(l===37&&ma(e.charCodeAt(n+1))&&ma(e.charCodeAt(n+2)))i=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(c=String.fromCharCode(l));else if(l>55295&&l<57344){const u=e.charCodeAt(n+1);l<56320&&u>56319&&u<57344?(c=String.fromCharCode(l,u),i=1):c="�"}else c=String.fromCharCode(l);c&&(t.push(e.slice(a,n),encodeURIComponent(c)),a=n+i+1,c=""),i&&(n+=i,i=0)}return t.join("")+e.slice(a)}function Kt(e,t,n,a){const i=a?a-1:Number.POSITIVE_INFINITY;let l=0;return c;function c(m){return Yt(m)?(e.enter(n),u(m)):t(m)}function u(m){return Yt(m)&&l++<i?(e.consume(m),u):(e.exit(n),t(m))}}const oY={tokenize:lY};function lY(e){const t=e.attempt(this.parser.constructs.contentInitial,a,i);let n;return t;function a(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Kt(e,t,"linePrefix")}function i(u){return e.enter("paragraph"),l(u)}function l(u){const m=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=m),n=m,c(u)}function c(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return gt(u)?(e.consume(u),e.exit("chunkText"),l):(e.consume(u),c)}}const cY={tokenize:dY},Y2={tokenize:uY};function dY(e){const t=this,n=[];let a=0,i,l,c;return u;function u(I){if(a<n.length){const B=n[a];return t.containerState=B[1],e.attempt(B[0].continuation,m,f)(I)}return f(I)}function m(I){if(a++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&M();const B=t.events.length;let K=B,j;for(;K--;)if(t.events[K][0]==="exit"&&t.events[K][1].type==="chunkFlow"){j=t.events[K][1].end;break}A(a);let z=B;for(;z<t.events.length;)t.events[z][1].end={...j},z++;return Ya(t.events,K+1,0,t.events.slice(B)),t.events.length=z,f(I)}return u(I)}function f(I){if(a===n.length){if(!i)return v(I);if(i.currentConstruct&&i.currentConstruct.concrete)return w(I);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Y2,g,h)(I)}function g(I){return i&&M(),A(a),v(I)}function h(I){return t.parser.lazy[t.now().line]=a!==n.length,c=t.now().offset,w(I)}function v(I){return t.containerState={},e.attempt(Y2,y,w)(I)}function y(I){return a++,n.push([t.currentConstruct,t.containerState]),v(I)}function w(I){if(I===null){i&&M(),A(0),e.consume(I);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:l}),T(I)}function T(I){if(I===null){C(e.exit("chunkFlow"),!0),A(0),e.consume(I);return}return gt(I)?(e.consume(I),C(e.exit("chunkFlow")),a=0,t.interrupt=void 0,u):(e.consume(I),T)}function C(I,B){const K=t.sliceStream(I);if(B&&K.push(null),I.previous=l,l&&(l.next=I),l=I,i.defineSkip(I.start),i.write(K),t.parser.lazy[I.start.line]){let j=i.events.length;for(;j--;)if(i.events[j][1].start.offset<c&&(!i.events[j][1].end||i.events[j][1].end.offset>c))return;const z=t.events.length;let U=z,Y,$;for(;U--;)if(t.events[U][0]==="exit"&&t.events[U][1].type==="chunkFlow"){if(Y){$=t.events[U][1].end;break}Y=!0}for(A(a),j=z;j<t.events.length;)t.events[j][1].end={...$},j++;Ya(t.events,U+1,0,t.events.slice(z)),t.events.length=j}}function A(I){let B=n.length;for(;B-- >I;){const K=n[B];t.containerState=K[1],K[0].exit.call(t,e)}n.length=I}function M(){i.write([null]),l=void 0,i=void 0,t.containerState._closeFlow=void 0}}function uY(e,t,n){return Kt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Go(e){if(e===null||vn(e)||$s(e))return 1;if(Wm(e))return 2}function Ym(e,t,n){const a=[];let i=-1;for(;++i<e.length;){const l=e[i].resolveAll;l&&!a.includes(l)&&(t=l(t,n),a.push(l))}return t}const ig={name:"attention",resolveAll:mY,tokenize:pY};function mY(e,t){let n=-1,a,i,l,c,u,m,f,g;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(a=n;a--;)if(e[a][0]==="exit"&&e[a][1].type==="attentionSequence"&&e[a][1]._open&&t.sliceSerialize(e[a][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[a][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[a][1].end.offset-e[a][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;m=e[a][1].end.offset-e[a][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[a][1].end},v={...e[n][1].start};Q2(h,-m),Q2(v,m),c={type:m>1?"strongSequence":"emphasisSequence",start:h,end:{...e[a][1].end}},u={type:m>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:v},l={type:m>1?"strongText":"emphasisText",start:{...e[a][1].end},end:{...e[n][1].start}},i={type:m>1?"strong":"emphasis",start:{...c.start},end:{...u.end}},e[a][1].end={...c.start},e[n][1].start={...u.end},f=[],e[a][1].end.offset-e[a][1].start.offset&&(f=dr(f,[["enter",e[a][1],t],["exit",e[a][1],t]])),f=dr(f,[["enter",i,t],["enter",c,t],["exit",c,t],["enter",l,t]]),f=dr(f,Ym(t.parser.constructs.insideSpan.null,e.slice(a+1,n),t)),f=dr(f,[["exit",l,t],["enter",u,t],["exit",u,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,f=dr(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,Ya(e,a-1,n-a+3,f),n=a+f.length-g-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function pY(e,t){const n=this.parser.constructs.attentionMarkers.null,a=this.previous,i=Go(a);let l;return c;function c(m){return l=m,e.enter("attentionSequence"),u(m)}function u(m){if(m===l)return e.consume(m),u;const f=e.exit("attentionSequence"),g=Go(m),h=!g||g===2&&i||n.includes(m),v=!i||i===2&&g||n.includes(a);return f._open=!!(l===42?h:h&&(i||!v)),f._close=!!(l===42?v:v&&(g||!h)),t(m)}}function Q2(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const fY={name:"autolink",tokenize:hY};function hY(e,t,n){let a=0;return i;function i(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(y){return wa(y)?(e.consume(y),c):y===64?n(y):f(y)}function c(y){return y===43||y===45||y===46||ma(y)?(a=1,u(y)):f(y)}function u(y){return y===58?(e.consume(y),a=0,m):(y===43||y===45||y===46||ma(y))&&a++<32?(e.consume(y),u):(a=0,f(y))}function m(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||wm(y)?n(y):(e.consume(y),m)}function f(y){return y===64?(e.consume(y),g):rY(y)?(e.consume(y),f):n(y)}function g(y){return ma(y)?h(y):n(y)}function h(y){return y===46?(e.consume(y),a=0,g):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):v(y)}function v(y){if((y===45||ma(y))&&a++<63){const w=y===45?v:h;return e.consume(y),w}return n(y)}}const zc={partial:!0,tokenize:gY};function gY(e,t,n){return a;function a(l){return Yt(l)?Kt(e,i,"linePrefix")(l):i(l)}function i(l){return l===null||gt(l)?t(l):n(l)}}const P5={continuation:{tokenize:yY},exit:vY,name:"blockQuote",tokenize:bY};function bY(e,t,n){const a=this;return i;function i(c){if(c===62){const u=a.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),l}return n(c)}function l(c){return Yt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function yY(e,t,n){const a=this;return i;function i(c){return Yt(c)?Kt(e,l,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):l(c)}function l(c){return e.attempt(P5,t,n)(c)}}function vY(e){e.exit("blockQuote")}const O5={name:"characterEscape",tokenize:xY};function xY(e,t,n){return a;function a(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),i}function i(l){return sY(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const z5={name:"characterReference",tokenize:wY};function wY(e,t,n){const a=this;let i=0,l,c;return u;function u(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),m}function m(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),l=31,c=ma,g(h))}function f(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,c=iY,g):(e.enter("characterReferenceValue"),l=7,c=rg,g(h))}function g(h){if(h===59&&i){const v=e.exit("characterReferenceValue");return c===ma&&!tb(a.sliceSerialize(v))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(h)&&i++<l?(e.consume(h),g):n(h)}}const X2={partial:!0,tokenize:SY},J2={concrete:!0,name:"codeFenced",tokenize:kY};function kY(e,t,n){const a=this,i={partial:!0,tokenize:K};let l=0,c=0,u;return m;function m(j){return f(j)}function f(j){const z=a.events[a.events.length-1];return l=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[1],!0).length:0,u=j,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(j)}function g(j){return j===u?(c++,e.consume(j),g):c<3?n(j):(e.exit("codeFencedFenceSequence"),Yt(j)?Kt(e,h,"whitespace")(j):h(j))}function h(j){return j===null||gt(j)?(e.exit("codeFencedFence"),a.interrupt?t(j):e.check(X2,T,B)(j)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),v(j))}function v(j){return j===null||gt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(j)):Yt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Kt(e,y,"whitespace")(j)):j===96&&j===u?n(j):(e.consume(j),v)}function y(j){return j===null||gt(j)?h(j):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(j))}function w(j){return j===null||gt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(j)):j===96&&j===u?n(j):(e.consume(j),w)}function T(j){return e.attempt(i,B,C)(j)}function C(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),A}function A(j){return l>0&&Yt(j)?Kt(e,M,"linePrefix",l+1)(j):M(j)}function M(j){return j===null||gt(j)?e.check(X2,T,B)(j):(e.enter("codeFlowValue"),I(j))}function I(j){return j===null||gt(j)?(e.exit("codeFlowValue"),M(j)):(e.consume(j),I)}function B(j){return e.exit("codeFenced"),t(j)}function K(j,z,U){let Y=0;return $;function $(se){return j.enter("lineEnding"),j.consume(se),j.exit("lineEnding"),D}function D(se){return j.enter("codeFencedFence"),Yt(se)?Kt(j,W,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(se):W(se)}function W(se){return se===u?(j.enter("codeFencedFenceSequence"),X(se)):U(se)}function X(se){return se===u?(Y++,j.consume(se),X):Y>=c?(j.exit("codeFencedFenceSequence"),Yt(se)?Kt(j,H,"whitespace")(se):H(se)):U(se)}function H(se){return se===null||gt(se)?(j.exit("codeFencedFence"),z(se)):U(se)}}}function SY(e,t,n){const a=this;return i;function i(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l)}function l(c){return a.parser.lazy[a.now().line]?n(c):t(c)}}const Bf={name:"codeIndented",tokenize:AY},CY={partial:!0,tokenize:TY};function AY(e,t,n){const a=this;return i;function i(f){return e.enter("codeIndented"),Kt(e,l,"linePrefix",5)(f)}function l(f){const g=a.events[a.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(f):n(f)}function c(f){return f===null?m(f):gt(f)?e.attempt(CY,c,m)(f):(e.enter("codeFlowValue"),u(f))}function u(f){return f===null||gt(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),u)}function m(f){return e.exit("codeIndented"),t(f)}}function TY(e,t,n){const a=this;return i;function i(c){return a.parser.lazy[a.now().line]?n(c):gt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),i):Kt(e,l,"linePrefix",5)(c)}function l(c){const u=a.events[a.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):gt(c)?i(c):n(c)}}const EY={name:"codeText",previous:MY,resolve:NY,tokenize:jY};function NY(e){let t=e.length-4,n=3,a,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(a=n;++a<t;)if(e[a][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(a=n-1,t++;++a<=t;)i===void 0?a!==t&&e[a][1].type!=="lineEnding"&&(i=a):(a===t||e[a][1].type==="lineEnding")&&(e[i][1].type="codeTextData",a!==i+2&&(e[i][1].end=e[a-1][1].end,e.splice(i+2,a-i-2),t-=a-i-2,a=i+2),i=void 0);return e}function MY(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function jY(e,t,n){let a=0,i,l;return c;function c(h){return e.enter("codeText"),e.enter("codeTextSequence"),u(h)}function u(h){return h===96?(e.consume(h),a++,u):(e.exit("codeTextSequence"),m(h))}function m(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),m):h===96?(l=e.enter("codeTextSequence"),i=0,g(h)):gt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(h))}function f(h){return h===null||h===32||h===96||gt(h)?(e.exit("codeTextData"),m(h)):(e.consume(h),f)}function g(h){return h===96?(e.consume(h),i++,g):i===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(l.type="codeTextData",f(h))}}class RY{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const a=n??Number.POSITIVE_INFINITY;return a<this.left.length?this.left.slice(t,a):t>this.left.length?this.right.slice(this.right.length-a+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-a+this.left.length).reverse())}splice(t,n,a){const i=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return a&&Zl(this.left,a),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Zl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Zl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Zl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Zl(this.left,n.reverse())}}}function Zl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function H5(e){const t={};let n=-1,a,i,l,c,u,m,f;const g=new RY(e);for(;++n<g.length;){for(;n in t;)n=t[n];if(a=g.get(n),n&&a[1].type==="chunkFlow"&&g.get(n-1)[1].type==="listItemPrefix"&&(m=a[1]._tokenizer.events,l=0,l<m.length&&m[l][1].type==="lineEndingBlank"&&(l+=2),l<m.length&&m[l][1].type==="content"))for(;++l<m.length&&m[l][1].type!=="content";)m[l][1].type==="chunkText"&&(m[l][1]._isInFirstContentOfListItem=!0,l++);if(a[0]==="enter")a[1].contentType&&(Object.assign(t,_Y(g,n)),n=t[n],f=!0);else if(a[1]._container){for(l=n,i=void 0;l--;)if(c=g.get(l),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(i&&(g.get(i)[1].type="lineEndingBlank"),c[1].type="lineEnding",i=l);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;i&&(a[1].end={...g.get(i)[1].start},u=g.slice(i,n),u.unshift(a),g.splice(i,n-i+1,u))}}return Ya(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!f}function _Y(e,t){const n=e.get(t)[1],a=e.get(t)[2];let i=t-1;const l=[];let c=n._tokenizer;c||(c=a.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const u=c.events,m=[],f={};let g,h,v=-1,y=n,w=0,T=0;const C=[T];for(;y;){for(;e.get(++i)[1]!==y;);l.push(i),y._tokenizer||(g=a.sliceStream(y),y.next||g.push(null),h&&c.defineSkip(y.start),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(g),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),h=y,y=y.next}for(y=n;++v<u.length;)u[v][0]==="exit"&&u[v-1][0]==="enter"&&u[v][1].type===u[v-1][1].type&&u[v][1].start.line!==u[v][1].end.line&&(T=v+1,C.push(T),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(c.events=[],y?(y._tokenizer=void 0,y.previous=void 0):C.pop(),v=C.length;v--;){const A=u.slice(C[v],C[v+1]),M=l.pop();m.push([M,M+A.length-1]),e.splice(M,2,A)}for(m.reverse(),v=-1;++v<m.length;)f[w+m[v][0]]=w+m[v][1],w+=m[v][1]-m[v][0]-1;return f}const DY={resolve:LY,tokenize:PY},IY={partial:!0,tokenize:OY};function LY(e){return H5(e),e}function PY(e,t){let n;return a;function a(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(u)}function i(u){return u===null?l(u):gt(u)?e.check(IY,c,l)(u):(e.consume(u),i)}function l(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function c(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function OY(e,t,n){const a=this;return i;function i(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Kt(e,l,"linePrefix")}function l(c){if(c===null||gt(c))return n(c);const u=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):e.interrupt(a.parser.constructs.flow,n,t)(c)}}function B5(e,t,n,a,i,l,c,u,m){const f=m||Number.POSITIVE_INFINITY;let g=0;return h;function h(A){return A===60?(e.enter(a),e.enter(i),e.enter(l),e.consume(A),e.exit(l),v):A===null||A===32||A===41||wm(A)?n(A):(e.enter(a),e.enter(c),e.enter(u),e.enter("chunkString",{contentType:"string"}),T(A))}function v(A){return A===62?(e.enter(l),e.consume(A),e.exit(l),e.exit(i),e.exit(a),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),y(A))}function y(A){return A===62?(e.exit("chunkString"),e.exit(u),v(A)):A===null||A===60||gt(A)?n(A):(e.consume(A),A===92?w:y)}function w(A){return A===60||A===62||A===92?(e.consume(A),y):y(A)}function T(A){return!g&&(A===null||A===41||vn(A))?(e.exit("chunkString"),e.exit(u),e.exit(c),e.exit(a),t(A)):g<f&&A===40?(e.consume(A),g++,T):A===41?(e.consume(A),g--,T):A===null||A===32||A===40||wm(A)?n(A):(e.consume(A),A===92?C:T)}function C(A){return A===40||A===41||A===92?(e.consume(A),T):T(A)}}function $5(e,t,n,a,i,l){const c=this;let u=0,m;return f;function f(y){return e.enter(a),e.enter(i),e.consume(y),e.exit(i),e.enter(l),g}function g(y){return u>999||y===null||y===91||y===93&&!m||y===94&&!u&&"_hiddenFootnoteSupport"in c.parser.constructs?n(y):y===93?(e.exit(l),e.enter(i),e.consume(y),e.exit(i),e.exit(a),t):gt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===null||y===91||y===93||gt(y)||u++>999?(e.exit("chunkString"),g(y)):(e.consume(y),m||(m=!Yt(y)),y===92?v:h)}function v(y){return y===91||y===92||y===93?(e.consume(y),u++,h):h(y)}}function q5(e,t,n,a,i,l){let c;return u;function u(v){return v===34||v===39||v===40?(e.enter(a),e.enter(i),e.consume(v),e.exit(i),c=v===40?41:v,m):n(v)}function m(v){return v===c?(e.enter(i),e.consume(v),e.exit(i),e.exit(a),t):(e.enter(l),f(v))}function f(v){return v===c?(e.exit(l),m(c)):v===null?n(v):gt(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),Kt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===c||v===null||gt(v)?(e.exit("chunkString"),f(v)):(e.consume(v),v===92?h:g)}function h(v){return v===c||v===92?(e.consume(v),g):g(v)}}function fc(e,t){let n;return a;function a(i){return gt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,a):Yt(i)?Kt(e,a,n?"linePrefix":"lineSuffix")(i):t(i)}}const zY={name:"definition",tokenize:BY},HY={partial:!0,tokenize:$Y};function BY(e,t,n){const a=this;let i;return l;function l(y){return e.enter("definition"),c(y)}function c(y){return $5.call(a,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function u(y){return i=xr(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),m):n(y)}function m(y){return vn(y)?fc(e,f)(y):f(y)}function f(y){return B5(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(HY,h,h)(y)}function h(y){return Yt(y)?Kt(e,v,"whitespace")(y):v(y)}function v(y){return y===null||gt(y)?(e.exit("definition"),a.parser.defined.push(i),t(y)):n(y)}}function $Y(e,t,n){return a;function a(u){return vn(u)?fc(e,i)(u):n(u)}function i(u){return q5(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function l(u){return Yt(u)?Kt(e,c,"whitespace")(u):c(u)}function c(u){return u===null||gt(u)?t(u):n(u)}}const qY={name:"hardBreakEscape",tokenize:FY};function FY(e,t,n){return a;function a(l){return e.enter("hardBreakEscape"),e.consume(l),i}function i(l){return gt(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const UY={name:"headingAtx",resolve:GY,tokenize:KY};function GY(e,t){let n=e.length-2,a=3,i,l;return e[a][1].type==="whitespace"&&(a+=2),n-2>a&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(a===n-1||n-4>a&&e[n-2][1].type==="whitespace")&&(n-=a+1===n?2:4),n>a&&(i={type:"atxHeadingText",start:e[a][1].start,end:e[n][1].end},l={type:"chunkText",start:e[a][1].start,end:e[n][1].end,contentType:"text"},Ya(e,a,n-a+1,[["enter",i,t],["enter",l,t],["exit",l,t],["exit",i,t]])),e}function KY(e,t,n){let a=0;return i;function i(g){return e.enter("atxHeading"),l(g)}function l(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&a++<6?(e.consume(g),c):g===null||vn(g)?(e.exit("atxHeadingSequence"),u(g)):n(g)}function u(g){return g===35?(e.enter("atxHeadingSequence"),m(g)):g===null||gt(g)?(e.exit("atxHeading"),t(g)):Yt(g)?Kt(e,u,"whitespace")(g):(e.enter("atxHeadingText"),f(g))}function m(g){return g===35?(e.consume(g),m):(e.exit("atxHeadingSequence"),u(g))}function f(g){return g===null||g===35||vn(g)?(e.exit("atxHeadingText"),u(g)):(e.consume(g),f)}}const VY=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Z2=["pre","script","style","textarea"],WY={concrete:!0,name:"htmlFlow",resolveTo:XY,tokenize:JY},YY={partial:!0,tokenize:eQ},QY={partial:!0,tokenize:ZY};function XY(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function JY(e,t,n){const a=this;let i,l,c,u,m;return f;function f(P){return g(P)}function g(P){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(P),h}function h(P){return P===33?(e.consume(P),v):P===47?(e.consume(P),l=!0,T):P===63?(e.consume(P),i=3,a.interrupt?t:q):wa(P)?(e.consume(P),c=String.fromCharCode(P),C):n(P)}function v(P){return P===45?(e.consume(P),i=2,y):P===91?(e.consume(P),i=5,u=0,w):wa(P)?(e.consume(P),i=4,a.interrupt?t:q):n(P)}function y(P){return P===45?(e.consume(P),a.interrupt?t:q):n(P)}function w(P){const Ee="CDATA[";return P===Ee.charCodeAt(u++)?(e.consume(P),u===Ee.length?a.interrupt?t:W:w):n(P)}function T(P){return wa(P)?(e.consume(P),c=String.fromCharCode(P),C):n(P)}function C(P){if(P===null||P===47||P===62||vn(P)){const Ee=P===47,$e=c.toLowerCase();return!Ee&&!l&&Z2.includes($e)?(i=1,a.interrupt?t(P):W(P)):VY.includes(c.toLowerCase())?(i=6,Ee?(e.consume(P),A):a.interrupt?t(P):W(P)):(i=7,a.interrupt&&!a.parser.lazy[a.now().line]?n(P):l?M(P):I(P))}return P===45||ma(P)?(e.consume(P),c+=String.fromCharCode(P),C):n(P)}function A(P){return P===62?(e.consume(P),a.interrupt?t:W):n(P)}function M(P){return Yt(P)?(e.consume(P),M):$(P)}function I(P){return P===47?(e.consume(P),$):P===58||P===95||wa(P)?(e.consume(P),B):Yt(P)?(e.consume(P),I):$(P)}function B(P){return P===45||P===46||P===58||P===95||ma(P)?(e.consume(P),B):K(P)}function K(P){return P===61?(e.consume(P),j):Yt(P)?(e.consume(P),K):I(P)}function j(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),m=P,z):Yt(P)?(e.consume(P),j):U(P)}function z(P){return P===m?(e.consume(P),m=null,Y):P===null||gt(P)?n(P):(e.consume(P),z)}function U(P){return P===null||P===34||P===39||P===47||P===60||P===61||P===62||P===96||vn(P)?K(P):(e.consume(P),U)}function Y(P){return P===47||P===62||Yt(P)?I(P):n(P)}function $(P){return P===62?(e.consume(P),D):n(P)}function D(P){return P===null||gt(P)?W(P):Yt(P)?(e.consume(P),D):n(P)}function W(P){return P===45&&i===2?(e.consume(P),R):P===60&&i===1?(e.consume(P),re):P===62&&i===4?(e.consume(P),V):P===63&&i===3?(e.consume(P),q):P===93&&i===5?(e.consume(P),Ce):gt(P)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(YY,ce,X)(P)):P===null||gt(P)?(e.exit("htmlFlowData"),X(P)):(e.consume(P),W)}function X(P){return e.check(QY,H,ce)(P)}function H(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),se}function se(P){return P===null||gt(P)?X(P):(e.enter("htmlFlowData"),W(P))}function R(P){return P===45?(e.consume(P),q):W(P)}function re(P){return P===47?(e.consume(P),c="",ue):W(P)}function ue(P){if(P===62){const Ee=c.toLowerCase();return Z2.includes(Ee)?(e.consume(P),V):W(P)}return wa(P)&&c.length<8?(e.consume(P),c+=String.fromCharCode(P),ue):W(P)}function Ce(P){return P===93?(e.consume(P),q):W(P)}function q(P){return P===62?(e.consume(P),V):P===45&&i===2?(e.consume(P),q):W(P)}function V(P){return P===null||gt(P)?(e.exit("htmlFlowData"),ce(P)):(e.consume(P),V)}function ce(P){return e.exit("htmlFlow"),t(P)}}function ZY(e,t,n){const a=this;return i;function i(c){return gt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):n(c)}function l(c){return a.parser.lazy[a.now().line]?n(c):t(c)}}function eQ(e,t,n){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(zc,t,n)}}const tQ={name:"htmlText",tokenize:nQ};function nQ(e,t,n){const a=this;let i,l,c;return u;function u(q){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(q),m}function m(q){return q===33?(e.consume(q),f):q===47?(e.consume(q),K):q===63?(e.consume(q),I):wa(q)?(e.consume(q),U):n(q)}function f(q){return q===45?(e.consume(q),g):q===91?(e.consume(q),l=0,w):wa(q)?(e.consume(q),M):n(q)}function g(q){return q===45?(e.consume(q),y):n(q)}function h(q){return q===null?n(q):q===45?(e.consume(q),v):gt(q)?(c=h,re(q)):(e.consume(q),h)}function v(q){return q===45?(e.consume(q),y):h(q)}function y(q){return q===62?R(q):q===45?v(q):h(q)}function w(q){const V="CDATA[";return q===V.charCodeAt(l++)?(e.consume(q),l===V.length?T:w):n(q)}function T(q){return q===null?n(q):q===93?(e.consume(q),C):gt(q)?(c=T,re(q)):(e.consume(q),T)}function C(q){return q===93?(e.consume(q),A):T(q)}function A(q){return q===62?R(q):q===93?(e.consume(q),A):T(q)}function M(q){return q===null||q===62?R(q):gt(q)?(c=M,re(q)):(e.consume(q),M)}function I(q){return q===null?n(q):q===63?(e.consume(q),B):gt(q)?(c=I,re(q)):(e.consume(q),I)}function B(q){return q===62?R(q):I(q)}function K(q){return wa(q)?(e.consume(q),j):n(q)}function j(q){return q===45||ma(q)?(e.consume(q),j):z(q)}function z(q){return gt(q)?(c=z,re(q)):Yt(q)?(e.consume(q),z):R(q)}function U(q){return q===45||ma(q)?(e.consume(q),U):q===47||q===62||vn(q)?Y(q):n(q)}function Y(q){return q===47?(e.consume(q),R):q===58||q===95||wa(q)?(e.consume(q),$):gt(q)?(c=Y,re(q)):Yt(q)?(e.consume(q),Y):R(q)}function $(q){return q===45||q===46||q===58||q===95||ma(q)?(e.consume(q),$):D(q)}function D(q){return q===61?(e.consume(q),W):gt(q)?(c=D,re(q)):Yt(q)?(e.consume(q),D):Y(q)}function W(q){return q===null||q===60||q===61||q===62||q===96?n(q):q===34||q===39?(e.consume(q),i=q,X):gt(q)?(c=W,re(q)):Yt(q)?(e.consume(q),W):(e.consume(q),H)}function X(q){return q===i?(e.consume(q),i=void 0,se):q===null?n(q):gt(q)?(c=X,re(q)):(e.consume(q),X)}function H(q){return q===null||q===34||q===39||q===60||q===61||q===96?n(q):q===47||q===62||vn(q)?Y(q):(e.consume(q),H)}function se(q){return q===47||q===62||vn(q)?Y(q):n(q)}function R(q){return q===62?(e.consume(q),e.exit("htmlTextData"),e.exit("htmlText"),t):n(q)}function re(q){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(q),e.exit("lineEnding"),ue}function ue(q){return Yt(q)?Kt(e,Ce,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):Ce(q)}function Ce(q){return e.enter("htmlTextData"),c(q)}}const nb={name:"labelEnd",resolveAll:sQ,resolveTo:oQ,tokenize:lQ},aQ={tokenize:cQ},rQ={tokenize:dQ},iQ={tokenize:uQ};function sQ(e){let t=-1;const n=[];for(;++t<e.length;){const a=e[t][1];if(n.push(e[t]),a.type==="labelImage"||a.type==="labelLink"||a.type==="labelEnd"){const i=a.type==="labelImage"?4:2;a.type="data",t+=i}}return e.length!==n.length&&Ya(e,0,e.length,n),e}function oQ(e,t){let n=e.length,a=0,i,l,c,u;for(;n--;)if(i=e[n][1],l){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(l=n,i.type!=="labelLink")){a=2;break}}else i.type==="labelEnd"&&(c=n);const m={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[l][1].start},end:{...e[c][1].end}},g={type:"labelText",start:{...e[l+a+2][1].end},end:{...e[c-2][1].start}};return u=[["enter",m,t],["enter",f,t]],u=dr(u,e.slice(l+1,l+a+3)),u=dr(u,[["enter",g,t]]),u=dr(u,Ym(t.parser.constructs.insideSpan.null,e.slice(l+a+4,c-3),t)),u=dr(u,[["exit",g,t],e[c-2],e[c-1],["exit",f,t]]),u=dr(u,e.slice(c+1)),u=dr(u,[["exit",m,t]]),Ya(e,l,e.length,u),e}function lQ(e,t,n){const a=this;let i=a.events.length,l,c;for(;i--;)if((a.events[i][1].type==="labelImage"||a.events[i][1].type==="labelLink")&&!a.events[i][1]._balanced){l=a.events[i][1];break}return u;function u(v){return l?l._inactive?h(v):(c=a.parser.defined.includes(xr(a.sliceSerialize({start:l.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(v),e.exit("labelMarker"),e.exit("labelEnd"),m):n(v)}function m(v){return v===40?e.attempt(aQ,g,c?g:h)(v):v===91?e.attempt(rQ,g,c?f:h)(v):c?g(v):h(v)}function f(v){return e.attempt(iQ,g,h)(v)}function g(v){return t(v)}function h(v){return l._balanced=!0,n(v)}}function cQ(e,t,n){return a;function a(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),i}function i(h){return vn(h)?fc(e,l)(h):l(h)}function l(h){return h===41?g(h):B5(e,c,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function c(h){return vn(h)?fc(e,m)(h):g(h)}function u(h){return n(h)}function m(h){return h===34||h===39||h===40?q5(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):g(h)}function f(h){return vn(h)?fc(e,g)(h):g(h)}function g(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function dQ(e,t,n){const a=this;return i;function i(u){return $5.call(a,e,l,c,"reference","referenceMarker","referenceString")(u)}function l(u){return a.parser.defined.includes(xr(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function c(u){return n(u)}}function uQ(e,t,n){return a;function a(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),i}function i(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const mQ={name:"labelStartImage",resolveAll:nb.resolveAll,tokenize:pQ};function pQ(e,t,n){const a=this;return i;function i(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),l}function l(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),c):n(u)}function c(u){return u===94&&"_hiddenFootnoteSupport"in a.parser.constructs?n(u):t(u)}}const fQ={name:"labelStartLink",resolveAll:nb.resolveAll,tokenize:hQ};function hQ(e,t,n){const a=this;return i;function i(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),l}function l(c){return c===94&&"_hiddenFootnoteSupport"in a.parser.constructs?n(c):t(c)}}const $f={name:"lineEnding",tokenize:gQ};function gQ(e,t){return n;function n(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Kt(e,t,"linePrefix")}}const Vu={name:"thematicBreak",tokenize:bQ};function bQ(e,t,n){let a=0,i;return l;function l(f){return e.enter("thematicBreak"),c(f)}function c(f){return i=f,u(f)}function u(f){return f===i?(e.enter("thematicBreakSequence"),m(f)):a>=3&&(f===null||gt(f))?(e.exit("thematicBreak"),t(f)):n(f)}function m(f){return f===i?(e.consume(f),a++,m):(e.exit("thematicBreakSequence"),Yt(f)?Kt(e,u,"whitespace")(f):u(f))}}const Da={continuation:{tokenize:wQ},exit:SQ,name:"list",tokenize:xQ},yQ={partial:!0,tokenize:CQ},vQ={partial:!0,tokenize:kQ};function xQ(e,t,n){const a=this,i=a.events[a.events.length-1];let l=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,c=0;return u;function u(y){const w=a.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!a.containerState.marker||y===a.containerState.marker:rg(y)){if(a.containerState.type||(a.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Vu,n,f)(y):f(y);if(!a.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(y)}return n(y)}function m(y){return rg(y)&&++c<10?(e.consume(y),m):(!a.interrupt||c<2)&&(a.containerState.marker?y===a.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):n(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||y,e.check(zc,a.interrupt?n:g,e.attempt(yQ,v,h))}function g(y){return a.containerState.initialBlankLine=!0,l++,v(y)}function h(y){return Yt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),v):n(y)}function v(y){return a.containerState.size=l+a.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function wQ(e,t,n){const a=this;return a.containerState._closeFlow=void 0,e.check(zc,i,l);function i(u){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,Kt(e,t,"listItemIndent",a.containerState.size+1)(u)}function l(u){return a.containerState.furtherBlankLines||!Yt(u)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,c(u)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,e.attempt(vQ,t,c)(u))}function c(u){return a.containerState._closeFlow=!0,a.interrupt=void 0,Kt(e,e.attempt(Da,t,n),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function kQ(e,t,n){const a=this;return Kt(e,i,"listItemIndent",a.containerState.size+1);function i(l){const c=a.events[a.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===a.containerState.size?t(l):n(l)}}function SQ(e){e.exit(this.containerState.type)}function CQ(e,t,n){const a=this;return Kt(e,i,"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(l){const c=a.events[a.events.length-1];return!Yt(l)&&c&&c[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const ew={name:"setextUnderline",resolveTo:AQ,tokenize:TQ};function AQ(e,t){let n=e.length,a,i,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){a=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const c={type:"setextHeading",start:{...e[a][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",l?(e.splice(i,0,["enter",c,t]),e.splice(l+1,0,["exit",e[a][1],t]),e[a][1].end={...e[l][1].end}):e[a][1]=c,e.push(["exit",c,t]),e}function TQ(e,t,n){const a=this;let i;return l;function l(f){let g=a.events.length,h;for(;g--;)if(a.events[g][1].type!=="lineEnding"&&a.events[g][1].type!=="linePrefix"&&a.events[g][1].type!=="content"){h=a.events[g][1].type==="paragraph";break}return!a.parser.lazy[a.now().line]&&(a.interrupt||h)?(e.enter("setextHeadingLine"),i=f,c(f)):n(f)}function c(f){return e.enter("setextHeadingLineSequence"),u(f)}function u(f){return f===i?(e.consume(f),u):(e.exit("setextHeadingLineSequence"),Yt(f)?Kt(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||gt(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const EQ={tokenize:NQ};function NQ(e){const t=this,n=e.attempt(zc,a,e.attempt(this.parser.constructs.flowInitial,i,Kt(e,e.attempt(this.parser.constructs.flow,i,e.attempt(DY,i)),"linePrefix")));return n;function a(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const MQ={resolveAll:U5()},jQ=F5("string"),RQ=F5("text");function F5(e){return{resolveAll:U5(e==="text"?_Q:void 0),tokenize:t};function t(n){const a=this,i=this.parser.constructs[e],l=n.attempt(i,c,u);return c;function c(g){return f(g)?l(g):u(g)}function u(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),m}function m(g){return f(g)?(n.exit("data"),l(g)):(n.consume(g),m)}function f(g){if(g===null)return!0;const h=i[g];let v=-1;if(h)for(;++v<h.length;){const y=h[v];if(!y.previous||y.previous.call(a,a.previous))return!0}return!1}}}function U5(e){return t;function t(n,a){let i=-1,l;for(;++i<=n.length;)l===void 0?n[i]&&n[i][1].type==="data"&&(l=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==l+2&&(n[l][1].end=n[i-1][1].end,n.splice(l+2,i-l-2),i=l+2),l=void 0);return e?e(n,a):n}}function _Q(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const a=e[n-1][1],i=t.sliceStream(a);let l=i.length,c=-1,u=0,m;for(;l--;){const f=i[l];if(typeof f=="string"){for(c=f.length;f.charCodeAt(c-1)===32;)u++,c--;if(c)break;c=-1}else if(f===-2)m=!0,u++;else if(f!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const f={type:n===e.length||m||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?c:a.start._bufferIndex+c,_index:a.start._index+l,line:a.end.line,column:a.end.column-u,offset:a.end.offset-u},end:{...a.end}};a.end={...f.start},a.start.offset===a.end.offset?Object.assign(a,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const DQ={42:Da,43:Da,45:Da,48:Da,49:Da,50:Da,51:Da,52:Da,53:Da,54:Da,55:Da,56:Da,57:Da,62:P5},IQ={91:zY},LQ={[-2]:Bf,[-1]:Bf,32:Bf},PQ={35:UY,42:Vu,45:[ew,Vu],60:WY,61:ew,95:Vu,96:J2,126:J2},OQ={38:z5,92:O5},zQ={[-5]:$f,[-4]:$f,[-3]:$f,33:mQ,38:z5,42:ig,60:[fY,tQ],91:fQ,92:[qY,O5],93:nb,95:ig,96:EY},HQ={null:[ig,MQ]},BQ={null:[42,95]},$Q={null:[]},qQ=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:BQ,contentInitial:IQ,disable:$Q,document:DQ,flow:PQ,flowInitial:LQ,insideSpan:HQ,string:OQ,text:zQ},Symbol.toStringTag,{value:"Module"}));function FQ(e,t,n){let a={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},l=[];let c=[],u=[];const m={attempt:z(K),check:z(j),consume:M,enter:I,exit:B,interrupt:z(j,{interrupt:!0})},f={code:null,containerState:{},defineSkip:T,events:[],now:w,parser:e,previous:null,sliceSerialize:v,sliceStream:y,write:h};let g=t.tokenize.call(f,m);return t.resolveAll&&l.push(t),f;function h(D){return c=dr(c,D),C(),c[c.length-1]!==null?[]:(U(t,0),f.events=Ym(l,f.events,f),f.events)}function v(D,W){return GQ(y(D),W)}function y(D){return UQ(c,D)}function w(){const{_bufferIndex:D,_index:W,line:X,column:H,offset:se}=a;return{_bufferIndex:D,_index:W,line:X,column:H,offset:se}}function T(D){i[D.line]=D.column,$()}function C(){let D;for(;a._index<c.length;){const W=c[a._index];if(typeof W=="string")for(D=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===D&&a._bufferIndex<W.length;)A(W.charCodeAt(a._bufferIndex));else A(W)}}function A(D){g=g(D)}function M(D){gt(D)?(a.line++,a.column=1,a.offset+=D===-3?2:1,$()):D!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===c[a._index].length&&(a._bufferIndex=-1,a._index++)),f.previous=D}function I(D,W){const X=W||{};return X.type=D,X.start=w(),f.events.push(["enter",X,f]),u.push(X),X}function B(D){const W=u.pop();return W.end=w(),f.events.push(["exit",W,f]),W}function K(D,W){U(D,W.from)}function j(D,W){W.restore()}function z(D,W){return X;function X(H,se,R){let re,ue,Ce,q;return Array.isArray(H)?ce(H):"tokenize"in H?ce([H]):V(H);function V(qe){return Ze;function Ze(Qe){const Re=Qe!==null&&qe[Qe],Xe=Qe!==null&&qe.null,wt=[...Array.isArray(Re)?Re:Re?[Re]:[],...Array.isArray(Xe)?Xe:Xe?[Xe]:[]];return ce(wt)(Qe)}}function ce(qe){return re=qe,ue=0,qe.length===0?R:P(qe[ue])}function P(qe){return Ze;function Ze(Qe){return q=Y(),Ce=qe,qe.partial||(f.currentConstruct=qe),qe.name&&f.parser.constructs.disable.null.includes(qe.name)?$e():qe.tokenize.call(W?Object.assign(Object.create(f),W):f,m,Ee,$e)(Qe)}}function Ee(qe){return D(Ce,q),se}function $e(qe){return q.restore(),++ue<re.length?P(re[ue]):R}}}function U(D,W){D.resolveAll&&!l.includes(D)&&l.push(D),D.resolve&&Ya(f.events,W,f.events.length-W,D.resolve(f.events.slice(W),f)),D.resolveTo&&(f.events=D.resolveTo(f.events,f))}function Y(){const D=w(),W=f.previous,X=f.currentConstruct,H=f.events.length,se=Array.from(u);return{from:H,restore:R};function R(){a=D,f.previous=W,f.currentConstruct=X,f.events.length=H,u=se,$()}}function $(){a.line in i&&a.column<2&&(a.column=i[a.line],a.offset+=i[a.line]-1)}}function UQ(e,t){const n=t.start._index,a=t.start._bufferIndex,i=t.end._index,l=t.end._bufferIndex;let c;if(n===i)c=[e[n].slice(a,l)];else{if(c=e.slice(n,i),a>-1){const u=c[0];typeof u=="string"?c[0]=u.slice(a):c.shift()}l>0&&c.push(e[i].slice(0,l))}return c}function GQ(e,t){let n=-1;const a=[];let i;for(;++n<e.length;){const l=e[n];let c;if(typeof l=="string")c=l;else switch(l){case-5:{c="\r";break}case-4:{c=`
|
|
522
522
|
`;break}case-3:{c=`\r
|
|
523
523
|
`;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&i)continue;c=" ";break}default:c=String.fromCharCode(l)}i=l===-2,a.push(c)}return a.join("")}function KQ(e){const a={constructs:I5([qQ,...(e||{}).extensions||[]]),content:i(oY),defined:[],document:i(cY),flow:i(EQ),lazy:{},string:i(jQ),text:i(RQ)};return a;function i(l){return c;function c(u){return FQ(a,l,u)}}}function VQ(e){for(;!H5(e););return e}const tw=/[\0\t\n\r]/g;function WQ(){let e=1,t="",n=!0,a;return i;function i(l,c,u){const m=[];let f,g,h,v,y;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(c||void 0).decode(l)),h=0,t="",n&&(l.charCodeAt(0)===65279&&h++,n=void 0);h<l.length;){if(tw.lastIndex=h,f=tw.exec(l),v=f&&f.index!==void 0?f.index:l.length,y=l.charCodeAt(v),!f){t=l.slice(h);break}if(y===10&&h===v&&a)m.push(-3),a=void 0;else switch(a&&(m.push(-5),a=void 0),h<v&&(m.push(l.slice(h,v)),e+=v-h),y){case 0:{m.push(65533),e++;break}case 9:{for(g=Math.ceil(e/4)*4,m.push(-2);e++<g;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:a=!0,e=1}h=v+1}return u&&(a&&m.push(-5),t&&m.push(t),m.push(null)),m}}const YQ=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function QQ(e){return e.replace(YQ,XQ)}function XQ(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),l=i===120||i===88;return L5(n.slice(l?2:1),l?16:10)}return tb(n)||e}const G5={}.hasOwnProperty;function JQ(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),ZQ(n)(VQ(KQ(n).document().write(WQ()(e,t,!0))))}function ZQ(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Gt),autolinkProtocol:Y,autolinkEmail:Y,atxHeading:l(Dt),blockQuote:l(Xe),characterEscape:Y,characterReference:Y,codeFenced:l(wt),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(wt,c),codeText:l(mt,c),codeTextData:Y,data:Y,codeFlowValue:Y,definition:l(kt),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l(lt),hardBreakEscape:l(ht),hardBreakTrailing:l(ht),htmlFlow:l(Oe,c),htmlFlowData:Y,htmlText:l(Oe,c),htmlTextData:Y,image:l(Nt),label:c,link:l(Gt),listItem:l(et),listItemValue:v,listOrdered:l(ie,h),listUnordered:l(ie),paragraph:l(at),reference:P,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(Dt),strong:l(ye),thematicBreak:l(De)},exit:{atxHeading:m(),atxHeadingSequence:K,autolink:m(),autolinkEmail:Re,autolinkProtocol:Qe,blockQuote:m(),characterEscapeValue:$,characterReferenceMarkerHexadecimal:$e,characterReferenceMarkerNumeric:$e,characterReferenceValue:qe,characterReference:Ze,codeFenced:m(C),codeFencedFence:T,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:$,codeIndented:m(A),codeText:m(se),codeTextData:$,data:$,definition:m(),definitionDestinationString:B,definitionLabelString:M,definitionTitleString:I,emphasis:m(),hardBreakEscape:m(W),hardBreakTrailing:m(W),htmlFlow:m(X),htmlFlowData:$,htmlText:m(H),htmlTextData:$,image:m(re),label:Ce,labelText:ue,lineEnding:D,link:m(R),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:Ee,resourceDestinationString:q,resourceTitleString:V,resource:ce,setextHeading:m(U),setextHeadingLineSequence:z,setextHeadingText:j,strong:m(),thematicBreak:m()}};K5(t,(e||{}).mdastExtensions||[]);const n={};return a;function a(te){let F={type:"root",children:[]};const ae={stack:[F],tokenStack:[],config:t,enter:u,exit:f,buffer:c,resume:g,data:n},we=[];let Le=-1;for(;++Le<te.length;)if(te[Le][1].type==="listOrdered"||te[Le][1].type==="listUnordered")if(te[Le][0]==="enter")we.push(Le);else{const He=we.pop();Le=i(te,He,Le)}for(Le=-1;++Le<te.length;){const He=t[te[Le][0]];G5.call(He,te[Le][1].type)&&He[te[Le][1].type].call(Object.assign({sliceSerialize:te[Le][2].sliceSerialize},ae),te[Le][1])}if(ae.tokenStack.length>0){const He=ae.tokenStack[ae.tokenStack.length-1];(He[1]||nw).call(ae,void 0,He[0])}for(F.position={start:Gi(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:Gi(te.length>0?te[te.length-2][1].end:{line:1,column:1,offset:0})},Le=-1;++Le<t.transforms.length;)F=t.transforms[Le](F)||F;return F}function i(te,F,ae){let we=F-1,Le=-1,He=!1,de,fe,Ge,ct;for(;++we<=ae;){const We=te[we];switch(We[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{We[0]==="enter"?Le++:Le--,ct=void 0;break}case"lineEndingBlank":{We[0]==="enter"&&(de&&!ct&&!Le&&!Ge&&(Ge=we),ct=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ct=void 0}if(!Le&&We[0]==="enter"&&We[1].type==="listItemPrefix"||Le===-1&&We[0]==="exit"&&(We[1].type==="listUnordered"||We[1].type==="listOrdered")){if(de){let ut=we;for(fe=void 0;ut--;){const Ft=te[ut];if(Ft[1].type==="lineEnding"||Ft[1].type==="lineEndingBlank"){if(Ft[0]==="exit")continue;fe&&(te[fe][1].type="lineEndingBlank",He=!0),Ft[1].type="lineEnding",fe=ut}else if(!(Ft[1].type==="linePrefix"||Ft[1].type==="blockQuotePrefix"||Ft[1].type==="blockQuotePrefixWhitespace"||Ft[1].type==="blockQuoteMarker"||Ft[1].type==="listItemIndent"))break}Ge&&(!fe||Ge<fe)&&(de._spread=!0),de.end=Object.assign({},fe?te[fe][1].start:We[1].end),te.splice(fe||we,0,["exit",de,We[2]]),we++,ae++}if(We[1].type==="listItemPrefix"){const ut={type:"listItem",_spread:!1,start:Object.assign({},We[1].start),end:void 0};de=ut,te.splice(we,0,["enter",ut,We[2]]),we++,ae++,Ge=void 0,ct=!0}}}return te[F][1]._spread=He,ae}function l(te,F){return ae;function ae(we){u.call(this,te(we),we),F&&F.call(this,we)}}function c(){this.stack.push({type:"fragment",children:[]})}function u(te,F,ae){this.stack[this.stack.length-1].children.push(te),this.stack.push(te),this.tokenStack.push([F,ae||void 0]),te.position={start:Gi(F.start),end:void 0}}function m(te){return F;function F(ae){te&&te.call(this,ae),f.call(this,ae)}}function f(te,F){const ae=this.stack.pop(),we=this.tokenStack.pop();if(we)we[0].type!==te.type&&(F?F.call(this,te,we[0]):(we[1]||nw).call(this,te,we[0]));else throw new Error("Cannot close `"+te.type+"` ("+pc({start:te.start,end:te.end})+"): it’s not open");ae.position.end=Gi(te.end)}function g(){return eb(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function v(te){if(this.data.expectingFirstListItemValue){const F=this.stack[this.stack.length-2];F.start=Number.parseInt(this.sliceSerialize(te),10),this.data.expectingFirstListItemValue=void 0}}function y(){const te=this.resume(),F=this.stack[this.stack.length-1];F.lang=te}function w(){const te=this.resume(),F=this.stack[this.stack.length-1];F.meta=te}function T(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const te=this.resume(),F=this.stack[this.stack.length-1];F.value=te.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function A(){const te=this.resume(),F=this.stack[this.stack.length-1];F.value=te.replace(/(\r?\n|\r)$/g,"")}function M(te){const F=this.resume(),ae=this.stack[this.stack.length-1];ae.label=F,ae.identifier=xr(this.sliceSerialize(te)).toLowerCase()}function I(){const te=this.resume(),F=this.stack[this.stack.length-1];F.title=te}function B(){const te=this.resume(),F=this.stack[this.stack.length-1];F.url=te}function K(te){const F=this.stack[this.stack.length-1];if(!F.depth){const ae=this.sliceSerialize(te).length;F.depth=ae}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function z(te){const F=this.stack[this.stack.length-1];F.depth=this.sliceSerialize(te).codePointAt(0)===61?1:2}function U(){this.data.setextHeadingSlurpLineEnding=void 0}function Y(te){const ae=this.stack[this.stack.length-1].children;let we=ae[ae.length-1];(!we||we.type!=="text")&&(we=Ne(),we.position={start:Gi(te.start),end:void 0},ae.push(we)),this.stack.push(we)}function $(te){const F=this.stack.pop();F.value+=this.sliceSerialize(te),F.position.end=Gi(te.end)}function D(te){const F=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ae=F.children[F.children.length-1];ae.position.end=Gi(te.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(F.type)&&(Y.call(this,te),$.call(this,te))}function W(){this.data.atHardBreak=!0}function X(){const te=this.resume(),F=this.stack[this.stack.length-1];F.value=te}function H(){const te=this.resume(),F=this.stack[this.stack.length-1];F.value=te}function se(){const te=this.resume(),F=this.stack[this.stack.length-1];F.value=te}function R(){const te=this.stack[this.stack.length-1];if(this.data.inReference){const F=this.data.referenceType||"shortcut";te.type+="Reference",te.referenceType=F,delete te.url,delete te.title}else delete te.identifier,delete te.label;this.data.referenceType=void 0}function re(){const te=this.stack[this.stack.length-1];if(this.data.inReference){const F=this.data.referenceType||"shortcut";te.type+="Reference",te.referenceType=F,delete te.url,delete te.title}else delete te.identifier,delete te.label;this.data.referenceType=void 0}function ue(te){const F=this.sliceSerialize(te),ae=this.stack[this.stack.length-2];ae.label=QQ(F),ae.identifier=xr(F).toLowerCase()}function Ce(){const te=this.stack[this.stack.length-1],F=this.resume(),ae=this.stack[this.stack.length-1];if(this.data.inReference=!0,ae.type==="link"){const we=te.children;ae.children=we}else ae.alt=F}function q(){const te=this.resume(),F=this.stack[this.stack.length-1];F.url=te}function V(){const te=this.resume(),F=this.stack[this.stack.length-1];F.title=te}function ce(){this.data.inReference=void 0}function P(){this.data.referenceType="collapsed"}function Ee(te){const F=this.resume(),ae=this.stack[this.stack.length-1];ae.label=F,ae.identifier=xr(this.sliceSerialize(te)).toLowerCase(),this.data.referenceType="full"}function $e(te){this.data.characterReferenceType=te.type}function qe(te){const F=this.sliceSerialize(te),ae=this.data.characterReferenceType;let we;ae?(we=L5(F,ae==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):we=tb(F);const Le=this.stack[this.stack.length-1];Le.value+=we}function Ze(te){const F=this.stack.pop();F.position.end=Gi(te.end)}function Qe(te){$.call(this,te);const F=this.stack[this.stack.length-1];F.url=this.sliceSerialize(te)}function Re(te){$.call(this,te);const F=this.stack[this.stack.length-1];F.url="mailto:"+this.sliceSerialize(te)}function Xe(){return{type:"blockquote",children:[]}}function wt(){return{type:"code",lang:null,meta:null,value:""}}function mt(){return{type:"inlineCode",value:""}}function kt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function lt(){return{type:"emphasis",children:[]}}function Dt(){return{type:"heading",depth:0,children:[]}}function ht(){return{type:"break"}}function Oe(){return{type:"html",value:""}}function Nt(){return{type:"image",title:null,url:"",alt:null}}function Gt(){return{type:"link",title:null,url:"",children:[]}}function ie(te){return{type:"list",ordered:te.type==="listOrdered",start:null,spread:te._spread,children:[]}}function et(te){return{type:"listItem",spread:te._spread,checked:null,children:[]}}function at(){return{type:"paragraph",children:[]}}function ye(){return{type:"strong",children:[]}}function Ne(){return{type:"text",value:""}}function De(){return{type:"thematicBreak"}}}function Gi(e){return{line:e.line,column:e.column,offset:e.offset}}function K5(e,t){let n=-1;for(;++n<t.length;){const a=t[n];Array.isArray(a)?K5(e,a):eX(e,a)}}function eX(e,t){let n;for(n in t)if(G5.call(t,n))switch(n){case"canContainEols":{const a=t[n];a&&e[n].push(...a);break}case"transforms":{const a=t[n];a&&e[n].push(...a);break}case"enter":case"exit":{const a=t[n];a&&Object.assign(e[n],a);break}}}function nw(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+pc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+pc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+pc({start:t.start,end:t.end})+") is still open")}function tX(e){const t=this;t.parser=n;function n(a){return JQ(a,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function nX(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function aX(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -811,7 +811,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
811
811
|
`},f]}}const _ae=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_-]*/}}),Dae=["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"],Iae=["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"],Lae=[...Dae,...Iae],Pae=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),H3=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),B3=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Oae=["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(),zae=H3.concat(B3).sort().reverse();function Hae(e){const t=_ae(e),n=zae,a="and or not only",i="[\\w-]+",l="("+i+"|@\\{"+i+"\\})",c=[],u=[],m=function(I){return{className:"string",begin:"~?"+I+".*?"+I}},f=function(I,B,K){return{className:I,begin:B,relevance:K}},g={$pattern:/[a-z-]+/,keyword:a,attribute:Pae.join(" ")},h={begin:"\\(",end:"\\)",contains:u,keywords:g,relevance:0};u.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,h,f("variable","@@?"+i,10),f("variable","@\\{"+i+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:i+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const v=u.concat({begin:/\{/,end:/\}/,contains:c}),y={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(u)},w={begin:l+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Oae.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:u}}]},T={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:g,returnEnd:!0,contains:u,relevance:0}},C={className:"variable",variants:[{begin:"@"+i+"\\s*:",relevance:15},{begin:"@"+i}],starts:{end:"[;}]",returnEnd:!0,contains:v}},A={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,f("keyword","all\\b"),f("variable","@\\{"+i+"\\}"),{begin:"\\b("+Lae.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,f("selector-tag",l,0),f("selector-id","#"+l),f("selector-class","\\."+l,0),f("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+H3.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+B3.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:v},{begin:"!important"},t.FUNCTION_DISPATCH]},M={begin:i+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[A]};return c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,T,C,M,w,A,y,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:c}}function Bae(e){const t="\\[=*\\[",n="\\]=*\\]",a={begin:t,end:n,contains:["self"]},i=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[a],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:i.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:i}].concat(i)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[a],relevance:5}])}}function $ae(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]},a={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},i={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},l={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},c={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,a,i,l,c]}}function qae(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},a={begin:"^[-\\*]{3,}",end:"$"},i={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},l={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,m={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},g={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},h=e.inherit(f,{contains:[]}),v=e.inherit(g,{contains:[]});f.contains.push(v),g.contains.push(h);let y=[n,m];return[f,g,h,v].forEach(A=>{A.contains=A.contains.concat(y)}),y=y.concat(f,g),{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,f,g,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},i,a,m,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Fae(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_]*/,u={"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:u,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 Uae(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"],a=/[dualxmsipngr]{0,12}/,i={$pattern:/[\w.]+/,keyword:n.join(" ")},l={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:i},c={begin:/->\{/,end:/\}/},u={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:[u]},f={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},g=[e.BACKSLASH_ESCAPE,l,m],h=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],v=(T,C,A="\\1")=>{const M=A==="\\1"?A:t.concat(A,C);return t.concat(t.concat("(?:",T,")"),C,/(?:\\.|[^\\\/])*?/,M,/(?:\\.|[^\\\/])*?/,A,a)},y=(T,C,A)=>t.concat(t.concat("(?:",T,")"),C,/(?:\\.|[^\\\/])*?/,A,a),w=[m,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),c,{className:"string",contains:g,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},f,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:v("s|tr|y",t.either(...h,{capture:!0}))},{begin:v("s|tr|y","\\(","\\)")},{begin:v("s|tr|y","\\[","\\]")},{begin:v("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:y("(?:m|qr)?",/\//,/\//)},{begin:y("m|qr",t.either(...h,{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,u]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,u,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return l.contains=w,c.contains=w,{name:"Perl",aliases:["pl","pm"],keywords:i,contains:w}}function Gae(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,a=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),i=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),l=t.concat(/[A-Z]+/,n),c={scope:"variable",match:"\\$+"+a},u={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},m={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=e.inherit(e.APOS_STRING_MODE,{illegal:null}),g=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(m)}),h={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(m),"on:begin":(H,se)=>{se.data._beginMatch=H[1]||H[2]},"on:end":(H,se)=>{se.data._beginMatch!==H[1]&&se.ignoreMatch()}},v=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),y=`[
|
|
812
812
|
]`,w={scope:"string",variants:[g,f,h,v]},T={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},C=["false","null","true"],A=["__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"],M=["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"],B={keyword:A,literal:(H=>{const se=[];return H.forEach(R=>{se.push(R),R.toLowerCase()===R?se.push(R.toUpperCase()):se.push(R.toLowerCase())}),se})(C),built_in:M},K=H=>H.map(se=>se.replace(/\|\d+$/,"")),j={variants:[{match:[/new/,t.concat(y,"+"),t.concat("(?!",K(M).join("\\b|"),"\\b)"),i],scope:{1:"keyword",4:"title.class"}}]},z=t.concat(a,"\\b(?!\\()"),U={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),z],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[i,t.concat(/::/,t.lookahead(/(?!class\b)/)),z],scope:{1:"title.class",3:"variable.constant"}},{match:[i,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[i,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},Y={scope:"attr",match:t.concat(a,t.lookahead(":"),t.lookahead(/(?!::)/))},$={relevance:0,begin:/\(/,end:/\)/,keywords:B,contains:[Y,c,U,e.C_BLOCK_COMMENT_MODE,w,T,j]},D={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",K(A).join("\\b|"),"|",K(M).join("\\b|"),"\\b)"),a,t.concat(y,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[$]};$.contains.push(D);const W=[Y,U,e.C_BLOCK_COMMENT_MODE,w,T,j],X={begin:t.concat(/#\[\s*\\?/,t.either(i,l)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:C,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:C,keyword:["new","array"]},contains:["self",...W]},...W,{scope:"meta",variants:[{match:i},{match:l}]}]};return{case_insensitive:!1,keywords:B,contains:[X,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}]}},u,{scope:"variable.language",match:/\$this\b/},c,D,U,{match:[/const/,/\s/,a],scope:{1:"keyword",3:"variable.constant"}},j,{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:B,contains:["self",X,c,U,e.C_BLOCK_COMMENT_MODE,w,T]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},w,T]}}function Kae(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 Vae(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function Wae(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),a=["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"],u={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:a,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},m={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},g={begin:/\{\{/,relevance:0},h={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,g,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m,g,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,g,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,g,f]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},v="[0-9](_?[0-9])*",y=`(\\b(${v}))?\\.(${v})|\\b(${v})\\.`,w=`\\b|${a.join("|")}`,T={className:"number",relevance:0,variants:[{begin:`(\\b(${v})|(${y}))[eE][+-]?(${v})[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(${v})[jJ](?=${w})`}]},C={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},A={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",m,T,h,e.HASH_COMMENT_MODE]}]};return f.contains=[h,T,m],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[m,T,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},h,C,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[A]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[T,A,h]}]}}function Yae(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function Qae(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,a=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,l=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[i,a]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,a]},{scope:{1:"punctuation",2:"number"},match:[l,a]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,a]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:i},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:l},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function Xae(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",a=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=t.concat(a,/(::\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"]},u={className:"doctag",begin:"@[A-Za-z]+"},m={begin:"#<",end:">"},f=[e.COMMENT("#","$",{contains:[u]}),e.COMMENT("^=begin","^=end",{contains:[u],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],g={className:"subst",begin:/#\{/,end:/\}/,keywords:c},h={className:"string",contains:[e.BACKSLASH_ESCAPE,g],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,g]})]}]},v="[1-9](_?[0-9])*|0",y="[0-9](_?[0-9])*",w={className:"number",relevance:0,variants:[{begin:`\\b(${v})(\\.(${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"}]},T={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:c}]},j=[h,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:c},{match:[/(include|extend)\s+/,i],scope:{2:"title.class"},keywords:c},{relevance:0,match:[i,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:a,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[T]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[h,{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,g],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(m,f),relevance:0}].concat(m,f);g.contains=j,T.contains=j;const $=[{begin:/^\s*=>/,starts:{end:"$",contains:j}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:c,contains:j}}];return f.unshift(m),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:c,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat($).concat(f).concat(j)}}function Jae(e){const t=e.regex,n=/(r#)?/,a=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),l={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,t.lookahead(/\s*\(/))},c="([ui](8|16|32|64|128|size)|f(32|64))?",u=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],m=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],g=["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:g,keyword:u,literal:m,built_in:f},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],relevance:0},{begin:[/fn/,/\s+/,a],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,a],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,a,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,a],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,a],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:g}},{className:"punctuation",begin:"->"},l]}}const Zae=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_-]*/}}),ere=["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"],tre=["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"],nre=[...ere,...tre],are=["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(),rre=["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(),ire=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),sre=["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 ore(e){const t=Zae(e),n=ire,a=rre,i="@[a-z-]+",l="and or not only",u={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("+nre.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+a.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},u,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+sre.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,u,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:i,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:l,attribute:are.join(" ")},contains:[{begin:i,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},u,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function lre(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function cre(e){const t=e.regex,n=e.COMMENT("--","$"),a={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},l=["true","false","unknown"],c=["double precision","large object","with timezone","without timezone"],u=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],m=["add","asc","collation","desc","final","first","last","view"],f=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],g=["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"],h=["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"],v=["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=g,w=[...f,...m].filter(K=>!g.includes(K)),T={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},C={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},A={match:t.concat(/\b/,t.either(...y),/\s*\(/),relevance:0,keywords:{built_in:y}};function M(K){return t.concat(/\b/,t.either(...K.map(j=>j.replace(/\s+/,"\\s+"))),/\b/)}const I={scope:"keyword",match:M(v),relevance:0};function B(K,{exceptions:j,when:z}={}){const U=z;return j=j||[],K.map(Y=>Y.match(/\|\d+$/)||j.includes(Y)?Y:U(Y)?`${Y}|0`:Y)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:B(w,{when:K=>K.length<3}),literal:l,type:u,built_in:h},contains:[{scope:"type",match:M(c)},I,A,T,a,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,C]}}function $3(e){return e?typeof e=="string"?e:e.source:null}function tc(e){return hn("(?=",e,")")}function hn(...e){return e.map(n=>$3(n)).join("")}function dre(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function va(...e){return"("+(dre(e).capture?"":"?:")+e.map(a=>$3(a)).join("|")+")"}const Mb=e=>hn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),ure=["Protocol","Type"].map(Mb),fk=["init","self"].map(Mb),mre=["Any","Self"],bh=["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"],hk=["false","nil","true"],pre=["assignment","associativity","higherThan","left","lowerThan","none","right"],fre=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],gk=["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"],q3=va(/[/=\-+!*%<>&|^~?]/,/[\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]/),F3=va(q3,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),yh=hn(q3,F3,"*"),U3=va(/[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]/),Rm=va(U3,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Rr=hn(U3,Rm,"*"),Eu=hn(/[A-Z]/,Rm,"*"),hre=["attached","autoclosure",hn(/convention\(/,va("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",hn(/objc\(/,Rr,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],gre=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function bre(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),a=[e.C_LINE_COMMENT_MODE,n],i={match:[/\./,va(...ure,...fk)],className:{2:"keyword"}},l={match:hn(/\./,va(...bh)),relevance:0},c=bh.filter(ht=>typeof ht=="string").concat(["_|0"]),u=bh.filter(ht=>typeof ht!="string").concat(mre).map(Mb),m={variants:[{className:"keyword",match:va(...u,...fk)}]},f={$pattern:va(/\b\w+/,/#\w+/),keyword:c.concat(fre),literal:hk},g=[i,l,m],h={match:hn(/\./,va(...gk)),relevance:0},v={className:"built_in",match:hn(/\b/,va(...gk),/(?=\()/)},y=[h,v],w={match:/->/,relevance:0},T={className:"operator",relevance:0,variants:[{match:yh},{match:`\\.(\\.|${F3})+`}]},C=[w,T],A="([0-9]_*)+",M="([0-9a-fA-F]_*)+",I={className:"number",relevance:0,variants:[{match:`\\b(${A})(\\.(${A}))?([eE][+-]?(${A}))?\\b`},{match:`\\b0x(${M})(\\.(${M}))?([pP][+-]?(${A}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},B=(ht="")=>({className:"subst",variants:[{match:hn(/\\/,ht,/[0\\tnr"']/)},{match:hn(/\\/,ht,/u\{[0-9a-fA-F]{1,8}\}/)}]}),K=(ht="")=>({className:"subst",match:hn(/\\/,ht,/[\t ]*(?:[\r\n]|\r\n)/)}),j=(ht="")=>({className:"subst",label:"interpol",begin:hn(/\\/,ht,/\(/),end:/\)/}),z=(ht="")=>({begin:hn(ht,/"""/),end:hn(/"""/,ht),contains:[B(ht),K(ht),j(ht)]}),U=(ht="")=>({begin:hn(ht,/"/),end:hn(/"/,ht),contains:[B(ht),j(ht)]}),Y={className:"string",variants:[z(),z("#"),z("##"),z("###"),U(),U("#"),U("##"),U("###")]},$=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],D={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:$},W=ht=>{const Oe=hn(ht,/\//),Nt=hn(/\//,ht);return{begin:Oe,end:Nt,contains:[...$,{scope:"comment",begin:`#(?!.*${Nt})`,end:/$/}]}},X={scope:"regexp",variants:[W("###"),W("##"),W("#"),D]},H={match:hn(/`/,Rr,/`/)},se={className:"variable",match:/\$\d+/},R={className:"variable",match:`\\$${Rm}+`},re=[H,se,R],ue={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:gre,contains:[...C,I,Y]}]}},Ce={scope:"keyword",match:hn(/@/,va(...hre),tc(va(/\(/,/\s+/)))},q={scope:"meta",match:hn(/@/,Rr)},V=[ue,Ce,q],ce={match:tc(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:hn(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Rm,"+")},{className:"type",match:Eu,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:hn(/\s+&\s+/,tc(Eu)),relevance:0}]},P={begin:/</,end:/>/,keywords:f,contains:[...a,...g,...V,w,ce]};ce.contains.push(P);const Ee={match:hn(Rr,/\s*:/),keywords:"_|0",relevance:0},$e={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",Ee,...a,X,...g,...y,...C,I,Y,...re,...V,ce]},qe={begin:/</,end:/>/,keywords:"repeat each",contains:[...a,ce]},Ze={begin:va(tc(hn(Rr,/\s*:/)),tc(hn(Rr,/\s+/,Rr,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Rr}]},Qe={begin:/\(/,end:/\)/,keywords:f,contains:[Ze,...a,...g,...C,I,Y,...V,ce,$e],endsParent:!0,illegal:/["']/},Re={match:[/(func|macro)/,/\s+/,va(H.match,Rr,yh)],className:{1:"keyword",3:"title.function"},contains:[qe,Qe,t],illegal:[/\[/,/%/]},Xe={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[qe,Qe,t],illegal:/\[|%/},wt={match:[/operator/,/\s+/,yh],className:{1:"keyword",3:"title"}},mt={begin:[/precedencegroup/,/\s+/,Eu],className:{1:"keyword",3:"title"},contains:[ce],keywords:[...pre,...hk],end:/}/},kt={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},lt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Dt={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,Rr,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[qe,...g,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:Eu},...g],relevance:0}]};for(const ht of Y.variants){const Oe=ht.contains.find(Gt=>Gt.label==="interpol");Oe.keywords=f;const Nt=[...g,...y,...C,I,Y,...re];Oe.contains=[...Nt,{begin:/\(/,end:/\)/,contains:["self",...Nt]}]}return{name:"Swift",keywords:f,contains:[...a,Re,Xe,kt,lt,Dt,wt,mt,{beginKeywords:"import",end:/$/,contains:[...a],relevance:0},X,...g,...y,...C,I,Y,...re,...V,ce,$e]}}const _m="[A-Za-z$_][0-9A-Za-z$_]*",G3=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],K3=["true","false","null","undefined","NaN","Infinity"],V3=["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"],W3=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Y3=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Q3=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],X3=[].concat(Y3,V3,W3);function yre(e){const t=e.regex,n=(ue,{after:Ce})=>{const q="</"+ue[0].slice(1);return ue.input.indexOf(q,Ce)!==-1},a=_m,i={begin:"<>",end:"</>"},l=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(ue,Ce)=>{const q=ue[0].length+ue.index,V=ue.input[q];if(V==="<"||V===","){Ce.ignoreMatch();return}V===">"&&(n(ue,{after:q})||Ce.ignoreMatch());let ce;const P=ue.input.substring(q);if(ce=P.match(/^\s*=/)){Ce.ignoreMatch();return}if((ce=P.match(/^\s+extends\s+/))&&ce.index===0){Ce.ignoreMatch();return}}},u={$pattern:_m,keyword:G3,literal:K3,built_in:X3,"variable.language":Q3},m="[0-9](_?[0-9])*",f=`\\.(${m})`,g="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",h={className:"number",variants:[{begin:`(\\b(${g})((${f})|\\.)?|(${f}))[eE][+-]?(${m})\\b`},{begin:`\\b(${g})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},v={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,v],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,v],subLanguage:"css"}},T={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,v],subLanguage:"graphql"}},C={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,v]},M={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:a+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},I=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,T,C,{match:/\$\d+/},h];v.contains=I.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(I)});const B=[].concat(M,v.contains),K=B.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(B)}]),j={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:K},z={variants:[{match:[/class/,/\s+/,a,/\s+/,/extends/,/\s+/,t.concat(a,"(",t.concat(/\./,a),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,a],scope:{1:"keyword",3:"title.class"}}]},U={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:{_:[...V3,...W3]}},Y={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},$={variants:[{match:[/function/,/\s+/,a,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[j],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function W(ue){return t.concat("(?!",ue.join("|"),")")}const X={match:t.concat(/\b/,W([...Y3,"super","import"].map(ue=>`${ue}\\s*\\(`)),a,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},H={begin:t.concat(/\./,t.lookahead(t.concat(a,/(?![0-9A-Za-z$_(])/))),end:a,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},se={match:[/get|set/,/\s+/,a,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},j]},R="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",re={match:[/const|var|let/,/\s+/,a,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(R)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[j]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:K,CLASS_REFERENCE:U},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),Y,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,T,C,M,{match:/\$\d+/},h,U,{scope:"attr",match:a+t.lookahead(":"),relevance:0},re,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[M,e.REGEXP_MODE,{className:"function",begin:R,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:u,contains:K}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:l},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},$,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[j,e.inherit(e.TITLE_MODE,{begin:a,className:"title.function"})]},{match:/\.\.\./,relevance:0},H,{match:"\\$"+a,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[j]},X,D,z,se,{match:/\$[(.]/}]}}function vre(e){const t=e.regex,n=yre(e),a=_m,i=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],l={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:i},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},m=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:_m,keyword:G3.concat(m),literal:K3,built_in:X3.concat(i),"variable.language":Q3},g={className:"meta",begin:"@"+a},h=(T,C,A)=>{const M=T.contains.findIndex(I=>I.label===C);if(M===-1)throw new Error("can not find mode to replace");T.contains.splice(M,1,A)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(g);const v=n.contains.find(T=>T.scope==="attr"),y=Object.assign({},v,{match:t.concat(a,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,v,y]),n.contains=n.contains.concat([g,l,c,y]),h(n,"shebang",e.SHEBANG()),h(n,"use_strict",u);const w=n.contains.find(T=>T.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function xre(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},a={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},i=/\d{1,2}\/\d{1,2}\/\d{4}/,l=/\d{4}-\d{1,2}-\d{1,2}/,c=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,u=/\d{1,2}(:\d{1,2}){1,2}/,m={className:"literal",variants:[{begin:t.concat(/# */,t.either(l,i),/ *#/)},{begin:t.concat(/# */,u,/ *#/)},{begin:t.concat(/# */,c,/ *#/)},{begin:t.concat(/# */,t.either(l,i),/ +/,t.either(c,u),/ *#/)}]},f={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},g={className:"label",begin:/^\w+:/},h=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),v=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,a,m,f,g,h,v,{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:[v]}]}}function wre(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),a=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],i={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},l={className:"variable",begin:/\$[\w_]+/},c={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},u={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},m={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},f={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:a},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},l,c,i,e.QUOTE_STRING_MODE,m,f,u]}}function kre(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),a=/[\p{L}0-9._:-]+/u,i={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},l={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},c=e.inherit(l,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),m=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:a,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[l,m,u,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[l,c,m,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[m]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Sre(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",a={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},l={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},u=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),v={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},T={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},C=[a,{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}},v,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,T,l,c],A=[...C];return A.pop(),A.push(u),y.contains=A,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:C}}const Cre={arduino:iae,bash:sae,c:oae,cpp:lae,csharp:cae,css:yae,diff:vae,go:xae,graphql:wae,ini:kae,java:Sae,javascript:Nae,json:Mae,kotlin:Rae,less:Hae,lua:Bae,makefile:$ae,markdown:qae,objectivec:Fae,perl:Uae,php:Gae,"php-template":Kae,plaintext:Vae,python:Wae,"python-repl":Yae,r:Qae,ruby:Xae,rust:Jae,scss:ore,shell:lre,sql:cre,swift:bre,typescript:vre,vbnet:xre,wasm:wre,xml:kre,yaml:Sre};var vh,bk;function Are(){if(bk)return vh;bk=1;function e(Q){return Q instanceof Map?Q.clear=Q.delete=Q.set=function(){throw new Error("map is read-only")}:Q instanceof Set&&(Q.add=Q.clear=Q.delete=function(){throw new Error("set is read-only")}),Object.freeze(Q),Object.getOwnPropertyNames(Q).forEach(he=>{const Se=Q[he],Ye=typeof Se;(Ye==="object"||Ye==="function")&&!Object.isFrozen(Se)&&e(Se)}),Q}class t{constructor(he){he.data===void 0&&(he.data={}),this.data=he.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(Q){return Q.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function a(Q,...he){const Se=Object.create(null);for(const Ye in Q)Se[Ye]=Q[Ye];return he.forEach(function(Ye){for(const bt in Ye)Se[bt]=Ye[bt]}),Se}const i="</span>",l=Q=>!!Q.scope,c=(Q,{prefix:he})=>{if(Q.startsWith("language:"))return Q.replace("language:","language-");if(Q.includes(".")){const Se=Q.split(".");return[`${he}${Se.shift()}`,...Se.map((Ye,bt)=>`${Ye}${"_".repeat(bt+1)}`)].join(" ")}return`${he}${Q}`};class u{constructor(he,Se){this.buffer="",this.classPrefix=Se.classPrefix,he.walk(this)}addText(he){this.buffer+=n(he)}openNode(he){if(!l(he))return;const Se=c(he.scope,{prefix:this.classPrefix});this.span(Se)}closeNode(he){l(he)&&(this.buffer+=i)}value(){return this.buffer}span(he){this.buffer+=`<span class="${he}">`}}const m=(Q={})=>{const he={children:[]};return Object.assign(he,Q),he};class f{constructor(){this.rootNode=m(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(he){this.top.children.push(he)}openNode(he){const Se=m({scope:he});this.add(Se),this.stack.push(Se)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(he){return this.constructor._walk(he,this.rootNode)}static _walk(he,Se){return typeof Se=="string"?he.addText(Se):Se.children&&(he.openNode(Se),Se.children.forEach(Ye=>this._walk(he,Ye)),he.closeNode(Se)),he}static _collapse(he){typeof he!="string"&&he.children&&(he.children.every(Se=>typeof Se=="string")?he.children=[he.children.join("")]:he.children.forEach(Se=>{f._collapse(Se)}))}}class g extends f{constructor(he){super(),this.options=he}addText(he){he!==""&&this.add(he)}startScope(he){this.openNode(he)}endScope(){this.closeNode()}__addSublanguage(he,Se){const Ye=he.root;Se&&(Ye.scope=`language:${Se}`),this.add(Ye)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function h(Q){return Q?typeof Q=="string"?Q:Q.source:null}function v(Q){return T("(?=",Q,")")}function y(Q){return T("(?:",Q,")*")}function w(Q){return T("(?:",Q,")?")}function T(...Q){return Q.map(Se=>h(Se)).join("")}function C(Q){const he=Q[Q.length-1];return typeof he=="object"&&he.constructor===Object?(Q.splice(Q.length-1,1),he):{}}function A(...Q){return"("+(C(Q).capture?"":"?:")+Q.map(Ye=>h(Ye)).join("|")+")"}function M(Q){return new RegExp(Q.toString()+"|").exec("").length-1}function I(Q,he){const Se=Q&&Q.exec(he);return Se&&Se.index===0}const B=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function K(Q,{joinWith:he}){let Se=0;return Q.map(Ye=>{Se+=1;const bt=Se;let Ot=h(Ye),it="";for(;Ot.length>0;){const tt=B.exec(Ot);if(!tt){it+=Ot;break}it+=Ot.substring(0,tt.index),Ot=Ot.substring(tt.index+tt[0].length),tt[0][0]==="\\"&&tt[1]?it+="\\"+String(Number(tt[1])+bt):(it+=tt[0],tt[0]==="("&&Se++)}return it}).map(Ye=>`(${Ye})`).join(he)}const j=/\b\B/,z="[a-zA-Z]\\w*",U="[a-zA-Z_]\\w*",Y="\\b\\d+(\\.\\d+)?",$="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",D="\\b(0b[01]+)",W="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",X=(Q={})=>{const he=/^#![ ]*\//;return Q.binary&&(Q.begin=T(he,/.*\b/,Q.binary,/\b.*/)),a({scope:"meta",begin:he,end:/$/,relevance:0,"on:begin":(Se,Ye)=>{Se.index!==0&&Ye.ignoreMatch()}},Q)},H={begin:"\\\\[\\s\\S]",relevance:0},se={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[H]},R={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[H]},re={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},ue=function(Q,he,Se={}){const Ye=a({scope:"comment",begin:Q,end:he,contains:[]},Se);Ye.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 bt=A("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 Ye.contains.push({begin:T(/[ ]+/,"(",bt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ye},Ce=ue("//","$"),q=ue("/\\*","\\*/"),V=ue("#","$"),ce={scope:"number",begin:Y,relevance:0},P={scope:"number",begin:$,relevance:0},Ee={scope:"number",begin:D,relevance:0},$e={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[H,{begin:/\[/,end:/\]/,relevance:0,contains:[H]}]},qe={scope:"title",begin:z,relevance:0},Ze={scope:"title",begin:U,relevance:0},Qe={begin:"\\.\\s*"+U,relevance:0};var Xe=Object.freeze({__proto__:null,APOS_STRING_MODE:se,BACKSLASH_ESCAPE:H,BINARY_NUMBER_MODE:Ee,BINARY_NUMBER_RE:D,COMMENT:ue,C_BLOCK_COMMENT_MODE:q,C_LINE_COMMENT_MODE:Ce,C_NUMBER_MODE:P,C_NUMBER_RE:$,END_SAME_AS_BEGIN:function(Q){return Object.assign(Q,{"on:begin":(he,Se)=>{Se.data._beginMatch=he[1]},"on:end":(he,Se)=>{Se.data._beginMatch!==he[1]&&Se.ignoreMatch()}})},HASH_COMMENT_MODE:V,IDENT_RE:z,MATCH_NOTHING_RE:j,METHOD_GUARD:Qe,NUMBER_MODE:ce,NUMBER_RE:Y,PHRASAL_WORDS_MODE:re,QUOTE_STRING_MODE:R,REGEXP_MODE:$e,RE_STARTERS_RE:W,SHEBANG:X,TITLE_MODE:qe,UNDERSCORE_IDENT_RE:U,UNDERSCORE_TITLE_MODE:Ze});function wt(Q,he){Q.input[Q.index-1]==="."&&he.ignoreMatch()}function mt(Q,he){Q.className!==void 0&&(Q.scope=Q.className,delete Q.className)}function kt(Q,he){he&&Q.beginKeywords&&(Q.begin="\\b("+Q.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",Q.__beforeBegin=wt,Q.keywords=Q.keywords||Q.beginKeywords,delete Q.beginKeywords,Q.relevance===void 0&&(Q.relevance=0))}function lt(Q,he){Array.isArray(Q.illegal)&&(Q.illegal=A(...Q.illegal))}function Dt(Q,he){if(Q.match){if(Q.begin||Q.end)throw new Error("begin & end are not supported with match");Q.begin=Q.match,delete Q.match}}function ht(Q,he){Q.relevance===void 0&&(Q.relevance=1)}const Oe=(Q,he)=>{if(!Q.beforeMatch)return;if(Q.starts)throw new Error("beforeMatch cannot be used with starts");const Se=Object.assign({},Q);Object.keys(Q).forEach(Ye=>{delete Q[Ye]}),Q.keywords=Se.keywords,Q.begin=T(Se.beforeMatch,v(Se.begin)),Q.starts={relevance:0,contains:[Object.assign(Se,{endsParent:!0})]},Q.relevance=0,delete Se.beforeMatch},Nt=["of","and","for","in","not","or","if","then","parent","list","value"],Gt="keyword";function ie(Q,he,Se=Gt){const Ye=Object.create(null);return typeof Q=="string"?bt(Se,Q.split(" ")):Array.isArray(Q)?bt(Se,Q):Object.keys(Q).forEach(function(Ot){Object.assign(Ye,ie(Q[Ot],he,Ot))}),Ye;function bt(Ot,it){he&&(it=it.map(tt=>tt.toLowerCase())),it.forEach(function(tt){const St=tt.split("|");Ye[St[0]]=[Ot,et(St[0],St[1])]})}}function et(Q,he){return he?Number(he):at(Q)?0:1}function at(Q){return Nt.includes(Q.toLowerCase())}const ye={},Ne=Q=>{console.error(Q)},De=(Q,...he)=>{console.log(`WARN: ${Q}`,...he)},te=(Q,he)=>{ye[`${Q}/${he}`]||(console.log(`Deprecated as of ${Q}. ${he}`),ye[`${Q}/${he}`]=!0)},F=new Error;function ae(Q,he,{key:Se}){let Ye=0;const bt=Q[Se],Ot={},it={};for(let tt=1;tt<=he.length;tt++)it[tt+Ye]=bt[tt],Ot[tt+Ye]=!0,Ye+=M(he[tt-1]);Q[Se]=it,Q[Se]._emit=Ot,Q[Se]._multi=!0}function we(Q){if(Array.isArray(Q.begin)){if(Q.skip||Q.excludeBegin||Q.returnBegin)throw Ne("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),F;if(typeof Q.beginScope!="object"||Q.beginScope===null)throw Ne("beginScope must be object"),F;ae(Q,Q.begin,{key:"beginScope"}),Q.begin=K(Q.begin,{joinWith:""})}}function Le(Q){if(Array.isArray(Q.end)){if(Q.skip||Q.excludeEnd||Q.returnEnd)throw Ne("skip, excludeEnd, returnEnd not compatible with endScope: {}"),F;if(typeof Q.endScope!="object"||Q.endScope===null)throw Ne("endScope must be object"),F;ae(Q,Q.end,{key:"endScope"}),Q.end=K(Q.end,{joinWith:""})}}function He(Q){Q.scope&&typeof Q.scope=="object"&&Q.scope!==null&&(Q.beginScope=Q.scope,delete Q.scope)}function de(Q){He(Q),typeof Q.beginScope=="string"&&(Q.beginScope={_wrap:Q.beginScope}),typeof Q.endScope=="string"&&(Q.endScope={_wrap:Q.endScope}),we(Q),Le(Q)}function fe(Q){function he(it,tt){return new RegExp(h(it),"m"+(Q.case_insensitive?"i":"")+(Q.unicodeRegex?"u":"")+(tt?"g":""))}class Se{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(tt,St){St.position=this.position++,this.matchIndexes[this.matchAt]=St,this.regexes.push([St,tt]),this.matchAt+=M(tt)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const tt=this.regexes.map(St=>St[1]);this.matcherRe=he(K(tt,{joinWith:"|"}),!0),this.lastIndex=0}exec(tt){this.matcherRe.lastIndex=this.lastIndex;const St=this.matcherRe.exec(tt);if(!St)return null;const gn=St.findIndex((Qn,ha)=>ha>0&&Qn!==void 0),bn=this.matchIndexes[gn];return St.splice(0,gn),Object.assign(St,bn)}}class Ye{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(tt){if(this.multiRegexes[tt])return this.multiRegexes[tt];const St=new Se;return this.rules.slice(tt).forEach(([gn,bn])=>St.addRule(gn,bn)),St.compile(),this.multiRegexes[tt]=St,St}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(tt,St){this.rules.push([tt,St]),St.type==="begin"&&this.count++}exec(tt){const St=this.getMatcher(this.regexIndex);St.lastIndex=this.lastIndex;let gn=St.exec(tt);if(this.resumingScanAtSamePosition()&&!(gn&&gn.index===this.lastIndex)){const bn=this.getMatcher(0);bn.lastIndex=this.lastIndex+1,gn=bn.exec(tt)}return gn&&(this.regexIndex+=gn.position+1,this.regexIndex===this.count&&this.considerAll()),gn}}function bt(it){const tt=new Ye;return it.contains.forEach(St=>tt.addRule(St.begin,{rule:St,type:"begin"})),it.terminatorEnd&&tt.addRule(it.terminatorEnd,{type:"end"}),it.illegal&&tt.addRule(it.illegal,{type:"illegal"}),tt}function Ot(it,tt){const St=it;if(it.isCompiled)return St;[mt,Dt,de,Oe].forEach(bn=>bn(it,tt)),Q.compilerExtensions.forEach(bn=>bn(it,tt)),it.__beforeBegin=null,[kt,lt,ht].forEach(bn=>bn(it,tt)),it.isCompiled=!0;let gn=null;return typeof it.keywords=="object"&&it.keywords.$pattern&&(it.keywords=Object.assign({},it.keywords),gn=it.keywords.$pattern,delete it.keywords.$pattern),gn=gn||/\w+/,it.keywords&&(it.keywords=ie(it.keywords,Q.case_insensitive)),St.keywordPatternRe=he(gn,!0),tt&&(it.begin||(it.begin=/\B|\b/),St.beginRe=he(St.begin),!it.end&&!it.endsWithParent&&(it.end=/\B|\b/),it.end&&(St.endRe=he(St.end)),St.terminatorEnd=h(St.end)||"",it.endsWithParent&&tt.terminatorEnd&&(St.terminatorEnd+=(it.end?"|":"")+tt.terminatorEnd)),it.illegal&&(St.illegalRe=he(it.illegal)),it.contains||(it.contains=[]),it.contains=[].concat(...it.contains.map(function(bn){return ct(bn==="self"?it:bn)})),it.contains.forEach(function(bn){Ot(bn,St)}),it.starts&&Ot(it.starts,tt),St.matcher=bt(St),St}if(Q.compilerExtensions||(Q.compilerExtensions=[]),Q.contains&&Q.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return Q.classNameAliases=a(Q.classNameAliases||{}),Ot(Q)}function Ge(Q){return Q?Q.endsWithParent||Ge(Q.starts):!1}function ct(Q){return Q.variants&&!Q.cachedVariants&&(Q.cachedVariants=Q.variants.map(function(he){return a(Q,{variants:null},he)})),Q.cachedVariants?Q.cachedVariants:Ge(Q)?a(Q,{starts:Q.starts?a(Q.starts):null}):Object.isFrozen(Q)?a(Q):Q}var We="11.11.1";class ut extends Error{constructor(he,Se){super(he),this.name="HTMLInjectionError",this.html=Se}}const Ft=n,ln=a,Pt=Symbol("nomatch"),Ae=7,je=function(Q){const he=Object.create(null),Se=Object.create(null),Ye=[];let bt=!0;const Ot="Could not find the language '{}', did you forget to load/include a language module?",it={disableAutodetect:!0,name:"Plain text",contains:[]};let tt={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:g};function St(J){return tt.noHighlightRe.test(J)}function gn(J){let xe=J.className+" ";xe+=J.parentNode?J.parentNode.className:"";const st=tt.languageDetectRe.exec(xe);if(st){const Mt=aa(st[1]);return Mt||(De(Ot.replace("{}",st[1])),De("Falling back to no-highlight mode for this block.",J)),Mt?st[1]:"no-highlight"}return xe.split(/\s+/).find(Mt=>St(Mt)||aa(Mt))}function bn(J,xe,st){let Mt="",en="";typeof xe=="object"?(Mt=J,st=xe.ignoreIllegals,en=xe.language):(te("10.7.0","highlight(lang, code, ...args) has been deprecated."),te("10.7.0",`Please use highlight(code, options) instead.
|
|
813
813
|
https://github.com/highlightjs/highlight.js/issues/2277`),en=J,Mt=xe),st===void 0&&(st=!0);const Sn={code:Mt,language:en};Fr("before:highlight",Sn);const zn=Sn.result?Sn.result:Qn(Sn.language,Sn.code,st);return zn.code=Sn.code,Fr("after:highlight",zn),zn}function Qn(J,xe,st,Mt){const en=Object.create(null);function Sn(Je,pt){return Je.keywords[pt]}function zn(){if(!Tt.keywords){$n.addText(cn);return}let Je=0;Tt.keywordPatternRe.lastIndex=0;let pt=Tt.keywordPatternRe.exec(cn),Lt="";for(;pt;){Lt+=cn.substring(Je,pt.index);const Qt=ia.case_insensitive?pt[0].toLowerCase():pt[0],Rn=Sn(Tt,Qt);if(Rn){const[er,il]=Rn;if($n.addText(Lt),Lt="",en[Qt]=(en[Qt]||0)+1,en[Qt]<=Ae&&(vi+=il),er.startsWith("_"))Lt+=pt[0];else{const Kc=ia.classNameAliases[er]||er;on(pt[0],Kc)}}else Lt+=pt[0];Je=Tt.keywordPatternRe.lastIndex,pt=Tt.keywordPatternRe.exec(cn)}Lt+=cn.substring(Je),$n.addText(Lt)}function Rt(){if(cn==="")return;let Je=null;if(typeof Tt.subLanguage=="string"){if(!he[Tt.subLanguage]){$n.addText(cn);return}Je=Qn(Tt.subLanguage,cn,!0,Gc[Tt.subLanguage]),Gc[Tt.subLanguage]=Je._top}else Je=bi(cn,Tt.subLanguage.length?Tt.subLanguage:null);Tt.relevance>0&&(vi+=Je.relevance),$n.__addSublanguage(Je._emitter,Je.language)}function Ht(){Tt.subLanguage!=null?Rt():zn(),cn=""}function on(Je,pt){Je!==""&&($n.startScope(pt),$n.addText(Je),$n.endScope())}function Zn(Je,pt){let Lt=1;const Qt=pt.length-1;for(;Lt<=Qt;){if(!Je._emit[Lt]){Lt++;continue}const Rn=ia.classNameAliases[Je[Lt]]||Je[Lt],er=pt[Lt];Rn?on(er,Rn):(cn=er,zn(),cn=""),Lt++}}function da(Je,pt){return Je.scope&&typeof Je.scope=="string"&&$n.openNode(ia.classNameAliases[Je.scope]||Je.scope),Je.beginScope&&(Je.beginScope._wrap?(on(cn,ia.classNameAliases[Je.beginScope._wrap]||Je.beginScope._wrap),cn=""):Je.beginScope._multi&&(Zn(Je.beginScope,pt),cn="")),Tt=Object.create(Je,{parent:{value:Tt}}),Tt}function Ar(Je,pt,Lt){let Qt=I(Je.endRe,Lt);if(Qt){if(Je["on:end"]){const Rn=new t(Je);Je["on:end"](pt,Rn),Rn.isMatchIgnored&&(Qt=!1)}if(Qt){for(;Je.endsParent&&Je.parent;)Je=Je.parent;return Je}}if(Je.endsWithParent)return Ar(Je.parent,pt,Lt)}function Tr(Je){return Tt.matcher.regexIndex===0?(cn+=Je[0],1):(xi=!0,0)}function fp(Je){const pt=Je[0],Lt=Je.rule,Qt=new t(Lt),Rn=[Lt.__beforeBegin,Lt["on:begin"]];for(const er of Rn)if(er&&(er(Je,Qt),Qt.isMatchIgnored))return Tr(pt);return Lt.skip?cn+=pt:(Lt.excludeBegin&&(cn+=pt),Ht(),!Lt.returnBegin&&!Lt.excludeBegin&&(cn=pt)),da(Lt,Je),Lt.returnBegin?0:pt.length}function Ta(Je){const pt=Je[0],Lt=xe.substring(Je.index),Qt=Ar(Tt,Je,Lt);if(!Qt)return Pt;const Rn=Tt;Tt.endScope&&Tt.endScope._wrap?(Ht(),on(pt,Tt.endScope._wrap)):Tt.endScope&&Tt.endScope._multi?(Ht(),Zn(Tt.endScope,Je)):Rn.skip?cn+=pt:(Rn.returnEnd||Rn.excludeEnd||(cn+=pt),Ht(),Rn.excludeEnd&&(cn=pt));do Tt.scope&&$n.closeNode(),!Tt.skip&&!Tt.subLanguage&&(vi+=Tt.relevance),Tt=Tt.parent;while(Tt!==Qt.parent);return Qt.starts&&da(Qt.starts,Je),Rn.returnEnd?0:pt.length}function al(){const Je=[];for(let pt=Tt;pt!==ia;pt=pt.parent)pt.scope&&Je.unshift(pt.scope);Je.forEach(pt=>$n.openNode(pt))}let os={};function Ws(Je,pt){const Lt=pt&&pt[0];if(cn+=Je,Lt==null)return Ht(),0;if(os.type==="begin"&&pt.type==="end"&&os.index===pt.index&&Lt===""){if(cn+=xe.slice(pt.index,pt.index+1),!bt){const Qt=new Error(`0 width match regex (${J})`);throw Qt.languageName=J,Qt.badRule=os.rule,Qt}return 1}if(os=pt,pt.type==="begin")return fp(pt);if(pt.type==="illegal"&&!st){const Qt=new Error('Illegal lexeme "'+Lt+'" for mode "'+(Tt.scope||"<unnamed>")+'"');throw Qt.mode=Tt,Qt}else if(pt.type==="end"){const Qt=Ta(pt);if(Qt!==Pt)return Qt}if(pt.type==="illegal"&&Lt==="")return cn+=`
|
|
814
|
-
`,1;if(rl>1e5&&rl>pt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return cn+=Lt,Lt.length}const ia=aa(J);if(!ia)throw Ne(Ot.replace("{}",J)),new Error('Unknown language: "'+J+'"');const Uc=fe(ia);let Ys="",Tt=Mt||Uc;const Gc={},$n=new tt.__emitter(tt);al();let cn="",vi=0,Ur=0,rl=0,xi=!1;try{if(ia.__emitTokens)ia.__emitTokens(xe,$n);else{for(Tt.matcher.considerAll();;){rl++,xi?xi=!1:Tt.matcher.considerAll(),Tt.matcher.lastIndex=Ur;const Je=Tt.matcher.exec(xe);if(!Je)break;const pt=xe.substring(Ur,Je.index),Lt=Ws(pt,Je);Ur=Je.index+Lt}Ws(xe.substring(Ur))}return $n.finalize(),Ys=$n.toHTML(),{language:J,value:Ys,relevance:vi,illegal:!1,_emitter:$n,_top:Tt}}catch(Je){if(Je.message&&Je.message.includes("Illegal"))return{language:J,value:Ft(xe),illegal:!0,relevance:0,_illegalBy:{message:Je.message,index:Ur,context:xe.slice(Ur-100,Ur+100),mode:Je.mode,resultSoFar:Ys},_emitter:$n};if(bt)return{language:J,value:Ft(xe),illegal:!1,relevance:0,errorRaised:Je,_emitter:$n,_top:Tt};throw Je}}function ha(J){const xe={value:Ft(J),illegal:!1,relevance:0,_top:it,_emitter:new tt.__emitter(tt)};return xe._emitter.addText(J),xe}function bi(J,xe){xe=xe||tt.languages||Object.keys(he);const st=ha(J),Mt=xe.filter(aa).filter(Sr).map(Ht=>Qn(Ht,J,!1));Mt.unshift(st);const en=Mt.sort((Ht,on)=>{if(Ht.relevance!==on.relevance)return on.relevance-Ht.relevance;if(Ht.language&&on.language){if(aa(Ht.language).supersetOf===on.language)return 1;if(aa(on.language).supersetOf===Ht.language)return-1}return 0}),[Sn,zn]=en,Rt=Sn;return Rt.secondBest=zn,Rt}function ga(J,xe,st){const Mt=xe&&Se[xe]||st;J.classList.add("hljs"),J.classList.add(`language-${Mt}`)}function En(J){let xe=null;const st=gn(J);if(St(st))return;if(Fr("before:highlightElement",{el:J,language:st}),J.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",J);return}if(J.children.length>0&&(tt.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(J)),tt.throwUnescapedHTML))throw new ut("One of your code blocks includes unescaped HTML.",J.innerHTML);xe=J;const Mt=xe.textContent,en=st?bn(Mt,{language:st,ignoreIllegals:!0}):bi(Mt);J.innerHTML=en.value,J.dataset.highlighted="yes",ga(J,st,en.language),J.result={language:en.language,re:en.relevance,relevance:en.relevance},en.secondBest&&(J.secondBest={language:en.secondBest.language,relevance:en.secondBest.relevance}),Fr("after:highlightElement",{el:J,result:en,text:Mt})}function Xn(J){tt=ln(tt,J)}const wr=()=>{qr(),te("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function kr(){qr(),te("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Vs=!1;function qr(){function J(){qr()}if(document.readyState==="loading"){Vs||window.addEventListener("DOMContentLoaded",J,!1),Vs=!0;return}document.querySelectorAll(tt.cssSelector).forEach(En)}function is(J,xe){let st=null;try{st=xe(Q)}catch(Mt){if(Ne("Language definition for '{}' could not be registered.".replace("{}",J)),bt)Ne(Mt);else throw Mt;st=it}st.name||(st.name=J),he[J]=st,st.rawDefinition=xe.bind(null,Q),st.aliases&&hr(st.aliases,{languageName:J})}function Jn(J){delete he[J];for(const xe of Object.keys(Se))Se[xe]===J&&delete Se[xe]}function yi(){return Object.keys(he)}function aa(J){return J=(J||"").toLowerCase(),he[J]||he[Se[J]]}function hr(J,{languageName:xe}){typeof J=="string"&&(J=[J]),J.forEach(st=>{Se[st.toLowerCase()]=xe})}function Sr(J){const xe=aa(J);return xe&&!xe.disableAutodetect}function Cr(J){J["before:highlightBlock"]&&!J["before:highlightElement"]&&(J["before:highlightElement"]=xe=>{J["before:highlightBlock"](Object.assign({block:xe.el},xe))}),J["after:highlightBlock"]&&!J["after:highlightElement"]&&(J["after:highlightElement"]=xe=>{J["after:highlightBlock"](Object.assign({block:xe.el},xe))})}function In(J){Cr(J),Ye.push(J)}function ss(J){const xe=Ye.indexOf(J);xe!==-1&&Ye.splice(xe,1)}function Fr(J,xe){const st=J;Ye.forEach(function(Mt){Mt[st]&&Mt[st](xe)})}function Ba(J){return te("10.7.0","highlightBlock will be removed entirely in v12.0"),te("10.7.0","Please use highlightElement now."),En(J)}Object.assign(Q,{highlight:bn,highlightAuto:bi,highlightAll:qr,highlightElement:En,highlightBlock:Ba,configure:Xn,initHighlighting:wr,initHighlightingOnLoad:kr,registerLanguage:is,unregisterLanguage:Jn,listLanguages:yi,getLanguage:aa,registerAliases:hr,autoDetection:Sr,inherit:ln,addPlugin:In,removePlugin:ss}),Q.debugMode=function(){bt=!1},Q.safeMode=function(){bt=!0},Q.versionString=We,Q.regex={concat:T,lookahead:v,either:A,optional:w,anyNumberOfTimes:y};for(const J in Xe)typeof Xe[J]=="object"&&e(Xe[J]);return Object.assign(Q,Xe),Q},_e=je({});return _e.newInstance=()=>je({}),vh=_e,_e.HighlightJS=_e,_e.default=_e,vh}var Tre=Are();const Ere=Ic(Tre),yk={},Nre="hljs-";function Mre(e){const t=Ere.newInstance();return e&&l(e),{highlight:n,highlightAuto:a,listLanguages:i,register:l,registerAlias:c,registered:u};function n(m,f,g){const h=g||yk,v=typeof h.prefix=="string"?h.prefix:Nre;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:jre,classPrefix:v});const y=t.highlight(f,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,T=w.data;return T.language=y.language,T.relevance=y.relevance,w}function a(m,f){const h=(f||yk).subset||i();let v=-1,y=0,w;for(;++v<h.length;){const T=h[v];if(!t.getLanguage(T))continue;const C=n(T,m,f);C.data&&C.data.relevance!==void 0&&C.data.relevance>y&&(y=C.data.relevance,w=C)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function i(){return t.listLanguages()}function l(m,f){if(typeof m=="string")t.registerLanguage(m,f);else{let g;for(g in m)Object.hasOwn(m,g)&&t.registerLanguage(g,m[g])}}function c(m,f){if(typeof m=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:m});else{let g;for(g in m)if(Object.hasOwn(m,g)){const h=m[g];t.registerAliases(typeof h=="string"?h:[...h],{languageName:g})}}}function u(m){return!!t.getLanguage(m)}}class jre{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],a=n.children[n.children.length-1];a&&a.type==="text"?a.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const a=this.stack[this.stack.length-1],i=t.root.children;n?a.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):a.children.push(...i)}openNode(t){const n=this,a=t.split(".").map(function(c,u){return u?c+"_".repeat(u):n.options.classPrefix+c}),i=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:a},children:[]};i.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Rre={};function _re(e){const t=e||Rre,n=t.aliases,a=t.detect||!1,i=t.languages||Cre,l=t.plainText,c=t.prefix,u=t.subset;let m="hljs";const f=Mre(i);if(n&&f.registerAlias(n),c){const g=c.indexOf("-");m=g===-1?c:c.slice(0,g)}return function(g,h){Jm(g,"element",function(v,y,w){if(v.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const T=Dre(v);if(T===!1||!T&&!a||T&&l&&l.includes(T))return;Array.isArray(v.properties.className)||(v.properties.className=[]),v.properties.className.includes(m)||v.properties.className.unshift(m);const C=R3(v,{whitespace:"pre"});let A;try{A=T?f.highlight(T,C,{prefix:c}):f.highlightAuto(C,{prefix:c,subset:u})}catch(M){const I=M;if(T&&/Unknown language/.test(I.message)){h.message("Cannot highlight as `"+T+"`, it’s not registered",{ancestors:[w,v],cause:I,place:v.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw I}!T&&A.data&&A.data.language&&v.properties.className.push("language-"+A.data.language),A.children.length>0&&(v.children=A.children)})}}function Dre(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let a;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!a&&i.slice(0,5)==="lang-"&&(a=i.slice(5)),!a&&i.slice(0,9)==="language-"&&(a=i.slice(9))}return a}const Bs={agent:{label:"Agent",labelZh:"智能体",gradient:"from-violet-500 to-indigo-600",accent:"#8b5cf6",covers:[["#7c3aed","#4f46e5"],["#8b5cf6","#6366f1"],["#a855f7","#4338ca"],["#6d28d9","#2563eb"]]},team:{label:"Team",labelZh:"AI 小队",gradient:"from-cyan-500 to-blue-600",accent:"#06b6d4",covers:[["#0891b2","#2563eb"],["#06b6d4","#3b82f6"],["#0e7490","#1d4ed8"],["#22d3ee","#4f46e5"]]},skill:{label:"Skill",labelZh:"技能",gradient:"from-amber-500 to-orange-600",accent:"#f59e0b",covers:[["#f59e0b","#ea580c"],["#d97706","#dc2626"],["#fbbf24","#f97316"],["#f59e0b","#b45309"]]},connector:{label:"Connector",labelZh:"连接器",gradient:"from-emerald-500 to-teal-600",accent:"#10b981",covers:[["#10b981","#0d9488"],["#059669","#0891b2"],["#34d399","#14b8a6"],["#16a34a","#0f766e"]]}};function nl(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function J3(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 Ire={agent:258,team:205,skill:32,connector:162};function jb(e,t){const n=Ire[e],a=J3(t),i=((n+(a%68-34))%360+360)%360,l=(i+22+(a>>>8)%24)%360;return`linear-gradient(${120+a%44}deg, hsl(${i} 72% 56%), hsl(${l} 66% 43%))`}const vk=["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 Z3(e){return vk[J3(e+"g")%vk.length]}function eC(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 Lre(e){return!e||eC(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function Pre(e,t="user"){const n=t==="org"?"shapes":"thumbs",a=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${a}&radius=50&backgroundType=gradientLinear`}function Ho(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 xk(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const tC=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,nC=/^\.{1,2}\//,Ore=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,aC=/^[A-Za-z]:[\\/]/,rC=/^\\\\[^\\]/;function zre(e){const t=e.trim();return t?!!(/^file:/i.test(t)||aC.test(t)||rC.test(t)||t.startsWith("~/")||t.startsWith("/")||nC.test(t)):!1}const Hre=/(?:%[0-9A-Fa-f]{2})+/g;function iC(e){return e.includes("%")?e.replace(Hre,t=>{const n=new Uint8Array(t.length/3);for(let a=0;a<n.length;a++)n[a]=Number.parseInt(t.slice(a*3+1,a*3+3),16);try{const a=new TextDecoder("utf-8",{fatal:!0}).decode(n);return/[^\x00-\x7F]/.test(a)?a:t}catch{return t}}):e}function Rb(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=iC(t),t=t.replace(/\\+/g,"/"),t}function zle(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,a,i)=>`${n}${a.replace(/\\+/g,"/")}${i}`)}const Bre=/^(?:(?:\/|~\/|\.\.?\/)[\p{L}\p{N}\p{M}\w.@+\-\u3000-\u303f\uff00-\uffef]+(?:\/[\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]*)*|[A-Za-z]:[\\/][\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]+(?:(?:\\|\/)[\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]*)*)$/u;function $re(e){return e.length<2||e.length>500?!1:Bre.test(e)}function sC(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Nu(e,t){if(!e)return e;if(tC.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const a=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,i=a.split("/"),l=[];for(const u of i)!u||u==="."||(u===".."?l.pop():l.push(u));const c=l.join("/");return a.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function wk(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function kk(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(aC.test(n)||rC.test(n)){const{path:c,fragment:u}=wk(n);return{kind:"file",path:Nu(c,t),fragment:u}}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:Rb(n)}:{kind:"passthrough"};const a=wk(n),i=iC(a.path),l=a.fragment;return tC.test(i)?{kind:"file",path:Nu(i,t),fragment:l}:nC.test(i)?{kind:"file",path:Nu(i,t),fragment:l}:i&&Ore.test(i)&&!i.includes("://")?{kind:"file",path:Nu(i,t),fragment:l}:{kind:"passthrough"}}function qre(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 a=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const i of a)if(sC(i.textContent||"")===t||i.id===t){n=i;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function oC(e){return e.type==="text"?e.value??"":(e.children??[]).map(oC).join("")}function Fre(){return e=>{const t=new Map,n=a=>{if(a.type==="element"&&a.tagName&&/^h[1-6]$/.test(a.tagName)){const i=oC(a).trim();let l=sC(i);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),a.properties={...a.properties??{},id:l}}}for(const i of a.children??[])n(i)};n(e)}}function Sk(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let a=0,i="";for(const l of e.matchAll(n))i+=t(e.slice(a,l.index)),i+=l[0],a=l.index+l[0].length;return i+=t(e.slice(a)),i}function Hle(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,a)=>`$$${a}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,a)=>`$${a}$`),t}function Ure(e){return e.replace(/[$](?=[0-9])/g,(n,a,i)=>a>0&&i.charCodeAt(a-1)===92?n:"\\"+n)}const Mu="#mention:";function Ble(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,u)=>{const m=c??u;return`[@${m}](${Mu}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.length-l.length);let a="",i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){a+=e.slice(i);break}if(a+=e.slice(i,l),e[l+1]==="["){const g=e.indexOf("]",l+2);if(g>l+2){const h=e.slice(l+2,g);a+=`[@${h}](${Mu}${encodeURIComponent(h)})`,i=g+1;continue}}const c=e.slice(l+1),u=c.toLowerCase(),m=n.find(g=>u.startsWith(g.toLowerCase()));if(m){const g=c.slice(0,m.length);a+=`[@${g}](${Mu}${encodeURIComponent(g)})`,i=l+1+m.length;continue}const f=c.match(/^([\w\p{L}\p{N}]+)/u);if(f){const g=f[1];a+=`[@${g}](${Mu}${encodeURIComponent(g)})`,i=l+1+g.length;continue}a+="@",i=l+1}return a}const lC="#entity:",Gre=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),Kre=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function cC(e,t){const n=e.slice(0,t),a=n.lastIndexOf("](");return a===-1?!1:n.indexOf(")",a+2)===-1}function $le(e){return e.replace(Kre,(t,n,a)=>`[${n}](${lC}${a})`)}function qle(e){return e.replace(Gre,(t,n,a)=>cC(e,a)?t:`[${t}](${lC}${t})`)}const Vre=["\\s","<",">","`","\\u4e00-\\u9fff","\\u3000-\\u303f","\\uff00-\\uffef"].join(""),Wre=new RegExp(`https?://[^${Vre}]+`,"gi"),Yre=/(\*{1,3}|_{1,3}|~{1,2})$/;function Qre(e,t,n){const a=n.match(Yre);if(!a)return null;const i=a[1];return e.slice(Math.max(0,t-i.length),t)===i?i:null}function Xre(e){return e.replace(Wre,(t,n)=>{if(cC(e,n))return t;let a=t.replace(/[.,;:!?\]\)"']+$/,"");if(!a)return t;const i=Qre(e,n,a);if(i&&(a=a.slice(0,a.length-i.length)),!a)return t;const l=t.slice(a.length);return/[()[\]]/.test(a)?t:`[${a}](${a})${l}`})}function Jre(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const Zre={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 eie(e){return Zre[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function tie(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const nie=24;function aie(e){const t=e.indexOf("_");return t<0?!1:e.length>=t+1+nie}const dC={tsk:{load:async()=>(await Te.tasks.list({lean:!0,pageSize:500})).tasks.map(e=>e.id)},req:{load:async()=>(await Te.requirements.list({lean:!0})).requirements.map(e=>e.id)},proj:{load:async()=>(await Te.projects.list()).projects.map(e=>e.id)},dlv:{load:async()=>(await Te.deliverables.search({limit:500})).results.map(e=>e.id)},agt:{load:async()=>(await Te.agents.list({lean:!0})).agents.map(e=>e.id)},team:{load:async()=>(await Te.teams.list()).teams.map(e=>e.id)}},xh=new Map,Ck=new Map;function rie(e){const t=dC[e];if(!t)return null;let n=xh.get(e);return n||(n=t.load().catch(a=>{throw xh.delete(e),a}),xh.set(e,n)),n}async function iie(e){if(!e)return null;const t=e.indexOf("_");if(t<0)return null;const n=e.slice(0,t);if(!dC[n])return null;if(aie(e))return e;const a=Ck.get(e);if(a!==void 0)return a;const i=(await rie(n)??[]).filter(c=>c.startsWith(e)),l=i.length===1?i[0]:null;return Ck.set(e,l),l}const sie=k.lazy(()=>Ca(()=>import("./MarkdownMessage-DwxvYN4X.js"),[]).then(e=>({default:e.MarkdownMessage}))),oie={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Ak={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 lie({item:e,onClose:t,onOpenInPage:n}){const{t:a}=xt(["agent","common"]),i=oie[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=Ak[e.status]??Ak.active,c=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=f=>{f.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const u=o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[o.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),o.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:[o.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:[o.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${i.color}`,children:i.icon}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),o.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[o.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),o.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),o.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:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:a("agent:deliverables.summary")}),o.jsx("div",{className:"mt-1.5",children:o.jsx(k.Suspense,{fallback:o.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:o.jsx(sie,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:a("agent:deliverables.reference")}),o.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),c?o.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:a("common:open")}):o.jsx("button",{onClick:()=>{Te.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:a("common:open")})]})]}),e.diffStats&&o.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),o.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),o.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),o.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&o.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),o.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&o.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&o.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>o.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),o.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[o.jsxs("span",{children:[a("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),o.jsxs("span",{children:[a("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&o.jsx("span",{children:a("agent:deliverables.accessed",{count:e.accessCount})})]})]}),o.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:[o.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:[o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),a("agent:deliverables.openInPage")]}),o.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:a("common:close")})]})]})]});return typeof document<"u"?Lc.createPortal(u,document.body):u}const _b=new Set;function Ds(e){e&&_b.add(e)}function Eg(e){e&&_b.delete(e)}const Db="markus:browser-history",uC=300;function Ng(e){return`${e.kind}:${e.target}`}function Dm(e,t){const n=(t||"").trim();return n?e!=="url"?!0:n!=="about:blank"&&n!=="about:newtab":!1}function mC(e){const t=(e||"").trim();return t?t.startsWith("//")?`https:${t}`:t:""}function cie(e){return e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"")}function Ib(e){return(e||"").trim()}function pC(e){const t=(e.id||"").trim();if(t)return t;const n=`${e.reference||""}|${e.title||""}|${(e.summary||"").slice(0,48)}`;return n==="||"?"":n}function die(e){if(e.kind==="file"){const t=Ib(e.path||"");return Dm("file",t)?{kind:"file",target:t,title:(e.title||"").trim()||void 0}:null}if(e.kind==="deliverable"){const t=e.deliverable;if(!t)return null;const n=pC(t);return Dm("deliverable",n)?{kind:"deliverable",target:n,title:(t.title||"").trim()||void 0,location:(t.reference||"").trim()||void 0}:null}return null}function uie(e){return e.kind==="url"?cie(e.target):e.kind==="deliverable"&&e.location||e.target}function Tk(e){return typeof e=="string"&&e.trim()?e:void 0}function mie(e){if(!e||typeof e!="object")return null;const t=e,n=t.kind==="file"||t.kind==="deliverable"?t.kind:"url",a=typeof t.target=="string"?t.target:n==="url"&&typeof t.url=="string"?t.url:"",i=n==="url"?mC(a):Ib(a);return Dm(n,i)?{kind:n,target:i,title:Tk(t.title),location:n==="deliverable"?Tk(t.location):void 0,visitedAt:typeof t.visitedAt=="number"&&Number.isFinite(t.visitedAt)?t.visitedAt:0,visitCount:typeof t.visitCount=="number"&&t.visitCount>0?t.visitCount:1}:null}function Lb(){try{const e=localStorage.getItem(Db);if(!e)return[];const t=JSON.parse(e);if(!Array.isArray(t))return[];const n=[];for(const a of t){const i=mie(a);i&&n.push(i)}return n}catch{return[]}}function Pb(e){try{localStorage.setItem(Db,JSON.stringify(e.slice(0,uC)))}catch{}}function Ob(){return Lb().sort((e,t)=>t.visitedAt-e.visitedAt)}const Mg=new Set;function zb(e){for(const t of Mg)try{t(e)}catch{}}function Fle(e){Mg.add(e);const t=n=>{n.key!==null&&n.key!==Db||e(Ob())};return typeof window<"u"&&window.addEventListener("storage",t),()=>{Mg.delete(e),typeof window<"u"&&window.removeEventListener("storage",t)}}function fC(e,t=Date.now()){const n=e.kind==="url"?mC(e.target):Ib(e.target);if(!Dm(e.kind,n))return Ob();const a=`${e.kind}:${n}`,i=Lb(),l=i.find(m=>Ng(m)===a),c=i.filter(m=>Ng(m)!==a),u=[{kind:e.kind,target:n,title:(e.title||"").trim()||l?.title,location:(e.location||"").trim()||l?.location,visitedAt:t,visitCount:(l?.visitCount??0)+1},...c].sort((m,f)=>f.visitedAt-m.visitedAt).slice(0,uC);return Pb(u),zb(u),u}function Ule(e,t,n=Date.now()){return fC({kind:"url",target:e,title:t},n)}function Gle(e){const t=Lb().filter(n=>Ng(n)!==e);return Pb(t),zb(t),t}function Kle(){return Pb([]),zb([]),[]}function Vle(e,t=8){const n=Ob(),a=(e||"").trim().toLowerCase();if(!a)return n.slice(0,t);const i=a.split(/\s+/).filter(Boolean),l=[];for(const c of n){const u=c.target.toLowerCase(),m=(c.title||"").toLowerCase(),f=uie(c).toLowerCase(),g=`${f} ${m}`;let h=0,v=!0;for(const w of i){if(!g.includes(w)){v=!1;break}f.startsWith(w)?h+=120:u.startsWith(w)?h+=100:new RegExp(`(^|[./:?&=_-])${pie(w)}`).test(f)?h+=60:m.startsWith(w)?h+=50:h+=20}if(!v)continue;const y=Math.max(0,(Date.now()-c.visitedAt)/864e5);h+=Math.max(0,30-y*2),h+=Math.min(30,c.visitCount*3),l.push({entry:c,score:h})}return l.sort((c,u)=>u.score-c.score||u.entry.visitedAt-c.entry.visitedAt).slice(0,t).map(c=>c.entry)}function pie(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wle(e){if(!e.ctrlKey||e.metaKey||e.altKey)return null;const t=(e.key||"").toLowerCase();return t==="n"?"next":t==="p"?"prev":null}function Yle(e,t,n){return t<=0?-1:e<0?n==="next"?0:t-1:(e+(n==="next"?1:-1)+t)%t}const hC="markus_right_panel_v1",fie=10,jg=new Map;function hie(e,t=3e3){jg.set(e,Date.now()+t)}function gie(e){const t=jg.get(e);return t==null?!1:Date.now()>t?(jg.delete(e),!1):!0}function bie(e){return e.kind==="terminal"}function nc(e){return e.kind==="file"?`file:${e.path}`:e.kind==="url"?`url:${e.browserId||e.url}`:e.kind==="terminal"?`terminal:${e.terminalId}`:`deliverable:${pC(e.deliverable)||"unknown"}`}function Ek(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 Yi(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function ju(e){let t=e;for(;t.length>fie;){let n=-1;for(let i=t.length-1;i>=0;i--)if(!t[i].pinned){n=i;break}if(n<0)break;const a=t[n];a&&(Rg(a.payload),_g(a.payload)),t=t.filter((i,l)=>l!==n)}return t}function Rg(e){e?.kind==="url"&&e.browserId&&(hie(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function _g(e){e?.kind==="terminal"&&e.terminalId&&(Eg(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function yie(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?Cc(t.url||"")||Cc(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 vie(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 xie(){try{const e=localStorage.getItem(hC);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 wie(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=xie();if(!t)return e;const n=t.browserTabs.map((y,w)=>{try{return vie(y,w)}catch{return null}}).filter(y=>!(!y||y.payload.kind==="terminal"||y.payload.kind==="url"&&Cc(y.payload.url||""))),a=n.some(y=>y.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,i=(t.terminalTabs||[]).map((y,w)=>{const T=`term_${Date.now().toString(36)}_${w.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return Ds(T),{id:y.id||Yi(),title:y.title||"Terminal",payload:{kind:"terminal",terminalId:T,title:y.title||"Terminal",cwd:y.cwd}}}),l=i.some(y=>y.id===t.terminalActiveId)?t.terminalActiveId:i[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,u=!!t.terminalCollapsed&&i.length>0,m=c?[]:n,f=c?null:a,g=u?[]:i,h=u?null:l;let v=t.mode;return v==="terminal"&&g.length===0&&!u&&(v="browser"),v==="browser"&&m.length===0&&g.length>0&&(v="terminal"),{mode:v,browserTabs:m,browserActiveId:f,terminalTabs:g,terminalActiveId:h,stashedBrowserTabs:n,stashedBrowserActiveId:a,stashedTerminalTabs:i,stashedTerminalActiveId:l}}const gC=k.createContext(null);function kie({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),a=k.useMemo(()=>wie(),[]),[i,l]=k.useState(a.mode),[c,u]=k.useState(a.browserTabs),[m,f]=k.useState(a.terminalTabs),[g,h]=k.useState(a.browserActiveId),[v,y]=k.useState(a.terminalActiveId),[w,T]=k.useState(!1),[C,A]=k.useState(!1),[M,I]=k.useState("l0"),[B,K]=k.useState(null),j=k.useCallback(ye=>I(ye),[]),z=k.useCallback(ye=>K(ye),[]);k.useEffect(()=>{const ye=De=>{if(!(De instanceof HTMLElement))return!1;const te=De.tagName;return te==="INPUT"||te==="TEXTAREA"||te==="SELECT"?!0:De.isContentEditable},Ne=De=>{if(!(De.target instanceof Element))return;const te=document.activeElement;if(ye(te)){const we=te===De.target||te.contains(De.target),Le=!!De.target.closest("[data-keep-edit-focus]"),He=ye(De.target)||!!De.target.closest('input, textarea, select, [contenteditable="true"]'),de=!!De.target.closest(".xterm");!we&&!Le&&!He&&!de&&te.blur()}const F=De.target.closest("[data-keyboard-pane]");if(!F)return;const ae=F.getAttribute("data-keyboard-pane");if(!(ae!=="l0"&&ae!=="l1"&&ae!=="l2"&&ae!=="content")&&(I(ae),ae==="l0")){const Le=De.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");Le&&K(Le)}};return document.addEventListener("pointerdown",Ne,!0),()=>document.removeEventListener("pointerdown",Ne,!0)},[]);const U=k.useRef(a.stashedBrowserTabs.length>0?a.stashedBrowserTabs:a.browserTabs),Y=k.useRef(a.stashedBrowserActiveId??a.browserActiveId),$=k.useRef(a.stashedTerminalTabs.length>0?a.stashedTerminalTabs:a.terminalTabs),D=k.useRef(a.stashedTerminalActiveId??a.terminalActiveId),W=k.useRef(a.browserActiveId),X=k.useRef(a.terminalActiveId),H=k.useRef(a.browserTabs),se=k.useRef(a.terminalTabs),R=k.useRef(a.mode);W.current=g,X.current=v,H.current=c,se.current=m,R.current=i,k.useEffect(()=>{(a.mode==="terminal"||a.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),k.useEffect(()=>{const ye=c.length===0&&U.current.length>0,Ne=m.length===0&&$.current.length>0,De=ye?U.current:c,te=Ne?$.current:m,F=De.map(yie).filter(Le=>!!Le),ae=te.filter(Le=>Le.payload.kind==="terminal").map(Le=>({id:Le.id,title:Le.title,cwd:Le.payload.kind==="terminal"?Le.payload.cwd:void 0})),we={mode:i,browserTabs:F,browserActiveId:ye?Y.current:g,terminalTabs:ae,terminalActiveId:Ne?D.current:v,browserCollapsed:ye,terminalCollapsed:Ne};try{localStorage.setItem(hC,JSON.stringify(we))}catch{}},[i,c,g,m,v]);const re=k.useCallback(ye=>n(ye),[]),ue=k.useCallback(()=>n(ye=>!ye),[]),Ce=k.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),q=k.useCallback(ye=>{l(Ne=>Ne===ye?Ne:(ye==="terminal"&&Ce(),ye))},[Ce]),V=k.useCallback(ye=>{if(ye==="terminal"){if(Ce(),l("terminal"),n(!0),m.length>0)return;if($.current.length>0){const Le=$.current,He=D.current&&Le.some(de=>de.id===D.current)?D.current:Le[0].id;f(Le),y(He),D.current=He;return}const F=Yi(),ae=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;Ds(ae);const we={id:F,title:"Terminal",payload:{kind:"terminal",terminalId:ae,title:"Terminal"}};$.current=[we],f([we]),y(we.id),D.current=we.id;return}if(l("browser"),n(!0),c.length>0)return;if(U.current.length>0){const F=U.current,ae=Y.current&&F.some(we=>we.id===Y.current)?Y.current:F[0].id;u(F),h(ae),Y.current=ae;return}const Ne=Yi(),De=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,te={id:Ne,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:De}};U.current=[te],u([te]),h(te.id),Y.current=te.id},[c.length,m.length,Ce]),ce=k.useCallback(ye=>{const Ne=nc(ye),De=Yi(),te=bie(ye),F=die(ye);if(F&&fC(F),te){ye.kind==="terminal"&&Ds(ye.terminalId),l("terminal"),Ce();const ae=se.current,we=ae.find(de=>nc(de.payload)===Ne)??$.current.find(de=>nc(de.payload)===Ne);let Le,He;if(we)He=we.id,Le=ae.some(de=>de.id===we.id)?ae:ju([we,...ae]);else{const de={id:De,title:Ek(ye),payload:ye};Le=ju([de,...ae]),He=De}$.current=Le,se.current=Le,f(Le),y(He),D.current=He,X.current=He}else{l("browser");const ae=H.current,we=ae.find(de=>nc(de.payload)===Ne)??U.current.find(de=>nc(de.payload)===Ne);let Le,He;if(we)He=we.id,Le=ae.some(de=>de.id===we.id)?ae:ju([we,...ae]);else{const de={id:De,title:Ek(ye),payload:ye};Le=ju([de,...ae]),He=De}U.current=Le,H.current=Le,u(Le),h(He),Y.current=He,W.current=He}n(!0)},[Ce]),P=k.useCallback(ye=>{const Ne=H.current,De=Ne.findIndex(fe=>fe.id===ye);if(De>=0){const fe=Ne[De]?.payload,Ge=Ne.filter(Ft=>Ft.id!==ye),ct=W.current,ut=(Ne.some(Ft=>Ft.id===ct)?ct:Ne[0]?.id??null)===ye||Ge.length===0?Ge[Math.min(De,Ge.length-1)]?.id??null:void 0;U.current=Ge,H.current=Ge,u(Ge),Ge.length===0&&R.current==="browser"&&T(!1),ut!==void 0&&(h(ut),Y.current=ut,W.current=ut),Rg(fe);return}const te=se.current,F=te.findIndex(fe=>fe.id===ye);if(F<0)return;const ae=te[F]?.payload,we=te.filter(fe=>fe.id!==ye),Le=X.current,de=(te.some(fe=>fe.id===Le)?Le:te[0]?.id??null)===ye||we.length===0?we[Math.min(F,we.length-1)]?.id??null:void 0;$.current=we,se.current=we,f(we),we.length===0&&R.current==="terminal"&&T(!1),de!==void 0&&(y(de),D.current=de,X.current=de),_g(ae)},[]),Ee=k.useCallback(()=>{const ye=H.current.map(De=>De.payload),Ne=se.current.map(De=>De.payload);H.current=[],se.current=[],U.current=[],Y.current=null,$.current=[],D.current=null,W.current=null,X.current=null,u([]),f([]),h(null),y(null),T(!1);for(const De of ye)Rg(De);for(const De of Ne)_g(De)},[]),$e=k.useCallback(ye=>{R.current==="terminal"?(y(ye),D.current=ye):(h(ye),Y.current=ye)},[]),qe=k.useCallback((ye,Ne)=>{u(De=>{let te=!1;const F=De.map(ae=>{if(ae.payload.kind!=="url"||ae.payload.browserId!==ye)return ae;const we=Ne.url??ae.payload.url,Le=Ne.title||ae.payload.title||we,He=Ne.pageId??ae.payload.pageId;return we===ae.payload.url&&Le===(ae.payload.title||ae.title)&&He===ae.payload.pageId&&Le===ae.title?ae:(te=!0,{...ae,title:Le,payload:{...ae.payload,url:we,title:Le,...He!=null?{pageId:He}:{}}})});return te&&(U.current=F),te?F:De})},[]),Ze=k.useCallback((ye,Ne)=>{f(De=>{let te=!1;const F=De.map(ae=>{if(ae.payload.kind!=="terminal"||ae.payload.terminalId!==ye)return ae;const we=Ne.title||ae.payload.title||ae.title,Le=Ne.cwd??ae.payload.cwd;return we===ae.title&&Le===ae.payload.cwd&&we===(ae.payload.title||ae.title)?ae:(te=!0,{...ae,title:we,payload:{...ae.payload,title:we,...Le!=null?{cwd:Le}:{}}})});return te&&($.current=F),te?F:De})},[]),Qe=k.useCallback(()=>{R.current==="terminal"?(f(ye=>ye.length===0?ye:($.current=ye,X.current&&(D.current=X.current),[])),y(null)):(u(ye=>ye.length===0?ye:(U.current=ye,W.current&&(Y.current=W.current),[])),h(null),Ce()),T(!1)},[Ce]),Re=k.useCallback(()=>{if(R.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(U.current.length>0){const He=U.current,de=Y.current&&He.some(fe=>fe.id===Y.current)?Y.current:He[0].id;u(He),h(de),Y.current=de,n(!0);return}const ae=Yi(),we=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,Le={id:ae,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:we}};U.current=[Le],u([Le]),h(Le.id),Y.current=Le.id,n(!0);return}const ye=Yi(),Ne=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let De,te=!1,F=!1;l("browser"),u(ae=>{if(ae.length>0)return U.current=ae,W.current&&(Y.current=W.current),F=!0,De=null,[];if(U.current.length>0){te=!0;const Le=U.current;return De=Y.current&&Le.some(de=>de.id===Y.current)?Y.current:Le[0].id,Le}te=!0;const we={id:ye,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ne}};return U.current=[we],De=we.id,[we]}),te&&n(!0),F?(h(null),T(!1),Ce()):De!=null&&(h(De),Y.current=De)},[c.length,m.length,Ce]),Xe=k.useCallback(()=>{if(R.current==="browser"&&c.length>0){if(l("terminal"),Ce(),m.length>0){n(!0);return}if($.current.length>0){const He=$.current,de=D.current&&He.some(fe=>fe.id===D.current)?D.current:He[0].id;f(He),y(de),D.current=de,n(!0);return}const ae=Yi(),we=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;Ds(we);const Le={id:ae,title:"Terminal",payload:{kind:"terminal",terminalId:we,title:"Terminal"}};$.current=[Le],f([Le]),y(Le.id),D.current=Le.id,n(!0);return}const ye=Yi(),Ne=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;Ds(Ne);let De,te=!1,F=!1;l("terminal"),Ce(),f(ae=>{if(ae.length>0)return $.current=ae,X.current&&(D.current=X.current),F=!0,De=null,[];if($.current.length>0){te=!0;const Le=$.current;return De=D.current&&Le.some(de=>de.id===D.current)?D.current:Le[0].id,Le}te=!0;const we={id:ye,title:"Terminal",payload:{kind:"terminal",terminalId:Ne,title:"Terminal"}};return $.current=[we],De=we.id,[we]}),te&&n(!0),F?(y(null),T(!1)):De!=null&&(y(De),D.current=De)},[c.length,m.length,Ce]),wt=k.useCallback(ye=>{const Ne=R.current==="terminal"?m:c;if(Ne.length<2)return;const De=R.current==="terminal"?X.current:W.current,F=(Math.max(0,Ne.findIndex(we=>we.id===De))+ye+Ne.length)%Ne.length,ae=Ne[F].id;R.current==="terminal"?(y(ae),D.current=ae):(h(ae),Y.current=ae)},[c,m]),mt=k.useCallback(ye=>{const De=(R.current==="terminal"?m:c)[ye];De&&(R.current==="terminal"?(y(De.id),D.current=De.id):(h(De.id),Y.current=De.id))},[c,m]),kt=k.useCallback(()=>{if(R.current==="terminal"){const Ne=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ce({kind:"terminal",terminalId:Ne,title:"Terminal"});return}const ye=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ce({kind:"url",url:"about:blank",title:"New Tab",browserId:ye})},[ce]),lt=k.useCallback(ye=>{const Ne=se.current,De=Ne.findIndex(He=>He.payload.kind==="terminal"&&He.payload.terminalId===ye);if(De<0){Eg(ye),window.markusDesktop?.terminal?.destroy(ye);return}const te=Ne[De];if(Ne.length>1){P(te.id);return}Eg(ye),window.markusDesktop?.terminal?.destroy(ye);const F=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;Ds(F);const ae=te.payload.kind==="terminal"&&(te.payload.title||te.title)||"Terminal",we=te.payload.kind==="terminal"?te.payload.cwd:void 0,Le={id:te.id,title:ae,payload:{kind:"terminal",terminalId:F,title:ae,cwd:we}};$.current=[Le],f([Le]),y(Le.id),D.current=Le.id,R.current!=="terminal"&&l("terminal")},[P]),Dt=k.useCallback(ye=>T(ye),[]),ht=k.useCallback(()=>T(ye=>!ye),[]),Oe=i==="terminal"?m:c,Nt=i==="terminal"?v:g,Gt=Oe.find(ye=>ye.id===Nt)??Oe[0]??null,ie=Gt?.payload??null,et=Oe.length>0,at=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:re,toggleLeftCollapsed:ue,keyboardPane:M,setKeyboardPane:j,l0FocusPageId:B,setL0FocusPageId:z,rightPanelMode:i,setRightPanelMode:q,switchRightPanelMode:V,rightPanel:ie,rightPanelOpen:et,rightPanelTabs:Oe,activeRightPanelTabId:Gt?.id??null,openRightPanel:ce,closeRightPanel:Ee,closeRightPanelTab:P,setActiveRightPanelTab:$e,updateRightPanelBrowserTab:qe,updateRightPanelTerminalTab:Ze,toggleRightPanel:Re,toggleTerminalPanel:Xe,collapseRightPanelOnly:Qe,cycleRightPanelTab:wt,activateRightPanelTabAt:mt,openNewRightPanelTab:kt,handleTerminalExit:lt,rightPanelFullscreen:w,setRightPanelFullscreen:Dt,toggleRightPanelFullscreen:ht,hostAvailable:C,setHostAvailable:A}),[t,re,ue,M,j,B,z,i,q,V,ie,et,Oe,Gt,ce,Ee,P,$e,qe,Ze,Re,Xe,Qe,wt,mt,kt,lt,w,Dt,ht,C]);return o.jsx(gC.Provider,{value:at,children:e})}function pp(){return k.useContext(gC)}const Sie={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function bC(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const yC={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},vC={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},Cie=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function Im(e){return Cie.test(e.trim())}function Aie(e){const t=e.split("_")[0]?.toLowerCase();return t?Sie[t]:void 0}async function xC(e){const t=await iie(e)??e;t.startsWith("tsk_")?yt.navigate(me.WORK,{openTask:t}):t.startsWith("req_")?yt.navigate(me.WORK,{openRequirement:t}):t.startsWith("proj_")?yt.navigate(me.WORK,{projectId:t}):t.startsWith("dlv_")?yt.navigate(me.DELIVERABLES,{openDeliverable:t}):t.startsWith("agt_")?yt.navigate(me.TEAM,{agentId:t}):t.startsWith("team_")&&yt.navigate(me.TEAM,{selectTeam:t})}const Qu=new Map,Ru=new Map,Xu=new Map;function Tie(e,t){const n=Xu.get(e)??new Set;return n.add(t),Xu.set(e,n),()=>{n.delete(t),n.size===0&&Xu.delete(e)}}function Eie(e){Qu.delete(e);for(const t of Xu.get(e)??[])t()}const Nie=["task:update","task:create","requirement:update","requirement:updated","deliverable:update","deliverable:updated","project:update","team:update"];function Mie(e){const t=e?.payload??{};for(const n of["taskId","requirementId","deliverableId","projectId","teamId","id"]){const a=t[n];if(typeof a=="string")return a}for(const n of["requirement","deliverable","task","project","team"]){const a=t[n];if(a&&typeof a.id=="string")return a.id}}let Nk=!1;function jie(){if(Nk)return;Nk=!0;const e=t=>{const n=Mie(t);n&&Eie(n)};for(const t of Nie)try{_s.on(t,e)}catch{}}async function Rie(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const a=await Te.tasks.get(e);return{...n,title:a.task.title,status:a.task.status,blockedReason:a.task.blockedReason??null}}case"requirement":{const a=await Te.requirements.get(e),i=a.requirement;return{...n,title:a.requirement.title,status:a.requirement.status,blockedReason:i.blockedReason??null}}case"project":{const a=await Te.projects.get(e);return{...n,title:a.project.name,status:a.project.status,summary:a.project.description}}case"deliverable":{const a=await Te.deliverables.get(e);return{...n,title:a.deliverable.title,status:a.deliverable.status,summary:a.deliverable.summary,deliverable:a.deliverable}}case"agent":{const a=await Te.agents.get(e);return{...n,title:a.name,summary:a.role}}case"team":{const i=(await Te.teams.list()).teams.find(l=>l.id===e);return{...n,title:i?.name??e,notFound:!i}}}}catch{}return{...n,notFound:!0}}function wC(e,t){const n=t??Aie(e),[a,i]=k.useState(()=>Qu.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){i({id:e,type:"task",title:e,loading:!1,notFound:!0});return}let l=!0;const c=m=>{const f=m?Qu.get(e):void 0;if(f){i(f);return}m&&i(h=>({...h,type:n,loading:!0}));let g=Ru.get(e);g||(g=Rie(e,n),Ru.set(e,g)),g.then(h=>{Qu.set(e,h),Ru.delete(e),l&&i(h)}).catch(()=>{Ru.delete(e),l&&i({id:e,type:n,title:e,loading:!1,notFound:!0})})};c(!0),jie();const u=Tie(e,()=>c(!1));return()=>{l=!1,u()}},[e,n]),a}function kC(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function bc({id:e,type:t,label:n}){const a=wC(e,t),i=pp(),l=yC[a.type]??"🔗",c=n??(a.loading||a.notFound?kC(e):a.title),u=m=>{if(m.preventDefault(),m.stopPropagation(),a.type==="deliverable"&&a.deliverable&&i?.hostAvailable){i.openRightPanel({kind:"deliverable",deliverable:a.deliverable});return}xC(e)};return o.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:u,title:`${vC[a.type]}: ${a.notFound?e:a.title} (${e})`,children:[o.jsx("span",{className:"text-[10px]",children:l}),o.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:c})]})}function _ie({id:e,type:t,label:n}){const{t:a}=xt(["common"]),i=wC(e,t),[l,c]=k.useState(!1),u=pp(),m=yC[i.type]??"🔗",f=()=>{if(i.type==="deliverable"&&i.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:i.deliverable});return}c(!0);return}xC(e)},g=i.loading?kC(e):n||(i.notFound?e:i.title);return o.jsxs("span",{className:"not-prose block my-2",children:[o.jsxs("button",{type:"button",onClick:f,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:[o.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:m}),o.jsxs("span",{className:"flex-1 min-w-0 block",children:[o.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:vC[i.type]}),i.status&&(()=>{const h=i.type==="task"||i.type==="requirement"?cV(i.status,a,i.blockedReason):null;return o.jsx("span",{"data-testid":"entity-status","data-status":i.status,className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${h?.tone?.chip??Tn[iV(i.type,i.status)].chip}`,children:h?.label??i.status})})()]}),o.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${i.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:g}),i.summary&&i.summary.trim()!==i.title.trim()&&o.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:i.summary})]}),o.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:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l&&i.deliverable&&o.jsx(lie,{item:i.deliverable,onClose:()=>c(!1),onOpenInPage:h=>{c(!1),yt.navigate(me.DELIVERABLES,{openDeliverable:h})}})]})}function Die(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Iie(e){if((e.includes("\\")?"\\":"/")==="/")return{segments:e.split("/").filter(Boolean),root:"/"};const n=e.match(/^([A-Za-z]:\\)(.*)$/);return n?{segments:n[2].split("\\").filter(Boolean),root:n[1]}:{segments:e.split("\\").filter(Boolean),root:""}}function Lie(e,t,n){if(t.length===0)return e||".";const a=t.join(n);return n==="/"?e==="/"?`/${a}`:`${e}${a}`:`${e}${a}`}const Mk={md:"MD",markdown:"MD",html:"HTML",htm:"HTML",json:"JSON",csv:"CSV",pdf:"PDF",docx:"DOCX",doc:"DOC",xlsx:"XLSX",xls:"XLS",pptx:"PPTX",ppt:"PPT",txt:"TXT",ts:"TS",tsx:"TSX",js:"JS",jsx:"JSX",py:"PY",css:"CSS"},Dg={png:"IMG",jpg:"IMG",jpeg:"IMG",gif:"IMG",webp:"IMG",svg:"IMG",bmp:"IMG",ico:"IMG",avif:"IMG",mp3:"AUDIO",wav:"AUDIO",ogg:"AUDIO",flac:"AUDIO",aac:"AUDIO",m4a:"AUDIO",mp4:"VIDEO",webm:"VIDEO",mov:"VIDEO",mkv:"VIDEO",avi:"VIDEO",m4v:"VIDEO"};function Pie(e,t=!1){if(t)return"目录";if(!e)return"文件";const n=e.replace(/^\./,"").toLowerCase();return Dg[n]?Dg[n]:Mk[n]?Mk[n]:n.slice(0,6).toUpperCase()||"文件"}function Oie({path:e,entries:t,onNavigate:n,onOpenFile:a,onReveal:i,onCopyPath:l,emptyText:c}){const{segments:u,root:m}=k.useMemo(()=>Iie(e),[e]),f=e.includes("\\")?"\\":"/",[g,h]=k.useState(!1),v=async()=>{const w=l?.(e);try{if(w&&typeof w.then=="function"&&await w===!1)return}catch{return}h(!0),window.setTimeout(()=>h(!1),2e3)},y=k.useMemo(()=>{const w=[];m&&w.push({label:m.replace(/[\\/]$/,""),path:m});let T=m;for(let C=0;C<u.length;C++)T=Lie(m,u.slice(0,C+1),f),w.push({label:u[C],path:T});return w},[m,u,f]);return o.jsxs("div",{className:"flex flex-col min-h-0 h-full",children:[(i||l)&&o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle bg-surface-secondary/50 shrink-0","data-testid":"dir-top-actions",children:[o.jsx("span",{className:"flex-1 min-w-0 text-[11px] font-mono text-fg-tertiary truncate",title:e,children:e}),l&&o.jsx("button",{className:`shrink-0 text-[11px] cursor-pointer transition-colors ${g?"text-green-500 font-medium":"text-fg-secondary hover:text-fg-primary hover:underline"}`,onClick:()=>{v()},title:g?"已复制":"复制路径",children:g?"✓ 已复制":"复制路径"}),i&&o.jsx("button",{className:"shrink-0 text-[11px] text-fg-secondary hover:text-fg-primary hover:underline cursor-pointer",onClick:()=>i(e),children:"在文件浏览器中显示"})]}),o.jsx("div",{className:"flex items-center gap-1 flex-wrap px-3 py-2 border-b border-border-subtle bg-surface-secondary/50 text-xs shrink-0","data-testid":"dir-breadcrumb",children:y.map((w,T)=>{const C=T===y.length-1;return o.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[T>0&&o.jsx("span",{className:"text-fg-tertiary select-none",children:"/"}),C?o.jsx("span",{className:"text-fg-primary font-medium truncate max-w-[180px]",children:w.label}):o.jsx("button",{className:"text-fg-secondary hover:text-brand-500 hover:underline truncate max-w-[140px] cursor-pointer",onClick:()=>n(w.path),title:w.path,children:w.label})]},w.path)})}),o.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?o.jsx("p",{className:"px-4 py-8 text-center text-xs text-fg-tertiary",children:c??"此目录为空"}):t.map(w=>{const T=w.isDirectory?void 0:Pie(w.ext),C=!!w.ext&&!!Dg[w.ext.replace(/^\./,"").toLowerCase()];return o.jsxs("button",{className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left hover:bg-surface-overlay/60 transition-colors cursor-pointer group",onClick:()=>w.isDirectory?n(w.path):a(w.path),title:w.path,children:[w.isDirectory?o.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}):C?o.jsx("svg",{className:"w-4 h-4 shrink-0 text-purple-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 5a2 2 0 012-2h3.5a1.5 1.5 0 011.06.44l1.5 1.5c.14.14.331.22.53.22H14a2 2 0 012 2v7a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm4.5 4.5a.75.75 0 00-1.5 0v3a.75.75 0 001.06.68l2.5-1.5a.75.75 0 000-1.32l-2.5-1.5a.75.75 0 00-.56-.06z",clipRule:"evenodd"})}):o.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-tertiary group-hover:text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-primary truncate",children:w.name}),T&&o.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[10px] font-mono uppercase bg-surface-overlay/60 text-fg-tertiary border border-border-subtle",children:T}),!w.isDirectory&&o.jsx("span",{className:"shrink-0 text-[11px] text-fg-tertiary tabular-nums",children:Die(w.size)})]},w.path)})})]})}const jk=new Set(["pdf","docx","xlsx"]),zie=30*1024*1024;function Hie({data:e,reference:t,onFallback:n}){const{t:a}=xt("deliverables"),i=(e.format||"").toLowerCase().replace(/^\./,""),l=k.useRef(null),[c,u]=k.useState("loading"),[m,f]=k.useState(""),[g,h]=k.useState(0),[v,y]=k.useState(null),[w,T]=k.useState(1),[C,A]=k.useState(1),M=k.useCallback(()=>{n?.()},[n]),I=k.useCallback(async()=>{if(t)try{await Te.files.reveal(t);return}catch{}M()},[t,M]),B=k.useCallback(j=>{const z=l.current?.querySelector(`canvas[data-page="${j}"]`);z&&(z.scrollIntoView({behavior:"smooth",block:"start"}),T(j))},[]);k.useEffect(()=>{const j=l.current;if(!j||!jk.has(i)){u("ready");return}let z=!1,U;return u("loading"),f(""),j.innerHTML="",(async()=>{try{i==="pdf"?U=await Uie(e.streamUrl,j,{onReady:Y=>{y(Y),T(1)},zoom:C}):i==="docx"?U=await Gie(e.streamUrl,j):i==="xlsx"&&(U=await Kie(e.streamUrl,j)),z||u("ready")}catch(Y){z||(u("error"),f(String(Y)))}})(),()=>{z=!0,U&&U(),j.innerHTML=""}},[e.streamUrl,i,g,C]);const K=!jk.has(i);return o.jsx("div",{className:"flex flex-col h-full min-h-0",children:K?o.jsx(Bie,{format:i,size:e.size,onOpenSystem:I,onDownload:()=>M()}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-1.5 border-b border-border-default/60 bg-surface-elevated/40",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wide",children:i}),e.name&&o.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1 min-w-0",title:e.name,children:e.name}),e.size!=null&&e.size>zie&&o.jsx("span",{className:"text-[10px] text-amber-500 shrink-0",children:a("officeLargeFile")}),i==="pdf"&&v!=null&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx("button",{onClick:()=>B(Math.max(1,w-1)),disabled:w<=1,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"‹"}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[w,"/",v]}),o.jsx("button",{onClick:()=>B(Math.min(v??1,w+1)),disabled:w>=(v??1),className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"›"})]}),i==="pdf"&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx("button",{onClick:()=>A(j=>Math.max(.5,+(j-.25).toFixed(2))),disabled:C<=.5,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"−"}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[Math.round(C*100),"%"]}),o.jsx("button",{onClick:()=>A(j=>Math.min(3,+(j+.25).toFixed(2))),disabled:C>=3,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"+"})]}),o.jsx("button",{onClick:I,className:"shrink-0 text-[10px] text-fg-tertiary hover:text-fg-secondary px-1.5 py-0.5 rounded hover:bg-surface-overlay transition-colors",children:a("officeOpenSystem")})]}),o.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:[c==="loading"&&o.jsxs("div",{className:"flex items-center justify-center h-full text-fg-tertiary",children:[o.jsxs("svg",{className:"animate-spin w-4 h-4 mr-2",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),o.jsx("span",{className:"text-xs",children:a("officeLoading")})]}),c==="error"&&o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[o.jsx("span",{className:"text-[11px] text-fg-tertiary",children:a("officeFailed")}),o.jsx("span",{className:"text-[10px] text-fg-muted max-w-xs truncate",children:m}),o.jsxs("div",{className:"flex gap-2 mt-1",children:[o.jsx("button",{onClick:()=>h(j=>j+1),className:"px-3 py-1.5 text-xs bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors",children:a("officeRetry")}),o.jsx("button",{onClick:I,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:a("officeOpenSystem")})]})]}),o.jsx("div",{ref:l,className:c==="loading"?"hidden":""})]})]})})}function Bie({format:e,size:t,onOpenSystem:n,onDownload:a}){const{t:i}=xt("deliverables");return o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-center px-6",children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-surface-elevated flex items-center justify-center text-xl",children:"📄"}),o.jsx("div",{className:"text-xs text-fg-secondary",children:i("officeNoInlinePreview",{format:e})}),t!=null&&o.jsx("div",{className:"text-[10px] text-fg-tertiary",children:i("officeSize",{size:$ie(t)})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors",children:i("officeOpenSystem")}),o.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:i("officeDownload")})]})]})}function $ie(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function qie(){const e=Uint8Array.prototype;typeof e.toHex!="function"&&(e.toHex=function(){let i="",l=0,c=this.length,u;for(;l<c;++l)u=this[l],i+=(u>>>4).toString(16)+(u&15).toString(16);return i});const t=Map.prototype;typeof t.getOrInsertComputed!="function"&&(t.getOrInsertComputed=function(i,l){if(this.has(i))return this.get(i);const c=l(i);return this.set(i,c),c}),typeof t.getOrInsert!="function"&&(t.getOrInsert=function(i,l){return this.has(i)?this.get(i):(this.set(i,l),l)});const n=Promise;typeof n.try!="function"&&(n.try=function(i){return new Promise(l=>l(i()))});const a=typeof Iterator<"u"?Iterator.prototype:null;a&&typeof a.join!="function"&&(a.join=function(i=","){let l="",c=!0;for(const u of this)c||(l+=i),l+=String(u),c=!1;return l})}qie();let wh=null;function Fie(){if(!wh){const t=`
|
|
814
|
+
`,1;if(rl>1e5&&rl>pt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return cn+=Lt,Lt.length}const ia=aa(J);if(!ia)throw Ne(Ot.replace("{}",J)),new Error('Unknown language: "'+J+'"');const Uc=fe(ia);let Ys="",Tt=Mt||Uc;const Gc={},$n=new tt.__emitter(tt);al();let cn="",vi=0,Ur=0,rl=0,xi=!1;try{if(ia.__emitTokens)ia.__emitTokens(xe,$n);else{for(Tt.matcher.considerAll();;){rl++,xi?xi=!1:Tt.matcher.considerAll(),Tt.matcher.lastIndex=Ur;const Je=Tt.matcher.exec(xe);if(!Je)break;const pt=xe.substring(Ur,Je.index),Lt=Ws(pt,Je);Ur=Je.index+Lt}Ws(xe.substring(Ur))}return $n.finalize(),Ys=$n.toHTML(),{language:J,value:Ys,relevance:vi,illegal:!1,_emitter:$n,_top:Tt}}catch(Je){if(Je.message&&Je.message.includes("Illegal"))return{language:J,value:Ft(xe),illegal:!0,relevance:0,_illegalBy:{message:Je.message,index:Ur,context:xe.slice(Ur-100,Ur+100),mode:Je.mode,resultSoFar:Ys},_emitter:$n};if(bt)return{language:J,value:Ft(xe),illegal:!1,relevance:0,errorRaised:Je,_emitter:$n,_top:Tt};throw Je}}function ha(J){const xe={value:Ft(J),illegal:!1,relevance:0,_top:it,_emitter:new tt.__emitter(tt)};return xe._emitter.addText(J),xe}function bi(J,xe){xe=xe||tt.languages||Object.keys(he);const st=ha(J),Mt=xe.filter(aa).filter(Sr).map(Ht=>Qn(Ht,J,!1));Mt.unshift(st);const en=Mt.sort((Ht,on)=>{if(Ht.relevance!==on.relevance)return on.relevance-Ht.relevance;if(Ht.language&&on.language){if(aa(Ht.language).supersetOf===on.language)return 1;if(aa(on.language).supersetOf===Ht.language)return-1}return 0}),[Sn,zn]=en,Rt=Sn;return Rt.secondBest=zn,Rt}function ga(J,xe,st){const Mt=xe&&Se[xe]||st;J.classList.add("hljs"),J.classList.add(`language-${Mt}`)}function En(J){let xe=null;const st=gn(J);if(St(st))return;if(Fr("before:highlightElement",{el:J,language:st}),J.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",J);return}if(J.children.length>0&&(tt.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(J)),tt.throwUnescapedHTML))throw new ut("One of your code blocks includes unescaped HTML.",J.innerHTML);xe=J;const Mt=xe.textContent,en=st?bn(Mt,{language:st,ignoreIllegals:!0}):bi(Mt);J.innerHTML=en.value,J.dataset.highlighted="yes",ga(J,st,en.language),J.result={language:en.language,re:en.relevance,relevance:en.relevance},en.secondBest&&(J.secondBest={language:en.secondBest.language,relevance:en.secondBest.relevance}),Fr("after:highlightElement",{el:J,result:en,text:Mt})}function Xn(J){tt=ln(tt,J)}const wr=()=>{qr(),te("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function kr(){qr(),te("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Vs=!1;function qr(){function J(){qr()}if(document.readyState==="loading"){Vs||window.addEventListener("DOMContentLoaded",J,!1),Vs=!0;return}document.querySelectorAll(tt.cssSelector).forEach(En)}function is(J,xe){let st=null;try{st=xe(Q)}catch(Mt){if(Ne("Language definition for '{}' could not be registered.".replace("{}",J)),bt)Ne(Mt);else throw Mt;st=it}st.name||(st.name=J),he[J]=st,st.rawDefinition=xe.bind(null,Q),st.aliases&&hr(st.aliases,{languageName:J})}function Jn(J){delete he[J];for(const xe of Object.keys(Se))Se[xe]===J&&delete Se[xe]}function yi(){return Object.keys(he)}function aa(J){return J=(J||"").toLowerCase(),he[J]||he[Se[J]]}function hr(J,{languageName:xe}){typeof J=="string"&&(J=[J]),J.forEach(st=>{Se[st.toLowerCase()]=xe})}function Sr(J){const xe=aa(J);return xe&&!xe.disableAutodetect}function Cr(J){J["before:highlightBlock"]&&!J["before:highlightElement"]&&(J["before:highlightElement"]=xe=>{J["before:highlightBlock"](Object.assign({block:xe.el},xe))}),J["after:highlightBlock"]&&!J["after:highlightElement"]&&(J["after:highlightElement"]=xe=>{J["after:highlightBlock"](Object.assign({block:xe.el},xe))})}function In(J){Cr(J),Ye.push(J)}function ss(J){const xe=Ye.indexOf(J);xe!==-1&&Ye.splice(xe,1)}function Fr(J,xe){const st=J;Ye.forEach(function(Mt){Mt[st]&&Mt[st](xe)})}function Ba(J){return te("10.7.0","highlightBlock will be removed entirely in v12.0"),te("10.7.0","Please use highlightElement now."),En(J)}Object.assign(Q,{highlight:bn,highlightAuto:bi,highlightAll:qr,highlightElement:En,highlightBlock:Ba,configure:Xn,initHighlighting:wr,initHighlightingOnLoad:kr,registerLanguage:is,unregisterLanguage:Jn,listLanguages:yi,getLanguage:aa,registerAliases:hr,autoDetection:Sr,inherit:ln,addPlugin:In,removePlugin:ss}),Q.debugMode=function(){bt=!1},Q.safeMode=function(){bt=!0},Q.versionString=We,Q.regex={concat:T,lookahead:v,either:A,optional:w,anyNumberOfTimes:y};for(const J in Xe)typeof Xe[J]=="object"&&e(Xe[J]);return Object.assign(Q,Xe),Q},_e=je({});return _e.newInstance=()=>je({}),vh=_e,_e.HighlightJS=_e,_e.default=_e,vh}var Tre=Are();const Ere=Ic(Tre),yk={},Nre="hljs-";function Mre(e){const t=Ere.newInstance();return e&&l(e),{highlight:n,highlightAuto:a,listLanguages:i,register:l,registerAlias:c,registered:u};function n(m,f,g){const h=g||yk,v=typeof h.prefix=="string"?h.prefix:Nre;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:jre,classPrefix:v});const y=t.highlight(f,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,T=w.data;return T.language=y.language,T.relevance=y.relevance,w}function a(m,f){const h=(f||yk).subset||i();let v=-1,y=0,w;for(;++v<h.length;){const T=h[v];if(!t.getLanguage(T))continue;const C=n(T,m,f);C.data&&C.data.relevance!==void 0&&C.data.relevance>y&&(y=C.data.relevance,w=C)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function i(){return t.listLanguages()}function l(m,f){if(typeof m=="string")t.registerLanguage(m,f);else{let g;for(g in m)Object.hasOwn(m,g)&&t.registerLanguage(g,m[g])}}function c(m,f){if(typeof m=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:m});else{let g;for(g in m)if(Object.hasOwn(m,g)){const h=m[g];t.registerAliases(typeof h=="string"?h:[...h],{languageName:g})}}}function u(m){return!!t.getLanguage(m)}}class jre{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],a=n.children[n.children.length-1];a&&a.type==="text"?a.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const a=this.stack[this.stack.length-1],i=t.root.children;n?a.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):a.children.push(...i)}openNode(t){const n=this,a=t.split(".").map(function(c,u){return u?c+"_".repeat(u):n.options.classPrefix+c}),i=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:a},children:[]};i.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Rre={};function _re(e){const t=e||Rre,n=t.aliases,a=t.detect||!1,i=t.languages||Cre,l=t.plainText,c=t.prefix,u=t.subset;let m="hljs";const f=Mre(i);if(n&&f.registerAlias(n),c){const g=c.indexOf("-");m=g===-1?c:c.slice(0,g)}return function(g,h){Jm(g,"element",function(v,y,w){if(v.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const T=Dre(v);if(T===!1||!T&&!a||T&&l&&l.includes(T))return;Array.isArray(v.properties.className)||(v.properties.className=[]),v.properties.className.includes(m)||v.properties.className.unshift(m);const C=R3(v,{whitespace:"pre"});let A;try{A=T?f.highlight(T,C,{prefix:c}):f.highlightAuto(C,{prefix:c,subset:u})}catch(M){const I=M;if(T&&/Unknown language/.test(I.message)){h.message("Cannot highlight as `"+T+"`, it’s not registered",{ancestors:[w,v],cause:I,place:v.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw I}!T&&A.data&&A.data.language&&v.properties.className.push("language-"+A.data.language),A.children.length>0&&(v.children=A.children)})}}function Dre(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let a;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!a&&i.slice(0,5)==="lang-"&&(a=i.slice(5)),!a&&i.slice(0,9)==="language-"&&(a=i.slice(9))}return a}const Bs={agent:{label:"Agent",labelZh:"智能体",gradient:"from-violet-500 to-indigo-600",accent:"#8b5cf6",covers:[["#7c3aed","#4f46e5"],["#8b5cf6","#6366f1"],["#a855f7","#4338ca"],["#6d28d9","#2563eb"]]},team:{label:"Team",labelZh:"AI 小队",gradient:"from-cyan-500 to-blue-600",accent:"#06b6d4",covers:[["#0891b2","#2563eb"],["#06b6d4","#3b82f6"],["#0e7490","#1d4ed8"],["#22d3ee","#4f46e5"]]},skill:{label:"Skill",labelZh:"技能",gradient:"from-amber-500 to-orange-600",accent:"#f59e0b",covers:[["#f59e0b","#ea580c"],["#d97706","#dc2626"],["#fbbf24","#f97316"],["#f59e0b","#b45309"]]},connector:{label:"Connector",labelZh:"连接器",gradient:"from-emerald-500 to-teal-600",accent:"#10b981",covers:[["#10b981","#0d9488"],["#059669","#0891b2"],["#34d399","#14b8a6"],["#16a34a","#0f766e"]]}};function nl(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function J3(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 Ire={agent:258,team:205,skill:32,connector:162};function jb(e,t){const n=Ire[e],a=J3(t),i=((n+(a%68-34))%360+360)%360,l=(i+22+(a>>>8)%24)%360;return`linear-gradient(${120+a%44}deg, hsl(${i} 72% 56%), hsl(${l} 66% 43%))`}const vk=["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 Z3(e){return vk[J3(e+"g")%vk.length]}function eC(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 Lre(e){return!e||eC(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function Pre(e,t="user"){const n=t==="org"?"shapes":"thumbs",a=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${a}&radius=50&backgroundType=gradientLinear`}function Ho(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 xk(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const tC=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,nC=/^\.{1,2}\//,Ore=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,aC=/^[A-Za-z]:[\\/]/,rC=/^\\\\[^\\]/;function zre(e){const t=e.trim();return t?!!(/^file:/i.test(t)||aC.test(t)||rC.test(t)||t.startsWith("~/")||t.startsWith("/")||nC.test(t)):!1}const Hre=/(?:%[0-9A-Fa-f]{2})+/g;function iC(e){return e.includes("%")?e.replace(Hre,t=>{const n=new Uint8Array(t.length/3);for(let a=0;a<n.length;a++)n[a]=Number.parseInt(t.slice(a*3+1,a*3+3),16);try{const a=new TextDecoder("utf-8",{fatal:!0}).decode(n);return/[^\x00-\x7F]/.test(a)?a:t}catch{return t}}):e}function Rb(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=iC(t),t=t.replace(/\\+/g,"/"),t}function zle(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,a,i)=>`${n}${a.replace(/\\+/g,"/")}${i}`)}const Bre=/^(?:(?:\/|~\/|\.\.?\/)[\p{L}\p{N}\p{M}\w.@+\-\u3000-\u303f\uff00-\uffef]+(?:\/[\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]*)*|[A-Za-z]:[\\/][\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]+(?:(?:\\|\/)[\p{L}\p{N}\p{M}\w.@+\- \u3000-\u303f\uff00-\uffef]*)*)$/u;function $re(e){return e.length<2||e.length>500?!1:Bre.test(e)}function sC(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Nu(e,t){if(!e)return e;if(tC.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const a=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,i=a.split("/"),l=[];for(const u of i)!u||u==="."||(u===".."?l.pop():l.push(u));const c=l.join("/");return a.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function wk(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function kk(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(aC.test(n)||rC.test(n)){const{path:c,fragment:u}=wk(n);return{kind:"file",path:Nu(c,t),fragment:u}}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:Rb(n)}:{kind:"passthrough"};const a=wk(n),i=iC(a.path),l=a.fragment;return tC.test(i)?{kind:"file",path:Nu(i,t),fragment:l}:nC.test(i)?{kind:"file",path:Nu(i,t),fragment:l}:i&&Ore.test(i)&&!i.includes("://")?{kind:"file",path:Nu(i,t),fragment:l}:{kind:"passthrough"}}function qre(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 a=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const i of a)if(sC(i.textContent||"")===t||i.id===t){n=i;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function oC(e){return e.type==="text"?e.value??"":(e.children??[]).map(oC).join("")}function Fre(){return e=>{const t=new Map,n=a=>{if(a.type==="element"&&a.tagName&&/^h[1-6]$/.test(a.tagName)){const i=oC(a).trim();let l=sC(i);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),a.properties={...a.properties??{},id:l}}}for(const i of a.children??[])n(i)};n(e)}}function Sk(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let a=0,i="";for(const l of e.matchAll(n))i+=t(e.slice(a,l.index)),i+=l[0],a=l.index+l[0].length;return i+=t(e.slice(a)),i}function Hle(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,a)=>`$$${a}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,a)=>`$${a}$`),t}function Ure(e){return e.replace(/[$](?=[0-9])/g,(n,a,i)=>a>0&&i.charCodeAt(a-1)===92?n:"\\"+n)}const Mu="#mention:";function Ble(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,u)=>{const m=c??u;return`[@${m}](${Mu}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.length-l.length);let a="",i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){a+=e.slice(i);break}if(a+=e.slice(i,l),e[l+1]==="["){const g=e.indexOf("]",l+2);if(g>l+2){const h=e.slice(l+2,g);a+=`[@${h}](${Mu}${encodeURIComponent(h)})`,i=g+1;continue}}const c=e.slice(l+1),u=c.toLowerCase(),m=n.find(g=>u.startsWith(g.toLowerCase()));if(m){const g=c.slice(0,m.length);a+=`[@${g}](${Mu}${encodeURIComponent(g)})`,i=l+1+m.length;continue}const f=c.match(/^([\w\p{L}\p{N}]+)/u);if(f){const g=f[1];a+=`[@${g}](${Mu}${encodeURIComponent(g)})`,i=l+1+g.length;continue}a+="@",i=l+1}return a}const lC="#entity:",Gre=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),Kre=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function cC(e,t){const n=e.slice(0,t),a=n.lastIndexOf("](");return a===-1?!1:n.indexOf(")",a+2)===-1}function $le(e){return e.replace(Kre,(t,n,a)=>`[${n}](${lC}${a})`)}function qle(e){return e.replace(Gre,(t,n,a)=>cC(e,a)?t:`[${t}](${lC}${t})`)}const Vre=["\\s","<",">","`","\\u4e00-\\u9fff","\\u3000-\\u303f","\\uff00-\\uffef"].join(""),Wre=new RegExp(`https?://[^${Vre}]+`,"gi"),Yre=/(\*{1,3}|_{1,3}|~{1,2})$/;function Qre(e,t,n){const a=n.match(Yre);if(!a)return null;const i=a[1];return e.slice(Math.max(0,t-i.length),t)===i?i:null}function Xre(e){return e.replace(Wre,(t,n)=>{if(cC(e,n))return t;let a=t.replace(/[.,;:!?\]\)"']+$/,"");if(!a)return t;const i=Qre(e,n,a);if(i&&(a=a.slice(0,a.length-i.length)),!a)return t;const l=t.slice(a.length);return/[()[\]]/.test(a)?t:`[${a}](${a})${l}`})}function Jre(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const Zre={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 eie(e){return Zre[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function tie(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const nie=24;function aie(e){const t=e.indexOf("_");return t<0?!1:e.length>=t+1+nie}const dC={tsk:{load:async()=>(await Te.tasks.list({lean:!0,pageSize:500})).tasks.map(e=>e.id)},req:{load:async()=>(await Te.requirements.list({lean:!0})).requirements.map(e=>e.id)},proj:{load:async()=>(await Te.projects.list()).projects.map(e=>e.id)},dlv:{load:async()=>(await Te.deliverables.search({limit:500})).results.map(e=>e.id)},agt:{load:async()=>(await Te.agents.list({lean:!0})).agents.map(e=>e.id)},team:{load:async()=>(await Te.teams.list()).teams.map(e=>e.id)}},xh=new Map,Ck=new Map;function rie(e){const t=dC[e];if(!t)return null;let n=xh.get(e);return n||(n=t.load().catch(a=>{throw xh.delete(e),a}),xh.set(e,n)),n}async function iie(e){if(!e)return null;const t=e.indexOf("_");if(t<0)return null;const n=e.slice(0,t);if(!dC[n])return null;if(aie(e))return e;const a=Ck.get(e);if(a!==void 0)return a;const i=(await rie(n)??[]).filter(c=>c.startsWith(e)),l=i.length===1?i[0]:null;return Ck.set(e,l),l}const sie=k.lazy(()=>Ca(()=>import("./MarkdownMessage-DedA8Zob.js"),[]).then(e=>({default:e.MarkdownMessage}))),oie={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Ak={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 lie({item:e,onClose:t,onOpenInPage:n}){const{t:a}=xt(["agent","common"]),i=oie[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=Ak[e.status]??Ak.active,c=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=f=>{f.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const u=o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[o.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),o.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:[o.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:[o.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${i.color}`,children:i.icon}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),o.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[o.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),o.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),o.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:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:a("agent:deliverables.summary")}),o.jsx("div",{className:"mt-1.5",children:o.jsx(k.Suspense,{fallback:o.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:o.jsx(sie,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&o.jsxs("div",{children:[o.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:a("agent:deliverables.reference")}),o.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),c?o.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:a("common:open")}):o.jsx("button",{onClick:()=>{Te.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:a("common:open")})]})]}),e.diffStats&&o.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),o.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),o.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),o.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&o.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[o.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),o.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&o.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&o.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>o.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),o.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[o.jsxs("span",{children:[a("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),o.jsxs("span",{children:[a("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&o.jsx("span",{children:a("agent:deliverables.accessed",{count:e.accessCount})})]})]}),o.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:[o.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:[o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),a("agent:deliverables.openInPage")]}),o.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:a("common:close")})]})]})]});return typeof document<"u"?Lc.createPortal(u,document.body):u}const _b=new Set;function Ds(e){e&&_b.add(e)}function Eg(e){e&&_b.delete(e)}const Db="markus:browser-history",uC=300;function Ng(e){return`${e.kind}:${e.target}`}function Dm(e,t){const n=(t||"").trim();return n?e!=="url"?!0:n!=="about:blank"&&n!=="about:newtab":!1}function mC(e){const t=(e||"").trim();return t?t.startsWith("//")?`https:${t}`:t:""}function cie(e){return e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"")}function Ib(e){return(e||"").trim()}function pC(e){const t=(e.id||"").trim();if(t)return t;const n=`${e.reference||""}|${e.title||""}|${(e.summary||"").slice(0,48)}`;return n==="||"?"":n}function die(e){if(e.kind==="file"){const t=Ib(e.path||"");return Dm("file",t)?{kind:"file",target:t,title:(e.title||"").trim()||void 0}:null}if(e.kind==="deliverable"){const t=e.deliverable;if(!t)return null;const n=pC(t);return Dm("deliverable",n)?{kind:"deliverable",target:n,title:(t.title||"").trim()||void 0,location:(t.reference||"").trim()||void 0}:null}return null}function uie(e){return e.kind==="url"?cie(e.target):e.kind==="deliverable"&&e.location||e.target}function Tk(e){return typeof e=="string"&&e.trim()?e:void 0}function mie(e){if(!e||typeof e!="object")return null;const t=e,n=t.kind==="file"||t.kind==="deliverable"?t.kind:"url",a=typeof t.target=="string"?t.target:n==="url"&&typeof t.url=="string"?t.url:"",i=n==="url"?mC(a):Ib(a);return Dm(n,i)?{kind:n,target:i,title:Tk(t.title),location:n==="deliverable"?Tk(t.location):void 0,visitedAt:typeof t.visitedAt=="number"&&Number.isFinite(t.visitedAt)?t.visitedAt:0,visitCount:typeof t.visitCount=="number"&&t.visitCount>0?t.visitCount:1}:null}function Lb(){try{const e=localStorage.getItem(Db);if(!e)return[];const t=JSON.parse(e);if(!Array.isArray(t))return[];const n=[];for(const a of t){const i=mie(a);i&&n.push(i)}return n}catch{return[]}}function Pb(e){try{localStorage.setItem(Db,JSON.stringify(e.slice(0,uC)))}catch{}}function Ob(){return Lb().sort((e,t)=>t.visitedAt-e.visitedAt)}const Mg=new Set;function zb(e){for(const t of Mg)try{t(e)}catch{}}function Fle(e){Mg.add(e);const t=n=>{n.key!==null&&n.key!==Db||e(Ob())};return typeof window<"u"&&window.addEventListener("storage",t),()=>{Mg.delete(e),typeof window<"u"&&window.removeEventListener("storage",t)}}function fC(e,t=Date.now()){const n=e.kind==="url"?mC(e.target):Ib(e.target);if(!Dm(e.kind,n))return Ob();const a=`${e.kind}:${n}`,i=Lb(),l=i.find(m=>Ng(m)===a),c=i.filter(m=>Ng(m)!==a),u=[{kind:e.kind,target:n,title:(e.title||"").trim()||l?.title,location:(e.location||"").trim()||l?.location,visitedAt:t,visitCount:(l?.visitCount??0)+1},...c].sort((m,f)=>f.visitedAt-m.visitedAt).slice(0,uC);return Pb(u),zb(u),u}function Ule(e,t,n=Date.now()){return fC({kind:"url",target:e,title:t},n)}function Gle(e){const t=Lb().filter(n=>Ng(n)!==e);return Pb(t),zb(t),t}function Kle(){return Pb([]),zb([]),[]}function Vle(e,t=8){const n=Ob(),a=(e||"").trim().toLowerCase();if(!a)return n.slice(0,t);const i=a.split(/\s+/).filter(Boolean),l=[];for(const c of n){const u=c.target.toLowerCase(),m=(c.title||"").toLowerCase(),f=uie(c).toLowerCase(),g=`${f} ${m}`;let h=0,v=!0;for(const w of i){if(!g.includes(w)){v=!1;break}f.startsWith(w)?h+=120:u.startsWith(w)?h+=100:new RegExp(`(^|[./:?&=_-])${pie(w)}`).test(f)?h+=60:m.startsWith(w)?h+=50:h+=20}if(!v)continue;const y=Math.max(0,(Date.now()-c.visitedAt)/864e5);h+=Math.max(0,30-y*2),h+=Math.min(30,c.visitCount*3),l.push({entry:c,score:h})}return l.sort((c,u)=>u.score-c.score||u.entry.visitedAt-c.entry.visitedAt).slice(0,t).map(c=>c.entry)}function pie(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wle(e){if(!e.ctrlKey||e.metaKey||e.altKey)return null;const t=(e.key||"").toLowerCase();return t==="n"?"next":t==="p"?"prev":null}function Yle(e,t,n){return t<=0?-1:e<0?n==="next"?0:t-1:(e+(n==="next"?1:-1)+t)%t}const hC="markus_right_panel_v1",fie=10,jg=new Map;function hie(e,t=3e3){jg.set(e,Date.now()+t)}function gie(e){const t=jg.get(e);return t==null?!1:Date.now()>t?(jg.delete(e),!1):!0}function bie(e){return e.kind==="terminal"}function nc(e){return e.kind==="file"?`file:${e.path}`:e.kind==="url"?`url:${e.browserId||e.url}`:e.kind==="terminal"?`terminal:${e.terminalId}`:`deliverable:${pC(e.deliverable)||"unknown"}`}function Ek(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 Yi(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function ju(e){let t=e;for(;t.length>fie;){let n=-1;for(let i=t.length-1;i>=0;i--)if(!t[i].pinned){n=i;break}if(n<0)break;const a=t[n];a&&(Rg(a.payload),_g(a.payload)),t=t.filter((i,l)=>l!==n)}return t}function Rg(e){e?.kind==="url"&&e.browserId&&(hie(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function _g(e){e?.kind==="terminal"&&e.terminalId&&(Eg(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function yie(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?Cc(t.url||"")||Cc(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 vie(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 xie(){try{const e=localStorage.getItem(hC);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 wie(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=xie();if(!t)return e;const n=t.browserTabs.map((y,w)=>{try{return vie(y,w)}catch{return null}}).filter(y=>!(!y||y.payload.kind==="terminal"||y.payload.kind==="url"&&Cc(y.payload.url||""))),a=n.some(y=>y.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,i=(t.terminalTabs||[]).map((y,w)=>{const T=`term_${Date.now().toString(36)}_${w.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return Ds(T),{id:y.id||Yi(),title:y.title||"Terminal",payload:{kind:"terminal",terminalId:T,title:y.title||"Terminal",cwd:y.cwd}}}),l=i.some(y=>y.id===t.terminalActiveId)?t.terminalActiveId:i[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,u=!!t.terminalCollapsed&&i.length>0,m=c?[]:n,f=c?null:a,g=u?[]:i,h=u?null:l;let v=t.mode;return v==="terminal"&&g.length===0&&!u&&(v="browser"),v==="browser"&&m.length===0&&g.length>0&&(v="terminal"),{mode:v,browserTabs:m,browserActiveId:f,terminalTabs:g,terminalActiveId:h,stashedBrowserTabs:n,stashedBrowserActiveId:a,stashedTerminalTabs:i,stashedTerminalActiveId:l}}const gC=k.createContext(null);function kie({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),a=k.useMemo(()=>wie(),[]),[i,l]=k.useState(a.mode),[c,u]=k.useState(a.browserTabs),[m,f]=k.useState(a.terminalTabs),[g,h]=k.useState(a.browserActiveId),[v,y]=k.useState(a.terminalActiveId),[w,T]=k.useState(!1),[C,A]=k.useState(!1),[M,I]=k.useState("l0"),[B,K]=k.useState(null),j=k.useCallback(ye=>I(ye),[]),z=k.useCallback(ye=>K(ye),[]);k.useEffect(()=>{const ye=De=>{if(!(De instanceof HTMLElement))return!1;const te=De.tagName;return te==="INPUT"||te==="TEXTAREA"||te==="SELECT"?!0:De.isContentEditable},Ne=De=>{if(!(De.target instanceof Element))return;const te=document.activeElement;if(ye(te)){const we=te===De.target||te.contains(De.target),Le=!!De.target.closest("[data-keep-edit-focus]"),He=ye(De.target)||!!De.target.closest('input, textarea, select, [contenteditable="true"]'),de=!!De.target.closest(".xterm");!we&&!Le&&!He&&!de&&te.blur()}const F=De.target.closest("[data-keyboard-pane]");if(!F)return;const ae=F.getAttribute("data-keyboard-pane");if(!(ae!=="l0"&&ae!=="l1"&&ae!=="l2"&&ae!=="content")&&(I(ae),ae==="l0")){const Le=De.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");Le&&K(Le)}};return document.addEventListener("pointerdown",Ne,!0),()=>document.removeEventListener("pointerdown",Ne,!0)},[]);const U=k.useRef(a.stashedBrowserTabs.length>0?a.stashedBrowserTabs:a.browserTabs),Y=k.useRef(a.stashedBrowserActiveId??a.browserActiveId),$=k.useRef(a.stashedTerminalTabs.length>0?a.stashedTerminalTabs:a.terminalTabs),D=k.useRef(a.stashedTerminalActiveId??a.terminalActiveId),W=k.useRef(a.browserActiveId),X=k.useRef(a.terminalActiveId),H=k.useRef(a.browserTabs),se=k.useRef(a.terminalTabs),R=k.useRef(a.mode);W.current=g,X.current=v,H.current=c,se.current=m,R.current=i,k.useEffect(()=>{(a.mode==="terminal"||a.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),k.useEffect(()=>{const ye=c.length===0&&U.current.length>0,Ne=m.length===0&&$.current.length>0,De=ye?U.current:c,te=Ne?$.current:m,F=De.map(yie).filter(Le=>!!Le),ae=te.filter(Le=>Le.payload.kind==="terminal").map(Le=>({id:Le.id,title:Le.title,cwd:Le.payload.kind==="terminal"?Le.payload.cwd:void 0})),we={mode:i,browserTabs:F,browserActiveId:ye?Y.current:g,terminalTabs:ae,terminalActiveId:Ne?D.current:v,browserCollapsed:ye,terminalCollapsed:Ne};try{localStorage.setItem(hC,JSON.stringify(we))}catch{}},[i,c,g,m,v]);const re=k.useCallback(ye=>n(ye),[]),ue=k.useCallback(()=>n(ye=>!ye),[]),Ce=k.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),q=k.useCallback(ye=>{l(Ne=>Ne===ye?Ne:(ye==="terminal"&&Ce(),ye))},[Ce]),V=k.useCallback(ye=>{if(ye==="terminal"){if(Ce(),l("terminal"),n(!0),m.length>0)return;if($.current.length>0){const Le=$.current,He=D.current&&Le.some(de=>de.id===D.current)?D.current:Le[0].id;f(Le),y(He),D.current=He;return}const F=Yi(),ae=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;Ds(ae);const we={id:F,title:"Terminal",payload:{kind:"terminal",terminalId:ae,title:"Terminal"}};$.current=[we],f([we]),y(we.id),D.current=we.id;return}if(l("browser"),n(!0),c.length>0)return;if(U.current.length>0){const F=U.current,ae=Y.current&&F.some(we=>we.id===Y.current)?Y.current:F[0].id;u(F),h(ae),Y.current=ae;return}const Ne=Yi(),De=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,te={id:Ne,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:De}};U.current=[te],u([te]),h(te.id),Y.current=te.id},[c.length,m.length,Ce]),ce=k.useCallback(ye=>{const Ne=nc(ye),De=Yi(),te=bie(ye),F=die(ye);if(F&&fC(F),te){ye.kind==="terminal"&&Ds(ye.terminalId),l("terminal"),Ce();const ae=se.current,we=ae.find(de=>nc(de.payload)===Ne)??$.current.find(de=>nc(de.payload)===Ne);let Le,He;if(we)He=we.id,Le=ae.some(de=>de.id===we.id)?ae:ju([we,...ae]);else{const de={id:De,title:Ek(ye),payload:ye};Le=ju([de,...ae]),He=De}$.current=Le,se.current=Le,f(Le),y(He),D.current=He,X.current=He}else{l("browser");const ae=H.current,we=ae.find(de=>nc(de.payload)===Ne)??U.current.find(de=>nc(de.payload)===Ne);let Le,He;if(we)He=we.id,Le=ae.some(de=>de.id===we.id)?ae:ju([we,...ae]);else{const de={id:De,title:Ek(ye),payload:ye};Le=ju([de,...ae]),He=De}U.current=Le,H.current=Le,u(Le),h(He),Y.current=He,W.current=He}n(!0)},[Ce]),P=k.useCallback(ye=>{const Ne=H.current,De=Ne.findIndex(fe=>fe.id===ye);if(De>=0){const fe=Ne[De]?.payload,Ge=Ne.filter(Ft=>Ft.id!==ye),ct=W.current,ut=(Ne.some(Ft=>Ft.id===ct)?ct:Ne[0]?.id??null)===ye||Ge.length===0?Ge[Math.min(De,Ge.length-1)]?.id??null:void 0;U.current=Ge,H.current=Ge,u(Ge),Ge.length===0&&R.current==="browser"&&T(!1),ut!==void 0&&(h(ut),Y.current=ut,W.current=ut),Rg(fe);return}const te=se.current,F=te.findIndex(fe=>fe.id===ye);if(F<0)return;const ae=te[F]?.payload,we=te.filter(fe=>fe.id!==ye),Le=X.current,de=(te.some(fe=>fe.id===Le)?Le:te[0]?.id??null)===ye||we.length===0?we[Math.min(F,we.length-1)]?.id??null:void 0;$.current=we,se.current=we,f(we),we.length===0&&R.current==="terminal"&&T(!1),de!==void 0&&(y(de),D.current=de,X.current=de),_g(ae)},[]),Ee=k.useCallback(()=>{const ye=H.current.map(De=>De.payload),Ne=se.current.map(De=>De.payload);H.current=[],se.current=[],U.current=[],Y.current=null,$.current=[],D.current=null,W.current=null,X.current=null,u([]),f([]),h(null),y(null),T(!1);for(const De of ye)Rg(De);for(const De of Ne)_g(De)},[]),$e=k.useCallback(ye=>{R.current==="terminal"?(y(ye),D.current=ye):(h(ye),Y.current=ye)},[]),qe=k.useCallback((ye,Ne)=>{u(De=>{let te=!1;const F=De.map(ae=>{if(ae.payload.kind!=="url"||ae.payload.browserId!==ye)return ae;const we=Ne.url??ae.payload.url,Le=Ne.title||ae.payload.title||we,He=Ne.pageId??ae.payload.pageId;return we===ae.payload.url&&Le===(ae.payload.title||ae.title)&&He===ae.payload.pageId&&Le===ae.title?ae:(te=!0,{...ae,title:Le,payload:{...ae.payload,url:we,title:Le,...He!=null?{pageId:He}:{}}})});return te&&(U.current=F),te?F:De})},[]),Ze=k.useCallback((ye,Ne)=>{f(De=>{let te=!1;const F=De.map(ae=>{if(ae.payload.kind!=="terminal"||ae.payload.terminalId!==ye)return ae;const we=Ne.title||ae.payload.title||ae.title,Le=Ne.cwd??ae.payload.cwd;return we===ae.title&&Le===ae.payload.cwd&&we===(ae.payload.title||ae.title)?ae:(te=!0,{...ae,title:we,payload:{...ae.payload,title:we,...Le!=null?{cwd:Le}:{}}})});return te&&($.current=F),te?F:De})},[]),Qe=k.useCallback(()=>{R.current==="terminal"?(f(ye=>ye.length===0?ye:($.current=ye,X.current&&(D.current=X.current),[])),y(null)):(u(ye=>ye.length===0?ye:(U.current=ye,W.current&&(Y.current=W.current),[])),h(null),Ce()),T(!1)},[Ce]),Re=k.useCallback(()=>{if(R.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(U.current.length>0){const He=U.current,de=Y.current&&He.some(fe=>fe.id===Y.current)?Y.current:He[0].id;u(He),h(de),Y.current=de,n(!0);return}const ae=Yi(),we=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,Le={id:ae,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:we}};U.current=[Le],u([Le]),h(Le.id),Y.current=Le.id,n(!0);return}const ye=Yi(),Ne=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let De,te=!1,F=!1;l("browser"),u(ae=>{if(ae.length>0)return U.current=ae,W.current&&(Y.current=W.current),F=!0,De=null,[];if(U.current.length>0){te=!0;const Le=U.current;return De=Y.current&&Le.some(de=>de.id===Y.current)?Y.current:Le[0].id,Le}te=!0;const we={id:ye,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ne}};return U.current=[we],De=we.id,[we]}),te&&n(!0),F?(h(null),T(!1),Ce()):De!=null&&(h(De),Y.current=De)},[c.length,m.length,Ce]),Xe=k.useCallback(()=>{if(R.current==="browser"&&c.length>0){if(l("terminal"),Ce(),m.length>0){n(!0);return}if($.current.length>0){const He=$.current,de=D.current&&He.some(fe=>fe.id===D.current)?D.current:He[0].id;f(He),y(de),D.current=de,n(!0);return}const ae=Yi(),we=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;Ds(we);const Le={id:ae,title:"Terminal",payload:{kind:"terminal",terminalId:we,title:"Terminal"}};$.current=[Le],f([Le]),y(Le.id),D.current=Le.id,n(!0);return}const ye=Yi(),Ne=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;Ds(Ne);let De,te=!1,F=!1;l("terminal"),Ce(),f(ae=>{if(ae.length>0)return $.current=ae,X.current&&(D.current=X.current),F=!0,De=null,[];if($.current.length>0){te=!0;const Le=$.current;return De=D.current&&Le.some(de=>de.id===D.current)?D.current:Le[0].id,Le}te=!0;const we={id:ye,title:"Terminal",payload:{kind:"terminal",terminalId:Ne,title:"Terminal"}};return $.current=[we],De=we.id,[we]}),te&&n(!0),F?(y(null),T(!1)):De!=null&&(y(De),D.current=De)},[c.length,m.length,Ce]),wt=k.useCallback(ye=>{const Ne=R.current==="terminal"?m:c;if(Ne.length<2)return;const De=R.current==="terminal"?X.current:W.current,F=(Math.max(0,Ne.findIndex(we=>we.id===De))+ye+Ne.length)%Ne.length,ae=Ne[F].id;R.current==="terminal"?(y(ae),D.current=ae):(h(ae),Y.current=ae)},[c,m]),mt=k.useCallback(ye=>{const De=(R.current==="terminal"?m:c)[ye];De&&(R.current==="terminal"?(y(De.id),D.current=De.id):(h(De.id),Y.current=De.id))},[c,m]),kt=k.useCallback(()=>{if(R.current==="terminal"){const Ne=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ce({kind:"terminal",terminalId:Ne,title:"Terminal"});return}const ye=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ce({kind:"url",url:"about:blank",title:"New Tab",browserId:ye})},[ce]),lt=k.useCallback(ye=>{const Ne=se.current,De=Ne.findIndex(He=>He.payload.kind==="terminal"&&He.payload.terminalId===ye);if(De<0){Eg(ye),window.markusDesktop?.terminal?.destroy(ye);return}const te=Ne[De];if(Ne.length>1){P(te.id);return}Eg(ye),window.markusDesktop?.terminal?.destroy(ye);const F=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;Ds(F);const ae=te.payload.kind==="terminal"&&(te.payload.title||te.title)||"Terminal",we=te.payload.kind==="terminal"?te.payload.cwd:void 0,Le={id:te.id,title:ae,payload:{kind:"terminal",terminalId:F,title:ae,cwd:we}};$.current=[Le],f([Le]),y(Le.id),D.current=Le.id,R.current!=="terminal"&&l("terminal")},[P]),Dt=k.useCallback(ye=>T(ye),[]),ht=k.useCallback(()=>T(ye=>!ye),[]),Oe=i==="terminal"?m:c,Nt=i==="terminal"?v:g,Gt=Oe.find(ye=>ye.id===Nt)??Oe[0]??null,ie=Gt?.payload??null,et=Oe.length>0,at=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:re,toggleLeftCollapsed:ue,keyboardPane:M,setKeyboardPane:j,l0FocusPageId:B,setL0FocusPageId:z,rightPanelMode:i,setRightPanelMode:q,switchRightPanelMode:V,rightPanel:ie,rightPanelOpen:et,rightPanelTabs:Oe,activeRightPanelTabId:Gt?.id??null,openRightPanel:ce,closeRightPanel:Ee,closeRightPanelTab:P,setActiveRightPanelTab:$e,updateRightPanelBrowserTab:qe,updateRightPanelTerminalTab:Ze,toggleRightPanel:Re,toggleTerminalPanel:Xe,collapseRightPanelOnly:Qe,cycleRightPanelTab:wt,activateRightPanelTabAt:mt,openNewRightPanelTab:kt,handleTerminalExit:lt,rightPanelFullscreen:w,setRightPanelFullscreen:Dt,toggleRightPanelFullscreen:ht,hostAvailable:C,setHostAvailable:A}),[t,re,ue,M,j,B,z,i,q,V,ie,et,Oe,Gt,ce,Ee,P,$e,qe,Ze,Re,Xe,Qe,wt,mt,kt,lt,w,Dt,ht,C]);return o.jsx(gC.Provider,{value:at,children:e})}function pp(){return k.useContext(gC)}const Sie={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function bC(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const yC={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},vC={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},Cie=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function Im(e){return Cie.test(e.trim())}function Aie(e){const t=e.split("_")[0]?.toLowerCase();return t?Sie[t]:void 0}async function xC(e){const t=await iie(e)??e;t.startsWith("tsk_")?yt.navigate(me.WORK,{openTask:t}):t.startsWith("req_")?yt.navigate(me.WORK,{openRequirement:t}):t.startsWith("proj_")?yt.navigate(me.WORK,{projectId:t}):t.startsWith("dlv_")?yt.navigate(me.DELIVERABLES,{openDeliverable:t}):t.startsWith("agt_")?yt.navigate(me.TEAM,{agentId:t}):t.startsWith("team_")&&yt.navigate(me.TEAM,{selectTeam:t})}const Qu=new Map,Ru=new Map,Xu=new Map;function Tie(e,t){const n=Xu.get(e)??new Set;return n.add(t),Xu.set(e,n),()=>{n.delete(t),n.size===0&&Xu.delete(e)}}function Eie(e){Qu.delete(e);for(const t of Xu.get(e)??[])t()}const Nie=["task:update","task:create","requirement:update","requirement:updated","deliverable:update","deliverable:updated","project:update","team:update"];function Mie(e){const t=e?.payload??{};for(const n of["taskId","requirementId","deliverableId","projectId","teamId","id"]){const a=t[n];if(typeof a=="string")return a}for(const n of["requirement","deliverable","task","project","team"]){const a=t[n];if(a&&typeof a.id=="string")return a.id}}let Nk=!1;function jie(){if(Nk)return;Nk=!0;const e=t=>{const n=Mie(t);n&&Eie(n)};for(const t of Nie)try{_s.on(t,e)}catch{}}async function Rie(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const a=await Te.tasks.get(e);return{...n,title:a.task.title,status:a.task.status,blockedReason:a.task.blockedReason??null}}case"requirement":{const a=await Te.requirements.get(e),i=a.requirement;return{...n,title:a.requirement.title,status:a.requirement.status,blockedReason:i.blockedReason??null}}case"project":{const a=await Te.projects.get(e);return{...n,title:a.project.name,status:a.project.status,summary:a.project.description}}case"deliverable":{const a=await Te.deliverables.get(e);return{...n,title:a.deliverable.title,status:a.deliverable.status,summary:a.deliverable.summary,deliverable:a.deliverable}}case"agent":{const a=await Te.agents.get(e);return{...n,title:a.name,summary:a.role}}case"team":{const i=(await Te.teams.list()).teams.find(l=>l.id===e);return{...n,title:i?.name??e,notFound:!i}}}}catch{}return{...n,notFound:!0}}function wC(e,t){const n=t??Aie(e),[a,i]=k.useState(()=>Qu.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){i({id:e,type:"task",title:e,loading:!1,notFound:!0});return}let l=!0;const c=m=>{const f=m?Qu.get(e):void 0;if(f){i(f);return}m&&i(h=>({...h,type:n,loading:!0}));let g=Ru.get(e);g||(g=Rie(e,n),Ru.set(e,g)),g.then(h=>{Qu.set(e,h),Ru.delete(e),l&&i(h)}).catch(()=>{Ru.delete(e),l&&i({id:e,type:n,title:e,loading:!1,notFound:!0})})};c(!0),jie();const u=Tie(e,()=>c(!1));return()=>{l=!1,u()}},[e,n]),a}function kC(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function bc({id:e,type:t,label:n}){const a=wC(e,t),i=pp(),l=yC[a.type]??"🔗",c=n??(a.loading||a.notFound?kC(e):a.title),u=m=>{if(m.preventDefault(),m.stopPropagation(),a.type==="deliverable"&&a.deliverable&&i?.hostAvailable){i.openRightPanel({kind:"deliverable",deliverable:a.deliverable});return}xC(e)};return o.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:u,title:`${vC[a.type]}: ${a.notFound?e:a.title} (${e})`,children:[o.jsx("span",{className:"text-[10px]",children:l}),o.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:c})]})}function _ie({id:e,type:t,label:n}){const{t:a}=xt(["common"]),i=wC(e,t),[l,c]=k.useState(!1),u=pp(),m=yC[i.type]??"🔗",f=()=>{if(i.type==="deliverable"&&i.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:i.deliverable});return}c(!0);return}xC(e)},g=i.loading?kC(e):n||(i.notFound?e:i.title);return o.jsxs("span",{className:"not-prose block my-2",children:[o.jsxs("button",{type:"button",onClick:f,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:[o.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:m}),o.jsxs("span",{className:"flex-1 min-w-0 block",children:[o.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:vC[i.type]}),i.status&&(()=>{const h=i.type==="task"||i.type==="requirement"?cV(i.status,a,i.blockedReason):null;return o.jsx("span",{"data-testid":"entity-status","data-status":i.status,className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${h?.tone?.chip??Tn[iV(i.type,i.status)].chip}`,children:h?.label??i.status})})()]}),o.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${i.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:g}),i.summary&&i.summary.trim()!==i.title.trim()&&o.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:i.summary})]}),o.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:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l&&i.deliverable&&o.jsx(lie,{item:i.deliverable,onClose:()=>c(!1),onOpenInPage:h=>{c(!1),yt.navigate(me.DELIVERABLES,{openDeliverable:h})}})]})}function Die(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Iie(e){if((e.includes("\\")?"\\":"/")==="/")return{segments:e.split("/").filter(Boolean),root:"/"};const n=e.match(/^([A-Za-z]:\\)(.*)$/);return n?{segments:n[2].split("\\").filter(Boolean),root:n[1]}:{segments:e.split("\\").filter(Boolean),root:""}}function Lie(e,t,n){if(t.length===0)return e||".";const a=t.join(n);return n==="/"?e==="/"?`/${a}`:`${e}${a}`:`${e}${a}`}const Mk={md:"MD",markdown:"MD",html:"HTML",htm:"HTML",json:"JSON",csv:"CSV",pdf:"PDF",docx:"DOCX",doc:"DOC",xlsx:"XLSX",xls:"XLS",pptx:"PPTX",ppt:"PPT",txt:"TXT",ts:"TS",tsx:"TSX",js:"JS",jsx:"JSX",py:"PY",css:"CSS"},Dg={png:"IMG",jpg:"IMG",jpeg:"IMG",gif:"IMG",webp:"IMG",svg:"IMG",bmp:"IMG",ico:"IMG",avif:"IMG",mp3:"AUDIO",wav:"AUDIO",ogg:"AUDIO",flac:"AUDIO",aac:"AUDIO",m4a:"AUDIO",mp4:"VIDEO",webm:"VIDEO",mov:"VIDEO",mkv:"VIDEO",avi:"VIDEO",m4v:"VIDEO"};function Pie(e,t=!1){if(t)return"目录";if(!e)return"文件";const n=e.replace(/^\./,"").toLowerCase();return Dg[n]?Dg[n]:Mk[n]?Mk[n]:n.slice(0,6).toUpperCase()||"文件"}function Oie({path:e,entries:t,onNavigate:n,onOpenFile:a,onReveal:i,onCopyPath:l,emptyText:c}){const{segments:u,root:m}=k.useMemo(()=>Iie(e),[e]),f=e.includes("\\")?"\\":"/",[g,h]=k.useState(!1),v=async()=>{const w=l?.(e);try{if(w&&typeof w.then=="function"&&await w===!1)return}catch{return}h(!0),window.setTimeout(()=>h(!1),2e3)},y=k.useMemo(()=>{const w=[];m&&w.push({label:m.replace(/[\\/]$/,""),path:m});let T=m;for(let C=0;C<u.length;C++)T=Lie(m,u.slice(0,C+1),f),w.push({label:u[C],path:T});return w},[m,u,f]);return o.jsxs("div",{className:"flex flex-col min-h-0 h-full",children:[(i||l)&&o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle bg-surface-secondary/50 shrink-0","data-testid":"dir-top-actions",children:[o.jsx("span",{className:"flex-1 min-w-0 text-[11px] font-mono text-fg-tertiary truncate",title:e,children:e}),l&&o.jsx("button",{className:`shrink-0 text-[11px] cursor-pointer transition-colors ${g?"text-green-500 font-medium":"text-fg-secondary hover:text-fg-primary hover:underline"}`,onClick:()=>{v()},title:g?"已复制":"复制路径",children:g?"✓ 已复制":"复制路径"}),i&&o.jsx("button",{className:"shrink-0 text-[11px] text-fg-secondary hover:text-fg-primary hover:underline cursor-pointer",onClick:()=>i(e),children:"在文件浏览器中显示"})]}),o.jsx("div",{className:"flex items-center gap-1 flex-wrap px-3 py-2 border-b border-border-subtle bg-surface-secondary/50 text-xs shrink-0","data-testid":"dir-breadcrumb",children:y.map((w,T)=>{const C=T===y.length-1;return o.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[T>0&&o.jsx("span",{className:"text-fg-tertiary select-none",children:"/"}),C?o.jsx("span",{className:"text-fg-primary font-medium truncate max-w-[180px]",children:w.label}):o.jsx("button",{className:"text-fg-secondary hover:text-brand-500 hover:underline truncate max-w-[140px] cursor-pointer",onClick:()=>n(w.path),title:w.path,children:w.label})]},w.path)})}),o.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?o.jsx("p",{className:"px-4 py-8 text-center text-xs text-fg-tertiary",children:c??"此目录为空"}):t.map(w=>{const T=w.isDirectory?void 0:Pie(w.ext),C=!!w.ext&&!!Dg[w.ext.replace(/^\./,"").toLowerCase()];return o.jsxs("button",{className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left hover:bg-surface-overlay/60 transition-colors cursor-pointer group",onClick:()=>w.isDirectory?n(w.path):a(w.path),title:w.path,children:[w.isDirectory?o.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}):C?o.jsx("svg",{className:"w-4 h-4 shrink-0 text-purple-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4 5a2 2 0 012-2h3.5a1.5 1.5 0 011.06.44l1.5 1.5c.14.14.331.22.53.22H14a2 2 0 012 2v7a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm4.5 4.5a.75.75 0 00-1.5 0v3a.75.75 0 001.06.68l2.5-1.5a.75.75 0 000-1.32l-2.5-1.5a.75.75 0 00-.56-.06z",clipRule:"evenodd"})}):o.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-tertiary group-hover:text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})}),o.jsx("span",{className:"flex-1 min-w-0 text-sm text-fg-primary truncate",children:w.name}),T&&o.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[10px] font-mono uppercase bg-surface-overlay/60 text-fg-tertiary border border-border-subtle",children:T}),!w.isDirectory&&o.jsx("span",{className:"shrink-0 text-[11px] text-fg-tertiary tabular-nums",children:Die(w.size)})]},w.path)})})]})}const jk=new Set(["pdf","docx","xlsx"]),zie=30*1024*1024;function Hie({data:e,reference:t,onFallback:n}){const{t:a}=xt("deliverables"),i=(e.format||"").toLowerCase().replace(/^\./,""),l=k.useRef(null),[c,u]=k.useState("loading"),[m,f]=k.useState(""),[g,h]=k.useState(0),[v,y]=k.useState(null),[w,T]=k.useState(1),[C,A]=k.useState(1),M=k.useCallback(()=>{n?.()},[n]),I=k.useCallback(async()=>{if(t)try{await Te.files.reveal(t);return}catch{}M()},[t,M]),B=k.useCallback(j=>{const z=l.current?.querySelector(`canvas[data-page="${j}"]`);z&&(z.scrollIntoView({behavior:"smooth",block:"start"}),T(j))},[]);k.useEffect(()=>{const j=l.current;if(!j||!jk.has(i)){u("ready");return}let z=!1,U;return u("loading"),f(""),j.innerHTML="",(async()=>{try{i==="pdf"?U=await Uie(e.streamUrl,j,{onReady:Y=>{y(Y),T(1)},zoom:C}):i==="docx"?U=await Gie(e.streamUrl,j):i==="xlsx"&&(U=await Kie(e.streamUrl,j)),z||u("ready")}catch(Y){z||(u("error"),f(String(Y)))}})(),()=>{z=!0,U&&U(),j.innerHTML=""}},[e.streamUrl,i,g,C]);const K=!jk.has(i);return o.jsx("div",{className:"flex flex-col h-full min-h-0",children:K?o.jsx(Bie,{format:i,size:e.size,onOpenSystem:I,onDownload:()=>M()}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-1.5 border-b border-border-default/60 bg-surface-elevated/40",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wide",children:i}),e.name&&o.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1 min-w-0",title:e.name,children:e.name}),e.size!=null&&e.size>zie&&o.jsx("span",{className:"text-[10px] text-amber-500 shrink-0",children:a("officeLargeFile")}),i==="pdf"&&v!=null&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx("button",{onClick:()=>B(Math.max(1,w-1)),disabled:w<=1,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"‹"}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[w,"/",v]}),o.jsx("button",{onClick:()=>B(Math.min(v??1,w+1)),disabled:w>=(v??1),className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"›"})]}),i==="pdf"&&o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx("button",{onClick:()=>A(j=>Math.max(.5,+(j-.25).toFixed(2))),disabled:C<=.5,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"−"}),o.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[Math.round(C*100),"%"]}),o.jsx("button",{onClick:()=>A(j=>Math.min(3,+(j+.25).toFixed(2))),disabled:C>=3,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"+"})]}),o.jsx("button",{onClick:I,className:"shrink-0 text-[10px] text-fg-tertiary hover:text-fg-secondary px-1.5 py-0.5 rounded hover:bg-surface-overlay transition-colors",children:a("officeOpenSystem")})]}),o.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:[c==="loading"&&o.jsxs("div",{className:"flex items-center justify-center h-full text-fg-tertiary",children:[o.jsxs("svg",{className:"animate-spin w-4 h-4 mr-2",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),o.jsx("span",{className:"text-xs",children:a("officeLoading")})]}),c==="error"&&o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[o.jsx("span",{className:"text-[11px] text-fg-tertiary",children:a("officeFailed")}),o.jsx("span",{className:"text-[10px] text-fg-muted max-w-xs truncate",children:m}),o.jsxs("div",{className:"flex gap-2 mt-1",children:[o.jsx("button",{onClick:()=>h(j=>j+1),className:"px-3 py-1.5 text-xs bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors",children:a("officeRetry")}),o.jsx("button",{onClick:I,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:a("officeOpenSystem")})]})]}),o.jsx("div",{ref:l,className:c==="loading"?"hidden":""})]})]})})}function Bie({format:e,size:t,onOpenSystem:n,onDownload:a}){const{t:i}=xt("deliverables");return o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-center px-6",children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-surface-elevated flex items-center justify-center text-xl",children:"📄"}),o.jsx("div",{className:"text-xs text-fg-secondary",children:i("officeNoInlinePreview",{format:e})}),t!=null&&o.jsx("div",{className:"text-[10px] text-fg-tertiary",children:i("officeSize",{size:$ie(t)})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs bg-brand-600 text-on-brand rounded-lg hover:bg-brand-500 transition-colors",children:i("officeOpenSystem")}),o.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:i("officeDownload")})]})]})}function $ie(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function qie(){const e=Uint8Array.prototype;typeof e.toHex!="function"&&(e.toHex=function(){let i="",l=0,c=this.length,u;for(;l<c;++l)u=this[l],i+=(u>>>4).toString(16)+(u&15).toString(16);return i});const t=Map.prototype;typeof t.getOrInsertComputed!="function"&&(t.getOrInsertComputed=function(i,l){if(this.has(i))return this.get(i);const c=l(i);return this.set(i,c),c}),typeof t.getOrInsert!="function"&&(t.getOrInsert=function(i,l){return this.has(i)?this.get(i):(this.set(i,l),l)});const n=Promise;typeof n.try!="function"&&(n.try=function(i){return new Promise(l=>l(i()))});const a=typeof Iterator<"u"?Iterator.prototype:null;a&&typeof a.join!="function"&&(a.join=function(i=","){let l="",c=!0;for(const u of this)c||(l+=i),l+=String(u),c=!1;return l})}qie();let wh=null;function Fie(){if(!wh){const t=`
|
|
815
815
|
if (typeof Uint8Array.prototype.toHex !== 'function') {
|
|
816
816
|
Uint8Array.prototype.toHex = function() {
|
|
817
817
|
var s = '', i = 0, n = this.length, b;
|
|
@@ -844,14 +844,14 @@ if (ip && typeof ip.join !== 'function') {
|
|
|
844
844
|
};
|
|
845
845
|
}
|
|
846
846
|
await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).toString()}");
|
|
847
|
-
`;wh=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return wh}async function Uie(e,t,n){const a=await Ca(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=Fie();const i=await a.getDocument({url:e}).promise,l=[];for(let c=1;c<=i.numPages;c++){const u=await i.getPage(c),m=u.getViewport({scale:1.5*n.zoom}),f=document.createElement("canvas");f.width=Math.floor(m.width),f.height=Math.floor(m.height),f.style.width=`${Math.floor(m.width)}px`,f.style.height=`${Math.floor(m.height)}px`,f.style.marginBottom="8px",f.style.boxShadow="0 1px 4px rgba(0,0,0,0.15)",f.style.borderRadius="2px";const g=f.getContext("2d");if(!g)throw new Error("canvas 2d context unavailable");await u.render({canvas:f,canvasContext:g,viewport:m}).promise,f.dataset.page=String(c),t.appendChild(f),l.push(f)}return n.onReady(i.numPages),()=>{for(const c of l)c.remove();i.cleanup()}}async function Gie(e,t){const{renderAsync:n}=await Ca(async()=>{const{renderAsync:i}=await import("./docx-preview-
|
|
847
|
+
`;wh=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return wh}async function Uie(e,t,n){const a=await Ca(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=Fie();const i=await a.getDocument({url:e}).promise,l=[];for(let c=1;c<=i.numPages;c++){const u=await i.getPage(c),m=u.getViewport({scale:1.5*n.zoom}),f=document.createElement("canvas");f.width=Math.floor(m.width),f.height=Math.floor(m.height),f.style.width=`${Math.floor(m.width)}px`,f.style.height=`${Math.floor(m.height)}px`,f.style.marginBottom="8px",f.style.boxShadow="0 1px 4px rgba(0,0,0,0.15)",f.style.borderRadius="2px";const g=f.getContext("2d");if(!g)throw new Error("canvas 2d context unavailable");await u.render({canvas:f,canvasContext:g,viewport:m}).promise,f.dataset.page=String(c),t.appendChild(f),l.push(f)}return n.onReady(i.numPages),()=>{for(const c of l)c.remove();i.cleanup()}}async function Gie(e,t){const{renderAsync:n}=await Ca(async()=>{const{renderAsync:i}=await import("./docx-preview-DBAZFeEb.js");return{renderAsync:i}},[]),a=await fetch(e).then(i=>{if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.blob()});if(a.size===0)throw new Error("empty docx");return await n(a,t,void 0,{inWrapper:!0,ignoreWidth:!0,ignoreHeight:!1,breakPages:!0,className:"office-docx"}),()=>{t.innerHTML=""}}async function Kie(e,t){const n=await Ca(()=>import("./xlsx-CNerDvZX.js"),[]),a=await fetch(e).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);return u.arrayBuffer()});if(a.byteLength===0)throw new Error("empty xlsx");const i=n.read(a,{type:"array"});if(!i.SheetNames||i.SheetNames.length===0)throw new Error("no sheets");const l=n.utils.sheet_to_html(i.Sheets[i.SheetNames[0]],{id:"office-xlsx-sheet",editable:!1});t.innerHTML=l;const c=document.createElement("style");return c.textContent=`
|
|
848
848
|
#office-xlsx-sheet { border-collapse: collapse; font-size: 12px; color: var(--fg-primary, #333); }
|
|
849
849
|
#office-xlsx-sheet td, #office-xlsx-sheet th {
|
|
850
850
|
border: 1px solid var(--border-default, #ddd); padding: 4px 8px; white-space: nowrap;
|
|
851
851
|
background: var(--surface-primary, #fff);
|
|
852
852
|
}
|
|
853
853
|
#office-xlsx-sheet th { background: var(--surface-elevated, #f3f4f6); font-weight: 600; }
|
|
854
|
-
`,t.prepend(c),()=>{t.innerHTML=""}}let Dc=null;const Ig=new Set;function SC(){for(const e of Ig)e()}function Vie(e){Dc!==e&&(Dc=e,SC())}function Wie(){Dc!==null&&(Dc=null,SC())}function Rk(){return Dc}function Yie(e){return Ig.add(e),()=>{Ig.delete(e)}}k.lazy(()=>Ca(()=>import("./MarkdownMessage-DwxvYN4X.js"),[]).then(e=>({default:e.MarkdownMessage})));const Qie=k.lazy(()=>Ca(()=>import("./ContentRenderer-DxgRNOd1.js"),[]).then(e=>({default:e.ContentRenderer})));let Io=[],_k=60;function Xie(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++_k);return k.useEffect(()=>{const a=()=>t.current();Io.push(a);const i=l=>{l.key==="Escape"&&Io[Io.length-1]===a&&(l.preventDefault(),a())};return window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("keydown",i,!0),Io=Io.filter(l=>l!==a),Io.length===0&&(_k=60)}},[]),n}const Dk=500,Ji=new Map,Lm=new Set,Ju=new Map;let Zu=null;function Jie(){if(Ji.size<=Dk)return;const e=Ji.size-Dk,t=Ji.keys();for(let n=0;n<e;n++){const{value:a,done:i}=t.next();if(i)break;Ji.delete(a)}}function Ik(e,t){Ji.delete(e),Ji.set(e,t),Jie()}function Lk(e){const t=Ju.get(e);if(t)for(const n of t)n()}function Zie(){Zu=null;const e=[...Lm];Lm.clear(),e.length!==0&&Te.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))Ik(n,a),Lk(n)}).catch(()=>{for(const t of e)Ik(t,{exists:!1,isFile:!1,type:"unknown"}),Lk(t)})}function ese(e){Ji.has(e)||Lm.has(e)||(Lm.add(e),Zu&&clearTimeout(Zu),Zu=setTimeout(Zie,30))}function tse(e,t){let n=Ju.get(e);return n||(n=new Set,Ju.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Ju.delete(e)}}function nse(e){const t=k.useCallback(i=>tse(e,i),[e]),n=k.useCallback(()=>Ji.get(e),[e]),a=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{ese(e)},[e]),a}function ase(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function rse({filePath:e,onClose:t}){const n=Xie(t),[a,i]=k.useState(e),[l,c]=k.useState(!0),[u,m]=k.useState(null),[f,g]=k.useState(""),[h,v]=k.useState(""),[y,w]=k.useState(""),[T,C]=k.useState(""),[A,M]=k.useState(""),[I,B]=k.useState(null),[K,j]=k.useState(!1);k.useEffect(()=>{c(!0),m(null),g(""),B(null),Te.files.preview(a).then(D=>{if(D.type==="directory"&&Array.isArray(D.entries)){v("directory"),w(D.name),B(D.entries);return}v(D.type),w(D.name),C(D.mimeType||""),g(typeof D.content=="string"?D.content:""),M(D.streamUrl||(D.path?Te.files.streamUrl(D.path):"")||(D.type==="audio"||D.type==="video"?Te.files.streamUrl(a):""))}).catch(D=>{m(String(D?.message||D))}).finally(()=>{c(!1)})},[a]);const z=y||a.split(/[/\\]/).pop()||a,U=h==="directory"||a!==e,Y=()=>i(D=>ase(D)),$=()=>{navigator.clipboard?.writeText(a).then(()=>{j(!0),setTimeout(()=>j(!1),1500)}).catch(()=>{})};return Lc.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:o.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:D=>D.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h==="directory"&&o.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}),h!=="directory"&&o.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})}),o.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:z}),o.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:a})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[U&&o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:Y,title:"返回上级目录",children:"← 上级"}),o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:$,title:"复制路径",children:K?"✓ 已复制":"复制路径"}),o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Te.files.reveal(a),title:"Reveal in file explorer",children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})})}),o.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})})})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[l&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),u&&o.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[o.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),o.jsx("p",{className:"text-xs text-fg-tertiary",children:u})]}),!l&&!u&&h==="directory"&&I&&o.jsx(Oie,{path:a,entries:I,onNavigate:D=>i(D),onOpenFile:D=>i(D),onReveal:D=>Te.files.reveal(D),onCopyPath:D=>{navigator.clipboard?.writeText(D).then(()=>{j(!0),setTimeout(()=>j(!1),1500)}).catch(()=>{})}}),!l&&!u&&h==="office"&&A&&o.jsx(Hie,{data:{format:(a.split(".").pop()||"pdf").toLowerCase(),streamUrl:A,name:z},reference:a,onFallback:()=>{Te.files.reveal(a)}}),!l&&!u&&h==="image"&&f&&o.jsx("div",{className:"flex justify-center",children:o.jsx("img",{src:`data:${T||"image/png"};base64,${f}`,alt:z,className:"max-w-full rounded"})}),!l&&!u&&h==="audio"&&A&&o.jsx("audio",{controls:!0,preload:"metadata",src:A,className:"w-full"}),!l&&!u&&h==="video"&&A&&o.jsx("video",{controls:!0,preload:"metadata",src:A,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!l&&!u&&(h==="binary"||!f&&h!=="image"&&h!=="audio"&&h!=="video"&&h!=="directory")&&o.jsxs("div",{className:"text-center py-8 space-y-3",children:[o.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),o.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:()=>{Te.files.reveal(a)},children:"Reveal in file explorer"})]}),!l&&!u&&f&&h!=="image"&&h!=="audio"&&h!=="video"&&h!=="binary"&&h!=="directory"&&o.jsx(k.Suspense,{fallback:o.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:o.jsx(Qie,{content:f,format:h==="text"?"text":h,className:"text-sm"})})]})]})}),document.body)}function ise({path:e}){const t=nse(e),n=pp(),a=t?.exists??!1,i=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video"||t?.type==="office"||t?.type==="directory",l=k.useCallback(m=>{if(m.preventDefault(),m.stopPropagation(),!!a)if(i){if(n?.hostAvailable){n.openRightPanel({kind:"file",path:e});return}Vie(e)}else Te.files.reveal(e)},[a,i,e,n]),c="inline w-3 h-3 align-[-0.125em]",u=i?o.jsx("svg",{className:c,viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})}):o.jsx("svg",{className:c,viewBox:"0 0 20 20",fill:"currentColor",children:o.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?a?o.jsxs("code",{"data-file-path-link":"ready",className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:l,title:i?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[o.jsxs("span",{className:"whitespace-nowrap",children:[u,e.charAt(0)]}),e.slice(1)]}):o.jsx("code",{"data-file-path-link":"missing",className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:"File not found",children:e}):o.jsx("code",{"data-file-path-link":"loading",className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}function sse(){const e=k.useSyncExternalStore(Yie,Rk,Rk);return e?o.jsx(rse,{filePath:e,onClose:Wie},e):null}let kh=null;function ose(){return kh||(kh=Ca(()=>import("./mermaid.core-BSghRCEC.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),kh}function lse(){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 cse(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 dse(){return lse()}function use(){return k.useSyncExternalStore(cse,dse)}function CC({code:e}){const{t}=xt("common"),n=k.useRef(null),[a,i]=k.useState(null),[l,c]=k.useState(!0),u=k.useId(),m=k.useRef(0),f=k.useRef(null),g=use();return k.useEffect(()=>{if(!e.trim()||f.current&&f.current.code===e&&f.current.dark===g)return;let h=!1;return c(!0),i(null),m.current+=1,(async()=>{try{const v=await ose();if(h)return;v.default.initialize({startOnLoad:!1,theme:g?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${u.replace(/:/g,"")}-${m.current}`,{svg:w}=await v.default.render(y,e.trim());if(h)return;n.current&&(n.current.innerHTML=w,f.current={code:e,dark:g})}catch(v){h||i(v instanceof Error?v.message:String(v))}finally{h||c(!1)}})(),()=>{h=!0}},[e,u,g]),a?o.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[o.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:[o.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.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"})}),o.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.mermaidRenderError")})]}),a&&o.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:a}),o.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):o.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&o.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),o.jsx("div",{ref:n,className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`})]})}const mse="/assets/viz-global-C_AyN6D9.js";let _u=!1,Sh=null;function pse(){return _u?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(_u=!0,e()):(n.addEventListener("load",()=>{_u=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const a=document.createElement("script");a.setAttribute("data-plantuml-viz",""),a.src=mse,a.onload=()=>{_u=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function fse(){return Sh||(Sh=pse().then(()=>Ca(()=>import("./plantuml-DezRDxd4.js"),[]))),Sh}let Pk=Promise.resolve();function hse(e,t){const n=Pk.then(()=>new Promise((a,i)=>{fse().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,i,{dark:t})}).catch(i)}));return Pk=n.then(()=>{},()=>{}),n}function gse(){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 bse(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 yse(){return k.useSyncExternalStore(bse,()=>gse())}function AC({code:e}){const{t}=xt("common"),[n,a]=k.useState(null),[i,l]=k.useState(null),[c,u]=k.useState(!0),m=k.useRef(null),f=yse();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===f)return;let g=!1;return u(!0),l(null),hse(e.trim(),f).then(h=>{g||(a(h),m.current={code:e,dark:f})}).catch(h=>{g||l(h instanceof Error?h.message:String(h))}).finally(()=>{g||u(!1)}),()=>{g=!0}},[e,f]),i?o.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[o.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:[o.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.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"})}),o.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.plantumlRenderError")})]}),i&&o.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:i}),o.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):o.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[c&&o.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),n&&o.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${c?" hidden":""}`,dangerouslySetInnerHTML:{__html:n}})]})}function vse(e,t,n){const a=e.cloneNode(!0),i=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",c=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},u=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:${u.text};line-height:1.7;`,h1:`font-size:${c.h1}em;font-weight:700;color:${u.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${u.border};padding-bottom:6px;`,h2:`font-size:${c.h2}em;font-weight:700;color:${u.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${u.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.h4}em;font-weight:600;color:${u.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${u.strong};`,em:"font-style:italic;",a:`color:${u.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:${u.text};`,blockquote:`border-left:3px solid ${u.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${u.blockquoteText};`,hr:`border:none;border-top:1px solid ${u.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${u.tableHeaderBg};`,th:`border:1px solid ${u.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${u.tableHeaderText};`,td:`border:1px solid ${u.tableBorder};padding:8px 12px;color:${u.text};`,img:"max-width:100%;height:auto;"};function f(g){g.removeAttribute("class");const h=g.tagName.toLowerCase();if(h==="pre"){g.setAttribute("style",`background:${u.preBg};color:${u.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${u.preBorder};`);const v=g.querySelector("code");v&&(v.removeAttribute("class"),v.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}h==="code"?g.setAttribute("style",`background:${u.codeBg};color:${u.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[h]&&g.setAttribute("style",m[h]),Array.from(g.children).forEach(f)}return a.removeAttribute("class"),Array.from(a.children).forEach(g=>f(g)),`<div style="background:${u.bg};color:${u.text};padding:20px 24px;font-family:${i};font-size:${l};line-height:1.7;max-width:800px;">${a.innerHTML}</div>`}async function TC(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 Qle(e,t,n,a){const i=vse(e,t,a);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([i],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await TC(n),method:"text"}}}function Lg({code:e,language:t,children:n}){const{t:a}=xt("common"),[i,l]=k.useState("rendered"),[c,u]=k.useState(!1),m=k.useCallback(async()=>{await TC(e)&&(u(!0),setTimeout(()=>u(!1),1800))},[e]);return o.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${i==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),a("markdown.viewRendered")]})}),o.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${i==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),a("markdown.viewSource")]})})]})]}),i==="rendered"?o.jsx("div",{children:n}):o.jsxs("div",{className:"relative group/source",children:[o.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}),o.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:a("markdown.copyContent"),children:c?o.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.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 xse=[CC,AC];function wse(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return tie(n)}return null}function yc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(yc).join("");if(k.isValidElement(e)){const t=e.props;return yc(t.children)}return""}function kse({children:e}){const{t}=xt("common"),n=wse(e),a=k.useRef(null),[i,l]=k.useState(!1),[c,u]=k.useState("rendered"),m=k.useCallback(async()=>{let g;c==="source"?g=yc(e):g=a.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(g),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(k.Children.toArray(e).some(g=>k.isValidElement(g)&&xse.includes(g.type))){const g=yc(e),h=n==="mermaid"||n==="plantuml"?n:"diagram";return o.jsx(Lg,{code:g,language:h,children:e})}return n==="mermaid"||n==="plantuml"?o.jsx(o.Fragment,{children:e}):o.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:eie(n)}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>u("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),o.jsx("button",{onClick:()=>u("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),o.jsxs("div",{className:"relative",children:[c==="rendered"?o.jsx("pre",{ref:a,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,g=>k.isValidElement(g)?k.cloneElement(g,{style:{background:"transparent",padding:0}}):g)}):o.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:yc(e)}),o.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:t("markdown.copyContent"),children:i?o.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.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 Ok="#mention:",Pm="#entity:",Sse=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,EC=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Pg="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function Og(e){return e.type==="text"?e.value??"":(e.children??[]).map(Og).join("")}function Cse(e){return e.type==="text"&&(e.value??"").trim()===""}function Ase(e){if(!e?.children)return null;const t=e.children.filter(a=>!Cse(a));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const a=n.properties?.href;if(!a)return null;const i=Og(n);if(a.startsWith(Pm))return{id:a.slice(Pm.length)};const l=a.match(EC);return l&&l[1]!=="workflow"?{id:l[2],type:bC(l[1]),label:i}:null}if(n.type==="element"&&n.tagName==="code"){const a=Og(n).trim();if(Im(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Im(a))return{id:a}}return null}const Tse={p:({children:e})=>o.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>o.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>o.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>o.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>o.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>o.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>o.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>o.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>o.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>o.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),a=n.trim();if(t?.includes("language-plantuml")||Jre(a))return o.jsx(Lg,{code:a,language:"plantuml",children:o.jsx(AC,{code:a})});if(t?.includes("language-mermaid"))return o.jsx(Lg,{code:a,language:"mermaid",children:o.jsx(CC,{code:a})});if(t?.includes("language-"))return o.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Im(n))return o.jsx(bc,{id:n.trim()});const i=n.match(Sse);return i?o.jsx(bc,{id:i[2],label:i[1]}):$re(n)?o.jsx(ise,{path:n}):o.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})=>o.jsx(kse,{children:e}),strong:({children:e})=>o.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>o.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>o.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>o.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>o.jsx("a",{href:e,className:Pg,children:t}),hr:()=>o.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>o.jsx("div",{className:"overflow-x-auto my-2",children:o.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>o.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>o.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>o.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>o.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})=>o.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},Ese=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function Nse(e){const t=Rb(e);return zre(e)&&Ese.test(t.split("?")[0]??t)}function Mse(e,t){const n=Rb(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const i=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of i)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function jse(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function Rse(e,t){return Nse(e)?jse(Mse(e,t)):null}const Lo=new Map,ac=new Map,_se=k.memo(function({src:t,alt:n,onPreview:a,basePath:i}){const l=k.useMemo(()=>Rse(t,i)??t,[t,i]),c=l.startsWith("/api/files/image?"),u=Lo.get(l),m=ac.get(l),[f,g]=k.useState(u??(c?null:l)),[h,v]=k.useState(!!u),[y,w]=k.useState(!!m),[T,C]=k.useState(m??null),[A,M]=k.useState(0),I=k.useRef(0),B=k.useCallback(j=>{ac.set(l,j),C(j),w(!0),v(!1)},[l]),K=k.useCallback(()=>{Lo.delete(l),ac.delete(l),w(!1),C(null),v(!1),g(c?null:`${l}${l.includes("?")?"&":"?"}retry=${Date.now()}`),M(j=>j+1)},[l,c]);return k.useEffect(()=>{if(!c)return;const j=Lo.get(l);if(j){g(j),v(!0),w(!1),C(null);return}const z=ac.get(l);if(z!==void 0){w(!0),C(z),v(!1);return}const U=++I.current;w(!1),C(null),v(!1),g(null),(async()=>{try{const Y=await fetch(l,{credentials:"same-origin"});if(U!==I.current)return;if(!Y.ok){let W=`HTTP ${Y.status}`;try{const X=await Y.json();X.error&&(W=X.error)}catch{}throw new Error(W)}const $=await Y.blob();if(U!==I.current)return;if($.size===0)throw new Error("Empty image response");if($.type&&!$.type.startsWith("image/")&&!$.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${$.type}`);const D=URL.createObjectURL($);Lo.set(l,D),g(D),v(!0),w(!1),C(null)}catch(Y){if(U!==I.current)return;const $=Y instanceof Error?Y.message:String(Y);console.warn("[MarkdownImage] failed to load local image",l,Y),B($)}})()},[c,l,A]),k.useEffect(()=>{if(c)return;const j=ac.get(l);if(j!==void 0){w(!0),C(j),v(!1);return}g(l),v(!!Lo.get(l)),w(!1),C(null)},[l,c,A]),y?o.jsxs("button",{type:"button",onClick:K,title:T??"Click to retry",className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[o.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[o.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),o.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),o.jsx("polyline",{points:"21 15 16 10 5 21"})]}),o.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",T?` (${T})`:""]})]}):o.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!h&&o.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),f?o.jsx("img",{src:f,alt:n??"",onLoad:()=>{c||Lo.set(l,l),v(!0)},onError:()=>{B("Image decode failed")},onClick:()=>a?.(f),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${h?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})});async function zk(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function Dse(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const a=n.getContext("2d");if(!a)throw new Error("Canvas unavailable");return a.drawImage(t,0,0),t.close(),new Promise((i,l)=>{n.toBlob(c=>c?i(c):l(new Error("PNG encode failed")),"image/png")})}function Ise(e,t){try{const i=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(i&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(i))return decodeURIComponent(i)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function Xle({src:e,onClose:t}){const{t:n}=xt("common"),[a,i]=k.useState(null),[l,c]=k.useState(null);Fs(!0),k.useEffect(()=>{const h=v=>{v.key==="Escape"&&t()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[t]);const u=k.useCallback(h=>{i(h),window.setTimeout(()=>i(null),1600)},[]),m=k.useCallback(async h=>{if(h.stopPropagation(),!l){c("copy");try{const v=await zk(e),y=await Dse(v);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),u(n("imageCopied"))}catch{u(n("imageCopyFailed"))}finally{c(null)}}},[l,u,e,n]),f=k.useCallback(async h=>{if(h.stopPropagation(),!l){c("download");try{const v=await zk(e),y=URL.createObjectURL(v),w=document.createElement("a");w.href=y,w.download=Ise(e,v),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),u(n("imageDownloaded"))}catch{u(n("imageDownloadFailed"))}finally{c(null)}}},[l,u,e,n]),g="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 Lc.createPortal(o.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[o.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:h=>h.stopPropagation(),children:[o.jsxs("button",{type:"button",className:g,onClick:m,disabled:!!l,title:n("copyImage"),children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),o.jsxs("button",{type:"button",className:g,onClick:f,disabled:!!l,title:n("downloadImage"),children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),o.jsx("polyline",{points:"7 10 12 15 17 10"}),o.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),o.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:o.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a&&o.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:a}),o.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:h=>h.stopPropagation()})]}),document.body)}function Lse(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:i,hostAvailable:l,openRightPanel:c}=e,u=k.useCallback((m,f)=>{const g=kk(f,n);if(g.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),g.kind==="fragment"){qre(i?.current??null,g.id);return}if(g.kind==="file"){l&&c?c({kind:"file",path:g.path,title:g.path.split(/[/\\]/).pop()}):Te.files.reveal(g.path).catch(()=>{});return}if(g.kind==="external"){if(l&&c&&/^https?:\/\//i.test(g.url)){c({kind:"url",url:g.url,title:g.url});return}Or(g.url)}}},[n,i,l,c]);return k.useMemo(()=>({...Tse,img:({src:m,alt:f})=>o.jsx(_se,{src:m??"",alt:f,onPreview:a,basePath:n},m??""),p:({children:m,node:f})=>{const g=Ase(f);return g?o.jsx(_ie,{id:g.id,type:g.type,label:g.label}):o.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:m})},a:({href:m,children:f})=>{if(m?.startsWith(Ok)){const h=decodeURIComponent(m.slice(Ok.length));return o.jsx("span",{className:`text-brand-500 font-medium${t?" cursor-pointer hover:underline":""}`,onClick:t?v=>{v.preventDefault(),v.stopPropagation(),t(h,v)}:void 0,title:h,children:f})}if(m?.startsWith(Pm))return o.jsx(bc,{id:m.slice(Pm.length)});{const h=m?.match(EC);if(h){const[,v,y]=h;if(v==="workflow")return o.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:T=>{T.preventDefault(),T.stopPropagation(),yt.navigate(me.WORK,{boardType:"workflows"})},title:`workflow: ${y}`,children:[o.jsx("span",{className:"text-[10px]",children:"⚙️"}),o.jsx("span",{children:f})]});const w=bC(v);if(w)return o.jsx(bc,{id:y,type:w,label:f})}}if(m&&Im(m))return o.jsx(bc,{id:m.trim(),label:f});const g=kk(m,n);return g.kind==="fragment"||g.kind==="file"||g.kind==="external"?o.jsx("a",{href:m,className:Pg,onClick:h=>u(h,m),title:g.kind==="fragment"?`#${g.id}`:g.kind==="file"?g.path:g.url,children:f}):o.jsx("a",{href:m,className:Pg,onClick:h=>{Uo()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&h.preventDefault()},children:f})}}),[t,n,a,u])}const Hk={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"}},Pse=["development","devops","management","productivity","browser","custom","general"],Ose=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],zse={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 Ch({value:e,onChange:t,renderAs:n="span",className:a,editClassName:i,placeholder:l,multiline:c,readOnly:u}){const[m,f]=k.useState(!1),[g,h]=k.useState(e),v=k.useRef(null);if(k.useEffect(()=>{h(e)},[e]),k.useEffect(()=>{m&&v.current?.focus()},[m]),u){const I=e||l,K=`${a??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?o.jsx("h1",{className:K,children:I}):n==="p"?o.jsx("p",{className:K,children:I}):o.jsx("span",{className:K,children:I})}const y=()=>{f(!1),g!==e&&t(g)},w=()=>{h(e),f(!1)},T=I=>{I.key==="Escape"&&w(),I.key==="Enter"&&!c&&y()};if(m){const I=`bg-transparent outline-none w-full ${i??a??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?o.jsx("textarea",{ref:v,value:g,onChange:B=>h(B.target.value),onBlur:y,onKeyDown:T,className:`${I} resize-y min-h-[60px]`,placeholder:l}):o.jsx("input",{ref:v,value:g,onChange:B=>h(B.target.value),onBlur:y,onKeyDown:T,className:I,placeholder:l})}const C=e||l,A=!e,M="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?o.jsx("h1",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:C}):n==="p"?o.jsx("p",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:C}):n==="badge"?o.jsx("span",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:C}):o.jsx("span",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:C})}function Hse({value:e,options:t,onChange:n,className:a,readOnly:i}){const[l,c]=k.useState(!1),[u,m]=k.useState(e),f=k.useRef(null),g=k.useRef(null);if(k.useEffect(()=>{l&&(m(e),setTimeout(()=>f.current?.focus(),0))},[l,e]),i)return o.jsx("span",{className:a,children:e});const h=t.filter(y=>y.toLowerCase().includes(u.toLowerCase())),v=y=>{const w=y.trim();w&&w!==e&&n(w),c(!1)};return l?o.jsxs("div",{ref:g,className:"relative inline-block",children:[o.jsx("input",{ref:f,value:u,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),v(u)):y.key==="Escape"&&c(!1)},onBlur:y=>{g.current?.contains(y.relatedTarget)||v(u)},className:`${a??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),h.length>0&&o.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:h.map(y=>o.jsx("button",{onMouseDown:w=>{w.preventDefault(),v(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):o.jsx("span",{onClick:()=>c(!0),className:`${a??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function Bse({tags:e,onChange:t,readOnly:n}){const{t:a}=xt(["builder"]),[i,l]=k.useState(!1),[c,u]=k.useState(""),m=k.useRef(null);if(k.useEffect(()=>{i&&m.current?.focus()},[i]),n)return o.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(g=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:g},g))});const f=g=>{if((g.key==="Enter"||g.key===",")&&c.trim()){g.preventDefault();const h=c.trim().toLowerCase();e.includes(h)||t([...e,h]),u("")}else g.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):g.key==="Escape"&&(l(!1),u(""))};return i?o.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(g=>o.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:[g,o.jsx("button",{onClick:()=>t(e.filter(h=>h!==g)),className:"text-fg-muted hover:text-red-500",children:"×"})]},g)),o.jsx("input",{ref:m,value:c,onChange:g=>u(g.target.value),onKeyDown:f,onBlur:()=>{c||l(!1)},className:"flex-1 min-w-[80px] bg-transparent text-xs text-fg-primary placeholder:text-fg-muted focus:outline-none",placeholder:a("detail.typeTagAndEnter")})]}):o.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(g=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:g},g)):o.jsx("span",{className:"text-[10px] text-fg-muted italic",children:a("detail.typeTagAndEnter")})})}function zg({content:e}){const t=[jee,Sne,Tne],n=[Fre,[aae,{strict:"ignore"}],[_re,{detect:!0,ignoreMissing:!0}]],a=Lse({}),i=k.useMemo(()=>{let l=Sk(e,Ure);return l=Sk(l,Xre),l},[e]);return o.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
854
|
+
`,t.prepend(c),()=>{t.innerHTML=""}}let Dc=null;const Ig=new Set;function SC(){for(const e of Ig)e()}function Vie(e){Dc!==e&&(Dc=e,SC())}function Wie(){Dc!==null&&(Dc=null,SC())}function Rk(){return Dc}function Yie(e){return Ig.add(e),()=>{Ig.delete(e)}}k.lazy(()=>Ca(()=>import("./MarkdownMessage-DedA8Zob.js"),[]).then(e=>({default:e.MarkdownMessage})));const Qie=k.lazy(()=>Ca(()=>import("./ContentRenderer-C-V5k_3K.js"),[]).then(e=>({default:e.ContentRenderer})));let Io=[],_k=60;function Xie(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++_k);return k.useEffect(()=>{const a=()=>t.current();Io.push(a);const i=l=>{l.key==="Escape"&&Io[Io.length-1]===a&&(l.preventDefault(),a())};return window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("keydown",i,!0),Io=Io.filter(l=>l!==a),Io.length===0&&(_k=60)}},[]),n}const Dk=500,Ji=new Map,Lm=new Set,Ju=new Map;let Zu=null;function Jie(){if(Ji.size<=Dk)return;const e=Ji.size-Dk,t=Ji.keys();for(let n=0;n<e;n++){const{value:a,done:i}=t.next();if(i)break;Ji.delete(a)}}function Ik(e,t){Ji.delete(e),Ji.set(e,t),Jie()}function Lk(e){const t=Ju.get(e);if(t)for(const n of t)n()}function Zie(){Zu=null;const e=[...Lm];Lm.clear(),e.length!==0&&Te.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))Ik(n,a),Lk(n)}).catch(()=>{for(const t of e)Ik(t,{exists:!1,isFile:!1,type:"unknown"}),Lk(t)})}function ese(e){Ji.has(e)||Lm.has(e)||(Lm.add(e),Zu&&clearTimeout(Zu),Zu=setTimeout(Zie,30))}function tse(e,t){let n=Ju.get(e);return n||(n=new Set,Ju.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Ju.delete(e)}}function nse(e){const t=k.useCallback(i=>tse(e,i),[e]),n=k.useCallback(()=>Ji.get(e),[e]),a=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{ese(e)},[e]),a}function ase(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function rse({filePath:e,onClose:t}){const n=Xie(t),[a,i]=k.useState(e),[l,c]=k.useState(!0),[u,m]=k.useState(null),[f,g]=k.useState(""),[h,v]=k.useState(""),[y,w]=k.useState(""),[T,C]=k.useState(""),[A,M]=k.useState(""),[I,B]=k.useState(null),[K,j]=k.useState(!1);k.useEffect(()=>{c(!0),m(null),g(""),B(null),Te.files.preview(a).then(D=>{if(D.type==="directory"&&Array.isArray(D.entries)){v("directory"),w(D.name),B(D.entries);return}v(D.type),w(D.name),C(D.mimeType||""),g(typeof D.content=="string"?D.content:""),M(D.streamUrl||(D.path?Te.files.streamUrl(D.path):"")||(D.type==="audio"||D.type==="video"?Te.files.streamUrl(a):""))}).catch(D=>{m(String(D?.message||D))}).finally(()=>{c(!1)})},[a]);const z=y||a.split(/[/\\]/).pop()||a,U=h==="directory"||a!==e,Y=()=>i(D=>ase(D)),$=()=>{navigator.clipboard?.writeText(a).then(()=>{j(!0),setTimeout(()=>j(!1),1500)}).catch(()=>{})};return Lc.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:o.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:D=>D.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h==="directory"&&o.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}),h!=="directory"&&o.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})}),o.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:z}),o.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:a})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[U&&o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:Y,title:"返回上级目录",children:"← 上级"}),o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:$,title:"复制路径",children:K?"✓ 已复制":"复制路径"}),o.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Te.files.reveal(a),title:"Reveal in file explorer",children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})})}),o.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})})})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[l&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),u&&o.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[o.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),o.jsx("p",{className:"text-xs text-fg-tertiary",children:u})]}),!l&&!u&&h==="directory"&&I&&o.jsx(Oie,{path:a,entries:I,onNavigate:D=>i(D),onOpenFile:D=>i(D),onReveal:D=>Te.files.reveal(D),onCopyPath:D=>{navigator.clipboard?.writeText(D).then(()=>{j(!0),setTimeout(()=>j(!1),1500)}).catch(()=>{})}}),!l&&!u&&h==="office"&&A&&o.jsx(Hie,{data:{format:(a.split(".").pop()||"pdf").toLowerCase(),streamUrl:A,name:z},reference:a,onFallback:()=>{Te.files.reveal(a)}}),!l&&!u&&h==="image"&&f&&o.jsx("div",{className:"flex justify-center",children:o.jsx("img",{src:`data:${T||"image/png"};base64,${f}`,alt:z,className:"max-w-full rounded"})}),!l&&!u&&h==="audio"&&A&&o.jsx("audio",{controls:!0,preload:"metadata",src:A,className:"w-full"}),!l&&!u&&h==="video"&&A&&o.jsx("video",{controls:!0,preload:"metadata",src:A,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!l&&!u&&(h==="binary"||!f&&h!=="image"&&h!=="audio"&&h!=="video"&&h!=="directory")&&o.jsxs("div",{className:"text-center py-8 space-y-3",children:[o.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),o.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:()=>{Te.files.reveal(a)},children:"Reveal in file explorer"})]}),!l&&!u&&f&&h!=="image"&&h!=="audio"&&h!=="video"&&h!=="binary"&&h!=="directory"&&o.jsx(k.Suspense,{fallback:o.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:o.jsx(Qie,{content:f,format:h==="text"?"text":h,className:"text-sm"})})]})]})}),document.body)}function ise({path:e}){const t=nse(e),n=pp(),a=t?.exists??!1,i=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video"||t?.type==="office"||t?.type==="directory",l=k.useCallback(m=>{if(m.preventDefault(),m.stopPropagation(),!!a)if(i){if(n?.hostAvailable){n.openRightPanel({kind:"file",path:e});return}Vie(e)}else Te.files.reveal(e)},[a,i,e,n]),c="inline w-3 h-3 align-[-0.125em]",u=i?o.jsx("svg",{className:c,viewBox:"0 0 20 20",fill:"currentColor",children:o.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"})}):o.jsx("svg",{className:c,viewBox:"0 0 20 20",fill:"currentColor",children:o.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?a?o.jsxs("code",{"data-file-path-link":"ready",className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:l,title:i?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[o.jsxs("span",{className:"whitespace-nowrap",children:[u,e.charAt(0)]}),e.slice(1)]}):o.jsx("code",{"data-file-path-link":"missing",className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:"File not found",children:e}):o.jsx("code",{"data-file-path-link":"loading",className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}function sse(){const e=k.useSyncExternalStore(Yie,Rk,Rk);return e?o.jsx(rse,{filePath:e,onClose:Wie},e):null}let kh=null;function ose(){return kh||(kh=Ca(()=>import("./mermaid.core-MkJR6w4B.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),kh}function lse(){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 cse(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 dse(){return lse()}function use(){return k.useSyncExternalStore(cse,dse)}function CC({code:e}){const{t}=xt("common"),n=k.useRef(null),[a,i]=k.useState(null),[l,c]=k.useState(!0),u=k.useId(),m=k.useRef(0),f=k.useRef(null),g=use();return k.useEffect(()=>{if(!e.trim()||f.current&&f.current.code===e&&f.current.dark===g)return;let h=!1;return c(!0),i(null),m.current+=1,(async()=>{try{const v=await ose();if(h)return;v.default.initialize({startOnLoad:!1,theme:g?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${u.replace(/:/g,"")}-${m.current}`,{svg:w}=await v.default.render(y,e.trim());if(h)return;n.current&&(n.current.innerHTML=w,f.current={code:e,dark:g})}catch(v){h||i(v instanceof Error?v.message:String(v))}finally{h||c(!1)}})(),()=>{h=!0}},[e,u,g]),a?o.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[o.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:[o.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.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"})}),o.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.mermaidRenderError")})]}),a&&o.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:a}),o.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):o.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&o.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),o.jsx("div",{ref:n,className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`})]})}const mse="/assets/viz-global-C_AyN6D9.js";let _u=!1,Sh=null;function pse(){return _u?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(_u=!0,e()):(n.addEventListener("load",()=>{_u=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const a=document.createElement("script");a.setAttribute("data-plantuml-viz",""),a.src=mse,a.onload=()=>{_u=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function fse(){return Sh||(Sh=pse().then(()=>Ca(()=>import("./plantuml-DezRDxd4.js"),[]))),Sh}let Pk=Promise.resolve();function hse(e,t){const n=Pk.then(()=>new Promise((a,i)=>{fse().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,i,{dark:t})}).catch(i)}));return Pk=n.then(()=>{},()=>{}),n}function gse(){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 bse(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 yse(){return k.useSyncExternalStore(bse,()=>gse())}function AC({code:e}){const{t}=xt("common"),[n,a]=k.useState(null),[i,l]=k.useState(null),[c,u]=k.useState(!0),m=k.useRef(null),f=yse();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===f)return;let g=!1;return u(!0),l(null),hse(e.trim(),f).then(h=>{g||(a(h),m.current={code:e,dark:f})}).catch(h=>{g||l(h instanceof Error?h.message:String(h))}).finally(()=>{g||u(!1)}),()=>{g=!0}},[e,f]),i?o.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[o.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:[o.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.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"})}),o.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.plantumlRenderError")})]}),i&&o.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:i}),o.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):o.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[c&&o.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),n&&o.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${c?" hidden":""}`,dangerouslySetInnerHTML:{__html:n}})]})}function vse(e,t,n){const a=e.cloneNode(!0),i=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",c=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},u=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:${u.text};line-height:1.7;`,h1:`font-size:${c.h1}em;font-weight:700;color:${u.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${u.border};padding-bottom:6px;`,h2:`font-size:${c.h2}em;font-weight:700;color:${u.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${u.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.h4}em;font-weight:600;color:${u.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${u.strong};`,em:"font-style:italic;",a:`color:${u.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:${u.text};`,blockquote:`border-left:3px solid ${u.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${u.blockquoteText};`,hr:`border:none;border-top:1px solid ${u.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${u.tableHeaderBg};`,th:`border:1px solid ${u.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${u.tableHeaderText};`,td:`border:1px solid ${u.tableBorder};padding:8px 12px;color:${u.text};`,img:"max-width:100%;height:auto;"};function f(g){g.removeAttribute("class");const h=g.tagName.toLowerCase();if(h==="pre"){g.setAttribute("style",`background:${u.preBg};color:${u.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${u.preBorder};`);const v=g.querySelector("code");v&&(v.removeAttribute("class"),v.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}h==="code"?g.setAttribute("style",`background:${u.codeBg};color:${u.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[h]&&g.setAttribute("style",m[h]),Array.from(g.children).forEach(f)}return a.removeAttribute("class"),Array.from(a.children).forEach(g=>f(g)),`<div style="background:${u.bg};color:${u.text};padding:20px 24px;font-family:${i};font-size:${l};line-height:1.7;max-width:800px;">${a.innerHTML}</div>`}async function TC(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 Qle(e,t,n,a){const i=vse(e,t,a);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([i],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await TC(n),method:"text"}}}function Lg({code:e,language:t,children:n}){const{t:a}=xt("common"),[i,l]=k.useState("rendered"),[c,u]=k.useState(!1),m=k.useCallback(async()=>{await TC(e)&&(u(!0),setTimeout(()=>u(!1),1800))},[e]);return o.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${i==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),a("markdown.viewRendered")]})}),o.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${i==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),a("markdown.viewSource")]})})]})]}),i==="rendered"?o.jsx("div",{children:n}):o.jsxs("div",{className:"relative group/source",children:[o.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}),o.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:a("markdown.copyContent"),children:c?o.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.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 xse=[CC,AC];function wse(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return tie(n)}return null}function yc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(yc).join("");if(k.isValidElement(e)){const t=e.props;return yc(t.children)}return""}function kse({children:e}){const{t}=xt("common"),n=wse(e),a=k.useRef(null),[i,l]=k.useState(!1),[c,u]=k.useState("rendered"),m=k.useCallback(async()=>{let g;c==="source"?g=yc(e):g=a.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(g),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(k.Children.toArray(e).some(g=>k.isValidElement(g)&&xse.includes(g.type))){const g=yc(e),h=n==="mermaid"||n==="plantuml"?n:"diagram";return o.jsx(Lg,{code:g,language:h,children:e})}return n==="mermaid"||n==="plantuml"?o.jsx(o.Fragment,{children:e}):o.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[o.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:eie(n)}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>u("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),o.jsx("button",{onClick:()=>u("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${c==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),o.jsxs("div",{className:"relative",children:[c==="rendered"?o.jsx("pre",{ref:a,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,g=>k.isValidElement(g)?k.cloneElement(g,{style:{background:"transparent",padding:0}}):g)}):o.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:yc(e)}),o.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:t("markdown.copyContent"),children:i?o.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.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 Ok="#mention:",Pm="#entity:",Sse=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,EC=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Pg="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function Og(e){return e.type==="text"?e.value??"":(e.children??[]).map(Og).join("")}function Cse(e){return e.type==="text"&&(e.value??"").trim()===""}function Ase(e){if(!e?.children)return null;const t=e.children.filter(a=>!Cse(a));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const a=n.properties?.href;if(!a)return null;const i=Og(n);if(a.startsWith(Pm))return{id:a.slice(Pm.length)};const l=a.match(EC);return l&&l[1]!=="workflow"?{id:l[2],type:bC(l[1]),label:i}:null}if(n.type==="element"&&n.tagName==="code"){const a=Og(n).trim();if(Im(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Im(a))return{id:a}}return null}const Tse={p:({children:e})=>o.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>o.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>o.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>o.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>o.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>o.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>o.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>o.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>o.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>o.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),a=n.trim();if(t?.includes("language-plantuml")||Jre(a))return o.jsx(Lg,{code:a,language:"plantuml",children:o.jsx(AC,{code:a})});if(t?.includes("language-mermaid"))return o.jsx(Lg,{code:a,language:"mermaid",children:o.jsx(CC,{code:a})});if(t?.includes("language-"))return o.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Im(n))return o.jsx(bc,{id:n.trim()});const i=n.match(Sse);return i?o.jsx(bc,{id:i[2],label:i[1]}):$re(n)?o.jsx(ise,{path:n}):o.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})=>o.jsx(kse,{children:e}),strong:({children:e})=>o.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>o.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>o.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>o.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>o.jsx("a",{href:e,className:Pg,children:t}),hr:()=>o.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>o.jsx("div",{className:"overflow-x-auto my-2",children:o.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>o.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>o.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>o.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>o.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})=>o.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},Ese=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function Nse(e){const t=Rb(e);return zre(e)&&Ese.test(t.split("?")[0]??t)}function Mse(e,t){const n=Rb(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const i=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of i)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function jse(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function Rse(e,t){return Nse(e)?jse(Mse(e,t)):null}const Lo=new Map,ac=new Map,_se=k.memo(function({src:t,alt:n,onPreview:a,basePath:i}){const l=k.useMemo(()=>Rse(t,i)??t,[t,i]),c=l.startsWith("/api/files/image?"),u=Lo.get(l),m=ac.get(l),[f,g]=k.useState(u??(c?null:l)),[h,v]=k.useState(!!u),[y,w]=k.useState(!!m),[T,C]=k.useState(m??null),[A,M]=k.useState(0),I=k.useRef(0),B=k.useCallback(j=>{ac.set(l,j),C(j),w(!0),v(!1)},[l]),K=k.useCallback(()=>{Lo.delete(l),ac.delete(l),w(!1),C(null),v(!1),g(c?null:`${l}${l.includes("?")?"&":"?"}retry=${Date.now()}`),M(j=>j+1)},[l,c]);return k.useEffect(()=>{if(!c)return;const j=Lo.get(l);if(j){g(j),v(!0),w(!1),C(null);return}const z=ac.get(l);if(z!==void 0){w(!0),C(z),v(!1);return}const U=++I.current;w(!1),C(null),v(!1),g(null),(async()=>{try{const Y=await fetch(l,{credentials:"same-origin"});if(U!==I.current)return;if(!Y.ok){let W=`HTTP ${Y.status}`;try{const X=await Y.json();X.error&&(W=X.error)}catch{}throw new Error(W)}const $=await Y.blob();if(U!==I.current)return;if($.size===0)throw new Error("Empty image response");if($.type&&!$.type.startsWith("image/")&&!$.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${$.type}`);const D=URL.createObjectURL($);Lo.set(l,D),g(D),v(!0),w(!1),C(null)}catch(Y){if(U!==I.current)return;const $=Y instanceof Error?Y.message:String(Y);console.warn("[MarkdownImage] failed to load local image",l,Y),B($)}})()},[c,l,A]),k.useEffect(()=>{if(c)return;const j=ac.get(l);if(j!==void 0){w(!0),C(j),v(!1);return}g(l),v(!!Lo.get(l)),w(!1),C(null)},[l,c,A]),y?o.jsxs("button",{type:"button",onClick:K,title:T??"Click to retry",className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[o.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[o.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),o.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),o.jsx("polyline",{points:"21 15 16 10 5 21"})]}),o.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",T?` (${T})`:""]})]}):o.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!h&&o.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),f?o.jsx("img",{src:f,alt:n??"",onLoad:()=>{c||Lo.set(l,l),v(!0)},onError:()=>{B("Image decode failed")},onClick:()=>a?.(f),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${h?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})});async function zk(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function Dse(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const a=n.getContext("2d");if(!a)throw new Error("Canvas unavailable");return a.drawImage(t,0,0),t.close(),new Promise((i,l)=>{n.toBlob(c=>c?i(c):l(new Error("PNG encode failed")),"image/png")})}function Ise(e,t){try{const i=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(i&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(i))return decodeURIComponent(i)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function Xle({src:e,onClose:t}){const{t:n}=xt("common"),[a,i]=k.useState(null),[l,c]=k.useState(null);Fs(!0),k.useEffect(()=>{const h=v=>{v.key==="Escape"&&t()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[t]);const u=k.useCallback(h=>{i(h),window.setTimeout(()=>i(null),1600)},[]),m=k.useCallback(async h=>{if(h.stopPropagation(),!l){c("copy");try{const v=await zk(e),y=await Dse(v);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),u(n("imageCopied"))}catch{u(n("imageCopyFailed"))}finally{c(null)}}},[l,u,e,n]),f=k.useCallback(async h=>{if(h.stopPropagation(),!l){c("download");try{const v=await zk(e),y=URL.createObjectURL(v),w=document.createElement("a");w.href=y,w.download=Ise(e,v),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),u(n("imageDownloaded"))}catch{u(n("imageDownloadFailed"))}finally{c(null)}}},[l,u,e,n]),g="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 Lc.createPortal(o.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[o.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:h=>h.stopPropagation(),children:[o.jsxs("button",{type:"button",className:g,onClick:m,disabled:!!l,title:n("copyImage"),children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),o.jsxs("button",{type:"button",className:g,onClick:f,disabled:!!l,title:n("downloadImage"),children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),o.jsx("polyline",{points:"7 10 12 15 17 10"}),o.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),o.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:o.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a&&o.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:a}),o.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:h=>h.stopPropagation()})]}),document.body)}function Lse(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:i,hostAvailable:l,openRightPanel:c}=e,u=k.useCallback((m,f)=>{const g=kk(f,n);if(g.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),g.kind==="fragment"){qre(i?.current??null,g.id);return}if(g.kind==="file"){l&&c?c({kind:"file",path:g.path,title:g.path.split(/[/\\]/).pop()}):Te.files.reveal(g.path).catch(()=>{});return}if(g.kind==="external"){if(l&&c&&/^https?:\/\//i.test(g.url)){c({kind:"url",url:g.url,title:g.url});return}Or(g.url)}}},[n,i,l,c]);return k.useMemo(()=>({...Tse,img:({src:m,alt:f})=>o.jsx(_se,{src:m??"",alt:f,onPreview:a,basePath:n},m??""),p:({children:m,node:f})=>{const g=Ase(f);return g?o.jsx(_ie,{id:g.id,type:g.type,label:g.label}):o.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:m})},a:({href:m,children:f})=>{if(m?.startsWith(Ok)){const h=decodeURIComponent(m.slice(Ok.length));return o.jsx("span",{className:`text-brand-500 font-medium${t?" cursor-pointer hover:underline":""}`,onClick:t?v=>{v.preventDefault(),v.stopPropagation(),t(h,v)}:void 0,title:h,children:f})}if(m?.startsWith(Pm))return o.jsx(bc,{id:m.slice(Pm.length)});{const h=m?.match(EC);if(h){const[,v,y]=h;if(v==="workflow")return o.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:T=>{T.preventDefault(),T.stopPropagation(),yt.navigate(me.WORK,{boardType:"workflows"})},title:`workflow: ${y}`,children:[o.jsx("span",{className:"text-[10px]",children:"⚙️"}),o.jsx("span",{children:f})]});const w=bC(v);if(w)return o.jsx(bc,{id:y,type:w,label:f})}}if(m&&Im(m))return o.jsx(bc,{id:m.trim(),label:f});const g=kk(m,n);return g.kind==="fragment"||g.kind==="file"||g.kind==="external"?o.jsx("a",{href:m,className:Pg,onClick:h=>u(h,m),title:g.kind==="fragment"?`#${g.id}`:g.kind==="file"?g.path:g.url,children:f}):o.jsx("a",{href:m,className:Pg,onClick:h=>{Uo()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&h.preventDefault()},children:f})}}),[t,n,a,u])}const Hk={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"}},Pse=["development","devops","management","productivity","browser","custom","general"],Ose=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],zse={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 Ch({value:e,onChange:t,renderAs:n="span",className:a,editClassName:i,placeholder:l,multiline:c,readOnly:u}){const[m,f]=k.useState(!1),[g,h]=k.useState(e),v=k.useRef(null);if(k.useEffect(()=>{h(e)},[e]),k.useEffect(()=>{m&&v.current?.focus()},[m]),u){const I=e||l,K=`${a??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?o.jsx("h1",{className:K,children:I}):n==="p"?o.jsx("p",{className:K,children:I}):o.jsx("span",{className:K,children:I})}const y=()=>{f(!1),g!==e&&t(g)},w=()=>{h(e),f(!1)},T=I=>{I.key==="Escape"&&w(),I.key==="Enter"&&!c&&y()};if(m){const I=`bg-transparent outline-none w-full ${i??a??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?o.jsx("textarea",{ref:v,value:g,onChange:B=>h(B.target.value),onBlur:y,onKeyDown:T,className:`${I} resize-y min-h-[60px]`,placeholder:l}):o.jsx("input",{ref:v,value:g,onChange:B=>h(B.target.value),onBlur:y,onKeyDown:T,className:I,placeholder:l})}const C=e||l,A=!e,M="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?o.jsx("h1",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:C}):n==="p"?o.jsx("p",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:C}):n==="badge"?o.jsx("span",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:C}):o.jsx("span",{onClick:()=>f(!0),className:`${a??""} ${M} ${A?"text-fg-muted italic":""}`,children:C})}function Hse({value:e,options:t,onChange:n,className:a,readOnly:i}){const[l,c]=k.useState(!1),[u,m]=k.useState(e),f=k.useRef(null),g=k.useRef(null);if(k.useEffect(()=>{l&&(m(e),setTimeout(()=>f.current?.focus(),0))},[l,e]),i)return o.jsx("span",{className:a,children:e});const h=t.filter(y=>y.toLowerCase().includes(u.toLowerCase())),v=y=>{const w=y.trim();w&&w!==e&&n(w),c(!1)};return l?o.jsxs("div",{ref:g,className:"relative inline-block",children:[o.jsx("input",{ref:f,value:u,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),v(u)):y.key==="Escape"&&c(!1)},onBlur:y=>{g.current?.contains(y.relatedTarget)||v(u)},className:`${a??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),h.length>0&&o.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:h.map(y=>o.jsx("button",{onMouseDown:w=>{w.preventDefault(),v(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):o.jsx("span",{onClick:()=>c(!0),className:`${a??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function Bse({tags:e,onChange:t,readOnly:n}){const{t:a}=xt(["builder"]),[i,l]=k.useState(!1),[c,u]=k.useState(""),m=k.useRef(null);if(k.useEffect(()=>{i&&m.current?.focus()},[i]),n)return o.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(g=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:g},g))});const f=g=>{if((g.key==="Enter"||g.key===",")&&c.trim()){g.preventDefault();const h=c.trim().toLowerCase();e.includes(h)||t([...e,h]),u("")}else g.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):g.key==="Escape"&&(l(!1),u(""))};return i?o.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(g=>o.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:[g,o.jsx("button",{onClick:()=>t(e.filter(h=>h!==g)),className:"text-fg-muted hover:text-red-500",children:"×"})]},g)),o.jsx("input",{ref:m,value:c,onChange:g=>u(g.target.value),onKeyDown:f,onBlur:()=>{c||l(!1)},className:"flex-1 min-w-[80px] bg-transparent text-xs text-fg-primary placeholder:text-fg-muted focus:outline-none",placeholder:a("detail.typeTagAndEnter")})]}):o.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(g=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:g},g)):o.jsx("span",{className:"text-[10px] text-fg-muted italic",children:a("detail.typeTagAndEnter")})})}function zg({content:e}){const t=[jee,Sne,Tne],n=[Fre,[aae,{strict:"ignore"}],[_re,{detect:!0,ignoreMissing:!0}]],a=Lse({}),i=k.useMemo(()=>{let l=Sk(e,Ure);return l=Sk(l,Xre),l},[e]);return o.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
855
855
|
prose-headings:text-fg-primary prose-headings:font-semibold
|
|
856
856
|
prose-p:text-fg-secondary prose-p:leading-relaxed
|
|
857
857
|
prose-a:text-brand-400 prose-a:no-underline hover:prose-a:underline
|
|
@@ -864,4 +864,4 @@ await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).t
|
|
|
864
864
|
|
|
865
865
|
${m("share.rejectedEncourage")}`})},className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 hover:bg-red-500/10 transition-colors inline-flex items-center gap-1 cursor-pointer",title:m("share.rejectedTip"),children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}),o.jsxs("button",{onClick:()=>{ye({visibility:j.visibility})},disabled:U,className:"text-xs px-3 py-1.5 rounded-lg border border-brand-500/40 text-brand-400 hover:bg-brand-500/10 hover:border-brand-500/60 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),m(U?"share.updating":"share.resubmit")]})]}),!j.moderationStatus&&j.pendingReview&&o.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:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}),fe&&o.jsxs("a",{href:fe,target:"_blank",rel:"noopener noreferrer",onClick:We=>{Uo()&&(We.preventDefault(),Or(fe))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${j.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":j.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:[j.visibility==="org"?o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):j.visibility==="unlisted"?o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.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"}),o.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"})]}):o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),j.visibility==="org"?m("visibility.sharedOrg"):j.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),ct&&o.jsx("button",{onClick:()=>{ye({visibility:j.visibility})},disabled:U,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50",children:U?m("share.updating"):m("share.updateVersion",{version:Ge})})]})})(),!i&&!j.shared&&o.jsx("button",{onClick:()=>re(!0),disabled:U,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50",children:m(U?"share.sharing":"share.toHub")})]})]}),!i&&$&&!W&&o.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:[o.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),o.jsx("button",{onClick:()=>X(!0),className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("versionBump.bumpVersion")})]}),!i&&W&&o.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:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),o.jsx("input",{type:"text",defaultValue:(()=>{const de=(Qe||"1.0.0").split(".");return de[2]=String(Number(de[2]??0)+1),de.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:de=>{de.key==="Enter"&&et("version",de.target.value)}}),o.jsx("button",{onClick:de=>{const fe=de.target.parentElement?.querySelector("input");fe&&et("version",fe.value)},className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("common:confirm")}),o.jsx("button",{onClick:()=>X(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),j.shared&&o.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),o.jsxs("div",{className:`flex gap-8 ${f?"flex-col":""}`,children:[o.jsxs("div",{className:`${f?"w-full":"flex-1 min-w-0"}`,children:[o.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[o.jsxs("div",{className:"relative",children:[o.jsx("div",{onClick:()=>!i&&Ce(!ue),className:`w-16 h-16 rounded-xl ${te.bg} flex items-center justify-center text-3xl shrink-0 ${i?"":"cursor-pointer hover:ring-2"} ${te.ring} transition-all overflow-hidden`,children:lt&<.startsWith("images/")?o.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(v)}/images/${encodeURIComponent(lt.replace("images/",""))}?v=${ce}`,alt:"",className:"w-full h-full object-cover"}):lt&&(lt.startsWith("http")||lt.startsWith("/"))?o.jsx("img",{src:lt,alt:"",className:"w-full h-full object-cover"}):(()=>{const de=lt||"";if(de&&[...de].length<=2&&new RegExp("\\p{Emoji}","u").test(de))return de;const Ge=Bs[nl(e)].accent;return o.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:o.jsx("path",{d:Z3(Ee||t||e),fill:Ge})})})()}),!i&&ue&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Ce(!1)}),o.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:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.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:lt,onKeyDown:de=>{de.key==="Enter"&&(et("icon",de.target.value),Ce(!1))}}),o.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"),o.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async de=>{const fe=de.target.files?.[0];if(!fe)return;const Ge=new FormData;Ge.append("image",fe);try{const ct=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(v)}/images`,{method:"POST",body:Ge,credentials:"include"});if(ct.ok){const ut=(await ct.json()).path;if(Dt(ut),Ce(!1),C){const Ft={...C,icon:ut};A(Ft),await Te.builder.artifacts.save(e,Ft)}D(!0)}}catch{}}})]}),lt&&o.jsx("button",{onClick:()=>{et("icon",""),Ce(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),o.jsx("div",{className:"max-h-64 overflow-y-auto",children:Ose.map(de=>o.jsxs("div",{className:"mb-2.5",children:[o.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:de.label}),o.jsx("div",{className:"flex flex-wrap gap-0.5",children:de.emojis.map(fe=>o.jsx("button",{onClick:()=>{et("icon",fe),Ce(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${lt===fe?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:fe},fe))})]},de.label))})]})]})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx(Ch,{value:Ee,onChange:de=>et("displayName",de),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:i}),o.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${te.bg} ${te.color}`,children:te.label}),o.jsx(Ch,{value:Qe,onChange:de=>et("version",de),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:i})]}),o.jsx(Ch,{value:qe,onChange:de=>et("description",de),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:i}),o.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[o.jsx(Hse,{value:Xe,options:Pse,onChange:de=>et("category",de),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:i}),o.jsx(Bse,{tags:mt,onChange:de=>et("tags",de),readOnly:i})]})]})]}),o.jsx("div",{className:"mb-8",children:o.jsx(qse,{images:F,artifactType:e,artifactName:t,onUpload:Ne,onRemove:De,readOnly:i,cacheBust:ce})}),u&&o.jsx("div",{className:"mb-8",children:u}),e==="team"&&C.team&&o.jsx("div",{className:"mb-8",children:o.jsx(Fse,{members:C.team.members,teamTopFiles:Le,files:w,artifactName:v,onFileSave:at,readOnly:i})}),e==="agent"&&we.length>0&&o.jsxs("div",{className:"mb-8",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),o.jsx(Om,{noHeader:!0,files:we,onSave:at,readOnly:i})]}),e==="skill"&&o.jsxs("div",{className:"mb-8",children:[C.skill?.requiredPermissions&&C.skill.requiredPermissions.length>0&&o.jsxs("div",{className:"mb-6",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),o.jsx("div",{className:"flex flex-wrap gap-2",children:C.skill.requiredPermissions.map(de=>{const fe=zse[de];return o.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${fe?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[o.jsx("span",{className:"font-mono text-[10px]",children:fe?.icon??"?"})," ",de]},de)})})]}),C.skill?.mcpServers&&Object.keys(C.skill.mcpServers).length>0&&o.jsxs("div",{className:"mb-6",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),o.jsx("div",{className:"grid gap-2",children:Object.entries(C.skill.mcpServers).map(([de,fe])=>o.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[o.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:"◎"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs font-medium text-fg-primary",children:de}),o.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof fe=="object"?JSON.stringify(fe).slice(0,80):String(fe)})]})]},de))})]}),ae&&o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),o.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:o.jsx(zg,{content:ae})})]})]}),He.length>0&&o.jsx(Om,{files:He,onSave:at,readOnly:i})]}),o.jsx("div",{className:`${f?"w-full":"w-72 shrink-0"}`,children:o.jsxs("div",{className:`${f?"":"sticky top-6"} space-y-4`,children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),o.jsxs("div",{className:"space-y-2 text-xs",children:[o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),o.jsx("span",{className:`font-medium ${te.color}`,children:te.label})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),o.jsx("span",{className:"text-fg-secondary",children:Xe})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),o.jsx("span",{className:"text-fg-secondary font-mono",children:Qe})]}),C.author&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),o.jsx("span",{className:"text-fg-secondary",children:typeof C.author=="string"?C.author:C.author?.name??""})]})]})]}),e==="agent"&&C.agent&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),o.jsxs("div",{className:"space-y-2 text-xs",children:[C.agent.roleName&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),o.jsx("span",{className:"text-fg-secondary",children:C.agent.roleName})]}),C.agent.llmProvider&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),o.jsx("span",{className:"text-fg-secondary",children:C.agent.llmProvider})]}),C.agent.llmModel&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),o.jsx("span",{className:"text-fg-secondary font-mono",children:C.agent.llmModel})]}),C.agent.temperature!==void 0&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),o.jsx("span",{className:"text-fg-secondary",children:C.agent.temperature})]})]})]}),e==="team"&&C.team&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),o.jsxs("div",{className:"space-y-2 text-xs",children:[o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),o.jsx("span",{className:"text-fg-secondary",children:C.team.members.reduce((de,fe)=>de+fe.count,0)})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),o.jsx("span",{className:"text-amber-400",children:C.team.members.filter(de=>de.role==="manager").reduce((de,fe)=>de+fe.count,0)})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),o.jsx("span",{className:"text-blue-400",children:C.team.members.filter(de=>de.role!=="manager").reduce((de,fe)=>de+fe.count,0)})]})]})]}),e==="skill"&&C.skill&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),o.jsxs("div",{className:"space-y-2 text-xs",children:[C.skill.alwaysOn!==void 0&&o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),o.jsx("span",{className:C.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:C.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),o.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:C.skill.skillFile})]}),C.skill.requiredPermissions&&C.skill.requiredPermissions.length>0&&o.jsxs("div",{children:[o.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),o.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:C.skill.requiredPermissions.map(de=>o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:de},de))})]})]})]}),C.dependencies&&(C.dependencies.skills?.length||C.dependencies.env?.length)?o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[o.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),C.dependencies.skills?.length?o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),o.jsx("div",{className:"flex flex-wrap gap-1",children:C.dependencies.skills.map(de=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:de},de))})]}):null,C.dependencies.env?.length?o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),o.jsx("div",{className:"flex flex-wrap gap-1",children:C.dependencies.env.map(de=>o.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:de},de))})]}):null]}):null,!i&&M&&o.jsxs("button",{onClick:()=>Te.system.openPath(M).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:M,children:[o.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),M.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!i&&H&&o.jsx(Gse,{onClose:()=>se(!1),onConfirm:(de,fe)=>{se(!1),ye({donationsEnabled:!1,priceCents:de==="paid"?fe:void 0})},isUpdate:j.shared}),!i&&R&&o.jsx(Use,{onClose:()=>re(!1),onConfirm:(de,fe,Ge,ct)=>{re(!1),ye({visibility:de,orgId:fe,priceCents:Ge,donationsEnabled:ct})}}),q&&o.jsx(vr,{alertOnly:!0,variant:q.variant??"primary",title:q.title,message:q.message,onConfirm:()=>V(null),onCancel:()=>V(null)})]}):o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsxs("div",{className:"px-6 py-8",children:[o.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[o.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:o.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),o.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function Use({onClose:e,onConfirm:t}){const{t:n}=xt(["builder","common"]),[a,i]=k.useState("public"),[l,c]=k.useState([]),[u,m]=k.useState(""),[f,g]=k.useState(!1),[h,v]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{a==="org"&&l.length===0&&(g(!0),nt.myOrgs().then(A=>{c(A.memberships),A.memberships.length>0&&m(A.memberships[0].id)}).catch(()=>{}).finally(()=>g(!1)))},[a,l.length]);const T=a==="public"||a==="unlisted",C=[{value:"public",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),o.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:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.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:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.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"}),o.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 o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:A=>A.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),o.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),o.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),o.jsx("div",{className:"space-y-2 mb-5",children:C.map(A=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${a===A.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"visibility",checked:a===A.value,onChange:()=>i(A.value),className:"accent-brand-500"}),o.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:A.icon}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:A.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:A.desc})]})]},A.value))}),a==="org"&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),f?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):o.jsx("select",{value:u,onChange:A=>m(A.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(A=>o.jsx("option",{value:A.id,children:A.name},A.id))})]}),T&&o.jsxs("div",{className:"mb-5",children:[o.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),o.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:NC.map(A=>o.jsx("button",{type:"button",onClick:()=>v(A.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${h===A.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:A.label},A.cents))}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:y,onChange:A=>w(A.target.checked),className:"accent-brand-500"}),o.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),T&&o.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),o.jsxs("div",{className:"flex gap-3",children:[o.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")}),o.jsx("button",{onClick:()=>t(a,a==="org"?u:void 0,T&&h>0?h:void 0,T?y:void 0),disabled:a==="org"&&!u,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const NC=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Gse({onClose:e,onConfirm:t,isUpdate:n}){const{t:a}=xt(["builder","common"]),[i,l]=k.useState(0);return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:o.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:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:a(n?"shareMode.titleUpdate":"share.toHub")}),o.jsx("div",{className:"space-y-2 mb-5",children:NC.map(c=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"sharePrice",checked:i===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?a("shareMode.freeDesc"):a("shareMode.paidDesc")})]})]},c.cents))}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:a("common:cancel")}),o.jsx("button",{onClick:()=>t(i>0?"paid":"free",i),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:a(n?"shareMode.update":"shareMode.share")})]})]})})}function zm(e,t){return!e||!eC(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function Kse({type:e,seed:t,icon:n,hubBase:a,size:i=44,className:l="",rounded:c="rounded-xl"}){const u=nl(e),m=zm(n,a),f=k.useMemo(()=>jb(u,t),[u,t]),g=k.useMemo(()=>Z3(t),[t]),[h,v]=k.useState(!1);return m&&!h?o.jsx("img",{src:m,alt:"",onError:()=>v(!0),style:{width:i,height:i},className:`${c} object-cover shrink-0 ${l}`}):Lre(n)?o.jsx("div",{style:{width:i,height:i,background:f,fontSize:i*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:o.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&XK(n)?o.jsx("div",{style:{width:i,height:i,background:f},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:o.jsx(c5,{name:n,size:i*.52,className:"drop-shadow-sm"})}):o.jsx("div",{style:{width:i,height:i,background:f},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:o.jsx("svg",{width:i*.55,height:i*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:o.jsx("path",{d:g,fill:"rgba(255,255,255,0.92)"})})})}function Hm({name:e,username:t,avatarUrl:n,hubBase:a,size:i=24,className:l="",verified:c}){const u=t||e||"markus",m=zm(n,a),[f,g]=k.useState(!1),h=m&&!f?m:Pre(u);return o.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:i,height:i},children:[o.jsx("img",{src:h,alt:e||t||"",onError:()=>g(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),c&&o.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 text-on-brand ring-2 ring-surface-primary",style:{width:i*.42,height:i*.42},children:o.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"currentColor","aria-hidden":!0,children:o.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function Vse({type:e,className:t=""}){const n=nl(e),a=Bs[n];return o.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white bg-gradient-to-r ${a.gradient} ${t}`,children:a.label})}function $k({rating:e=0}){const t=Math.round(e);return o.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>o.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:o.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 pr(e){const{type:t,name:n,description:a,seed:i,icon:l,cover:c,hubBase:u,author:m,authorLabel:f,version:g,category:h,tags:v,rating:y=0,ratingCount:w=0,downloadCount:T=0,priceCents:C,currency:A="usd",installed:M,glowing:I,selected:B,showTypeBadge:K=!0,hideStats:j=!1,cornerLabel:z,actions:U,footerLeft:Y,headerAction:$,onClick:D,className:W=""}=e,X=nl(t),H=Bs[X],se=i||n,R=(C??0)>0,re=!!zm(c||void 0,u),ue=jb(X,se),Ce=f??m?.displayName??m?.username??"",[q,V]=k.useState(null),ce=M?o.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:o.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})}):z?o.jsx("span",{className:"chip",children:z}):R?o.jsx("span",{className:"badge-paid",children:xk(C,A)}):null;if(re){const P=zm(c||void 0,u);return o.jsxs("div",{onClick:D,style:{aspectRatio:q??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${D?"cursor-pointer":""} ${B?"ring-1 ring-brand-500/60":""} ${I?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${W}`,children:[o.jsx("img",{src:P,alt:"",onLoad:Ee=>{const $e=Ee.currentTarget;$e.naturalWidth&&$e.naturalHeight&&V(Math.min(1.9,Math.max(1,$e.naturalWidth/$e.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),o.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),o.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[o.jsx("span",{children:K&&o.jsx(Vse,{type:X})}),o.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ee=>Ee.stopPropagation(),children:[M?o.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:o.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})}):z?o.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:z}):$?null:o.jsx("span",{className:R?"badge-paid":"badge-free",children:xk(C,A)}),$]})]}),o.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),g&&o.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",g]})]}),Ce&&o.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&o.jsx(Hm,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:u,size:15}),o.jsx("span",{className:"truncate",children:Ce})]}),a&&o.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:a}),(h||v&&v.length>0)&&o.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[h&&o.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:h}),v?.slice(0,3).map(Ee=>o.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:Ee},Ee))]}),(!j||U)&&o.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[j?o.jsx("span",{}):o.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx($k,{rating:y}),w>0&&o.jsxs("span",{className:"text-white/60",children:["(",Ho(w),")"]})]}),o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:o.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ho(T)]})]}),U&&o.jsx("div",{className:"flex items-center gap-2",onClick:Ee=>Ee.stopPropagation(),children:U})]})]})]})}return o.jsxs("div",{onClick:D,className:`group asset-card card-shine relative flex flex-col ${D?"cursor-pointer":""} ${B?"ring-1 ring-brand-500/60":""} ${I?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${W}`,children:[o.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, ${H.accent}, transparent)`}}),o.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:ue}}),$&&o.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:P=>P.stopPropagation(),children:$}),o.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Kse,{type:X,seed:se,icon:l,hubBase:u,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),o.jsxs("div",{className:`min-w-0 flex-1 ${$?"pr-7":""}`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),g&&o.jsxs("span",{className:"chip shrink-0",children:["v",g]}),ce&&o.jsx("span",{className:"ml-auto shrink-0",children:ce})]}),(Ce||K)&&o.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&o.jsx(Hm,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:u,size:15}),Ce&&o.jsx("span",{className:"truncate",children:Ce}),K&&o.jsxs(o.Fragment,{children:[Ce&&o.jsx("span",{className:"text-fg-muted",children:"·"}),o.jsx("span",{className:"font-semibold shrink-0",style:{color:H.accent},children:H.label})]})]})]})]}),a&&o.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:a}),(h||v&&v.length>0)&&o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[h&&o.jsx("span",{className:"chip-accent capitalize",children:h}),v?.slice(0,3).map(P=>o.jsx("span",{className:"chip",children:P},P)),(v?.length??0)>3&&o.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(v?.length??0)-3]})]}),(()=>{const P=Y??(j?null:o.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx($k,{rating:y}),o.jsx("span",{className:"text-fg-muted",children:w>0?`(${Ho(w)})`:""})]}),o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:o.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ho(T)]})]}));return!P&&!U?null:o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Ee=>Ee.stopPropagation(),children:[P&&o.jsx("div",{className:"min-w-0 flex items-center gap-2",children:P}),U&&o.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:U})]})})()]})]})}function Oa({children:e,maxCardWidth:t=400,gap:n="1rem",className:a=""}){const i=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const g=i.current;if(!g)return;c(g.clientWidth);const h=new ResizeObserver(v=>{for(const y of v)c(y.contentRect.width)});return h.observe(g),()=>h.disconnect()},[]);const u=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),f=Array.from({length:u},()=>[]);return m.forEach((g,h)=>{f[h%u].push(g)}),o.jsx("div",{ref:i,className:`flex items-start ${a}`,style:{gap:n},children:f.map((g,h)=>o.jsx("div",{className:"cv-stack flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:g},h))})}function Wse(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const Yse=[{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 Qse(){const[e,t]=k.useState(()=>{const a=window.location.hash.slice(1).split("/");return kc(a[0])===me.BUILDER&&a[1]&&a[2]?{type:a[1],name:decodeURIComponent(a[2])}:null});return k.useEffect(()=>{const n=()=>{const i=window.location.hash.slice(1).split("/");kc(i[0])===me.BUILDER&&i[1]&&i[2]?t({type:i[1],name:decodeURIComponent(i[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const MC="markus_builder_shared_map";function Xse(){try{const e=localStorage.getItem(MC);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Du(e){try{localStorage.setItem(MC,JSON.stringify(Object.fromEntries(e)))}catch{}}function jC({authUser:e}={}){const{t}=xt(["builder","common"]),n=Yo(),a=Qse(),[i,l]=k.useState([]),[c,u]=k.useState([]),[m,f]=k.useState(!1),[g,h]=k.useState("all"),[v,y]=k.useState(null),[w,T]=k.useState(new Map),[C,A]=k.useState(null),[M,I]=k.useState(null),[B,K]=k.useState(null),[j,z]=k.useState(Xse),[U,Y]=k.useState(null),[$,D]=k.useState(null),[W,X]=k.useState(null),[H,se]=k.useState(null),[R,re]=k.useState(null),[ue,Ce]=k.useState("creations"),[q,V]=k.useState([]),[ce,P]=k.useState(""),[Ee,$e]=k.useState([]),[qe,Ze]=k.useState(!1),[Qe,Re]=k.useState("all"),Xe=k.useCallback(()=>{f(!0),Promise.all([(Ps(La.builderArtifacts)??Te.builder.artifacts.list()).then(ie=>ie?.artifacts??[]).catch(()=>[]),(Ps(La.builderAgents)??Te.agents.list()).then(ie=>ie?.agents??[]).catch(()=>[]),(Ps(La.builderHubMyItems)??nt.myItems()).then(ie=>ie?.items??[]).catch(()=>[]),(Ps(La.builderInstalled)??Te.builder.artifacts.installed()).then(ie=>ie?.installed??{}).catch(()=>({}))]).then(([ie,et,at,ye])=>{if(u(ie),l(et),at.length>0){const De=new Map;for(const te of at){const F=te.itemType==="agent"?"agent":te.itemType==="team"?"team":"skill";for(const ae of ie)ae.type===F&&(te.slug===ae.name||te.name===(ae.meta.displayName||ae.meta.name||ae.name))&&De.set(`${ae.type}/${ae.name}`,{id:te.id,name:te.name,slug:te.slug||ae.name,version:te.version||"1.0.0",visibility:te.visibility??"public",moderationStatus:te.moderationStatus,moderationNote:te.moderationNote,pendingReview:te.pendingReview})}De.size>0&&z(te=>{const F=new Map(te);for(const[ae,we]of De)F.set(ae,we);return Du(F),F})}const Ne=new Map;for(const De of ie){const te=`${De.type}/${De.name}`,F=ye[te];F&&Ne.set(te,{agentId:F.agentId,agentIds:F.agentIds,teamId:F.teamId})}T(Ne)}).finally(()=>f(!1))},[]);k.useEffect(()=>{Xe();const ie=et=>{et.detail?.page===me.BUILDER&&Xe()};return window.addEventListener("markus:navigate",ie),()=>window.removeEventListener("markus:navigate",ie)},[Xe]);const wt=ie=>{const et=i.find(at=>at.role==="Secretary"||at.name==="Secretary");et?yt.navigate(me.TEAM,{agentId:et.id,prefillMessage:ie}):yt.navigate(me.TEAM,{prefillMessage:ie})},mt=async ie=>{const et=`${ie.type}/${ie.name}`;if(!w.has(et)){y({key:et,action:"install"});try{const at=await Te.builder.artifacts.install(ie.type,ie.name),ye={};at.agent&&typeof at.agent=="object"&&(ye.agentId=at.agent.id),at.team&&typeof at.team=="object"&&(ye.teamId=at.team.id),Array.isArray(at.agents)&&(ye.agentIds=at.agents.map(Ne=>Ne.id)),T(Ne=>new Map(Ne).set(et,ye)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(at){console.error("Install failed:",at),D({title:t("common:install"),message:t("installFailed",{error:String(at)}),variant:"danger"})}finally{y(null)}}},kt=async ie=>{const et=`${ie.type}/${ie.name}`;if(w.has(et)){y({key:et,action:"uninstall"});try{await Te.builder.artifacts.uninstall(ie.type,ie.name),T(at=>{const ye=new Map(at);return ye.delete(et),ye}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(at){console.error("Uninstall failed:",at),D({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(at)}),variant:"danger"})}finally{y(null)}}},lt=async(ie,et)=>{const at=`${ie.type}/${ie.name}`;y({key:at,action:"share"});try{const ye=await Te.builder.artifacts.ensureSlugSafe(ie.type,ie.name,ie.meta.displayName||ie.meta.name||ie.name),Ne=ye.name,De=ye.slug||Tc(Ne);if(!De)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 te=`${ie.type}/${Ne}`;ye.converted&&(u(ln=>ln.map(Pt=>Pt.type===ie.type&&Pt.name===ie.name?{...Pt,name:Ne,path:ye.path,meta:{...Pt.meta,name:Ne,displayName:ye.displayName??Pt.meta.displayName??ie.name}}:Pt)),z(ln=>{const Pt=new Map(ln),Ae=Pt.get(at);return Ae&&(Pt.delete(at),Pt.set(te,{...Ae,slug:De,name:ye.displayName??Ae.name})),Du(Pt),Pt}),T(ln=>{const Pt=new Map(ln),Ae=Pt.get(at);return Ae&&(Pt.delete(at),Pt.set(te,Ae)),Pt}));const F=await Te.builder.artifacts.get(ie.type,Ne);let ae={...ie.meta,name:Ne,displayName:ye.displayName??ie.meta.displayName??ie.name};try{const ln=F.files?.[`${ie.type}.json`]??F.files?.["agent.json"]??F.files?.["team.json"]??F.files?.["skill.json"];ln&&(ae={...JSON.parse(ln),...ae,name:Ne,displayName:ae.displayName})}catch{}const we=ae.displayName||ae.name||Ne,Le=ae.description||"",He=ae.category||"general",de=Array.isArray(ae.tags)?ae.tags:[];let fe=ae.icon||void 0;const Ge=ae.version||"1.0.0";if(fe&&!fe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(fe)){const ln=fe.split("/").pop()??fe;try{const Pt=await fetch(`/api/builder/artifacts/${ie.type}s/${encodeURIComponent(Ne)}/images/${encodeURIComponent(ln)}`);if(Pt.ok){const Ae=await Pt.blob(),je=new File([Ae],ln,{type:Ae.type}),_e=await nt.uploadImage(je);_e?.url&&(fe=_e.url)}}catch{}}let ct;const We=[],ut=Array.isArray(ae.screenshots)?ae.screenshots:[];for(let ln=0;ln<ut.length;ln++){const Pt=ut[ln],Ae=Pt.split("/").pop()??Pt;try{const je=await fetch(`/api/builder/artifacts/${ie.type}s/${encodeURIComponent(Ne)}/images/${encodeURIComponent(Ae)}`);if(je.ok){const _e=await je.blob(),Q=new File([_e],Ae,{type:_e.type}),he=await nt.uploadImage(Q);he?.url&&(We.push({url:he.url,alt:Ae,order:ln}),(ln===0||ae.thumbnail===Pt)&&(ct=he.url))}}catch{}}const Ft=await nt.publishViaProxy({itemType:ie.type==="team"?"team":ie.type==="skill"?"skill":"agent",name:we,slug:De,description:Le,category:He,tags:de,icon:fe,version:Ge,config:{...ae,name:Ne,displayName:we},files:F.files&&Object.keys(F.files).length>0?F.files:void 0,thumbnailUrl:ct,images:We.length>0?We:void 0,priceCents:et?.priceCents,donationsEnabled:et?.donationsEnabled,visibility:et?.visibility,orgId:et?.orgId});Ft.id&&(z(Pt=>{const Ae=new Map(Pt);return Ae.set(te,{id:Ft.id,name:we,slug:Ft.slug??De,version:Ge,visibility:Ft.visibility??et?.visibility??"public",moderationStatus:Ft.moderationStatus,pendingReview:Ft.pendingReview}),Du(Ae),Ae}),(Ft.visibility??et?.visibility??"public")!=="org"?D({title:t("common:share"),message:ye.converted?t("share.convertedAndSubmitted",{previous:ie.name,slug:De}):Ft.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):ye.converted&&D({title:t("common:share"),message:t("share.convertedSlug",{previous:ie.name,slug:De}),variant:"primary"}))}catch(ye){console.error("Share failed:",ye),D({title:t("common:share"),message:t("shareFailed",{error:ye instanceof Error?ye.message:String(ye)}),variant:"danger"})}finally{y(null)}},Dt=async()=>{if(!U)return;const{key:ie}=U,et=j.get(ie);if(Y(null),!et)return;const at=et.id;y({key:ie,action:"hubDelete"});try{await nt.deleteItem(at),z(ye=>{const Ne=new Map(ye);return Ne.delete(ie),Du(Ne),Ne})}catch(ye){console.error("Hub delete failed:",ye),D({title:t("unshare"),message:t("hubDeleteFailed",{error:String(ye)}),variant:"danger"})}finally{y(null)}},ht=async()=>{if(!C)return;const ie=C,et=`${ie.type}/${ie.name}`;A(null),y({key:et,action:"delete"});try{await Te.builder.artifacts.delete(ie.type,ie.name),u(at=>at.filter(ye=>!(ye.type===ie.type&&ye.name===ie.name))),T(at=>{const ye=new Map(at);return ye.delete(et),ye}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(at){console.error("Delete failed:",at)}finally{y(null)}},Oe=g==="all"?c:c.filter(ie=>ie.type===g);k.useEffect(()=>{ue!=="orgAssets"||q.length>0||nt.myOrgs().then(ie=>{V(ie.memberships),ie.memberships.length>0&&!ce&&P(ie.memberships[0].id)}).catch(()=>{})},[ue,q.length,ce]),k.useEffect(()=>{ue!=="orgAssets"||!ce||(Ze(!0),nt.browseItems({orgId:ce,limit:100}).then(ie=>$e(ie.items??[])).catch(()=>$e([])).finally(()=>Ze(!1)))},[ue,ce]);const Nt=Qe==="all"?Ee:Ee.filter(ie=>ie.itemType===Qe),Gt=ie=>{history.pushState(null,"",Hs(me.BUILDER,`${ie.type}/${encodeURIComponent(ie.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return k.useEffect(()=>(Qx(me.BUILDER,a?1:0),()=>Qx(me.BUILDER,0)),[a]),a?o.jsx(qs,{type:a.type,name:a.name,authUser:e,onBack:()=>{history.pushState(null,"",Hs(me.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[o.jsxs("div",{className:"mb-6",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),o.jsx("button",{onClick:Xe,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")})]}),o.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:Yse.map(ie=>{const et=t(`prompts.${ie.id}Prompt`),at=t(`prompts.${ie.id}Examples`,{returnObjects:!0}),ye=Array.isArray(at)?at:[];return o.jsx("button",{onClick:()=>wt(et),className:`group text-left w-full rounded-xl border ${ie.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${ie.bgColor} flex items-center justify-center shrink-0`,children:ie.icon}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ie.color} bg-clip-text text-transparent`,children:t(`prompts.${ie.id}`)}),o.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ie.id}Desc`)}),ye.length>0&&o.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ye.slice(0,2).map((Ne,De)=>o.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:te=>{te.stopPropagation(),wt(et+Ne)},children:["“",Ne,"”"]},De))})]})]})},ie.id)})})]}),o.jsx("div",{className:"mb-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:()=>Ce("creations"),className:`text-sm font-semibold transition-colors ${ue==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),o.jsx("button",{onClick:()=>Ce("orgAssets"),className:`text-sm font-semibold transition-colors ${ue==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),ue==="creations"&&o.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ie=>o.jsx("button",{onClick:()=>h(ie),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${g===ie?"bg-brand-600 text-on-brand":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ie==="all"?"myCreations.filterAll":ie==="agent"?"myCreations.filterAgents":ie==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ie))}),ue==="orgAssets"&&o.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ie=>o.jsx("button",{onClick:()=>Re(ie),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${Qe===ie?"bg-brand-600 text-on-brand":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ie==="all"?"myCreations.filterAll":ie==="agent"?"myCreations.filterAgents":ie==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ie))})]})}),ue==="orgAssets"&&q.length>0&&o.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:q.map(ie=>o.jsx("button",{onClick:()=>P(ie.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${ce===ie.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:ie.name},ie.id))}),ue==="orgAssets"&&(q.length===0&&!qe?o.jsx("div",{className:"text-center py-12",children:o.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):qe?o.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):Nt.length===0?o.jsx("div",{className:"text-center py-12",children:o.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):o.jsx(Oa,{children:Nt.map(ie=>{const et=ie.author?.username&&ie.slug?`${nt.getUrl()}/@${encodeURIComponent(ie.author.username)}/${encodeURIComponent(ie.slug)}`:null;return o.jsx(pr,{type:ie.itemType,name:ie.name,description:ie.description,seed:ie.slug||ie.id||ie.name,icon:ie.icon,cover:ie.thumbnailUrl,hubBase:nt.getUrl(),author:ie.author,version:ie.version,rating:parseFloat(ie.avgRating)||0,ratingCount:ie.ratingCount,downloadCount:ie.downloadCount,actions:et?o.jsxs("a",{href:et,target:"_blank",rel:"noopener noreferrer",onClick:at=>{at.stopPropagation(),Uo()&&(at.preventDefault(),Or(et))},className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors inline-flex items-center gap-1",children:[o.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},ie.id)})})),ue==="creations"&&(m&&c.length===0?o.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):Oe.length===0?o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),o.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):o.jsx(Oa,{children:Oe.map(ie=>{const et=ie.meta.displayName||ie.meta.name||ie.name,at=ie.meta.description||"",ye=`${ie.type}/${ie.name}`,Ne=v?.key===ye?v.action:null,De=j.get(ye),te=ie.meta.version||"1.0.0",F=!!De,ae=F&&De.version!==te,we=()=>{const We=nt.getUser();return!De||!We?null:`${nt.getUrl()}/@${encodeURIComponent(We.username)}/${encodeURIComponent(De.slug)}`},Le=F&&De?.moderationStatus==="rejected",He=o.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:We=>We.stopPropagation(),children:[w.has(ye)?o.jsxs("button",{onClick:()=>K(ie),disabled:!!Ne,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:[o.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:[o.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),o.jsx("polyline",{points:"17 8 12 3 7 8"}),o.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(Ne==="uninstall"?"common:uninstalling":"common:uninstall")]}):o.jsxs("button",{onClick:()=>I(ie),disabled:!!Ne,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[o.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:[o.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),o.jsx("polyline",{points:"7 10 12 15 17 10"}),o.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(Ne==="install"?"common:installing":"common:install")]}),F&&Le?o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>{D({title:t("share.rejectedDetailTitle"),variant:"danger",message:`${t("share.rejectedReasonLabel")}${De?.moderationNote?De.moderationNote:t("share.rejectedNoReason")}
|
|
866
866
|
|
|
867
|
-
${t("share.rejectedEncourage")}`})},className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 hover:bg-red-500/10 transition-colors inline-flex items-center gap-1 cursor-pointer",title:t("share.rejectedTip"),children:[o.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:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}),o.jsxs("button",{onClick:()=>{lt(ie,{visibility:De?.visibility??"public"})},disabled:!!Ne,className:"text-xs px-3 py-1.5 rounded-lg border border-brand-500/40 text-brand-400 hover:bg-brand-500/10 hover:border-brand-500/60 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[o.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:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),t(Ne==="share"?"common:sharing":"share.resubmit")]})]}):F?o.jsxs(o.Fragment,{children:[ae&&o.jsxs("button",{onClick:()=>{const We=De?.visibility??"public";lt(ie,{visibility:We})},disabled:!!Ne,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:[o.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:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.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"})]}),Ne==="share"?t("common:sharing"):t("share.updateVersion",{version:te})]}),o.jsxs("a",{href:we()??"#",target:"_blank",rel:"noopener noreferrer",onClick:We=>{const ut=we();Uo()&&ut&&(We.preventDefault(),Or(ut))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${De?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":De?.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:[De?.visibility==="org"?o.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:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):De?.visibility==="unlisted"?o.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:[o.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"}),o.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"})]}):o.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:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),De?.visibility==="org"?t("visibility.sharedOrg"):De?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),o.jsxs("button",{onClick:()=>Y({key:ye,name:et}),disabled:!!Ne,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:[o.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:[o.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),o.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):o.jsxs("button",{onClick:async()=>{await nt.ensureAuth(),Array.isArray(ie.meta.screenshots)&&ie.meta.screenshots.length>0?re(ie):X(ie)},disabled:!!Ne,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:[o.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:[o.jsx("circle",{cx:"18",cy:"5",r:"3"}),o.jsx("circle",{cx:"6",cy:"12",r:"3"}),o.jsx("circle",{cx:"18",cy:"19",r:"3"}),o.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),o.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(Ne==="share"?"common:sharing":"common:share")]})]}),de=o.jsx("button",{onClick:()=>A(ie),disabled:!!Ne,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:o.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:[o.jsx("polyline",{points:"3 6 5 6 21 6"}),o.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),fe=ie.meta.icon,ct=!!fe&&/\.(png|jpe?g|gif|webp|svg)$/i.test(fe)?fe.startsWith("http")||fe.startsWith("/")?fe:`/api/builder/artifacts/${ie.type}s/${encodeURIComponent(ie.name)}/images/${encodeURIComponent(fe.split("/").pop()??"")}?v=${ie.updatedAt??""}`:fe;return o.jsx(pr,{type:ie.type,name:et,description:at,seed:ye,icon:ct,version:te,footerLeft:o.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[o.jsx("button",{onClick:We=>{We.stopPropagation(),Te.system.openPath(ie.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ie.path,children:Wse(ie.path)}),o.jsx("span",{className:"shrink-0",children:"·"}),o.jsx("span",{className:"shrink-0",children:new Date(ie.updatedAt).toLocaleDateString()})]}),headerAction:de,actions:He,onClick:()=>Gt(ie)},ye)})})),M&&o.jsx(vr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:M.meta.displayName||M.meta.name||M.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ie=M;I(null),mt(ie)},onCancel:()=>I(null)}),B&&o.jsx(vr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:B.meta.displayName||B.meta.name||B.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ie=B;K(null),kt(ie)},onCancel:()=>K(null)}),C&&o.jsx(vr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:C.meta.displayName||C.meta.name||C.name}),confirmLabel:t("common:delete"),onConfirm:ht,onCancel:()=>A(null)}),U&&o.jsx(vr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:U.name}),confirmLabel:t("unshare"),onConfirm:()=>{Dt()},onCancel:()=>Y(null)}),$&&o.jsx(vr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>D(null),onCancel:()=>D(null)}),W&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>X(null),children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),o.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:()=>{const ie=W;X(null),re(ie)},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")}),o.jsx("button",{onClick:()=>{const ie=W;X(null),Gt(ie)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:t("share.addImagesFirst")})]})]})}),H&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>se(null),children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:o.jsx(Zse,{isUpdate:j.has(`${H.type}/${H.name}`),onCancel:()=>se(null),onConfirm:(ie,et)=>{const at=H;se(null),lt(at,{priceCents:et>0?et:void 0})}})})}),R&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>re(null),children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:o.jsx(Jse,{onCancel:()=>re(null),onConfirm:(ie,et,at,ye)=>{const Ne=R;re(null),lt(Ne,{visibility:ie,orgId:et,priceCents:at,donationsEnabled:ye})}})})})]})})}function Jse({onCancel:e,onConfirm:t}){const{t:n}=xt(["builder","common"]),[a,i]=k.useState("public"),[l,c]=k.useState([]),[u,m]=k.useState(""),[f,g]=k.useState(!1),[h,v]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{a==="org"&&l.length===0&&(g(!0),nt.myOrgs().then(A=>{c(A.memberships),A.memberships.length>0&&m(A.memberships[0].id)}).catch(()=>{}).finally(()=>g(!1)))},[a,l.length]);const T=a==="public"||a==="unlisted",C=[{value:"public",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),o.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:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.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:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.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"}),o.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 o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),o.jsx("div",{className:"space-y-2 mb-5",children:C.map(A=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${a===A.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"visibility",checked:a===A.value,onChange:()=>i(A.value),className:"accent-brand-500"}),o.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:A.icon}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:A.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:A.desc})]})]},A.value))}),a==="org"&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),f?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):o.jsx("select",{value:u,onChange:A=>m(A.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(A=>o.jsx("option",{value:A.id,children:A.name},A.id))})]}),T&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),o.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:RC.map(A=>o.jsx("button",{type:"button",onClick:()=>v(A.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${h===A.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:A.label},A.cents))}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:y,onChange:A=>w(A.target.checked),className:"accent-brand-500"}),o.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),T&&o.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),o.jsxs("div",{className:"flex gap-3",children:[o.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")}),o.jsx("button",{onClick:()=>t(a,a==="org"?u:void 0,T&&h>0?h:void 0,T?y:void 0),disabled:a==="org"&&!u,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const RC=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Zse({isUpdate:e,onCancel:t,onConfirm:n}){const{t:a}=xt(["builder","common"]),[i,l]=k.useState(0);return o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:a(e?"shareMode.titleUpdate":"shareMode.title")}),o.jsx("div",{className:"space-y-2 mb-5",children:RC.map(c=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"sharePrice",checked:i===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?a("shareMode.freeDesc"):a("shareMode.paidDesc")})]})]},c.cents))}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:a("common:cancel")}),o.jsx("button",{onClick:()=>n(i>0?"paid":"free",i),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:a(e?"shareMode.update":"shareMode.share")})]})]})}const eoe=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:jC},Symbol.toStringTag,{value:"Module"}));function toe(e,t="读取失败"){return e instanceof Error&&e.message?e.message:(typeof e=="string"?e:"")||t}function Iu(){return{state:"loading",items:[],error:null}}function noe(e){return{state:"ok",items:e,error:null}}function aoe(e,t=[]){return{state:"error",items:t,error:toe(e)}}async function qk(e,t={}){try{return noe(await e())}catch(n){return aoe(n,t.keep??[])}}function Jle(e){const t=e.state==="loading",n=e.state==="error";return{loading:t,error:n,rows:e.items,empty:!t&&!n&&e.items.length===0}}function roe(e){const t=[];let n=!1,a=!1;for(const l of e)l.state==="loading"?n=!0:l.state==="error"?t.push(l.label):a=!0;return{state:n?"loading":t.length>0?"error":"ok",loading:n,failures:t,anyOk:a}}async function ioe(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(a=>a.id===t);if(n)return{items:[n,...e.filter(a=>a.id!==t)],highlighted:n,missing:!1};try{const{item:a}=await nt.getItem(t);return a?{items:[a,...e],highlighted:a,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function _C(e){const{catalogType:t,search:n,highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c}=e,[u,m]=k.useState(Iu()),[f,g]=k.useState(Iu()),[h,v]=k.useState(0),y=k.useRef({highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c});y.current={highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c},k.useEffect(()=>{let C=!1;return m(Iu()),g(Iu()),(async()=>{const A=(async()=>{const K=await qk(async()=>{const z=n?null:await y.current.takeHubPrefetch?.()??null;return z||((await nt.search({type:t,q:n,limit:50})).items??[])});if(K.state!=="ok")return K;const j=await ioe([...K.items],y.current.highlightItemId??null);return j.missing&&y.current.onHighlightDone?.(),{state:"ok",items:j.items,error:null}})(),M=qk(()=>y.current.loadTemplates(n)),[I,B]=await Promise.all([A,M]);C||(m(I),g(B))})(),()=>{C=!0}},[t,n,h]);const w=k.useCallback(()=>v(C=>C+1),[]),T=roe([{label:"Hub 资产",state:u.state},{label:"本地模板",state:f.state}]);return{hub:u,templates:f,sources:T,reload:w}}function DC({subject:e,error:t,notEquals:n,onRetry:a,retryLabel:i="重试",hint:l,variant:c="bar"}){const u=o.jsxs("span",{className:c==="inline"?"text-[11px] text-rose-500":"text-xs text-rose-500",children:[e,"读取失败:",t,"(这不等于「",n,"」)"]}),m=a?o.jsx("button",{type:"button",onClick:a,className:"text-xs text-brand-500 hover:text-brand-400 shrink-0 cursor-pointer",children:i}):l?o.jsx("span",{className:"text-xs text-fg-tertiary shrink-0",children:l}):null;return c==="inline"?o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",role:"alert",children:[u,m]}):o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-rose-500/30 bg-rose-500/10 shrink-0",role:"alert",children:[u,m]})}function soe(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Bm(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Fk(e,t){return e.i18n?.[t]?.description||e.description}const ooe={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function loe({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:a,i18n:i}=xt(["store","common"]),l=i.language,[c,u]=k.useState(""),m=_C({catalogType:"agent",search:c,highlightItemId:t,onHighlightDone:n,loadTemplates:k.useCallback(async W=>{const X=new URLSearchParams;W&&X.set("q",W);const H=await fetch("/api/templates?"+X.toString(),{credentials:"include"});if(!H.ok)throw new Error(`HTTP ${H.status}`);const se=await H.json();return Array.isArray(se.templates)?se.templates:[]},[]),takeHubPrefetch:async()=>(await Ps(La.hubAgents))?.items??null}),f=m.templates.items,g=m.hub.items,h=m.sources.loading,[v,y]=k.useState(null),[w,T]=k.useState({}),[C,A]=k.useState(!1),[M,I]=k.useState(new Map),[B,K]=k.useState(new Set),[j,z]=k.useState(null),[U,Y]=k.useState(null),$=k.useCallback(async()=>{try{const[W,X]=await Promise.all([Te.builder.artifacts.list().catch(()=>({artifacts:[]})),Te.builder.artifacts.installed().catch(()=>({installed:{}}))]),H=new Map;for(const se of W.artifacts){if(se.type!=="agent")continue;const R=!!X.installed[`agent/${se.name}`];H.set(se.name,{installed:R,localVersion:se.meta.version||void 0,localUpdatedAt:se.updatedAt})}I(H)}catch{}},[]);k.useEffect(()=>{$(),nt.isAuthenticated()&&nt.purchases.mine().then(W=>K(new Set(W.purchases.map(X=>X.itemId)))).catch(()=>{})},[$]),k.useEffect(()=>{if(!v){T({});return}fetch(`/api/templates/${encodeURIComponent(v.id)}/files`,{credentials:"include"}).then(W=>W.json()).then(W=>T(W.files??{})).catch(()=>T({}))},[v]);const D=async(W,X,H)=>{try{const se=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:W,name:X,orgId:"default",teamId:H})});if(!se.ok)throw new Error(`Failed: ${se.status}`);A(!1),y(null)}catch(se){Y({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${se}`,variant:"danger"})}};if(j)return o.jsx(qs,{type:j.type,name:j.name,onBack:()=>z(null)});if(v){const W={type:"agent",name:v.id,displayName:Bm(v,l),version:v.version,description:Fk(v,l),author:v.author,category:v.category,tags:v.tags,icon:v.icon,files:w,agent:{roleName:v.roleId,agentRole:v.agentRole==="manager"?"manager":"worker"},dependencies:{skills:v.skills}},X=o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.roleConfig")}),o.jsxs("div",{className:"space-y-2.5 text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.role")}),o.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:v.roleId})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.position")}),o.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${ooe[v.agentRole]??""}`,children:v.agentRole})]})]})]}),o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.skills")}),o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[v.skills.map(H=>o.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:H},H)),v.skills.length===0&&o.jsx("span",{className:"text-xs text-fg-tertiary italic",children:a("agentStore.noSkills")})]})]})]}),v.starterTasks&&v.starterTasks.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.starterTasks")}),o.jsx("div",{className:"space-y-2",children:v.starterTasks.map((H,se)=>o.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${H.priority==="high"?"bg-red-400":H.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-fg-primary",children:H.title}),H.description&&o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:H.description})]})]},se))})]})]});return o.jsxs(o.Fragment,{children:[o.jsx(qs,{type:"agent",name:v.id,onBack:()=>y(null),readOnly:!0,initialManifest:W,actionSlot:o.jsx("button",{onClick:()=>A(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors font-medium",children:a("agentStore.hireAgent")}),contentSlot:X}),C&&o.jsx(Uk,{template:v,lang:l,onClose:()=>A(!1),onHire:D}),U&&o.jsx(vr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[o.jsx("h2",{className:"text-lg font-semibold",children:a("agentStore.title")}),o.jsx("input",{type:"text",placeholder:a("agentStore.searchPlaceholder"),value:c,onChange:W=>u(W.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"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:[m.sources.failures.length>0&&o.jsx(DC,{subject:m.sources.failures.join("、"),error:m.hub.error??m.templates.error??"读取失败",notEquals:"这里没有任何模板或 Hub 资产",onRetry:m.reload}),h?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((W,X)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},X))}):m.sources.failures.length===0&&f.length===0&&g.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?a("agentStore.noResults",{search:c}):a("agentStore.noAgents")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:a(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):o.jsxs(o.Fragment,{children:[f.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:a("agentStore.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:a("agentStore.available",{count:f.length})})]}),o.jsx(Oa,{columns:3,children:f.map(W=>o.jsx(pr,{type:"agent",name:Bm(W,l),description:Fk(W,l),seed:W.id,icon:W.icon,version:W.version,category:W.category,tags:W.tags,authorLabel:W.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(W)},W.id))})]}),g.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:a("agentStore.markusHub")}),o.jsx(Oa,{columns:3,children:g.map(W=>o.jsx(coe,{item:W,localInfo:M.get(Fc(W)),purchased:cm(W,B),onStatusChange:$,highlight:W.id===t,onHighlightDone:n,onViewDetail:X=>z({type:"agent",name:X})},W.id))})]})]})]}),C&&v&&o.jsx(Uk,{template:v,lang:l,onClose:()=>A(!1),onHire:D}),U&&o.jsx(vr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Fc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return mm(n||e.name,"hub-pkg")}function Os(e){return(async()=>{const t=await nt.download(e.id),n=t.name||e.name,a=t.config??{},i=Fc(e,a),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},u=(t.version||e.version||(typeof a.version=="string"?a.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Te.builder.artifacts.import(l,i,t.files,c,u);else{const m={...a,...u?{version:u}:{},name:i,displayName:a.displayName||n,description:e.description,source:c};await Te.builder.artifacts.save(l,m)}return await Te.builder.artifacts.install(l,i),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Hb(e,t){t("checking"),await nt.ensureAuth();const n=await nt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Os(e),"installed";try{if((await nt.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await nt.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Os(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const a=Uo();let i=null;return a?Or(n.checkoutUrl):i=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const u=Date.now(),m=300*1e3,f=setInterval(async()=>{if(Date.now()-u>m){clearInterval(f),l("cancelled");return}const h=!a&&i?i.closed:!1;try{if((await nt.purchases.checkout(e.id)).alreadyOwned){clearInterval(f),t("installing");try{await Os(e),l("installed")}catch(y){c(y)}return}}catch{}if(h){clearInterval(f);try{if((await nt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Os(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function coe({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:u}=xt(["store"]),[m,f]=k.useState(!1),[g,h]=k.useState(""),v=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(i&&v.current){v.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const U=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(U)}},[i,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&soe(e.version,t.localVersion),A=(e.priceCents??0)>0,M=async U=>{if(U.stopPropagation(),!m){f(!0),h("");try{await Os(e),h(C?u("card.upgraded"):u("card.installed")+"!"),a()}catch(Y){const $=Y instanceof Error?Y.message:"";$.includes("402")||$.includes("Purchase required")?h(u("card.purchaseRequired")):h(u("card.failed"))}finally{f(!1)}}},I=async U=>{if(U.stopPropagation(),!m){f(!0),h("");try{await Hb(e,$=>{$==="checkout_opened"?h(u("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&h(u("card.installing"))})==="installed"?(h(u("card.installed")+"!"),a()):h("")}catch(Y){h(Y instanceof Error?Y.message:u("card.failed"))}finally{f(!1)}}},B=A?`$${((e.priceCents??0)/100).toFixed(2)}`:null,K=e.slug&&e.author?.username?`${nt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,j=()=>{T&&c?c(Fc(e)):K&&window.open(K,"_blank","noopener,noreferrer")},z=o.jsxs(o.Fragment,{children:[C?o.jsx("button",{onClick:U=>{M(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?u("card.upgrading"):u("card.upgrade",{version:e.version})}):T?o.jsxs("button",{onClick:U=>{M(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):A&&!n?o.jsx("button",{onClick:U=>{I(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?g||u("card.installing"):o.jsxs(o.Fragment,{children:[u("card.buy","Buy")," ",B]})}):o.jsx("button",{onClick:U=>{M(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors disabled:opacity-50",children:u(m?"card.installing":"card.install")}),g&&!(A&&!n)&&o.jsx("span",{className:`text-[10px] ${g===u("card.failed")||g===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:g})]});return o.jsx("div",{ref:v,className:y?"animate-pulse":"",children:o.jsx(pr,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:nt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:T,glowing:y,onClick:j,actions:z})})}function Uk({template:e,lang:t,onClose:n,onHire:a}){const{t:i}=xt(["store"]),[l,c]=k.useState(`${Bm(e,t)} Agent`),[u,m]=k.useState(""),[f,g]=k.useState([]),[h,v]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>g(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){v(!0);try{await a(e.id,l.trim(),u||void 0)}finally{v(!1)}}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[o.jsx("div",{className:"flex items-center gap-3 mb-5",children:o.jsxs("div",{children:[o.jsx("h3",{className:"text-base font-semibold",children:i("hireModal.title")}),o.jsx("p",{className:"text-xs text-fg-tertiary",children:i("hireModal.creating",{name:Bm(e,t)})})]})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:i("hireModal.agentName")}),o.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"input-field",autoFocus:!0})]}),f.length>0&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:i("hireModal.assignTeam")}),o.jsxs("select",{value:u,onChange:w=>m(w.target.value),className:"input-field",children:[o.jsx("option",{value:"",children:i("hireModal.noTeam")}),f.map(w=>o.jsx("option",{value:w.id,children:w.name},w.id))]})]}),o.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:i("hireModal.agentConfig")}),o.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.role")}),o.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.position")}),o.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.skills")}),o.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||i("hireModal.none")})]})]})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[o.jsx("button",{onClick:n,className:"btn-secondary",children:i("hireModal.cancel")}),o.jsx("button",{onClick:y,disabled:!l.trim()||h,className:"btn-primary",children:i(h?"hireModal.creating_progress":"hireModal.create")})]})]})})}function Th(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Gk(e,t){return e.i18n?.[t]?.description||e.description}function Kk(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function doe(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function uoe({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=xt(["store","common"]),i=a.language,[l,c]=k.useState(""),u=_C({catalogType:"team",search:l,highlightItemId:e,onHighlightDone:t,loadTemplates:k.useCallback(D=>Te.teamTemplates.list(D||void 0).then(W=>W.templates??[]),[]),takeHubPrefetch:async()=>(await Ps(La.hubTeams))?.items??null}),m=u.templates.items,f=u.hub.items,g=u.sources.loading,[h,v]=k.useState(null),[y,w]=k.useState({}),[T,C]=k.useState(!1),[A,M]=k.useState(null),[I,B]=k.useState(new Map),[K,j]=k.useState(new Set),[z,U]=k.useState(null),Y=k.useCallback(async()=>{try{const[D,W]=await Promise.all([Te.builder.artifacts.list().catch(()=>({artifacts:[]})),Te.builder.artifacts.installed().catch(()=>({installed:{}}))]),X=new Map;for(const H of D.artifacts){if(H.type!=="team")continue;const se=!!W.installed[`team/${H.name}`];X.set(H.name,{installed:se,localVersion:H.meta.version||void 0,localUpdatedAt:H.updatedAt})}B(X)}catch{}},[]);k.useEffect(()=>{Y(),nt.isAuthenticated()&&nt.purchases.mine().then(D=>j(new Set(D.purchases.map(W=>W.itemId)))).catch(()=>{})},[Y]),k.useEffect(()=>{if(!h){w({});return}fetch(`/api/team-templates/${encodeURIComponent(h.id)}/files`,{credentials:"include"}).then(D=>D.json()).then(D=>w(D.files??{})).catch(()=>w({}))},[h]);const $=async D=>{C(!0),M(null);try{const X=(await Te.teams.create(D.name,D.description)).team.id;let H,se=0;const R=[];for(const ue of D.members){const Ce=ue.count??1;for(let q=0;q<Ce;q++){const V=ue.name??`${D.name} Agent ${q+1}`,ce=Ce>1?`${V} ${q+1}`:V,P=ue.roleName??ue.templateId;try{const Ee=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:ce,...P?{roleName:P}:{},orgId:"default",teamId:X,agentRole:ue.role??"worker",skills:ue.skills??[]})});if(Ee.ok){se++;const $e=await Ee.json();ue.role==="manager"&&!H&&(H=$e.agent?.id)}else{const $e=await Ee.json().catch(()=>({error:`HTTP ${Ee.status}`}));R.push(`${ce}: ${$e.error??Ee.statusText}`)}}catch(Ee){R.push(`${ce}: ${String(Ee)}`)}}}H&&await Te.teams.update(X,{managerId:H,managerType:"agent"}).catch(()=>{});const re=R.length>0?` (${R.length} failed: ${R[0]})`:"";M({ok:se>0,message:`Team "${Th(D,i)}" deployed with ${se} agent(s)${re}`})}catch(W){M({ok:!1,message:`Failed: ${W}`})}finally{C(!1)}};if(z)return o.jsx(qs,{type:z.type,name:z.name,onBack:()=>U(null)});if(h){const D={...y};h.announcements&&(D["ANNOUNCEMENT.md"]=h.announcements),h.norms&&(D["NORMS.md"]=h.norms);const W={type:"team",name:h.id,displayName:Th(h,i),version:h.version,description:Gk(h,i),author:h.author,category:h.category??"general",tags:h.tags??[],files:D,team:{members:h.members.map(H=>({name:Kk(h,H.name??H.roleName??H.templateId??"Agent",i),role:H.role??"worker",roleName:H.roleName??H.templateId,count:H.count??1,skills:H.skills??[]}))}},X=o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[o.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),o.jsx("div",{className:"p-5 space-y-2",children:h.members.map((H,se)=>{const R=Kk(h,H.name??H.roleName??H.templateId??"Agent",i);return o.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${H.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:(R[0]??"?").toUpperCase()}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm text-fg-primary font-medium",children:R}),o.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${H.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:H.role??"worker"}),(H.count??1)>1&&o.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",H.count]})]}),(H.roleName||H.templateId)&&o.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:H.roleName??H.templateId})]}),H.skills&&H.skills.length>0&&o.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[H.skills.slice(0,3).map(re=>o.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:re},re)),H.skills.length>3&&o.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",H.skills.length-3]})]})]},se)})})]});return o.jsx(o.Fragment,{children:o.jsx(qs,{type:"team",name:h.id,onBack:()=>{v(null),M(null)},readOnly:!0,initialManifest:W,contentSlot:X,actionSlot:o.jsxs(o.Fragment,{children:[A&&o.jsx("span",{className:`text-xs ${A.ok?"text-green-500":"text-red-500"}`,children:A.message}),o.jsx("button",{onClick:()=>{$(h)},disabled:T,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors font-medium disabled:opacity-50",children:n(T?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[o.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),o.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:D=>c(D.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"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:[u.sources.failures.length>0&&o.jsx(DC,{subject:u.sources.failures.join("、"),error:u.hub.error??u.templates.error??"读取失败",notEquals:"这里没有任何团队模板或 Hub 资产",onRetry:u.reload}),g?o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((D,W)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},W))}):u.sources.failures.length===0&&m.length===0&&f.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):o.jsxs(o.Fragment,{children:[m.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:m.length})})]}),o.jsx(Oa,{columns:2,children:m.map(D=>o.jsx(pr,{type:"team",name:Th(D,i),description:Gk(D,i),seed:D.id,icon:D.icon||"users",version:D.version,category:D.category,tags:D.tags,authorLabel:D.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>v(D)},D.id))})]}),f.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),o.jsx(Oa,{columns:2,children:f.map(D=>o.jsx(moe,{item:D,localInfo:I.get(Fc(D)),purchased:cm(D,K),onStatusChange:Y,highlight:D.id===e,onHighlightDone:t,onViewDetail:W=>U({type:"team",name:W})},D.id))})]})]})]})]})}function moe({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:u}=xt(["store"]),[m,f]=k.useState(!1),[g,h]=k.useState(""),v=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(i&&v.current){v.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const U=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(U)}},[i,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&doe(e.version,t.localVersion),A=(e.priceCents??0)>0,M=A?`$${((e.priceCents??0)/100).toFixed(2)}`:null,I=async U=>{if(U.stopPropagation(),!m){f(!0),h("");try{await Os(e),h(C?u("card.upgraded"):u("card.installed")+"!"),a()}catch(Y){const $=Y instanceof Error?Y.message:"";$.includes("402")||$.includes("Purchase required")?h(u("card.purchaseRequired")):h(u("card.failed"))}finally{f(!1)}}},B=async U=>{if(U.stopPropagation(),!m){f(!0),h("");try{await Hb(e,$=>{$==="checkout_opened"?h(u("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&h(u("card.installing"))})==="installed"?(h(u("card.installed")+"!"),a()):h("")}catch(Y){h(Y instanceof Error?Y.message:u("card.failed"))}finally{f(!1)}}},K=e.slug&&e.author?.username?`${nt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,j=()=>{T&&c?c(Fc(e)):K&&window.open(K,"_blank","noopener,noreferrer")},z=o.jsxs(o.Fragment,{children:[C?o.jsx("button",{onClick:U=>{I(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?u("card.upgrading"):u("card.upgrade",{version:e.version})}):T?o.jsxs("button",{onClick:U=>{I(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):A&&!n?o.jsx("button",{onClick:U=>{B(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?g||u("card.installing"):o.jsxs(o.Fragment,{children:[u("card.buy","Buy")," ",M]})}):o.jsx("button",{onClick:U=>{I(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors disabled:opacity-50",children:u(m?"card.installing":"card.install")}),g&&o.jsx("span",{className:`text-[10px] ${g===u("card.failed")||g===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:g})]});return o.jsx("div",{ref:v,className:y?"animate-pulse":"",children:o.jsx(pr,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:nt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:T,glowing:y,onClick:j,actions:z})})}function Eh(e,t){return e.i18n?.[t]?.displayName||e.name}function Nh(e,t){return e.i18n?.[t]?.description||e.description||""}function IC(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}const poe={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 foe({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i}){const{t:l}=xt(["store"]),[c,u]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",f=t.find(A=>A.name===e.name||A.name===m||!!e.slug&&A.name===e.slug),g=!!f,h=g&&e.version&&f?.version&&IC(e.version,f.version),v=(e.priceCents??0)>0,[y,w]=k.useState(""),T=async()=>{if(!c){u(!0),w("");try{await Os(e),a(h?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),i()}catch(A){const M=A instanceof Error?A.message:"";M.includes("402")||M.includes("Purchase required")?a(l("card.purchaseRequired"),"error"):a(l("card.failed"),"error")}finally{u(!1)}}},C=async()=>{if(!c){u(!0),w("");try{await Hb(e,M=>{M==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):M==="installing"&&w(l("card.installing"))})==="installed"&&(a(`Purchased & installed ${e.name}`,"success"),i()),w("")}catch(A){a(A instanceof Error?A.message:l("card.failed"),"error"),w("")}finally{u(!1)}}};if(h)return o.jsx("button",{onClick:()=>{T()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:c?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(g)return o.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),f?.version?` (v${f.version})`:""]});if(v&&!n){const A=`$${((e.priceCents??0)/100).toFixed(2)}`;return o.jsx("span",{className:"inline-flex items-center gap-1.5",children:o.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 inline-flex items-center gap-1",children:c?y||l("card.installing"):o.jsxs(o.Fragment,{children:[l("card.buy","Buy")," ",A]})})})}return o.jsx("button",{onClick:()=>{T()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function Vk({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i,highlight:l,onHighlightDone:c,type:u="skill"}){const m=k.useRef(null),[f,g]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),g(!0);const y=setTimeout(()=>{g(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const h=e.slug&&e.author?.username?`${nt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,v=()=>{h&&window.open(h,"_blank","noopener,noreferrer")};return o.jsx("div",{ref:m,className:f?"animate-pulse":"",children:o.jsx(pr,{type:u,showTypeBadge:u!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Gu(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:nt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:v,actions:o.jsx(foe,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i})})})}function hoe({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=xt(["store","common"]),i=a.language,l=Yo(),[c,u]=k.useState("skills"),[m,f]=k.useState(null),[g,h]=k.useState(new Set),[v,y]=k.useState([]),[w,T]=k.useState(null),[C,A]=k.useState([]),[M,I]=k.useState(0),[B,K]=k.useState(1),[j,z]=k.useState([]),[U,Y]=k.useState(""),[$,D]=k.useState("score"),[W,X]=k.useState(""),[H,se]=k.useState(!1),[R,re]=k.useState([]),[ue,Ce]=k.useState(!1),[q,V]=k.useState([]),[ce,P]=k.useState(""),[Ee,$e]=k.useState(!1),[qe,Ze]=k.useState([]),[Qe,Re]=k.useState([]),[Xe,wt]=k.useState(new Set),[mt,kt]=k.useState(!1),[lt,Dt]=k.useState(""),ht=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],Oe=(F,ae="success")=>{f({text:F,type:ae}),setTimeout(()=>f(null),ae==="error"?1e4:4e3)},Nt=k.useCallback(async()=>{try{const F=await Te.skills.list();y(F.skills)}catch{}},[]),Gt=k.useCallback(async()=>{Ce(!0);try{const F=await Te.skills.builtin();re(F.skills)}catch{}Ce(!1)},[]),ie=k.useCallback(async F=>{se(!0);try{const ae=await Te.skills.registrySkillhub({q:F?.q,category:F?.category,page:F?.page??1,limit:24,sort:F?.sort??$});A(ae.skills),I(ae.total),ae.categories?.length&&z(ae.categories)}catch{}se(!1)},[$]),et=k.useCallback(async F=>{$e(!0);try{const ae=await Te.skills.registrySkillssh(F);V(ae.skills)}catch{}$e(!1)},[]),at=k.useCallback(async F=>{kt(!0);try{const ae=F?nt.search({type:"skill",q:F,limit:50}):Ps(La.hubSkills)??nt.search({type:"skill",limit:50}),we=nt.search({subtype:"connector",q:F||void 0,limit:50}).catch(()=>({items:[]})),[Le,He]=await Promise.all([ae,we,nt.isAuthenticated()?nt.purchases.mine().then(Ge=>wt(new Set(Ge.purchases.map(ct=>ct.itemId)))).catch(()=>{}):Promise.resolve()]);let de=Le?.items??[],fe=He?.items??[];if(e){const Ge=de.some(We=>We.id===e),ct=fe.some(We=>We.id===e);if(!Ge&&!ct)try{const{item:We}=await nt.getItem(e);We?.subtype==="connector"?fe=[We,...fe]:We?de=[We,...de]:t?.()}catch{t?.()}else Ge&&(de=[de.find(ut=>ut.id===e),...de.filter(ut=>ut.id!==e)]),ct&&(fe=[fe.find(ut=>ut.id===e),...fe.filter(ut=>ut.id!==e)])}Ze(de),Re(fe)}catch{}kt(!1)},[e,t]);k.useEffect(()=>{Nt(),Gt(),ie(),et()},[]),k.useEffect(()=>{c==="skills"&&at(lt)},[c,lt,at]);const ye=async F=>{h(ae=>new Set(ae).add(F.name));try{const ae=await Te.skills.install({name:F.name,source:"skillhub",slug:F.slug,sourceUrl:F.homepage,description:F.description_zh??F.description,category:"custom",version:F.version});await Nt(),Oe(`"${F.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Oe(`Download failed for "${F.name}". You can try manually from: ${F.homepage}`,"error")}h(ae=>{const we=new Set(ae);return we.delete(F.name),we})},Ne=async F=>{h(ae=>new Set(ae).add(F.name));try{const ae=await Te.skills.install({name:F.name,source:"skillssh",sourceUrl:F.url,githubRepo:`${F.author}/${F.repo}`,githubSkillPath:F.name});await Nt(),Oe(`"${F.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Oe(`Download failed for "${F.name}". You can try manually from: ${F.url}`,"error")}h(ae=>{const we=new Set(ae);return we.delete(F.name),we})},De=async F=>{h(ae=>new Set(ae).add(F.name));try{const ae=await Te.skills.install({name:F.name,source:"builtin"});await Nt(),await Gt(),Oe(`"${F.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ae){Oe(`Install failed for "${F.name}": ${ae}`,"error")}h(ae=>{const we=new Set(ae);return we.delete(F.name),we})},te=q.filter(F=>{if(!ce)return!0;const ae=ce.toLowerCase();return F.name.toLowerCase().includes(ae)||F.repo.toLowerCase().includes(ae)});if(w){const F=w,ae={};F.instructions&&(ae["SKILL.md"]=F.instructions);const we={type:"skill",name:F.name,displayName:Eh(F,i),version:F.version,description:Nh(F,i),author:F.author??"",category:F.category??"general",tags:F.tags,files:ae,skill:{skillFile:F.instructions?"SKILL.md":"",requiredPermissions:F.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},Le=F.installed&&F.installedVersion&&IC(F.version,F.installedVersion)?o.jsx("button",{onClick:()=>{De(F)},disabled:g.has(F.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:g.has(F.name)?n("card.upgrading"):n("card.upgrade",{version:F.version})}):F.installed?o.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:[o.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),F.installedVersion?` v${F.installedVersion}`:""]}):o.jsx("button",{onClick:()=>{De(F)},disabled:g.has(F.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:g.has(F.name)?n("card.installing"):n("card.install")}),He=o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),o.jsxs("div",{className:"space-y-2.5 text-sm",children:[F.category&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),o.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${poe[F.category]??"bg-gray-500/15 text-fg-secondary"}`,children:F.category})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),o.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:F.version})]}),F.hasMcpServers&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),o.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),F.hasInstructions&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),o.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(F.requiredPermissions.length>0||F.tags.length>0)&&o.jsxs("div",{className:"space-y-4",children:[F.requiredPermissions.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.requiredPermissions.map(de=>o.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:de},de))})]}),F.tags.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.tags.map(de=>o.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:de},de))})]})]})]});return o.jsxs(o.Fragment,{children:[o.jsx(qs,{type:"skill",name:F.name,onBack:()=>T(null),readOnly:!0,initialManifest:we,actionSlot:Le,contentSlot:He}),m&&o.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 o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[o.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:o.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),o.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:ht.map(F=>o.jsx("button",{onClick:()=>u(F.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===F.id?"bg-brand-600 text-on-brand":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(F.labelKey)},F.id))})]}),m&&o.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 F=lt.trim().toLowerCase(),ae=F?R.filter(He=>Eh(He,i).toLowerCase().includes(F)||Nh(He,i).toLowerCase().includes(F)):R,we=ue&&mt,Le=ae.length===0&&qe.length===0&&Qe.length===0;return o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("input",{value:lt,onChange:He=>Dt(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"}`})}),we&&Le?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((He,de)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},de))}):Le?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),o.jsx("div",{children:n("skillStore.noBuiltin")}),o.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):o.jsxs(o.Fragment,{children:[ae.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:ae.length})})]}),o.jsx(Oa,{columns:3,children:ae.map(He=>o.jsx(pr,{type:"skill",name:Eh(He,i),description:Nh(He,i),seed:He.name,icon:Gu(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:()=>T(He)},He.name))})]}),qe.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),o.jsx(Oa,{columns:3,children:qe.map(He=>o.jsx(Vk,{item:He,installedSkills:v,purchased:cm(He,Xe),onMsg:Oe,onRefresh:()=>{Nt(),at(lt)},highlight:He.id===e,onHighlightDone:t},He.id))})]}),Qe.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3",children:[o.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),o.jsx(Oa,{columns:3,children:Qe.map(He=>o.jsx(Vk,{item:He,type:"connector",installedSkills:v,purchased:cm(He,Xe),onMsg:Oe,onRefresh:()=>{Nt(),at(lt)},highlight:He.id===e,onHighlightDone:t},He.id))})]})]})]})})(),c==="skillhub"&&o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[o.jsxs("select",{value:U,onChange:F=>{Y(F.target.value),K(1),ie({q:W||void 0,category:F.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:[o.jsx("option",{value:"",children:n("skillStore.allCategories")}),j.map(F=>o.jsx("option",{value:F,children:F},F))]}),o.jsxs("select",{value:$,onChange:F=>{D(F.target.value),K(1),ie({q:W||void 0,category:U||void 0,page:1,sort:F.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:[o.jsx("option",{value:"score",children:n("skillStore.sortScore")}),o.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),o.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),o.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&o.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:o.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),o.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[o.jsx("input",{value:W,onChange:F=>X(F.target.value),onKeyDown:F=>{F.key==="Enter"&&(K(1),ie({q:W||void 0,category:U||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),o.jsx("button",{onClick:()=>{K(1),ie({q:W||void 0,category:U||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg shrink-0",children:"Search"})]}),H?o.jsx("div",{className:"text-center text-fg-tertiary py-20",children:o.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):C.length===0?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),o.jsx("div",{children:n("skillStore.noSkillhub")})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:M.toLocaleString()})}),o.jsx(Oa,{columns:3,children:C.map(F=>{const ae=v.some(we=>we.name===F.name||we.name===F.slug);return o.jsx(pr,{type:"skill",name:F.name,description:F.description_zh??F.description??"",seed:F.slug,icon:Gu(F.slug||F.name,F.tags?.[0]),version:F.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:F.tags,installed:ae,hideStats:!0,onClick:()=>window.open(F.homepage,"_blank","noopener,noreferrer"),footerLeft:o.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[F.stars>0&&o.jsxs("span",{className:"text-amber-600",children:["★ ",F.stars.toLocaleString()]}),F.downloads>0&&o.jsxs("span",{children:[F.downloads>=1e4?`${(F.downloads/1e4).toFixed(1)}万`:F.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ae?void 0:o.jsx("button",{onClick:()=>{ye(F)},disabled:g.has(F.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:g.has(F.name)?"...":n("card.install")})},F.slug)})}),M>24&&o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[o.jsx("button",{disabled:B<=1,onClick:()=>{const F=B-1;K(F),ie({q:W||void 0,category:U||void 0,page:F})},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")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:B,total:Math.ceil(M/24)})}),o.jsx("button",{disabled:B>=Math.ceil(M/24),onClick:()=>{const F=B+1;K(F),ie({q:W||void 0,category:U||void 0,page:F})},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"&&o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[o.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[o.jsx("input",{value:ce,onChange:F=>P(F.target.value),onKeyDown:F=>{F.key==="Enter"&&ce.trim()&&et(ce)},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"}`}),o.jsx("button",{onClick:()=>{ce.trim()&&et(ce)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg shrink-0",children:"Search"}),!l&&o.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:o.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ee?o.jsx("div",{className:"text-center text-fg-tertiary py-20",children:o.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):te.length===0?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),o.jsx("div",{children:n("skillStore.browseSkillssh")}),o.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):o.jsx(Oa,{columns:3,children:te.map(F=>{const ae=v.some(we=>we.name===F.name);return o.jsx(pr,{type:"skill",name:F.name,description:F.description||"",seed:`${F.author}-${F.name}`,icon:Gu(F.name),authorLabel:`${F.author}/${F.repo}`,showTypeBadge:!1,installed:ae,hideStats:!0,cornerLabel:ae?void 0:"skills.sh",onClick:()=>window.open(F.url,"_blank","noopener,noreferrer"),footerLeft:F.installs?o.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[F.installs," installs"]}):void 0,actions:ae?void 0:o.jsx("button",{onClick:()=>{Ne(F)},disabled:g.has(F.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:g.has(F.name)?"...":n("card.install")})},`${F.author}-${F.name}`)})})]})]})}const goe=["agent","team","skill","connector"];function Mh({title:e,subtitle:t,onMore:n,moreLabel:a}){return o.jsxs("div",{className:"flex items-end justify-between mb-3",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"section-title",children:e}),t&&o.jsx("p",{className:"section-subtitle",children:t})]}),n&&o.jsxs("button",{className:"section-link",onClick:n,children:[a??"View all"," →"]})]})}function boe({item:e,onOpen:t}){const n=nl(e.subtype==="connector"?"connector":e.itemType),a=jb(n,e.slug||e.name),i=Bs[n];return o.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:a},children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),o.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:o.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"})}),o.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[o.jsxs("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:["★ Featured · ",i.label]}),o.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),o.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),o.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(Hm,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:nt.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),o.jsxs("span",{children:["↓ ",Ho(e.downloadCount)]}),(e.priceCents??0)>0?o.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):o.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function Wk({items:e,onOpen:t}){return o.jsx(Oa,{columns:3,children:e.map(n=>o.jsx(pr,{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:nt.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 Yk(){return o.jsx(Oa,{columns:3,children:Array.from({length:6}).map((e,t)=>o.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function yoe({onOpenType:e}){const{t}=xt(["store","common"]),[n,a]=k.useState([]),[i,l]=k.useState(!0);k.useEffect(()=>{let h=!1;return(async()=>{l(!0);try{const v=await nt.search({limit:60,sort:"popular"});h||a(v.items??[])}catch{h||a([])}finally{h||l(!1)}})(),()=>{h=!0}},[]);const c=k.useMemo(()=>{const h=n.filter(y=>y.featured);return(h.length>0?h:n).slice(0,3)},[n]),u=k.useMemo(()=>[...n].sort((h,v)=>(v.trendingScore??v.downloadCount)-(h.trendingScore??h.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((h,v)=>(v.createdAt||"").localeCompare(h.createdAt||"")).slice(0,10),[n]),f=k.useMemo(()=>{const h=new Map;for(const v of n){const y=v.author?.username||v.author?.id;if(!y)continue;const w=h.get(y)??{author:v.author,downloads:0,count:0};w.downloads+=v.downloadCount||0,w.count+=1,h.set(y,w)}return[...h.values()].sort((v,y)=>y.downloads-v.downloads).slice(0,6)},[n]),g=h=>e(nl(h.subtype==="connector"?"connector":h.itemType),h.id);return o.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[o.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[o.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),o.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),o.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:goe.map(h=>o.jsxs("button",{onClick:()=>e(h),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Bs[h].gradient} hover:opacity-90 transition-opacity`,children:[Bs[h].labelZh,o.jsx("span",{className:"opacity-70",children:Bs[h].label})]},h))})]}),i?o.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(h=>o.jsx(boe,{item:h,onOpen:()=>g(h)},h.id))}):null,o.jsxs("section",{children:[o.jsx(Mh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),i?o.jsx(Yk,{}):u.length>0?o.jsx(Wk,{items:u,onOpen:g}):o.jsx(voe,{})]}),o.jsxs("section",{children:[o.jsx(Mh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),i?o.jsx(Yk,{}):m.length>0?o.jsx(Wk,{items:m,onOpen:g}):null]}),f.length>0&&o.jsxs("section",{children:[o.jsx(Mh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),o.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:f.map((h,v)=>o.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[o.jsxs("div",{className:"relative",children:[o.jsx(Hm,{name:h.author?.displayName,username:h.author?.username,avatarUrl:h.author?.avatarUrl,hubBase:nt.getUrl(),size:48,verified:v<3}),v<3&&o.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:v+1})]}),o.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:h.author?.displayName||h.author?.username}),o.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[h.count," 作品 · ↓ ",Ho(h.downloads)]})]},h.author?.username||v))})]})]})}function voe(){const{t:e}=xt(["store"]);return o.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[o.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),o.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),o.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Lu(e,t,n){return e.i18n?.[n]?.[t]}function xoe(){const{t:e,i18n:t}=xt(["store","common"]),n=Yo(),a=t.language,[i,l]=k.useState([]),[c,u]=k.useState({}),[m,f]=k.useState(new Set),[g,h]=k.useState(null),[v,y]=k.useState(!0),[w,T]=k.useState(""),[C,A]=k.useState("all"),[M,I]=k.useState(null),B=k.useCallback(async()=>{y(!0);try{const[z,U,Y,$]=await Promise.all([Te.builder.artifacts.list().catch(()=>({artifacts:[]})),Te.builder.artifacts.installed().catch(()=>({installed:{}})),Te.skills.updates().catch(()=>({updates:[],count:0})),Te.skills.builtin().catch(()=>({skills:[]}))]),D={};for(const H of Y.updates)D[H.name]={availableVersion:H.availableVersion,installedVersion:H.installedVersion,displayName:H.displayName,description:H.description};u(D);const W=z.artifacts.filter(H=>{const se=`${H.type}/${H.name}`;return!!U.installed[se]}),X=new Set(W.filter(H=>H.type==="skill").map(H=>H.name));for(const H of $.skills)!H.installed||X.has(H.name)||!(U.installed[`skill/${H.name}`]||D[H.name])&&!H.updateAvailable||!U.installed[`skill/${H.name}`]&&!D[H.name]||(W.push({type:"skill",name:H.name,meta:{displayName:H.i18n?.[a]?.displayName||H.name,description:H.i18n?.[a]?.description||H.description||"",version:H.installedVersion||H.version,author:H.author,category:H.category,tags:H.tags,i18n:H.i18n},path:"",updatedAt:""}),X.add(H.name));for(const[H,se]of Object.entries(D))X.has(H)||(W.push({type:"skill",name:H,meta:{displayName:se.displayName||H,description:se.description||"",version:se.installedVersion},path:"",updatedAt:""}),X.add(H));l(W)}catch{}y(!1)},[a]);k.useEffect(()=>{B()},[B]),k.useEffect(()=>{const z=()=>{B()};return window.addEventListener("markus:data-changed",z),()=>window.removeEventListener("markus:data-changed",z)},[B]),k.useEffect(()=>{if(!g)return;const z=setTimeout(()=>h(null),3e3);return()=>clearTimeout(z)},[g]);const K=async(z,U)=>{if(!m.has(z)){f(Y=>new Set(Y).add(z));try{await Te.skills.install({name:z,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}h({text:e("installedTab.updateSuccess",{name:z,version:U}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await B()}catch{h({text:e("installedTab.updateFailed",{name:z}),type:"error"})}f(Y=>{const $=new Set(Y);return $.delete(z),$})}},j=i.filter(z=>{if(C!=="all"&&z.type!==C)return!1;if(!w)return!0;const U=w.toLowerCase(),Y=(Lu(z.meta,"displayName",a)||z.meta.displayName||z.name).toLowerCase(),$=(Lu(z.meta,"description",a)||z.meta.description||"").toLowerCase();return Y.includes(U)||$.includes(U)}).sort((z,U)=>{const Y=z.type==="skill"&&c[z.name]?1:0;return(U.type==="skill"&&c[U.name]?1:0)-Y});return M?o.jsx(qs,{type:M.type,name:M.name,onBack:()=>I(null)}):o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[o.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&o.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]})]}),o.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[o.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(z=>o.jsx("button",{onClick:()=>A(z),className:`px-3 py-1 text-xs rounded-md transition-colors ${C===z?"bg-brand-600 text-on-brand":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${z==="all"?"All":z==="agent"?"Agents":z==="team"?"Teams":"Skills"}`)},z))}),o.jsx("div",{className:"flex-1 min-w-[120px]",children:o.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:z=>T(z.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"})})]}),o.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:v?o.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):j.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):o.jsx(Oa,{columns:3,children:j.map(z=>{const U=Lu(z.meta,"displayName",a)||z.meta.displayName||z.name,Y=Lu(z.meta,"description",a)||z.meta.description||"",$=z.meta.version||"",D=z.meta.author||"",W=z.meta.tags??[],X=z.meta.category||"",H=z.meta.icon,se=H&&/\.(png|jpe?g|gif|webp|svg)$/i.test(H)&&!H.startsWith("http")&&!H.startsWith("data:")&&!H.startsWith("/")?`/api/builder/artifacts/${z.type}s/${encodeURIComponent(z.name)}/${H}`:H,R=z.type==="skill"?c[z.name]:void 0;return o.jsx(pr,{type:z.type,name:U,description:Y,seed:z.name,icon:se,author:null,authorLabel:D||void 0,version:R?R.installedVersion:$,category:X,tags:W,installed:!R,hideStats:!0,cornerLabel:R?e("installedTab.updateAvailable"):void 0,onClick:()=>{z.path&&I({type:z.type,name:z.name})},actions:R?o.jsx("button",{type:"button",disabled:m.has(z.name),onClick:()=>{K(z.name,R.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(z.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:R.availableVersion})}):void 0},`${z.type}/${z.name}`)})})}),g&&o.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 ${g.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:g.text})]})}const woe=50,koe=30;function Soe(e,t,n,a){const i=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{i.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),u=k.useCallback(m=>{const f=m.changedTouches[0].clientX-i.current,g=m.changedTouches[0].clientY-l.current,h=Math.abs(f),v=Math.abs(g);if(h<woe||Math.atan2(v,h)*(180/Math.PI)>koe)return;if(a?.scrollContainerRef?.current){const T=a.scrollContainerRef.current,C=T.scrollLeft<=1,A=T.scrollLeft+T.clientWidth>=T.scrollWidth-1;if(f>0&&!C||f<0&&!A)return}const w=e.findIndex(T=>T.id===t);f<0&&w<e.length-1?n(e[w+1].id):f>0&&w>0?n(e[w-1].id):f>0&&w===0&&a?.onSwipeOutLeft?a.onSwipeOutLeft():f<0&&w===e.length-1&&a?.onSwipeOutRight&&a.onSwipeOutRight()},[e,t,n,a]);return{onTouchStart:c,onTouchEnd:u}}const Coe=["builder","discover","agents","teams","skills","installed"],Aoe={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Hg(e){return!!e&&Coe.includes(e)}function Qk(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Hg(t)?t:"builder",installId:e}}function Toe({authUser:e}){const{t}=xt(["nav","store","common"]),n=k.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[a]=k.useState(Qk),[i,l]=k.useState(a.tab),[c,u]=k.useState(a.installId),m=Soe(n,i,l);k.useEffect(()=>{const g=Qk();g.installId&&(u(g.installId),Hg(g.tab)&&l(g.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const g=h=>{const v=h.detail,y=v.params?.storeTab??localStorage.getItem("markus_nav_storeTab");Hg(y)&&l(y);const w=v.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&u(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",g),()=>window.removeEventListener("markus:navigate",g)},[]);const f=(g,h)=>{h&&u(h),l(Aoe[g]??"agents")};return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[o.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[o.jsx(V4,{className:"ml-2"}),n.map(g=>o.jsx("button",{onClick:()=>l(g.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${i===g.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:g.label},g.id))]}),o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i==="builder"&&o.jsx(jC,{authUser:e}),i==="discover"&&o.jsx(yoe,{onOpenType:f}),i==="agents"&&o.jsx(loe,{authUser:e,highlightItemId:c,onHighlightDone:()=>u(null)}),i==="teams"&&o.jsx(uoe,{highlightItemId:c,onHighlightDone:()=>u(null)}),i==="skills"&&o.jsx(hoe,{highlightItemId:c,onHighlightDone:()=>u(null)}),i==="installed"&&o.jsx(xoe,{})]})]})}const Xk="usageType",jh="profile";function Eoe({onComplete:e,theme:t,onThemeChange:n,skipProfile:a,onProfileUpdated:i}){const{t:l}=xt(["onboarding","common"]),[c,u]=k.useState(0),[m,f]=k.useState("local"),[g,h]=k.useState(""),[v,y]=k.useState(""),[w,T]=k.useState(""),[C,A]=k.useState(""),[M,I]=k.useState(!1),[B,K]=k.useState(""),[j,z]=k.useState(!1),[U,Y]=k.useState(null);k.useEffect(()=>{Te.auth.me().then(({user:Oe})=>{Oe.name&&h(Oe.name),Oe.email&&y(Oe.email),Oe.avatarUrl&&Y(Oe.avatarUrl);const Nt=Oe.name||Oe.email?.split("@")[0]||"";Nt&&X(Gt=>Gt||l("usageType.defaultOrgName",{name:Nt}))}).catch(()=>{}),Te.settings.getOrg().then(({org:Oe})=>{Oe?.name&&Oe.name!=="My Organization"&&X(Oe.name)}).catch(()=>{}),kn()&&Te.hubOrgs.invitations().then(Oe=>{Oe.invitations?.length>0&&V(Oe.invitations)}).catch(()=>{})},[]);const[$,D]=k.useState(null),[W,X]=k.useState(""),[H,se]=k.useState(!1),[R,re]=k.useState(!1),[ue,Ce]=k.useState(""),[q,V]=k.useState([]),[ce,P]=k.useState(null),[Ee,$e]=k.useState(null),qe=async()=>{const Oe=W.trim();if(Oe){se(!0),Ce("");try{if(await Te.settings.updateOrg(Oe),kn()){const Nt=await Te.hubOrgs.mine(),Gt=Nt.orgs?.find(ie=>ie.role==="owner")??Nt.orgs?.[0];Gt?.id?await Te.hubOrgs.update(Gt.id,{name:Oe}):await Te.hubOrgs.create(Oe)}re(!0)}catch{Ce(l("usageType.orgNameSaveFailed"))}finally{se(!1)}}},[Ze,Qe]=k.useState(!0),Re=async()=>{if(K(""),!g.trim()){K(l("profile.errors.nameRequired"));return}if(!v.trim()){K(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v.trim())){K(l("profile.errors.emailInvalid"));return}if(w&&w.length<6){K(l("profile.errors.passwordTooShort"));return}if(w&&w!==C){K(l("profile.errors.passwordMismatch"));return}I(!0);try{const{user:Oe}=await Te.auth.updateProfile(g.trim(),v.trim());w&&await Te.auth.changePassword("",w),i?.(Oe),z(!0)}catch{K(l("profile.errors.saveFailed"))}finally{I(!1)}},Xe=[{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")}],wt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:o.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:o.jsx($T,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:o.jsx("strong",{className:"text-fg-primary"})}})})},{id:Xk,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("button",{onClick:()=>{D("personal"),re(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${$==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:"👤"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),o.jsxs("button",{onClick:()=>{D("organization"),re(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${$==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:"🏢"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),$==="organization"&&o.jsxs("div",{className:"space-y-4 mt-4",children:[q.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),q.map(Oe=>o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:Oe.orgName}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:Oe.invitedBy})})]}),o.jsx("button",{onClick:async()=>{P(Oe.orgId);try{await Te.hubOrgs.acceptInvitation(Oe.orgId),$e(Oe.orgId),re(!0)}catch{}finally{P(null)}},disabled:ce===Oe.orgId||Ee===Oe.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand transition-colors",children:Ee===Oe.orgId?l("usageType.accepted"):ce===Oe.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},Oe.orgId)),o.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),o.jsx("input",{type:"text",value:W,onChange:Oe=>{X(Oe.target.value),re(!1),Ce("")},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"})]}),ue&&o.jsx("p",{className:"text-xs text-red-500",children:ue}),o.jsx("button",{onClick:()=>{qe()},disabled:H||!W.trim()||R,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand text-sm rounded-xl transition-colors",children:l(H?"common:saving":R?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:jh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:j?o.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[o.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),o.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[g," · ",v]})]})]}):o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"flex justify-center",children:o.jsx(G4,{currentUrl:U,name:g,size:64,targetType:"user"})}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"text",value:g,onChange:Oe=>h(Oe.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})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"email",value:v,onChange:Oe=>y(Oe.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"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),o.jsx("input",{type:"password",value:w,onChange:Oe=>T(Oe.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"})]}),w&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),o.jsx("input",{type:"password",value:C,onChange:Oe=>A(Oe.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"})]}),B&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:B}),o.jsx("button",{onClick:()=>{Re()},disabled:M||!g.trim()||!v.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand text-sm rounded-xl transition-colors",children:l(M?"common:saving":"profile.saveProfile")})]})},{id:"accessScope",title:l("settings:accessScope.title"),subtitle:l("settings:accessScope.description"),content:o.jsxs("div",{className:"space-y-3",children:[[{id:"local",label:l("settings:accessScope.localOnly"),desc:l("settings:accessScope.localOnlyHint"),host:"127.0.0.1"},{id:"lan",label:l("settings:accessScope.lan"),desc:l("settings:accessScope.lanHint"),host:"0.0.0.0"}].map(Oe=>o.jsxs("button",{onClick:()=>{f(Oe.id),fetch("/api/settings/network",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:Oe.host})}).catch(()=>{})},className:`w-full text-left p-3 rounded-lg border transition-colors ${m===Oe.id?"border-brand-500 bg-brand-500/10":"border-border-default bg-surface-elevated/30"}`,children:[o.jsx("div",{className:"text-sm text-fg-primary",children:Oe.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:Oe.desc})]},Oe.id)),o.jsx("p",{className:"text-[11px] text-fg-muted",children:l("settings:accessScope.remoteNote")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"grid grid-cols-3 gap-3",children:Xe.map(Oe=>o.jsxs("button",{onClick:()=>n(Oe.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===Oe.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:Oe.icon}),o.jsx("span",{className:"text-sm font-medium text-fg-primary",children:Oe.label}),o.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:Oe.desc})]},Oe.value))}),o.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[o.jsx("input",{type:"checkbox",checked:Ze,onChange:Oe=>Qe(Oe.target.checked),className:"accent-brand-500 shrink-0"}),o.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],mt=a?wt.filter(Oe=>Oe.id!==jh):wt,kt=mt.findIndex(Oe=>Oe.id===Xk),lt=mt.findIndex(Oe=>Oe.id===jh),Dt=()=>{c===kt&&kt>=0&&!$||c===kt&&$==="organization"&&!R||c===lt&<>=0&&!j||(c<mt.length-1?u(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ze})}).catch(()=>{}),e()))},ht=mt[c];return o.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:o.jsx("div",{className:"w-full max-w-lg",children:o.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[o.jsx("div",{className:"flex gap-1.5 mb-8",children:mt.map((Oe,Nt)=>o.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Nt<=c?"bg-brand-500":"bg-surface-elevated"}`},Nt))}),o.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:ht.title}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:ht.subtitle}),ht.content,o.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?o.jsx("button",{onClick:()=>u(c-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):o.jsx("span",{}),o.jsx("button",{onClick:Dt,disabled:lt>=0&&c===lt&&!j||kt>=0&&c===kt&&(!$||$==="organization"&&!R),className:`px-6 py-2.5 text-on-brand text-sm rounded-xl transition-colors ${lt>=0&&c===lt&&!j||kt>=0&&c===kt&&(!$||$==="organization"&&!R)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===mt.length-1?l("getStarted"):l("common:next")})]})]})})})}const Jk="markus:legal-consent",Noe="https://markus.global";function Moe({onLogin:e,hasOwner:t}){const{t:n,i18n:a}=xt("auth"),[i,l]=k.useState(null),[c,u]=k.useState(""),[m,f]=k.useState(!1),[g,h]=k.useState(""),[v,y]=k.useState(""),[w,T]=k.useState(!1),[C,A]=k.useState(!1),M=D=>{const W=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${Noe}${D}${W}`},I=()=>{try{localStorage.setItem(Jk,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},B=()=>C?(I(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),K=async()=>{const D=kn(),W=mr();if(!D||!W){u(n("login.hubUnavailable"));return}const X=await Te.auth.hubLogin(D,W);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),X.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",X.cloudAiError?n("login.cloudAiNotReady",{error:X.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(X.user,X.needsOnboarding??!1,{fromHub:!0})},j=async(D,W=!1)=>{if(!(!W&&!B())){u(""),l(D??"hub");try{if(W&&kn()&&mr()){await K();return}await Ia({method:D,force:!0}),await K()}catch(X){const H=X instanceof Error?X.message:"";if(!H.includes("cancelled")){if(!W&&kn())return j(D,!0);u(H||n("login.hubUnavailable"))}}finally{l(null)}}},z=()=>{dK(),l(null),u("")};k.useEffect(()=>{const D=window.markusDesktop;if(!D?.peekPendingDeepLinkAuth&&!D?.consumePendingDeepLinkAuth)return;let W=!1;return(async()=>{const X=D.peekPendingDeepLinkAuth?await D.peekPendingDeepLinkAuth():null;if(W||!X)return;let H=!1;try{H=!!localStorage.getItem(Jk)}catch{}if(!C&&!H){u(n("login.consentRequired"));return}H&&!C&&A(!0),I();const se=D.consumePendingDeepLinkAuth?await D.consumePendingDeepLinkAuth():X;if(!(W||!se)){u(""),l("hub");try{if(!await cK(se)||!kn()||!mr()){u(n("login.hubUnavailable"));return}await K()}catch{u(n("login.hubUnavailable"))}finally{W||l(null)}}})().catch(()=>{}),()=>{W=!0}},[C]);const U=async D=>{if(D.preventDefault(),!(!g.trim()||!v)&&B()){u(""),l("local");try{const{user:W,needsOnboarding:X}=await Te.auth.login(g.trim(),v);e(W,X??!1)}catch{u(n("login.invalidCredentials"))}finally{l(null)}}},Y=n(t?"login.welcomeBack":"login.getStarted"),$="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[o.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[o.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]"}),o.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),o.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),o.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.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"}),o.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:Y})]}),o.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?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),o.jsxs("form",{onSubmit:U,className:"space-y-3",children:[o.jsx("input",{type:"email",value:g,onChange:D=>h(D.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}),o.jsx("input",{type:"password",value:v,onChange:D=>y(D.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&&o.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&&o.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),o.jsx("button",{type:"submit",disabled:i==="local"||!g||!v,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(i==="local"?"login.signingIn":"login.signIn")})]}),o.jsx("div",{className:"text-center",children:o.jsx("button",{onClick:()=>{f(!1),u("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):o.jsxs("div",{className:"space-y-3",children:[o.jsxs("button",{onClick:()=>j("google"),disabled:!!i,className:$,children:[o.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[o.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"}),o.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"}),o.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"}),o.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),n(i==="google"?"login.connectingHub":"login.withGoogle")]}),o.jsxs("button",{onClick:()=>j("github"),disabled:!!i,className:$,children:[o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),n(i==="github"?"login.connectingHub":"login.withGithub")]}),o.jsxs("button",{onClick:()=>j("email"),disabled:!!i,className:$,children:[o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(i==="email"?"login.connectingHub":"login.withEmail")]}),i&&(i==="google"||i==="github"||i==="email"||i==="hub")&&o.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:[o.jsx("p",{children:n("login.browserOpened")}),o.jsx("button",{type:"button",onClick:z,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&o.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}),o.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),o.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),o.jsx("button",{onClick:()=>{f(!0),u("")},disabled:!!i,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),o.jsxs("label",{onAnimationEnd:()=>T(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[o.jsx("input",{type:"checkbox",checked:C,onChange:D=>{A(D.target.checked),D.target.checked&&T(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),o.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",o.jsx("a",{href:M("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",o.jsx("a",{href:M("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),o.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:[o.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),o.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function joe({token:e,onComplete:t}){const{t:n}=xt("auth"),[a,i]=k.useState(null),[l,c]=k.useState(""),[u,m]=k.useState(""),[f,g]=k.useState(""),[h,v]=k.useState(!1),[y,w]=k.useState(!1),[T,C]=k.useState(!1);k.useEffect(()=>{Te.auth.inviteInfo(e).then(M=>i(M)).catch(()=>C(!0))},[e]);const A=async M=>{if(M.preventDefault(),g(""),l.length<6){g(n("invite.passwordMinLength"));return}if(l!==u){g(n("invite.passwordsDoNotMatch"));return}v(!0);try{await Te.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{g(n("invite.error"))}finally{v(!1)}};return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),o.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),o.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),o.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:T?o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),o.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):a?o.jsxs("form",{onSubmit:A,className:"space-y-5",children:[o.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:a.name})}),o.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:a.email}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),o.jsx("input",{type:"password",value:l,onChange:M=>c(M.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})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),o.jsx("input",{type:"password",value:u,onChange:M=>m(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})]}),f&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:f}),o.jsx("button",{type:"submit",disabled:h||!l||!u,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(h?"invite.settingUp":"invite.setupAccount")})]}):o.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function Roe({onComplete:e,isFirstTime:t}){const{t:n}=xt("auth"),[a,i]=k.useState(""),[l,c]=k.useState(""),[u,m]=k.useState(""),[f,g]=k.useState(""),[h,v]=k.useState(!1),y=async w=>{if(w.preventDefault(),g(""),l.length<6){g(n("changePassword.passwordMinLength"));return}if(l!==u){g(n("changePassword.passwordsDoNotMatch"));return}v(!0);try{await Te.auth.changePassword(a,l),e()}catch{g(n("changePassword.failedToChange"))}finally{v(!1)}};return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),o.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),o.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),o.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:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&o.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),o.jsx("input",{type:"password",value:a,onChange:w=>i(w.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),o.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})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),o.jsx("input",{type:"password",value:u,onChange:w=>m(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),f&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:f}),o.jsx("button",{type:"submit",disabled:h||!l||!u,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-medium rounded-xl transition-colors",children:n(h?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}const _oe=3e4;let sc=null,rc=null;function Zle(){sc=null}async function Doe(e){if(!e?.force&&sc&&Date.now()-sc.at<_oe)return sc.data;if(rc)return rc;const t=(async()=>{const n=await fetch("/api/settings/llm",{credentials:"include"});if(!n.ok)throw new Error(`HTTP ${n.status}`);const a=await n.json();return sc={at:Date.now(),data:a},a})();rc=t;try{return await t}finally{rc===t&&(rc=null)}}function Ioe({side:e,defaultWidth:t,minWidth:n,maxWidth:a,collapsedWidth:i=0,storageKey:l}){const[c,u]=k.useState(()=>{try{const T=localStorage.getItem(`${l}_w`);if(T)return Math.max(n,Math.min(a,parseInt(T,10)))}catch{}return t}),[m,f]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),g=k.useRef(!1),h=k.useRef(n),v=k.useRef(a);h.current=n,v.current=a,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{u(T=>Math.max(n,Math.min(a,T)))},[n,a]);const y=k.useCallback(T=>{T.preventDefault(),g.current=!0;const C=T.clientX,A=c,M=B=>{if(!g.current)return;const K=B.clientX-C;u(Math.max(h.current,Math.min(v.current,A+K)))},I=()=>{g.current=!1,document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",I),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",M),document.addEventListener("mouseup",I),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>f(T=>!T),[]);return{width:m?i:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:f,setWidth:u,onResizeStart:y}}const ece=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Bg="markus-theme";function Zk(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 Loe(){try{const e=localStorage.getItem(Bg);if(e==="midnight")return localStorage.setItem(Bg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function Poe(){const[e,t]=k.useState(Loe),n=k.useCallback(a=>{t(a);try{localStorage.setItem(Bg,a)}catch{}Zk(a)},[]);return k.useEffect(()=>{Zk(e)},[e]),{mode:e,setMode:n}}let $g=!1;const qg=new Set;function tce(e){if($g!==e){$g=e;for(const t of qg)t()}}function Ooe(e){return qg.add(e),()=>{qg.delete(e)}}function zoe(){return $g}const em={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},Hoe={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},Boe=["agents","tasks","requirements","projects","deliverables","workflows"];let e4="",t4="all",n4=em,a4=!1;function $oe({onClose:e,currentPage:t}){const{t:n}=xt(["common","home","work"]);Fs(!0);const[a,i]=k.useState(e4),[l,c]=k.useState(t4),[u,m]=k.useState(n4),[f,g]=k.useState(!1),[h,v]=k.useState(a4),[y,w]=k.useState(-1);k.useEffect(()=>{e4=a},[a]),k.useEffect(()=>{t4=l},[l]),k.useEffect(()=>{n4=u},[u]),k.useEffect(()=>{a4=h},[h]);const T=k.useRef(null),C=k.useRef(void 0),A=k.useRef(null),M=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{T.current?.focus(),T.current?.select()},100)},[]);const I=k.useCallback(async X=>{if(!X.trim()){m(em),v(!1),w(-1);return}g(!0),v(!0),w(-1);const H=X.toLowerCase();try{const[se,R,re,ue,Ce,q]=await Promise.allSettled([Te.agents.list({lean:!0}),Te.tasks.list({search:X,pageSize:20}),Te.requirements.list(),Te.projects.list(),Te.deliverables.search({q:X,limit:20}),Te.teams.list()]),V=se.status==="fulfilled"?se.value.agents.filter(Ze=>Ze.name?.toLowerCase().includes(H)||Ze.role?.toLowerCase().includes(H)):[],ce=R.status==="fulfilled"?R.value.tasks:[],P=re.status==="fulfilled"?re.value.requirements.filter(Ze=>Ze.title?.toLowerCase().includes(H)||Ze.description?.toLowerCase().includes(H)):[],Ee=ue.status==="fulfilled"?ue.value.projects.filter(Ze=>Ze.name?.toLowerCase().includes(H)||Ze.description?.toLowerCase().includes(H)):[],$e=Ce.status==="fulfilled"?Ce.value.results:[],qe=[];if(q.status==="fulfilled"){const Ze=await Promise.allSettled(q.value.teams.map(Qe=>Te.workflows.list(Qe.id)));for(const Qe of Ze)if(Qe.status==="fulfilled")for(const Re of Qe.value.workflows)(Re.name.toLowerCase().includes(H)||(Re.displayName||"").toLowerCase().includes(H)||Re.description?.toLowerCase().includes(H))&&qe.push(Re)}m({agents:V,tasks:ce,requirements:P,projects:Ee,deliverables:$e,workflows:qe})}catch{m(em)}finally{g(!1)}},[]),B=X=>{i(X),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>I(X),400)},K=k.useCallback((X,H)=>{e(),yt.navigate(X,H)},[e]),j=[{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:"工作流"})}],z=k.useMemo(()=>Hoe[t||""]||Boe,[t]),U=k.useMemo(()=>{const X=[],H=l==="all"?8:void 0,se=R=>{if(l!=="all"&&l!==R)return;const re=u[R].length;if(R==="workflows"){const ue=H?u.workflows.slice(0,H):u.workflows;for(const Ce of ue)X.push({id:Ce.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const ue=u[R],Ce=H?ue.slice(0,H):ue;for(const q of Ce)switch(R){case"agents":X.push({id:q.id,type:"agent",page:me.TEAM,params:{agentId:q.id}});break;case"tasks":X.push({id:q.id,type:"task",page:me.WORK,params:{openTask:q.id}});break;case"requirements":X.push({id:q.id,type:"requirement",page:me.WORK,params:{openRequirement:q.id}});break;case"projects":X.push({id:q.id,type:"project",page:me.WORK,params:{projectId:q.id}});break;case"deliverables":X.push({id:q.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:q.id}});break}}H&&re>H&&X.push({id:`more_${R}`,type:"showMore",page:"",expandCategory:R,totalCount:re})};for(const R of z)se(R);return X},[u,l,z]),Y=k.useCallback(X=>{if(X.type==="showMore"&&X.expandCategory){c(X.expandCategory),w(-1);return}K(X.page,X.params)},[K]);k.useEffect(()=>{const X=M.current;if(!X||y<0)return;const H=X.querySelector(`[data-idx="${y}"]`);H&&H.scrollIntoView({block:"nearest"})},[y]);const $=k.useCallback(X=>{if(X.key==="Escape"){e();return}if(X.key==="Tab"){X.preventDefault();const R=j.map(Ce=>Ce.id),re=R.indexOf(l),ue=X.shiftKey?re<=0?R.length-1:re-1:re>=R.length-1?0:re+1;c(R[ue]),w(-1);return}const H=X.ctrlKey&&X.key==="n"||X.key==="ArrowDown",se=X.ctrlKey&&X.key==="p"||X.key==="ArrowUp";if(H||se){X.preventDefault(),w(R=>{const re=U.length-1;return re<0?-1:H?R>=re?0:R+1:R<=0?re:R-1});return}X.key==="Enter"&&(X.preventDefault(),y>=0&&y<U.length&&Y(U[y]))},[e,U,y,Y,j,l]);k.useEffect(()=>(document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)),[$]);const D=U.length>0;let W=0;return o.jsx("div",{ref:A,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:X=>{X.target===A.current&&e()},children:o.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:[o.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[o.jsxs("div",{className:"relative",children:[o.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:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("input",{ref:T,value:a,onChange:X=>B(X.target.value),placeholder:n("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),a&&o.jsx("button",{onClick:()=>{i(""),m(em),v(!1),w(-1),T.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:j.map(X=>o.jsx("button",{onClick:()=>{c(X.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===X.id?"bg-brand-600 text-on-brand":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:X.label},X.id))})]}),o.jsxs("div",{ref:M,className:"flex-1 overflow-y-auto px-5 py-3",children:[f&&o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!f&&h&&!D&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.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:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!f&&D&&o.jsx("div",{className:"space-y-4",children:z.map(X=>{if(l!=="all"&&l!==X)return null;const H=l==="all"?8:void 0,se=R=>{const re=W++,ue=R==="agents"?u.agents.length:R==="tasks"?u.tasks.length:R==="requirements"?u.requirements.length:R==="projects"?u.projects.length:R==="workflows"?u.workflows.length:u.deliverables.length;return o.jsxs("button",{"data-idx":re,onClick:()=>{c(R),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${re===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:"查看全部"})," (",ue,")"]})};return X==="agents"&&u.agents.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.agents.slice(0,H):u.agents).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.TEAM,{agentId:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx(Fo,{name:R.name||"Agent",avatarUrl:R.avatarUrl,size:28}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:R.name}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:R.role||R.status})]}),o.jsx(qoe,{status:R.status})]},R.id)})}),H&&u.agents.length>H&&se("agents")]},"agents"):X==="tasks"&&u.tasks.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.tasks.slice(0,H):u.tasks).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.WORK,{openTask:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx(Foe,{status:R.status}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.status," · ",R.priority||""]})]})]},R.id)})}),H&&u.tasks.length>H&&se("tasks")]},"tasks"):X==="requirements"&&u.requirements.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.requirements.slice(0,H):u.requirements).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.WORK,{openRequirement:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${R.status==="approved"?"text-green-500 bg-green-500/15":R.status==="pending"?"text-amber-500 bg-amber-500/15":R.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"}),o.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),o.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.status," · ",R.priority||""]})]})]},R.id)})}),H&&u.requirements.length>H&&se("requirements")]},"requirements"):X==="projects"&&u.projects.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.projects.slice(0,H):u.projects).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.WORK,{projectId:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:o.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"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.name}),R.description&&o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:R.description})]})]},R.id)})}),H&&u.projects.length>H&&se("projects")]},"projects"):X==="deliverables"&&u.deliverables.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.deliverables.slice(0,H):u.deliverables).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.DELIVERABLES,{openDeliverable:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.type," · ",R.status]})]})]},R.id)})}),H&&u.deliverables.length>H&&se("deliverables")]},"deliverables"):X==="workflows"&&u.workflows.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.workflows.slice(0,H):u.workflows).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.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"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.displayName||R.name}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.stepCount," steps · v",R.version]})]})]},R.name)})}),H&&u.workflows.length>H&&se("workflows")]},"workflows"):null})}),!f&&!h&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.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:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),o.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:[o.jsxs("span",{children:[o.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:"唤起/关闭"})]}),o.jsxs("span",{children:[o.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:"切换分类"})]}),o.jsxs("span",{children:[o.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:"导航"})]}),o.jsxs("span",{children:[o.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:"打开"})]}),o.jsxs("span",{children:[o.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 qoe({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function Foe({status:e}){const t=Tn[Pc(e)].chip;return o.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M9 11l3 3L22 4"}),o.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const Uoe=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function Goe(e){return e===me.TEAM?"team":e===me.WORK?"work":e===me.DELIVERABLES?"deliverables":e===me.STORE?"store":"any"}function Koe({open:e,onClose:t,page:n}){const{t:a}=xt("common"),i=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=Goe(n);return k.useEffect(()=>{if(!e)return;const c=u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),t())};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,t]),e?o.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:c=>{c.target===c.currentTarget&&t()},role:"dialog","aria-modal":"true","aria-label":a("shortcuts.title"),children:o.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:[o.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:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:a("shortcuts.title")}),o.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":a("shortcuts.close"),children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"px-4 py-3 space-y-4",children:Uoe.map(c=>{const u=TK.filter(m=>{if(m.group!==c)return!1;const f=m.page??"any";return f==="any"?!0:f===l});return u.length===0?null:o.jsxs("section",{children:[o.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:a(`shortcuts.groups.${c}`)}),o.jsx("ul",{className:"space-y-1.5",children:u.map(m=>o.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[o.jsx("span",{className:"text-fg-secondary min-w-0",children:a(m.labelKey??m.label,{defaultValue:m.label})}),o.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default text-[13px] font-medium leading-none text-fg-primary font-mono",children:Q4(m.keys,i,m.bare)})]},m.id))})]},c)})})]})}):null}function Voe({authUser:e,onClose:t,onSaved:n,onUserUpdated:a}){const{t:i}=xt("common");Fs(!0);const[l,c]=k.useState(e.name||""),[u,m]=k.useState(e.email||""),[f,g]=k.useState(!1),[h,v]=k.useState(""),[y,w]=k.useState(()=>F4(e.avatarUrl,mr()?.avatarUrl)),T=async C=>{if(C.preventDefault(),!l.trim()){v(i("profile.nameRequired"));return}if(u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u.trim())){v(i("profile.invalidEmail"));return}g(!0),v("");try{const{user:A}=await Te.auth.updateProfile(l.trim(),u.trim());n({...A,avatarUrl:y??A.avatarUrl})}catch{v(i("profile.failedToSave"))}finally{g(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:o.jsxs("form",{onSubmit:T,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:C=>C.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold mb-5",children:i("profile.editProfile")}),o.jsx("div",{className:"flex justify-center mb-5",children:o.jsx(G4,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:C=>{w(C),a?.({...e,avatarUrl:C})}})}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("profile.name")}),o.jsx("input",{value:l,onChange:C=>c(C.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("profile.email")}),o.jsx("input",{value:u,onChange:C=>m(C.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),h&&o.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:h})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:i("cancel")}),o.jsx("button",{type:"submit",disabled:f,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand rounded-lg",children:i(f?"saving":"save")})]})]})})}const LC="markus_lan_notice_acked";let r4=null;function PC(){try{const t=globalThis.localStorage;if(t&&typeof t.getItem=="function"&&typeof t.setItem=="function"&&typeof t.removeItem=="function")return t}catch{}r4??=new Map;const e=r4;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}function Woe(e){return PC().getItem(LC)===e}function Yoe(e){PC().setItem(LC,e)}function Qoe(e,t){return e&&!Woe(t)}const i4=k.lazy(()=>Ca(()=>import("./Team-zVv87kaX.js"),__vite__mapDeps([2,3,4,5,6,7,8,9,10])).then(e=>({default:e.TeamPage}))),s4=k.lazy(()=>Ca(()=>import("./Settings-BkKMrBt2.js"),__vite__mapDeps([11,6,9])).then(e=>({default:e.Settings}))),Xoe=k.lazy(()=>Ca(()=>import("./Store-dLubNc0P.js"),[]).then(e=>({default:e.StorePage}))),Joe=k.lazy(()=>Ca(()=>Promise.resolve().then(()=>eoe),void 0).then(e=>({default:e.AgentBuilder}))),o4=k.lazy(()=>Ca(()=>import("./Work-DbPgRas-.js"),__vite__mapDeps([12,13,5,6,4,3,7,1,14,15])).then(e=>({default:e.WorkPage}))),l4=k.lazy(()=>Ca(()=>import("./Deliverables-BYacAH8w.js"),__vite__mapDeps([16,3,7,8,13,5])).then(e=>({default:e.DeliverablesPage}))),Zoe=k.lazy(()=>Ca(()=>import("./Search-jBc36ZOH.js"),__vite__mapDeps([17,6])).then(e=>({default:e.SearchPage}))),ele={display:"none"};function tle(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,a=e.preferences??{};if(a.locale===t&&a.timezone===n)return;Te.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function nle({docScroll:e}={}){return o.jsx("div",{className:`flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse ${e?"min-h-[50dvh]":""}`,children:"Loading..."})}function ale({error:e,onRetry:t,docScroll:n}){const{t:a}=xt("common");return o.jsx("div",{className:`flex-1 flex items-center justify-center p-8 ${n?"min-h-[50dvh]":""}`,children:o.jsxs("div",{className:"max-w-md w-full text-center space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-fg-primary",children:a("pageErrorTitle")}),o.jsx("p",{className:"text-xs text-fg-tertiary leading-relaxed",children:a("pageErrorHint")}),o.jsx("pre",{className:"text-[11px] text-left whitespace-pre-wrap break-words bg-surface-elevated rounded-lg p-3 text-fg-secondary max-h-40 overflow-auto",children:e.message}),o.jsx("button",{type:"button",onClick:t,className:"px-3 py-1.5 text-[11px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg font-medium",children:a("pageErrorRetry")})]})})}const rle=k.memo(function({id:t,activePage:n,docScroll:a,children:i}){const l=t===n,c=k.useRef(null),u=k.useRef(l);return k.useEffect(()=>{l&&!u.current&&c.current&&c.current.dispatchEvent(new CustomEvent("markus:page-shown",{bubbles:!0})),u.current=l},[l]),o.jsx("div",{ref:c,"data-page-slot":!0,"data-page-active":l?"true":"false",className:a?"block overflow-hidden":"flex-1 overflow-hidden flex flex-col",style:l?void 0:ele,children:o.jsx(k.Suspense,{fallback:o.jsx(nle,{docScroll:a}),children:o.jsx(HV,{resetKeys:[t,l],fallback:(m,f)=>o.jsx(ale,{error:m,onRetry:f,docScroll:a}),children:i})})})},(e,t)=>{if(e.docScroll!==t.docScroll)return!1;const n=e.id===e.activePage,a=t.id===t.activePage;return n!==a?!1:a?e.children===t.children:!0}),Pu={};function OC(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?N4[e]??e:e}function c4(){return OC(Sc())}function ile(){const{t:e}=xt("common"),[t,n]=k.useState(c4),[a,i]=k.useState(!1),[l,c]=k.useState(!0),u=Yo(),m=k.useSyncExternalStore(Ooe,zoe,()=>!1),f=u&&!(t===me.TEAM&&m),g=k.useSyncExternalStore(CG,D4,AG),h=u&&t!==me.SETTINGS&&t!==me.SEARCH&&_4(g,t);k.useEffect(()=>{const Ae=document.documentElement;return Ae.classList.toggle("mobile-doc-scroll",f),()=>{Ae.classList.remove("mobile-doc-scroll")}},[f]),k.useLayoutEffect(()=>{f&&window.scrollTo(0,0)},[t,f]);const v=Poe(),y=Ioe({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[w,T]=k.useState(()=>new Set([c4()])),[C,A]=k.useState("loading"),[M,I]=k.useState(!1),[B,K]=k.useState(null),[j,z]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[U,Y]=k.useState(!1),[$,D]=k.useState(!1),[W,X]=k.useState(null),[H,se]=k.useState(!1),[R,re]=k.useState(null),[ue,Ce]=k.useState(!1),[q,V]=k.useState(null),[ce,P]=k.useState(()=>{const Ae=localStorage.getItem("markus_update_dismissed");return Ae||null}),[Ee,$e]=k.useState(!1),[qe,Ze]=k.useState(!1),Qe=pp(),Re=Qe?.leftCollapsed??!1,Xe=Qe?.toggleLeftCollapsed,wt=Qe?.setLeftCollapsed,mt=Qe?.keyboardPane??"l0",kt=Qe?.setKeyboardPane,lt=Qe?.l0FocusPageId??null,Dt=Qe?.setL0FocusPageId,ht=k.useRef(t);ht.current=t;const Oe=k.useRef(me.HOME),Nt=Qe?.toggleRightPanel,Gt=Qe?.toggleTerminalPanel,ie=Qe?.cycleRightPanelTab,et=Qe?.activateRightPanelTabAt,at=Qe?.openNewRightPanelTab,ye=Qe?.rightPanelOpen??!1,Ne=Qe?.activeRightPanelTabId??null,De=Qe?.openRightPanel,te=Qe?.closeRightPanelTab,F=Qe?.updateRightPanelBrowserTab,ae=Qe?.updateRightPanelTerminalTab,we=k.useRef(Qe?.rightPanelTabs);we.current=Qe?.rightPanelTabs,k.useEffect(()=>{const Ae=window.markusDesktop?.browser?.onPageEvent;if(!(!Ae||!De))return Ae(je=>{if(je.type==="closed"){const _e=we.current?.find(Q=>Q.payload.kind==="url"&&Q.payload.browserId===je.browserId);_e&&te&&te(_e.id);return}if(je.type==="navigated"){if(je.url&&Cc(je.url))return;je.browserId&&F&&F(je.browserId,{url:je.url,title:je.title||je.url});return}if(je.type==="opened"||je.type==="selected"){if(!je.url&&!je.browserId||je.browserId.startsWith("eb_")||gie(je.browserId)||je.url&&Cc(je.url))return;De({kind:"url",url:je.url||"about:blank",title:je.title||je.url||"Browser",browserId:je.browserId,pageId:je.pageId})}})},[De,te,F]),k.useEffect(()=>{const Ae=window.markusDesktop?.terminal?.onEvent;if(!(!Ae||!De))return Ae(je=>{if(je.type==="closed"){const _e=we.current?.find(Q=>Q.payload.kind==="terminal"&&Q.payload.terminalId===je.id);_e&&te&&te(_e.id);return}if(je.type==="cwd"){je.cwd&&ae?.(je.id,{cwd:je.cwd});return}if(je.type==="selected"){(je.title||je.cwd)&&ae?.(je.id,{title:je.title,cwd:je.cwd});return}if(je.type==="opened"){if(_b.has(je.id)){(je.title||je.cwd)&&ae?.(je.id,{title:je.title,cwd:je.cwd});return}Ds(je.id),De({kind:"terminal",terminalId:je.id,title:je.title||"Terminal",cwd:je.cwd})}})},[De,te,ae]);const Le=Qe?.handleTerminalExit;k.useEffect(()=>{const Ae=window.markusDesktop?.terminal?.onExit;if(!(!Ae||!Le))return Ae(je=>{Le(je.id)})},[Le]),k.useLayoutEffect(()=>{const Ae=t===me.TEAM&&ye&&Qe?.rightPanelMode==="browser";Nf(Ae)},[t,ye,Qe?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const He=k.useRef(!1);k.useEffect(()=>{if(!He.current){He.current=!0;return}y.setCollapsed(Re)},[Re,y.setCollapsed]),k.useEffect(()=>{if(u)return;const Ae=navigator.platform.toUpperCase().includes("MAC"),je=Q=>{Ae&&Q.metaKey&&!Q.ctrlKey&&Q.key==="p"?(Q.preventDefault(),$e(he=>!he)):!Ae&&Q.ctrlKey&&!Q.metaKey&&Q.key==="p"&&(Q.preventDefault(),$e(he=>!he))},_e=()=>$e(!0);return document.addEventListener("keydown",je),window.addEventListener("markus:open-search",_e),()=>{document.removeEventListener("keydown",je),window.removeEventListener("markus:open-search",_e)}},[u]);const de=k.useCallback(()=>!ye||!Ne||!te?!1:(te(Ne),!0),[ye,Ne,te]);k.useEffect(()=>{const Ae=window.markusDesktop?.onAppShortcut?.(je=>{if(je.type==="close-tab"){de();return}je.type==="new-tab"&&at?.()});return()=>{Ae?.()}},[de,at]),k.useEffect(()=>{if(u||!Xe||!Nt)return;const Ae=navigator.platform.toUpperCase().includes("MAC"),je=_e=>{if(!(Ae?_e.metaKey&&!_e.ctrlKey:_e.ctrlKey&&!_e.metaKey)||_e.altKey)return;if(!_e.shiftKey&&(_e.key==="/"||_e.code==="Slash")){_e.preventDefault(),Ze(Se=>!Se);return}if(_e.shiftKey&&(_e.key==="?"||_e.key==="/")){_e.preventDefault(),Ze(Se=>!Se);return}if(_e.shiftKey&&ye&&ie){if(_e.key==="]"||_e.code==="BracketRight"){_e.preventDefault(),ie(1);return}if(_e.key==="["||_e.code==="BracketLeft"){_e.preventDefault(),ie(-1);return}}if(!_e.shiftKey&&ye&&et){const Se=_e.key>="1"&&_e.key<="9"?Number(_e.key):0;if(Se>=1){_e.preventDefault(),et(Se-1);return}}if(_e.shiftKey)return;const he=_e.key.toLowerCase();if(he==="w"){_e.preventDefault(),_e.stopPropagation(),de();return}if(he==="t"){_e.preventDefault(),at?.();return}if(he==="b"){if(t===me.DELIVERABLES)return;_e.preventDefault(),Xe()}else if(t===me.TEAM&&he==="l"){if(!Ae&&s2(_e.target)||Ae&&s2(_e.target)&&_e.ctrlKey)return;_e.preventDefault(),Nt()}else t===me.TEAM&&he==="j"&&Gt&&(_e.preventDefault(),Gt())};return document.addEventListener("keydown",je,!0),()=>document.removeEventListener("keydown",je,!0)},[u,t,Xe,Nt,Gt,ie,et,ye,de,at]);const fe=k.useCallback((Ae,je)=>{let _e=kc(Ae);u&&(_e=N4[_e]??_e),_e!==me.TEAM&&Nf(!1);const Q=Sc(),he=window.location.hash.slice(1);he!==Ph(Q)?Pu[Q]=he:delete Pu[Q];const Se=ht.current;if(_e===me.SETTINGS&&Se!==me.SETTINGS&&(Oe.current=Se,yt.setSettingsReturnPage(Se),kt?.("l1"),Dt?.(me.SETTINGS)),Se===me.SETTINGS&&_e!==me.SETTINGS&&(kt?.("l0"),Dt?.(_e)),_e===me.SETTINGS&&je?.tab){const bt=`settings/${je.tab}`;Pu[_e]=bt,history.pushState(null,"","#"+bt),window.dispatchEvent(new HashChangeEvent("hashchange")),n(_e),T(Ot=>Ot.has(_e)?Ot:new Set([...Ot,_e]));return}const Ye=_e!==me.WORK?Pu[_e]:void 0;Ye&&Ye!==Ph(_e)?(history.pushState(null,"",Hs(_e)),history.pushState(null,"","#"+Ye)):history.pushState(null,"",Hs(_e)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(_e),T(bt=>bt.has(_e)?bt:new Set([...bt,_e]))},[u,kt,Dt]);k.useEffect(()=>{yt.setHandler((Ae,je)=>fe(Ae,je))},[fe]);const Ge=k.useCallback(Ae=>{const je=ht.current,_e=jG(je,NG(je),Ae);_e&&(_e.sub&&IG(_e.page,_e.sub),fe(_e.page))},[fe]);BG({enabled:u,activePage:()=>ht.current,onStep:Ge}),k.useEffect(()=>{mt==="l0"&&t!==me.SETTINGS&&Dt?.(t)},[mt,t,Dt]),k.useEffect(()=>{if(u||!kt||!Dt)return;const Ae=je=>{if(je.metaKey||je.ctrlKey||je.altKey||i2(je.target))return;const _e=je.key.length===1?je.key.toLowerCase():je.key;if(t===me.SETTINGS&&(_e==="h"||_e==="ArrowLeft")){je.preventDefault(),je.stopImmediatePropagation(),yt.leaveSettings();return}if(mt!=="l0"||t===me.SETTINGS)return;const Q=lt&&No.includes(lt)?lt:t,he=Math.max(0,No.indexOf(Q));if(_e==="j"||_e==="ArrowDown"){je.preventDefault(),je.stopImmediatePropagation();const Se=No[Math.min(No.length-1,he+1)];Dt(Se),Se!==t&&fe(Se),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Se}"]`)?.scrollIntoView({block:"nearest"})});return}if(_e==="k"||_e==="ArrowUp"){je.preventDefault(),je.stopImmediatePropagation();const Se=No[Math.max(0,he-1)];Dt(Se),Se!==t&&fe(Se),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Se}"]`)?.scrollIntoView({block:"nearest"})});return}if(_e==="l"||_e==="ArrowRight"||_e==="Enter"){const Se=lt&&No.includes(lt)?lt:t;if(!vG.has(Se)){je.preventDefault(),je.stopImmediatePropagation();return}je.preventDefault(),je.stopImmediatePropagation(),Se!==t&&fe(Se),wt?.(!1),kt("l1");return}(_e==="h"||_e==="ArrowLeft")&&(je.preventDefault(),je.stopImmediatePropagation())};return document.addEventListener("keydown",Ae,!0),()=>document.removeEventListener("keydown",Ae,!0)},[u,mt,lt,t,fe,kt,Dt,wt]),k.useEffect(()=>{const Ae=()=>I(!0);return window.addEventListener("markus:open-edit-profile",Ae),()=>window.removeEventListener("markus:open-edit-profile",Ae)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!u&&t!==me.SETTINGS&&!y.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[y.collapsed,t,u]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Ae=>{if(Ae.page){const je=kc(Ae.page);Ae.params&&Object.entries(Ae.params).forEach(([_e,Q])=>localStorage.setItem(`markus_nav_${_e}`,Q)),fe(je),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:je,params:Ae.params}}));return}Ae.openNotifications&&($G(),fe(me.HOME))})},[fe]);const ct=k.useCallback(()=>{Doe().then(Ae=>{if(Ae?.providers){const je=Object.values(Ae.providers).some(_e=>_e.configured);X(je)}}).catch(()=>{})},[]),We=k.useCallback((Ae,je)=>{if(!Ae)return;const Q=je&&{agent:"agents",team:"teams",skill:"skills"}[je]||"agents";localStorage.setItem("markus_nav_installItem",Ae),localStorage.setItem("markus_nav_storeTab",Q);const he=new URLSearchParams(window.location.search);he.get("install")||(he.set("install",Ae),je&&he.set("type",je));const Se=he.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Se}${Hs(me.STORE)}`);const Ye=()=>yt.navigate(me.STORE,{storeTab:Q,installItem:Ae});Ye(),setTimeout(Ye,500),setTimeout(Ye,1500)},[]);k.useEffect(()=>{const Ae=()=>A(null);return window.addEventListener($h,Ae),()=>window.removeEventListener($h,Ae)},[]),k.useEffect(()=>{const Ae=new URLSearchParams(window.location.search),je=Ae.get("install");je&&We(je,Ae.get("type"));const _e=window.markusDesktop;_e?.onDeepLinkInstall?.(({id:Se,type:Ye})=>We(Se,Ye)),_e?.consumePendingDeepLinkInstall?.().then(Se=>{Se?.id&&We(Se.id,Se.type)}),Te.auth.me().then(({user:Se})=>{e2(),A(Se),K(!0),i(!1),Se.preferences?.guideHidden===!0&&!Qh(Se.id)&&Xh(Se.id),tle(Se),_s.connect(Se.id),ct(),Te.health().then(bt=>{bt.updateAvailable&&bt.latestVersion&&V({latestVersion:bt.latestVersion,currentVersion:bt.version});const Ot=bt.bindHost??"0.0.0.0";Qoe(bt.lanExposed===!0,Ot)&&re({host:Ot})}).catch(()=>{});const Ye=()=>{As(La.builderArtifacts,()=>Te.builder.artifacts.list()),As(La.builderAgents,()=>Te.agents.list()),As(La.builderHubMyItems,()=>nt.myItems()),As(La.builderInstalled,()=>Te.builder.artifacts.installed()),As(La.hubAgents,()=>nt.search({type:"agent",limit:50})),As(La.hubTeams,()=>nt.search({type:"team",limit:50})),As(La.hubSkills,()=>nt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Ye,{timeout:5e3}):setTimeout(Ye,3e3)}).catch(()=>{A(null),Te.auth.status().then(({initialized:Se,hasOwner:Ye,hasMultipleUsers:bt})=>{K(Se),z({hasOwner:Ye,hasMultipleUsers:bt})}).catch(()=>K(!0))}),_s.connect();const Q=_s.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),he=()=>{const Se=OC(Sc());Se!==me.TEAM&&Nf(!1),n(Se),T(Ye=>Ye.has(Se)?Ye:new Set([...Ye,Se]))};return window.addEventListener("hashchange",he),window.addEventListener("popstate",he),()=>{Q(),_s.disconnect(),window.removeEventListener("hashchange",he),window.removeEventListener("popstate",he)}},[]),k.useEffect(()=>{const Ae=C!=="loading"&&C!==null?C.id:void 0;if(!Ae)return;const je=navigator.platform.toUpperCase().includes("MAC"),_e=Q=>{if(i2(Q.target))return;const he={key:Q.key,code:Q.code,metaKey:Q.metaKey,ctrlKey:Q.ctrlKey,altKey:Q.altKey,shiftKey:Q.shiftKey};CK(he,Ae,je)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",_e,!0),()=>window.removeEventListener("keydown",_e,!0)},[C]);const ut=C!=="loading"&&C!==null?C:void 0,Ft=k.useMemo(()=>u?{[me.HOME]:o.jsx(M2,{authUser:ut}),[me.TEAM]:o.jsx(i4,{authUser:ut}),[me.BUILDER]:o.jsx(Toe,{authUser:ut}),[me.SETTINGS]:o.jsx(s4,{theme:v.mode,onThemeChange:v.setMode,authUser:ut,onLogout:()=>{Te.auth.logout().catch(()=>{}),Ls(),A(null)},onUserUpdated:Ae=>A(Ae)}),[me.WORK]:o.jsx(o4,{authUser:ut}),[me.DELIVERABLES]:o.jsx(l4,{authUser:ut}),[me.SEARCH]:o.jsx(Zoe,{})}:{[me.HOME]:o.jsx(M2,{authUser:ut}),[me.TEAM]:o.jsx(i4,{authUser:ut}),[me.SETTINGS]:o.jsx(s4,{theme:v.mode,onThemeChange:v.setMode,authUser:ut,onLogout:()=>{Te.auth.logout().catch(()=>{}),Ls(),A(null)},onUserUpdated:Ae=>A(Ae)}),[me.STORE]:o.jsx(Xoe,{authUser:ut}),[me.BUILDER]:o.jsx(Joe,{authUser:ut}),[me.WORK]:o.jsx(o4,{authUser:ut}),[me.DELIVERABLES]:o.jsx(l4,{authUser:ut})},[ut?.id,ut?.role,v.mode,u]);if(C==="loading"||C===null&&B===null)return o.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:o.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Pt=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Pt?o.jsx(joe,{token:Pt[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),i(!0),Y(!0),A("loading"),Te.auth.me().then(Ae=>{C2(Ae.user.id),A(Ae.user)}).catch(()=>A(null))}}):C===null?o.jsx(Moe,{hasOwner:j.hasOwner,hasMultipleUsers:j.hasMultipleUsers,onLogin:(Ae,je,_e)=>{e2(),A(Ae),_s.connect(Ae.id),je?(C2(Ae.id),i(!0),_e?.fromHub&&Y(!0)):(i(!1),Qh(Ae.id)?(Xh(Ae.id),Te.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),A({...Ae,preferences:{...Ae.preferences,guideHidden:!0}})):A(Ae))}}):$?o.jsx(Roe,{onComplete:()=>D(!1),isFirstTime:!0}):a?o.jsx(Eoe,{theme:v.mode,onThemeChange:v.setMode,skipProfile:U,onProfileUpdated:Ae=>{const je={id:Ae.id,name:Ae.name,email:Ae.email,role:Ae.role,orgId:Ae.orgId??"default",avatarUrl:Ae.avatarUrl};A(je)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),i(!1),Y(!1),Te.auth.me().then(Ae=>A(Ae.user)).catch(()=>{}),ct(),fe(me.HOME)}}):o.jsxs("div",{className:`flex ${f?"min-h-dvh":"h-dvh overflow-x-hidden"} bg-surface-primary text-fg-primary ${u?"flex-col":""}`,children:[!u&&t!==me.SETTINGS&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative z-40 shrink-0",style:{width:y.width},children:o.jsx(QV,{currentPage:t,onNavigate:Ae=>{fe(Ae),c(!1),kt?.("l0"),Dt?.(Ae)},authUser:C,collapsed:y.collapsed,onToggleCollapse:y.toggle,onLogout:()=>{Te.auth.logout().catch(()=>{}),Ls(),A(null)},keyboardFocusPageId:lt,keyboardPaneActive:mt==="l0"})}),o.jsx("div",{className:`${y.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:y.collapsed?void 0:y.onResizeStart,children:!y.collapsed&&o.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"})})]}),o.jsxs("div",{className:`flex-1 ${f?"":"overflow-hidden"} flex flex-col min-w-0 ${h?"pb-14":""}`,children:[W===!1&&!H&&t!==me.SETTINGS&&o.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:[o.jsx("span",{className:u?"text-xs":"",children:e("llmBanner.message")}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.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")}),o.jsx("button",{onClick:()=>se(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),q&&ce!==q.latestVersion&&o.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:[o.jsx("span",{className:u?"text-xs":"",children:e("update.available",{latest:q.latestVersion,current:q.currentVersion})}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[o.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")}),o.jsx("button",{onClick:()=>{P(q.latestVersion),localStorage.setItem("markus_update_dismissed",q.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),R&&!ue&&t!==me.SETTINGS&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-emerald-500/10 border-b border-emerald-500/25 text-emerald-600 dark:text-emerald-400 text-sm shrink-0",children:[o.jsx("span",{className:u?"text-xs":"",children:e("lanNotice.message",{host:R.host})}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[o.jsx("button",{onClick:()=>{window.location.hash="#settings/network"},className:"text-xs font-medium text-emerald-600 dark:text-emerald-400 hover:text-emerald-500 transition-colors",children:e("lanNotice.goToSettings")}),o.jsx("button",{onClick:()=>{Yoe(R.host),Ce(!0)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),o.jsx("main",{className:`flex-1 ${f?"":"overflow-hidden"} flex flex-col relative`,children:Object.keys(Ft).map(Ae=>w.has(Ae)?o.jsx(rle,{id:Ae,activePage:t,docScroll:f,children:Ft[Ae]},Ae):null)})]}),h&&o.jsx(uW,{currentPage:t,onNavigate:fe}),u&&o.jsx(wK,{authUser:ut,onNavigate:fe,onLogout:()=>{Te.auth.logout().catch(()=>{}),Ls(),A(null)}}),!u&&Ee&&o.jsx($oe,{onClose:()=>$e(!1),currentPage:t}),!u&&o.jsx(Koe,{open:qe,onClose:()=>Ze(!1),page:t}),o.jsx(sse,{}),M&&ut&&o.jsx(Voe,{authUser:ut,onClose:()=>I(!1),onUserUpdated:Ae=>A(Ae),onSaved:Ae=>{I(!1),A(Ae)}})]})}const d4="data-anim-paused",sle="data-anim-tick",u4=8,ole=250,zC=["animate-pulse","animate-spin","animate-bounce","activity-text-shimmer","exec-card-active"];zC.map(e=>`.${e}`).join(", ");function lle(){return document.visibilityState!=="visible"||document.hidden}let vc=null,oc=0;function cle(){vc===null&&(oc=oc%u4,m4(),vc=window.setInterval(()=>{oc=(oc+1)%u4,m4()},ole))}function m4(){const e=String(oc);for(const t of zC){const n=document.getElementsByClassName(t);for(let a=0;a<n.length;a++)n[a].setAttribute(sle,e)}}function dle(){vc!==null&&(window.clearInterval(vc),vc=null)}function Rh(){const e=document.documentElement;lle()?(e.setAttribute(d4,"true"),dle()):(e.removeAttribute(d4),cle())}let p4=!1;function ule(){p4||typeof document>"u"||(p4=!0,Rh(),document.addEventListener("visibilitychange",Rh,{passive:!0}),window.addEventListener("pageshow",Rh,{passive:!0}))}ule();YA.createRoot(document.getElementById("root")).render(o.jsx(k.StrictMode,{children:o.jsx(kie,{children:o.jsx(ile,{})})}));export{Ia as $,Fo as A,zre as B,SJ as C,Ure as D,HV as E,Hle as F,zle as G,$le as H,xoe as I,qle as J,Ble as K,Xre as L,vJ as M,TC as N,Qle as O,me as P,Ioe as Q,Qx as R,yoe as S,loe as T,_s as U,kn as V,kc as W,V4 as X,Oie as Y,Hie as Z,Ca as _,Yo as a,jle as a$,mle as a0,Ic as a1,c5 as a2,Lc as a3,vr as a4,Ele as a5,Cle as a6,L4 as a7,mr as a8,xle as a9,Kle as aA,Gle as aB,hle as aC,gle as aD,Ds as aE,Nu as aF,Ob as aG,die as aH,fC as aI,Or as aJ,Iu as aK,qk as aL,Jle as aM,mm as aN,Ile as aO,Wh as aP,oie as aQ,Ak as aR,Dle as aS,Mle as aT,Nle as aU,vle as aV,Zle as aW,tce as aX,sW as aY,Lle as aZ,rK as a_,Tle as aa,eK as ab,Ale as ac,Zx as ad,wle as ae,XG as af,Sle as ag,kle as ah,noe as ai,aoe as aj,Uo as ak,Doe as al,ece as am,fle as an,DC as ao,toe as ap,Fs as aq,$T as ar,uie as as,Ng as at,wG as au,Fle as av,Vle as aw,Ule as ax,Wle as ay,Yle as az,hK as b,G4 as b0,Q4 as b1,QK as b2,_le as b3,s2 as b4,$m as b5,FT as b6,ple as b7,ble as b8,yle as b9,Hs as ba,Rle as bb,cV as bc,e5 as bd,P4 as be,nV as bf,Ole as bg,pp as c,Soe as d,uoe as e,hoe as f,Os as g,nt as h,i2 as i,o as j,Te as k,Tn as l,Sk as m,yt as n,Lse as o,Fre as p,aae as q,k as r,_re as s,Pc as t,xt as u,jee as v,Sne as w,Tne as x,Xle as y,iC as z};
|
|
867
|
+
${t("share.rejectedEncourage")}`})},className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 hover:bg-red-500/10 transition-colors inline-flex items-center gap-1 cursor-pointer",title:t("share.rejectedTip"),children:[o.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:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),o.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}),o.jsxs("button",{onClick:()=>{lt(ie,{visibility:De?.visibility??"public"})},disabled:!!Ne,className:"text-xs px-3 py-1.5 rounded-lg border border-brand-500/40 text-brand-400 hover:bg-brand-500/10 hover:border-brand-500/60 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[o.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:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),t(Ne==="share"?"common:sharing":"share.resubmit")]})]}):F?o.jsxs(o.Fragment,{children:[ae&&o.jsxs("button",{onClick:()=>{const We=De?.visibility??"public";lt(ie,{visibility:We})},disabled:!!Ne,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:[o.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:[o.jsx("polyline",{points:"23 4 23 10 17 10"}),o.jsx("polyline",{points:"1 20 1 14 7 14"}),o.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"})]}),Ne==="share"?t("common:sharing"):t("share.updateVersion",{version:te})]}),o.jsxs("a",{href:we()??"#",target:"_blank",rel:"noopener noreferrer",onClick:We=>{const ut=we();Uo()&&ut&&(We.preventDefault(),Or(ut))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${De?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":De?.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:[De?.visibility==="org"?o.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:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):De?.visibility==="unlisted"?o.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:[o.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"}),o.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"})]}):o.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:[o.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),De?.visibility==="org"?t("visibility.sharedOrg"):De?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),o.jsxs("button",{onClick:()=>Y({key:ye,name:et}),disabled:!!Ne,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:[o.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:[o.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),o.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):o.jsxs("button",{onClick:async()=>{await nt.ensureAuth(),Array.isArray(ie.meta.screenshots)&&ie.meta.screenshots.length>0?re(ie):X(ie)},disabled:!!Ne,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:[o.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:[o.jsx("circle",{cx:"18",cy:"5",r:"3"}),o.jsx("circle",{cx:"6",cy:"12",r:"3"}),o.jsx("circle",{cx:"18",cy:"19",r:"3"}),o.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),o.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(Ne==="share"?"common:sharing":"common:share")]})]}),de=o.jsx("button",{onClick:()=>A(ie),disabled:!!Ne,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:o.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:[o.jsx("polyline",{points:"3 6 5 6 21 6"}),o.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),fe=ie.meta.icon,ct=!!fe&&/\.(png|jpe?g|gif|webp|svg)$/i.test(fe)?fe.startsWith("http")||fe.startsWith("/")?fe:`/api/builder/artifacts/${ie.type}s/${encodeURIComponent(ie.name)}/images/${encodeURIComponent(fe.split("/").pop()??"")}?v=${ie.updatedAt??""}`:fe;return o.jsx(pr,{type:ie.type,name:et,description:at,seed:ye,icon:ct,version:te,footerLeft:o.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[o.jsx("button",{onClick:We=>{We.stopPropagation(),Te.system.openPath(ie.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ie.path,children:Wse(ie.path)}),o.jsx("span",{className:"shrink-0",children:"·"}),o.jsx("span",{className:"shrink-0",children:new Date(ie.updatedAt).toLocaleDateString()})]}),headerAction:de,actions:He,onClick:()=>Gt(ie)},ye)})})),M&&o.jsx(vr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:M.meta.displayName||M.meta.name||M.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ie=M;I(null),mt(ie)},onCancel:()=>I(null)}),B&&o.jsx(vr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:B.meta.displayName||B.meta.name||B.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ie=B;K(null),kt(ie)},onCancel:()=>K(null)}),C&&o.jsx(vr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:C.meta.displayName||C.meta.name||C.name}),confirmLabel:t("common:delete"),onConfirm:ht,onCancel:()=>A(null)}),U&&o.jsx(vr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:U.name}),confirmLabel:t("unshare"),onConfirm:()=>{Dt()},onCancel:()=>Y(null)}),$&&o.jsx(vr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>D(null),onCancel:()=>D(null)}),W&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>X(null),children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),o.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:()=>{const ie=W;X(null),re(ie)},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")}),o.jsx("button",{onClick:()=>{const ie=W;X(null),Gt(ie)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:t("share.addImagesFirst")})]})]})}),H&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>se(null),children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:o.jsx(Zse,{isUpdate:j.has(`${H.type}/${H.name}`),onCancel:()=>se(null),onConfirm:(ie,et)=>{const at=H;se(null),lt(at,{priceCents:et>0?et:void 0})}})})}),R&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>re(null),children:o.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ie=>ie.stopPropagation(),children:o.jsx(Jse,{onCancel:()=>re(null),onConfirm:(ie,et,at,ye)=>{const Ne=R;re(null),lt(Ne,{visibility:ie,orgId:et,priceCents:at,donationsEnabled:ye})}})})})]})})}function Jse({onCancel:e,onConfirm:t}){const{t:n}=xt(["builder","common"]),[a,i]=k.useState("public"),[l,c]=k.useState([]),[u,m]=k.useState(""),[f,g]=k.useState(!1),[h,v]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{a==="org"&&l.length===0&&(g(!0),nt.myOrgs().then(A=>{c(A.memberships),A.memberships.length>0&&m(A.memberships[0].id)}).catch(()=>{}).finally(()=>g(!1)))},[a,l.length]);const T=a==="public"||a==="unlisted",C=[{value:"public",icon:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),o.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:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 21h18"}),o.jsx("path",{d:"M9 8h1"}),o.jsx("path",{d:"M9 12h1"}),o.jsx("path",{d:"M9 16h1"}),o.jsx("path",{d:"M14 8h1"}),o.jsx("path",{d:"M14 12h1"}),o.jsx("path",{d:"M14 16h1"}),o.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:o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.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"}),o.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 o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),o.jsx("div",{className:"space-y-2 mb-5",children:C.map(A=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${a===A.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"visibility",checked:a===A.value,onChange:()=>i(A.value),className:"accent-brand-500"}),o.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:A.icon}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:A.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:A.desc})]})]},A.value))}),a==="org"&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),f?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?o.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):o.jsx("select",{value:u,onChange:A=>m(A.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(A=>o.jsx("option",{value:A.id,children:A.name},A.id))})]}),T&&o.jsxs("div",{className:"mb-5",children:[o.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),o.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:RC.map(A=>o.jsx("button",{type:"button",onClick:()=>v(A.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${h===A.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:A.label},A.cents))}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:y,onChange:A=>w(A.target.checked),className:"accent-brand-500"}),o.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),T&&o.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),o.jsxs("div",{className:"flex gap-3",children:[o.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")}),o.jsx("button",{onClick:()=>t(a,a==="org"?u:void 0,T&&h>0?h:void 0,T?y:void 0),disabled:a==="org"&&!u,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const RC=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Zse({isUpdate:e,onCancel:t,onConfirm:n}){const{t:a}=xt(["builder","common"]),[i,l]=k.useState(0);return o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:a(e?"shareMode.titleUpdate":"shareMode.title")}),o.jsx("div",{className:"space-y-2 mb-5",children:RC.map(c=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[o.jsx("input",{type:"radio",name:"sharePrice",checked:i===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?a("shareMode.freeDesc"):a("shareMode.paidDesc")})]})]},c.cents))}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:a("common:cancel")}),o.jsx("button",{onClick:()=>n(i>0?"paid":"free",i),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:a(e?"shareMode.update":"shareMode.share")})]})]})}const eoe=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:jC},Symbol.toStringTag,{value:"Module"}));function toe(e,t="读取失败"){return e instanceof Error&&e.message?e.message:(typeof e=="string"?e:"")||t}function Iu(){return{state:"loading",items:[],error:null}}function noe(e){return{state:"ok",items:e,error:null}}function aoe(e,t=[]){return{state:"error",items:t,error:toe(e)}}async function qk(e,t={}){try{return noe(await e())}catch(n){return aoe(n,t.keep??[])}}function Jle(e){const t=e.state==="loading",n=e.state==="error";return{loading:t,error:n,rows:e.items,empty:!t&&!n&&e.items.length===0}}function roe(e){const t=[];let n=!1,a=!1;for(const l of e)l.state==="loading"?n=!0:l.state==="error"?t.push(l.label):a=!0;return{state:n?"loading":t.length>0?"error":"ok",loading:n,failures:t,anyOk:a}}async function ioe(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(a=>a.id===t);if(n)return{items:[n,...e.filter(a=>a.id!==t)],highlighted:n,missing:!1};try{const{item:a}=await nt.getItem(t);return a?{items:[a,...e],highlighted:a,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function _C(e){const{catalogType:t,search:n,highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c}=e,[u,m]=k.useState(Iu()),[f,g]=k.useState(Iu()),[h,v]=k.useState(0),y=k.useRef({highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c});y.current={highlightItemId:a,onHighlightDone:i,loadTemplates:l,takeHubPrefetch:c},k.useEffect(()=>{let C=!1;return m(Iu()),g(Iu()),(async()=>{const A=(async()=>{const K=await qk(async()=>{const z=n?null:await y.current.takeHubPrefetch?.()??null;return z||((await nt.search({type:t,q:n,limit:50})).items??[])});if(K.state!=="ok")return K;const j=await ioe([...K.items],y.current.highlightItemId??null);return j.missing&&y.current.onHighlightDone?.(),{state:"ok",items:j.items,error:null}})(),M=qk(()=>y.current.loadTemplates(n)),[I,B]=await Promise.all([A,M]);C||(m(I),g(B))})(),()=>{C=!0}},[t,n,h]);const w=k.useCallback(()=>v(C=>C+1),[]),T=roe([{label:"Hub 资产",state:u.state},{label:"本地模板",state:f.state}]);return{hub:u,templates:f,sources:T,reload:w}}function DC({subject:e,error:t,notEquals:n,onRetry:a,retryLabel:i="重试",hint:l,variant:c="bar"}){const u=o.jsxs("span",{className:c==="inline"?"text-[11px] text-rose-500":"text-xs text-rose-500",children:[e,"读取失败:",t,"(这不等于「",n,"」)"]}),m=a?o.jsx("button",{type:"button",onClick:a,className:"text-xs text-brand-500 hover:text-brand-400 shrink-0 cursor-pointer",children:i}):l?o.jsx("span",{className:"text-xs text-fg-tertiary shrink-0",children:l}):null;return c==="inline"?o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",role:"alert",children:[u,m]}):o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-rose-500/30 bg-rose-500/10 shrink-0",role:"alert",children:[u,m]})}function soe(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Bm(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Fk(e,t){return e.i18n?.[t]?.description||e.description}const ooe={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function loe({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:a,i18n:i}=xt(["store","common"]),l=i.language,[c,u]=k.useState(""),m=_C({catalogType:"agent",search:c,highlightItemId:t,onHighlightDone:n,loadTemplates:k.useCallback(async W=>{const X=new URLSearchParams;W&&X.set("q",W);const H=await fetch("/api/templates?"+X.toString(),{credentials:"include"});if(!H.ok)throw new Error(`HTTP ${H.status}`);const se=await H.json();return Array.isArray(se.templates)?se.templates:[]},[]),takeHubPrefetch:async()=>(await Ps(La.hubAgents))?.items??null}),f=m.templates.items,g=m.hub.items,h=m.sources.loading,[v,y]=k.useState(null),[w,T]=k.useState({}),[C,A]=k.useState(!1),[M,I]=k.useState(new Map),[B,K]=k.useState(new Set),[j,z]=k.useState(null),[U,Y]=k.useState(null),$=k.useCallback(async()=>{try{const[W,X]=await Promise.all([Te.builder.artifacts.list().catch(()=>({artifacts:[]})),Te.builder.artifacts.installed().catch(()=>({installed:{}}))]),H=new Map;for(const se of W.artifacts){if(se.type!=="agent")continue;const R=!!X.installed[`agent/${se.name}`];H.set(se.name,{installed:R,localVersion:se.meta.version||void 0,localUpdatedAt:se.updatedAt})}I(H)}catch{}},[]);k.useEffect(()=>{$(),nt.isAuthenticated()&&nt.purchases.mine().then(W=>K(new Set(W.purchases.map(X=>X.itemId)))).catch(()=>{})},[$]),k.useEffect(()=>{if(!v){T({});return}fetch(`/api/templates/${encodeURIComponent(v.id)}/files`,{credentials:"include"}).then(W=>W.json()).then(W=>T(W.files??{})).catch(()=>T({}))},[v]);const D=async(W,X,H)=>{try{const se=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:W,name:X,orgId:"default",teamId:H})});if(!se.ok)throw new Error(`Failed: ${se.status}`);A(!1),y(null)}catch(se){Y({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${se}`,variant:"danger"})}};if(j)return o.jsx(qs,{type:j.type,name:j.name,onBack:()=>z(null)});if(v){const W={type:"agent",name:v.id,displayName:Bm(v,l),version:v.version,description:Fk(v,l),author:v.author,category:v.category,tags:v.tags,icon:v.icon,files:w,agent:{roleName:v.roleId,agentRole:v.agentRole==="manager"?"manager":"worker"},dependencies:{skills:v.skills}},X=o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.roleConfig")}),o.jsxs("div",{className:"space-y-2.5 text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.role")}),o.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:v.roleId})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.position")}),o.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${ooe[v.agentRole]??""}`,children:v.agentRole})]})]})]}),o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.skills")}),o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[v.skills.map(H=>o.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:H},H)),v.skills.length===0&&o.jsx("span",{className:"text-xs text-fg-tertiary italic",children:a("agentStore.noSkills")})]})]})]}),v.starterTasks&&v.starterTasks.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.starterTasks")}),o.jsx("div",{className:"space-y-2",children:v.starterTasks.map((H,se)=>o.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${H.priority==="high"?"bg-red-400":H.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-fg-primary",children:H.title}),H.description&&o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:H.description})]})]},se))})]})]});return o.jsxs(o.Fragment,{children:[o.jsx(qs,{type:"agent",name:v.id,onBack:()=>y(null),readOnly:!0,initialManifest:W,actionSlot:o.jsx("button",{onClick:()=>A(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors font-medium",children:a("agentStore.hireAgent")}),contentSlot:X}),C&&o.jsx(Uk,{template:v,lang:l,onClose:()=>A(!1),onHire:D}),U&&o.jsx(vr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[o.jsx("h2",{className:"text-lg font-semibold",children:a("agentStore.title")}),o.jsx("input",{type:"text",placeholder:a("agentStore.searchPlaceholder"),value:c,onChange:W=>u(W.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"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:[m.sources.failures.length>0&&o.jsx(DC,{subject:m.sources.failures.join("、"),error:m.hub.error??m.templates.error??"读取失败",notEquals:"这里没有任何模板或 Hub 资产",onRetry:m.reload}),h?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((W,X)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},X))}):m.sources.failures.length===0&&f.length===0&&g.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?a("agentStore.noResults",{search:c}):a("agentStore.noAgents")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:a(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):o.jsxs(o.Fragment,{children:[f.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:a("agentStore.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:a("agentStore.available",{count:f.length})})]}),o.jsx(Oa,{columns:3,children:f.map(W=>o.jsx(pr,{type:"agent",name:Bm(W,l),description:Fk(W,l),seed:W.id,icon:W.icon,version:W.version,category:W.category,tags:W.tags,authorLabel:W.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(W)},W.id))})]}),g.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:a("agentStore.markusHub")}),o.jsx(Oa,{columns:3,children:g.map(W=>o.jsx(coe,{item:W,localInfo:M.get(Fc(W)),purchased:cm(W,B),onStatusChange:$,highlight:W.id===t,onHighlightDone:n,onViewDetail:X=>z({type:"agent",name:X})},W.id))})]})]})]}),C&&v&&o.jsx(Uk,{template:v,lang:l,onClose:()=>A(!1),onHire:D}),U&&o.jsx(vr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Fc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return mm(n||e.name,"hub-pkg")}function Os(e){return(async()=>{const t=await nt.download(e.id),n=t.name||e.name,a=t.config??{},i=Fc(e,a),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},u=(t.version||e.version||(typeof a.version=="string"?a.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Te.builder.artifacts.import(l,i,t.files,c,u);else{const m={...a,...u?{version:u}:{},name:i,displayName:a.displayName||n,description:e.description,source:c};await Te.builder.artifacts.save(l,m)}return await Te.builder.artifacts.install(l,i),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Hb(e,t){t("checking"),await nt.ensureAuth();const n=await nt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Os(e),"installed";try{if((await nt.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await nt.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Os(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const a=Uo();let i=null;return a?Or(n.checkoutUrl):i=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const u=Date.now(),m=300*1e3,f=setInterval(async()=>{if(Date.now()-u>m){clearInterval(f),l("cancelled");return}const h=!a&&i?i.closed:!1;try{if((await nt.purchases.checkout(e.id)).alreadyOwned){clearInterval(f),t("installing");try{await Os(e),l("installed")}catch(y){c(y)}return}}catch{}if(h){clearInterval(f);try{if((await nt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Os(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function coe({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:u}=xt(["store"]),[m,f]=k.useState(!1),[g,h]=k.useState(""),v=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(i&&v.current){v.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const U=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(U)}},[i,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&soe(e.version,t.localVersion),A=(e.priceCents??0)>0,M=async U=>{if(U.stopPropagation(),!m){f(!0),h("");try{await Os(e),h(C?u("card.upgraded"):u("card.installed")+"!"),a()}catch(Y){const $=Y instanceof Error?Y.message:"";$.includes("402")||$.includes("Purchase required")?h(u("card.purchaseRequired")):h(u("card.failed"))}finally{f(!1)}}},I=async U=>{if(U.stopPropagation(),!m){f(!0),h("");try{await Hb(e,$=>{$==="checkout_opened"?h(u("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&h(u("card.installing"))})==="installed"?(h(u("card.installed")+"!"),a()):h("")}catch(Y){h(Y instanceof Error?Y.message:u("card.failed"))}finally{f(!1)}}},B=A?`$${((e.priceCents??0)/100).toFixed(2)}`:null,K=e.slug&&e.author?.username?`${nt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,j=()=>{T&&c?c(Fc(e)):K&&window.open(K,"_blank","noopener,noreferrer")},z=o.jsxs(o.Fragment,{children:[C?o.jsx("button",{onClick:U=>{M(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?u("card.upgrading"):u("card.upgrade",{version:e.version})}):T?o.jsxs("button",{onClick:U=>{M(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):A&&!n?o.jsx("button",{onClick:U=>{I(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?g||u("card.installing"):o.jsxs(o.Fragment,{children:[u("card.buy","Buy")," ",B]})}):o.jsx("button",{onClick:U=>{M(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors disabled:opacity-50",children:u(m?"card.installing":"card.install")}),g&&!(A&&!n)&&o.jsx("span",{className:`text-[10px] ${g===u("card.failed")||g===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:g})]});return o.jsx("div",{ref:v,className:y?"animate-pulse":"",children:o.jsx(pr,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:nt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:T,glowing:y,onClick:j,actions:z})})}function Uk({template:e,lang:t,onClose:n,onHire:a}){const{t:i}=xt(["store"]),[l,c]=k.useState(`${Bm(e,t)} Agent`),[u,m]=k.useState(""),[f,g]=k.useState([]),[h,v]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>g(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){v(!0);try{await a(e.id,l.trim(),u||void 0)}finally{v(!1)}}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:o.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[o.jsx("div",{className:"flex items-center gap-3 mb-5",children:o.jsxs("div",{children:[o.jsx("h3",{className:"text-base font-semibold",children:i("hireModal.title")}),o.jsx("p",{className:"text-xs text-fg-tertiary",children:i("hireModal.creating",{name:Bm(e,t)})})]})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:i("hireModal.agentName")}),o.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"input-field",autoFocus:!0})]}),f.length>0&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:i("hireModal.assignTeam")}),o.jsxs("select",{value:u,onChange:w=>m(w.target.value),className:"input-field",children:[o.jsx("option",{value:"",children:i("hireModal.noTeam")}),f.map(w=>o.jsx("option",{value:w.id,children:w.name},w.id))]})]}),o.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:i("hireModal.agentConfig")}),o.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.role")}),o.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.position")}),o.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),o.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.skills")}),o.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||i("hireModal.none")})]})]})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[o.jsx("button",{onClick:n,className:"btn-secondary",children:i("hireModal.cancel")}),o.jsx("button",{onClick:y,disabled:!l.trim()||h,className:"btn-primary",children:i(h?"hireModal.creating_progress":"hireModal.create")})]})]})})}function Th(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function Gk(e,t){return e.i18n?.[t]?.description||e.description}function Kk(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function doe(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function uoe({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=xt(["store","common"]),i=a.language,[l,c]=k.useState(""),u=_C({catalogType:"team",search:l,highlightItemId:e,onHighlightDone:t,loadTemplates:k.useCallback(D=>Te.teamTemplates.list(D||void 0).then(W=>W.templates??[]),[]),takeHubPrefetch:async()=>(await Ps(La.hubTeams))?.items??null}),m=u.templates.items,f=u.hub.items,g=u.sources.loading,[h,v]=k.useState(null),[y,w]=k.useState({}),[T,C]=k.useState(!1),[A,M]=k.useState(null),[I,B]=k.useState(new Map),[K,j]=k.useState(new Set),[z,U]=k.useState(null),Y=k.useCallback(async()=>{try{const[D,W]=await Promise.all([Te.builder.artifacts.list().catch(()=>({artifacts:[]})),Te.builder.artifacts.installed().catch(()=>({installed:{}}))]),X=new Map;for(const H of D.artifacts){if(H.type!=="team")continue;const se=!!W.installed[`team/${H.name}`];X.set(H.name,{installed:se,localVersion:H.meta.version||void 0,localUpdatedAt:H.updatedAt})}B(X)}catch{}},[]);k.useEffect(()=>{Y(),nt.isAuthenticated()&&nt.purchases.mine().then(D=>j(new Set(D.purchases.map(W=>W.itemId)))).catch(()=>{})},[Y]),k.useEffect(()=>{if(!h){w({});return}fetch(`/api/team-templates/${encodeURIComponent(h.id)}/files`,{credentials:"include"}).then(D=>D.json()).then(D=>w(D.files??{})).catch(()=>w({}))},[h]);const $=async D=>{C(!0),M(null);try{const X=(await Te.teams.create(D.name,D.description)).team.id;let H,se=0;const R=[];for(const ue of D.members){const Ce=ue.count??1;for(let q=0;q<Ce;q++){const V=ue.name??`${D.name} Agent ${q+1}`,ce=Ce>1?`${V} ${q+1}`:V,P=ue.roleName??ue.templateId;try{const Ee=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:ce,...P?{roleName:P}:{},orgId:"default",teamId:X,agentRole:ue.role??"worker",skills:ue.skills??[]})});if(Ee.ok){se++;const $e=await Ee.json();ue.role==="manager"&&!H&&(H=$e.agent?.id)}else{const $e=await Ee.json().catch(()=>({error:`HTTP ${Ee.status}`}));R.push(`${ce}: ${$e.error??Ee.statusText}`)}}catch(Ee){R.push(`${ce}: ${String(Ee)}`)}}}H&&await Te.teams.update(X,{managerId:H,managerType:"agent"}).catch(()=>{});const re=R.length>0?` (${R.length} failed: ${R[0]})`:"";M({ok:se>0,message:`Team "${Th(D,i)}" deployed with ${se} agent(s)${re}`})}catch(W){M({ok:!1,message:`Failed: ${W}`})}finally{C(!1)}};if(z)return o.jsx(qs,{type:z.type,name:z.name,onBack:()=>U(null)});if(h){const D={...y};h.announcements&&(D["ANNOUNCEMENT.md"]=h.announcements),h.norms&&(D["NORMS.md"]=h.norms);const W={type:"team",name:h.id,displayName:Th(h,i),version:h.version,description:Gk(h,i),author:h.author,category:h.category??"general",tags:h.tags??[],files:D,team:{members:h.members.map(H=>({name:Kk(h,H.name??H.roleName??H.templateId??"Agent",i),role:H.role??"worker",roleName:H.roleName??H.templateId,count:H.count??1,skills:H.skills??[]}))}},X=o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[o.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),o.jsx("div",{className:"p-5 space-y-2",children:h.members.map((H,se)=>{const R=Kk(h,H.name??H.roleName??H.templateId??"Agent",i);return o.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[o.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${H.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:(R[0]??"?").toUpperCase()}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm text-fg-primary font-medium",children:R}),o.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${H.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:H.role??"worker"}),(H.count??1)>1&&o.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",H.count]})]}),(H.roleName||H.templateId)&&o.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:H.roleName??H.templateId})]}),H.skills&&H.skills.length>0&&o.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[H.skills.slice(0,3).map(re=>o.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:re},re)),H.skills.length>3&&o.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",H.skills.length-3]})]})]},se)})})]});return o.jsx(o.Fragment,{children:o.jsx(qs,{type:"team",name:h.id,onBack:()=>{v(null),M(null)},readOnly:!0,initialManifest:W,contentSlot:X,actionSlot:o.jsxs(o.Fragment,{children:[A&&o.jsx("span",{className:`text-xs ${A.ok?"text-green-500":"text-red-500"}`,children:A.message}),o.jsx("button",{onClick:()=>{$(h)},disabled:T,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors font-medium disabled:opacity-50",children:n(T?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[o.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),o.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:D=>c(D.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"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:[u.sources.failures.length>0&&o.jsx(DC,{subject:u.sources.failures.join("、"),error:u.hub.error??u.templates.error??"读取失败",notEquals:"这里没有任何团队模板或 Hub 资产",onRetry:u.reload}),g?o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((D,W)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},W))}):u.sources.failures.length===0&&m.length===0&&f.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):o.jsxs(o.Fragment,{children:[m.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:m.length})})]}),o.jsx(Oa,{columns:2,children:m.map(D=>o.jsx(pr,{type:"team",name:Th(D,i),description:Gk(D,i),seed:D.id,icon:D.icon||"users",version:D.version,category:D.category,tags:D.tags,authorLabel:D.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>v(D)},D.id))})]}),f.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),o.jsx(Oa,{columns:2,children:f.map(D=>o.jsx(moe,{item:D,localInfo:I.get(Fc(D)),purchased:cm(D,K),onStatusChange:Y,highlight:D.id===e,onHighlightDone:t,onViewDetail:W=>U({type:"team",name:W})},D.id))})]})]})]})]})}function moe({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:u}=xt(["store"]),[m,f]=k.useState(!1),[g,h]=k.useState(""),v=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(i&&v.current){v.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const U=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(U)}},[i,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&doe(e.version,t.localVersion),A=(e.priceCents??0)>0,M=A?`$${((e.priceCents??0)/100).toFixed(2)}`:null,I=async U=>{if(U.stopPropagation(),!m){f(!0),h("");try{await Os(e),h(C?u("card.upgraded"):u("card.installed")+"!"),a()}catch(Y){const $=Y instanceof Error?Y.message:"";$.includes("402")||$.includes("Purchase required")?h(u("card.purchaseRequired")):h(u("card.failed"))}finally{f(!1)}}},B=async U=>{if(U.stopPropagation(),!m){f(!0),h("");try{await Hb(e,$=>{$==="checkout_opened"?h(u("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&h(u("card.installing"))})==="installed"?(h(u("card.installed")+"!"),a()):h("")}catch(Y){h(Y instanceof Error?Y.message:u("card.failed"))}finally{f(!1)}}},K=e.slug&&e.author?.username?`${nt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,j=()=>{T&&c?c(Fc(e)):K&&window.open(K,"_blank","noopener,noreferrer")},z=o.jsxs(o.Fragment,{children:[C?o.jsx("button",{onClick:U=>{I(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?u("card.upgrading"):u("card.upgrade",{version:e.version})}):T?o.jsxs("button",{onClick:U=>{I(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[u("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):A&&!n?o.jsx("button",{onClick:U=>{B(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?g||u("card.installing"):o.jsxs(o.Fragment,{children:[u("card.buy","Buy")," ",M]})}):o.jsx("button",{onClick:U=>{I(U)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors disabled:opacity-50",children:u(m?"card.installing":"card.install")}),g&&o.jsx("span",{className:`text-[10px] ${g===u("card.failed")||g===u("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:g})]});return o.jsx("div",{ref:v,className:y?"animate-pulse":"",children:o.jsx(pr,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:nt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:T,glowing:y,onClick:j,actions:z})})}function Eh(e,t){return e.i18n?.[t]?.displayName||e.name}function Nh(e,t){return e.i18n?.[t]?.description||e.description||""}function IC(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,a.length);i++){const l=n[i]??0,c=a[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}const poe={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 foe({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i}){const{t:l}=xt(["store"]),[c,u]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",f=t.find(A=>A.name===e.name||A.name===m||!!e.slug&&A.name===e.slug),g=!!f,h=g&&e.version&&f?.version&&IC(e.version,f.version),v=(e.priceCents??0)>0,[y,w]=k.useState(""),T=async()=>{if(!c){u(!0),w("");try{await Os(e),a(h?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),i()}catch(A){const M=A instanceof Error?A.message:"";M.includes("402")||M.includes("Purchase required")?a(l("card.purchaseRequired"),"error"):a(l("card.failed"),"error")}finally{u(!1)}}},C=async()=>{if(!c){u(!0),w("");try{await Hb(e,M=>{M==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):M==="installing"&&w(l("card.installing"))})==="installed"&&(a(`Purchased & installed ${e.name}`,"success"),i()),w("")}catch(A){a(A instanceof Error?A.message:l("card.failed"),"error"),w("")}finally{u(!1)}}};if(h)return o.jsx("button",{onClick:()=>{T()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:c?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(g)return o.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),f?.version?` (v${f.version})`:""]});if(v&&!n){const A=`$${((e.priceCents??0)/100).toFixed(2)}`;return o.jsx("span",{className:"inline-flex items-center gap-1.5",children:o.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 inline-flex items-center gap-1",children:c?y||l("card.installing"):o.jsxs(o.Fragment,{children:[l("card.buy","Buy")," ",A]})})})}return o.jsx("button",{onClick:()=>{T()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function Vk({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i,highlight:l,onHighlightDone:c,type:u="skill"}){const m=k.useRef(null),[f,g]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),g(!0);const y=setTimeout(()=>{g(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const h=e.slug&&e.author?.username?`${nt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,v=()=>{h&&window.open(h,"_blank","noopener,noreferrer")};return o.jsx("div",{ref:m,className:f?"animate-pulse":"",children:o.jsx(pr,{type:u,showTypeBadge:u!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Gu(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:nt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:v,actions:o.jsx(foe,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:i})})})}function hoe({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=xt(["store","common"]),i=a.language,l=Yo(),[c,u]=k.useState("skills"),[m,f]=k.useState(null),[g,h]=k.useState(new Set),[v,y]=k.useState([]),[w,T]=k.useState(null),[C,A]=k.useState([]),[M,I]=k.useState(0),[B,K]=k.useState(1),[j,z]=k.useState([]),[U,Y]=k.useState(""),[$,D]=k.useState("score"),[W,X]=k.useState(""),[H,se]=k.useState(!1),[R,re]=k.useState([]),[ue,Ce]=k.useState(!1),[q,V]=k.useState([]),[ce,P]=k.useState(""),[Ee,$e]=k.useState(!1),[qe,Ze]=k.useState([]),[Qe,Re]=k.useState([]),[Xe,wt]=k.useState(new Set),[mt,kt]=k.useState(!1),[lt,Dt]=k.useState(""),ht=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],Oe=(F,ae="success")=>{f({text:F,type:ae}),setTimeout(()=>f(null),ae==="error"?1e4:4e3)},Nt=k.useCallback(async()=>{try{const F=await Te.skills.list();y(F.skills)}catch{}},[]),Gt=k.useCallback(async()=>{Ce(!0);try{const F=await Te.skills.builtin();re(F.skills)}catch{}Ce(!1)},[]),ie=k.useCallback(async F=>{se(!0);try{const ae=await Te.skills.registrySkillhub({q:F?.q,category:F?.category,page:F?.page??1,limit:24,sort:F?.sort??$});A(ae.skills),I(ae.total),ae.categories?.length&&z(ae.categories)}catch{}se(!1)},[$]),et=k.useCallback(async F=>{$e(!0);try{const ae=await Te.skills.registrySkillssh(F);V(ae.skills)}catch{}$e(!1)},[]),at=k.useCallback(async F=>{kt(!0);try{const ae=F?nt.search({type:"skill",q:F,limit:50}):Ps(La.hubSkills)??nt.search({type:"skill",limit:50}),we=nt.search({subtype:"connector",q:F||void 0,limit:50}).catch(()=>({items:[]})),[Le,He]=await Promise.all([ae,we,nt.isAuthenticated()?nt.purchases.mine().then(Ge=>wt(new Set(Ge.purchases.map(ct=>ct.itemId)))).catch(()=>{}):Promise.resolve()]);let de=Le?.items??[],fe=He?.items??[];if(e){const Ge=de.some(We=>We.id===e),ct=fe.some(We=>We.id===e);if(!Ge&&!ct)try{const{item:We}=await nt.getItem(e);We?.subtype==="connector"?fe=[We,...fe]:We?de=[We,...de]:t?.()}catch{t?.()}else Ge&&(de=[de.find(ut=>ut.id===e),...de.filter(ut=>ut.id!==e)]),ct&&(fe=[fe.find(ut=>ut.id===e),...fe.filter(ut=>ut.id!==e)])}Ze(de),Re(fe)}catch{}kt(!1)},[e,t]);k.useEffect(()=>{Nt(),Gt(),ie(),et()},[]),k.useEffect(()=>{c==="skills"&&at(lt)},[c,lt,at]);const ye=async F=>{h(ae=>new Set(ae).add(F.name));try{const ae=await Te.skills.install({name:F.name,source:"skillhub",slug:F.slug,sourceUrl:F.homepage,description:F.description_zh??F.description,category:"custom",version:F.version});await Nt(),Oe(`"${F.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Oe(`Download failed for "${F.name}". You can try manually from: ${F.homepage}`,"error")}h(ae=>{const we=new Set(ae);return we.delete(F.name),we})},Ne=async F=>{h(ae=>new Set(ae).add(F.name));try{const ae=await Te.skills.install({name:F.name,source:"skillssh",sourceUrl:F.url,githubRepo:`${F.author}/${F.repo}`,githubSkillPath:F.name});await Nt(),Oe(`"${F.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Oe(`Download failed for "${F.name}". You can try manually from: ${F.url}`,"error")}h(ae=>{const we=new Set(ae);return we.delete(F.name),we})},De=async F=>{h(ae=>new Set(ae).add(F.name));try{const ae=await Te.skills.install({name:F.name,source:"builtin"});await Nt(),await Gt(),Oe(`"${F.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ae){Oe(`Install failed for "${F.name}": ${ae}`,"error")}h(ae=>{const we=new Set(ae);return we.delete(F.name),we})},te=q.filter(F=>{if(!ce)return!0;const ae=ce.toLowerCase();return F.name.toLowerCase().includes(ae)||F.repo.toLowerCase().includes(ae)});if(w){const F=w,ae={};F.instructions&&(ae["SKILL.md"]=F.instructions);const we={type:"skill",name:F.name,displayName:Eh(F,i),version:F.version,description:Nh(F,i),author:F.author??"",category:F.category??"general",tags:F.tags,files:ae,skill:{skillFile:F.instructions?"SKILL.md":"",requiredPermissions:F.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},Le=F.installed&&F.installedVersion&&IC(F.version,F.installedVersion)?o.jsx("button",{onClick:()=>{De(F)},disabled:g.has(F.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:g.has(F.name)?n("card.upgrading"):n("card.upgrade",{version:F.version})}):F.installed?o.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:[o.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),F.installedVersion?` v${F.installedVersion}`:""]}):o.jsx("button",{onClick:()=>{De(F)},disabled:g.has(F.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:g.has(F.name)?n("card.installing"):n("card.install")}),He=o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),o.jsxs("div",{className:"space-y-2.5 text-sm",children:[F.category&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),o.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${poe[F.category]??"bg-gray-500/15 text-fg-secondary"}`,children:F.category})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),o.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:F.version})]}),F.hasMcpServers&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),o.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),F.hasInstructions&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),o.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(F.requiredPermissions.length>0||F.tags.length>0)&&o.jsxs("div",{className:"space-y-4",children:[F.requiredPermissions.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.requiredPermissions.map(de=>o.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:de},de))})]}),F.tags.length>0&&o.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[o.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.tags.map(de=>o.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:de},de))})]})]})]});return o.jsxs(o.Fragment,{children:[o.jsx(qs,{type:"skill",name:F.name,onBack:()=>T(null),readOnly:!0,initialManifest:we,actionSlot:Le,contentSlot:He}),m&&o.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 o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[o.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:o.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),o.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:ht.map(F=>o.jsx("button",{onClick:()=>u(F.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===F.id?"bg-brand-600 text-on-brand":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(F.labelKey)},F.id))})]}),m&&o.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 F=lt.trim().toLowerCase(),ae=F?R.filter(He=>Eh(He,i).toLowerCase().includes(F)||Nh(He,i).toLowerCase().includes(F)):R,we=ue&&mt,Le=ae.length===0&&qe.length===0&&Qe.length===0;return o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("input",{value:lt,onChange:He=>Dt(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"}`})}),we&&Le?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((He,de)=>o.jsx("div",{className:"h-56 rounded-2xl skeleton"},de))}):Le?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),o.jsx("div",{children:n("skillStore.noBuiltin")}),o.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):o.jsxs(o.Fragment,{children:[ae.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:ae.length})})]}),o.jsx(Oa,{columns:3,children:ae.map(He=>o.jsx(pr,{type:"skill",name:Eh(He,i),description:Nh(He,i),seed:He.name,icon:Gu(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:()=>T(He)},He.name))})]}),qe.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),o.jsx(Oa,{columns:3,children:qe.map(He=>o.jsx(Vk,{item:He,installedSkills:v,purchased:cm(He,Xe),onMsg:Oe,onRefresh:()=>{Nt(),at(lt)},highlight:He.id===e,onHighlightDone:t},He.id))})]}),Qe.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3",children:[o.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),o.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),o.jsx(Oa,{columns:3,children:Qe.map(He=>o.jsx(Vk,{item:He,type:"connector",installedSkills:v,purchased:cm(He,Xe),onMsg:Oe,onRefresh:()=>{Nt(),at(lt)},highlight:He.id===e,onHighlightDone:t},He.id))})]})]})]})})(),c==="skillhub"&&o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[o.jsxs("select",{value:U,onChange:F=>{Y(F.target.value),K(1),ie({q:W||void 0,category:F.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:[o.jsx("option",{value:"",children:n("skillStore.allCategories")}),j.map(F=>o.jsx("option",{value:F,children:F},F))]}),o.jsxs("select",{value:$,onChange:F=>{D(F.target.value),K(1),ie({q:W||void 0,category:U||void 0,page:1,sort:F.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:[o.jsx("option",{value:"score",children:n("skillStore.sortScore")}),o.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),o.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),o.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&o.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:o.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),o.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[o.jsx("input",{value:W,onChange:F=>X(F.target.value),onKeyDown:F=>{F.key==="Enter"&&(K(1),ie({q:W||void 0,category:U||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),o.jsx("button",{onClick:()=>{K(1),ie({q:W||void 0,category:U||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg shrink-0",children:"Search"})]}),H?o.jsx("div",{className:"text-center text-fg-tertiary py-20",children:o.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):C.length===0?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),o.jsx("div",{children:n("skillStore.noSkillhub")})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:M.toLocaleString()})}),o.jsx(Oa,{columns:3,children:C.map(F=>{const ae=v.some(we=>we.name===F.name||we.name===F.slug);return o.jsx(pr,{type:"skill",name:F.name,description:F.description_zh??F.description??"",seed:F.slug,icon:Gu(F.slug||F.name,F.tags?.[0]),version:F.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:F.tags,installed:ae,hideStats:!0,onClick:()=>window.open(F.homepage,"_blank","noopener,noreferrer"),footerLeft:o.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[F.stars>0&&o.jsxs("span",{className:"text-amber-600",children:["★ ",F.stars.toLocaleString()]}),F.downloads>0&&o.jsxs("span",{children:[F.downloads>=1e4?`${(F.downloads/1e4).toFixed(1)}万`:F.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ae?void 0:o.jsx("button",{onClick:()=>{ye(F)},disabled:g.has(F.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:g.has(F.name)?"...":n("card.install")})},F.slug)})}),M>24&&o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[o.jsx("button",{disabled:B<=1,onClick:()=>{const F=B-1;K(F),ie({q:W||void 0,category:U||void 0,page:F})},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")}),o.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:B,total:Math.ceil(M/24)})}),o.jsx("button",{disabled:B>=Math.ceil(M/24),onClick:()=>{const F=B+1;K(F),ie({q:W||void 0,category:U||void 0,page:F})},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"&&o.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[o.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[o.jsx("input",{value:ce,onChange:F=>P(F.target.value),onKeyDown:F=>{F.key==="Enter"&&ce.trim()&&et(ce)},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"}`}),o.jsx("button",{onClick:()=>{ce.trim()&&et(ce)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-on-brand text-xs rounded-lg shrink-0",children:"Search"}),!l&&o.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:o.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ee?o.jsx("div",{className:"text-center text-fg-tertiary py-20",children:o.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):te.length===0?o.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[o.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),o.jsx("div",{children:n("skillStore.browseSkillssh")}),o.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):o.jsx(Oa,{columns:3,children:te.map(F=>{const ae=v.some(we=>we.name===F.name);return o.jsx(pr,{type:"skill",name:F.name,description:F.description||"",seed:`${F.author}-${F.name}`,icon:Gu(F.name),authorLabel:`${F.author}/${F.repo}`,showTypeBadge:!1,installed:ae,hideStats:!0,cornerLabel:ae?void 0:"skills.sh",onClick:()=>window.open(F.url,"_blank","noopener,noreferrer"),footerLeft:F.installs?o.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[F.installs," installs"]}):void 0,actions:ae?void 0:o.jsx("button",{onClick:()=>{Ne(F)},disabled:g.has(F.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg disabled:opacity-50",children:g.has(F.name)?"...":n("card.install")})},`${F.author}-${F.name}`)})})]})]})}const goe=["agent","team","skill","connector"];function Mh({title:e,subtitle:t,onMore:n,moreLabel:a}){return o.jsxs("div",{className:"flex items-end justify-between mb-3",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"section-title",children:e}),t&&o.jsx("p",{className:"section-subtitle",children:t})]}),n&&o.jsxs("button",{className:"section-link",onClick:n,children:[a??"View all"," →"]})]})}function boe({item:e,onOpen:t}){const n=nl(e.subtype==="connector"?"connector":e.itemType),a=jb(n,e.slug||e.name),i=Bs[n];return o.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:a},children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),o.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:o.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"})}),o.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[o.jsxs("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:["★ Featured · ",i.label]}),o.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),o.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),o.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(Hm,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:nt.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),o.jsxs("span",{children:["↓ ",Ho(e.downloadCount)]}),(e.priceCents??0)>0?o.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):o.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function Wk({items:e,onOpen:t}){return o.jsx(Oa,{columns:3,children:e.map(n=>o.jsx(pr,{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:nt.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 Yk(){return o.jsx(Oa,{columns:3,children:Array.from({length:6}).map((e,t)=>o.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function yoe({onOpenType:e}){const{t}=xt(["store","common"]),[n,a]=k.useState([]),[i,l]=k.useState(!0);k.useEffect(()=>{let h=!1;return(async()=>{l(!0);try{const v=await nt.search({limit:60,sort:"popular"});h||a(v.items??[])}catch{h||a([])}finally{h||l(!1)}})(),()=>{h=!0}},[]);const c=k.useMemo(()=>{const h=n.filter(y=>y.featured);return(h.length>0?h:n).slice(0,3)},[n]),u=k.useMemo(()=>[...n].sort((h,v)=>(v.trendingScore??v.downloadCount)-(h.trendingScore??h.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((h,v)=>(v.createdAt||"").localeCompare(h.createdAt||"")).slice(0,10),[n]),f=k.useMemo(()=>{const h=new Map;for(const v of n){const y=v.author?.username||v.author?.id;if(!y)continue;const w=h.get(y)??{author:v.author,downloads:0,count:0};w.downloads+=v.downloadCount||0,w.count+=1,h.set(y,w)}return[...h.values()].sort((v,y)=>y.downloads-v.downloads).slice(0,6)},[n]),g=h=>e(nl(h.subtype==="connector"?"connector":h.itemType),h.id);return o.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[o.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[o.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),o.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),o.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:goe.map(h=>o.jsxs("button",{onClick:()=>e(h),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Bs[h].gradient} hover:opacity-90 transition-opacity`,children:[Bs[h].labelZh,o.jsx("span",{className:"opacity-70",children:Bs[h].label})]},h))})]}),i?o.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(h=>o.jsx(boe,{item:h,onOpen:()=>g(h)},h.id))}):null,o.jsxs("section",{children:[o.jsx(Mh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),i?o.jsx(Yk,{}):u.length>0?o.jsx(Wk,{items:u,onOpen:g}):o.jsx(voe,{})]}),o.jsxs("section",{children:[o.jsx(Mh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),i?o.jsx(Yk,{}):m.length>0?o.jsx(Wk,{items:m,onOpen:g}):null]}),f.length>0&&o.jsxs("section",{children:[o.jsx(Mh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),o.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:f.map((h,v)=>o.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[o.jsxs("div",{className:"relative",children:[o.jsx(Hm,{name:h.author?.displayName,username:h.author?.username,avatarUrl:h.author?.avatarUrl,hubBase:nt.getUrl(),size:48,verified:v<3}),v<3&&o.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:v+1})]}),o.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:h.author?.displayName||h.author?.username}),o.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[h.count," 作品 · ↓ ",Ho(h.downloads)]})]},h.author?.username||v))})]})]})}function voe(){const{t:e}=xt(["store"]);return o.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[o.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),o.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),o.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Lu(e,t,n){return e.i18n?.[n]?.[t]}function xoe(){const{t:e,i18n:t}=xt(["store","common"]),n=Yo(),a=t.language,[i,l]=k.useState([]),[c,u]=k.useState({}),[m,f]=k.useState(new Set),[g,h]=k.useState(null),[v,y]=k.useState(!0),[w,T]=k.useState(""),[C,A]=k.useState("all"),[M,I]=k.useState(null),B=k.useCallback(async()=>{y(!0);try{const[z,U,Y,$]=await Promise.all([Te.builder.artifacts.list().catch(()=>({artifacts:[]})),Te.builder.artifacts.installed().catch(()=>({installed:{}})),Te.skills.updates().catch(()=>({updates:[],count:0})),Te.skills.builtin().catch(()=>({skills:[]}))]),D={};for(const H of Y.updates)D[H.name]={availableVersion:H.availableVersion,installedVersion:H.installedVersion,displayName:H.displayName,description:H.description};u(D);const W=z.artifacts.filter(H=>{const se=`${H.type}/${H.name}`;return!!U.installed[se]}),X=new Set(W.filter(H=>H.type==="skill").map(H=>H.name));for(const H of $.skills)!H.installed||X.has(H.name)||!(U.installed[`skill/${H.name}`]||D[H.name])&&!H.updateAvailable||!U.installed[`skill/${H.name}`]&&!D[H.name]||(W.push({type:"skill",name:H.name,meta:{displayName:H.i18n?.[a]?.displayName||H.name,description:H.i18n?.[a]?.description||H.description||"",version:H.installedVersion||H.version,author:H.author,category:H.category,tags:H.tags,i18n:H.i18n},path:"",updatedAt:""}),X.add(H.name));for(const[H,se]of Object.entries(D))X.has(H)||(W.push({type:"skill",name:H,meta:{displayName:se.displayName||H,description:se.description||"",version:se.installedVersion},path:"",updatedAt:""}),X.add(H));l(W)}catch{}y(!1)},[a]);k.useEffect(()=>{B()},[B]),k.useEffect(()=>{const z=()=>{B()};return window.addEventListener("markus:data-changed",z),()=>window.removeEventListener("markus:data-changed",z)},[B]),k.useEffect(()=>{if(!g)return;const z=setTimeout(()=>h(null),3e3);return()=>clearTimeout(z)},[g]);const K=async(z,U)=>{if(!m.has(z)){f(Y=>new Set(Y).add(z));try{await Te.skills.install({name:z,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}h({text:e("installedTab.updateSuccess",{name:z,version:U}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await B()}catch{h({text:e("installedTab.updateFailed",{name:z}),type:"error"})}f(Y=>{const $=new Set(Y);return $.delete(z),$})}},j=i.filter(z=>{if(C!=="all"&&z.type!==C)return!1;if(!w)return!0;const U=w.toLowerCase(),Y=(Lu(z.meta,"displayName",a)||z.meta.displayName||z.name).toLowerCase(),$=(Lu(z.meta,"description",a)||z.meta.description||"").toLowerCase();return Y.includes(U)||$.includes(U)}).sort((z,U)=>{const Y=z.type==="skill"&&c[z.name]?1:0;return(U.type==="skill"&&c[U.name]?1:0)-Y});return M?o.jsx(qs,{type:M.type,name:M.name,onBack:()=>I(null)}):o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[o.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&o.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]})]}),o.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[o.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(z=>o.jsx("button",{onClick:()=>A(z),className:`px-3 py-1 text-xs rounded-md transition-colors ${C===z?"bg-brand-600 text-on-brand":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${z==="all"?"All":z==="agent"?"Agents":z==="team"?"Teams":"Skills"}`)},z))}),o.jsx("div",{className:"flex-1 min-w-[120px]",children:o.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:z=>T(z.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"})})]}),o.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:v?o.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):j.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),o.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),o.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):o.jsx(Oa,{columns:3,children:j.map(z=>{const U=Lu(z.meta,"displayName",a)||z.meta.displayName||z.name,Y=Lu(z.meta,"description",a)||z.meta.description||"",$=z.meta.version||"",D=z.meta.author||"",W=z.meta.tags??[],X=z.meta.category||"",H=z.meta.icon,se=H&&/\.(png|jpe?g|gif|webp|svg)$/i.test(H)&&!H.startsWith("http")&&!H.startsWith("data:")&&!H.startsWith("/")?`/api/builder/artifacts/${z.type}s/${encodeURIComponent(z.name)}/${H}`:H,R=z.type==="skill"?c[z.name]:void 0;return o.jsx(pr,{type:z.type,name:U,description:Y,seed:z.name,icon:se,author:null,authorLabel:D||void 0,version:R?R.installedVersion:$,category:X,tags:W,installed:!R,hideStats:!0,cornerLabel:R?e("installedTab.updateAvailable"):void 0,onClick:()=>{z.path&&I({type:z.type,name:z.name})},actions:R?o.jsx("button",{type:"button",disabled:m.has(z.name),onClick:()=>{K(z.name,R.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(z.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:R.availableVersion})}):void 0},`${z.type}/${z.name}`)})})}),g&&o.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 ${g.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:g.text})]})}const woe=50,koe=30;function Soe(e,t,n,a){const i=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{i.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),u=k.useCallback(m=>{const f=m.changedTouches[0].clientX-i.current,g=m.changedTouches[0].clientY-l.current,h=Math.abs(f),v=Math.abs(g);if(h<woe||Math.atan2(v,h)*(180/Math.PI)>koe)return;if(a?.scrollContainerRef?.current){const T=a.scrollContainerRef.current,C=T.scrollLeft<=1,A=T.scrollLeft+T.clientWidth>=T.scrollWidth-1;if(f>0&&!C||f<0&&!A)return}const w=e.findIndex(T=>T.id===t);f<0&&w<e.length-1?n(e[w+1].id):f>0&&w>0?n(e[w-1].id):f>0&&w===0&&a?.onSwipeOutLeft?a.onSwipeOutLeft():f<0&&w===e.length-1&&a?.onSwipeOutRight&&a.onSwipeOutRight()},[e,t,n,a]);return{onTouchStart:c,onTouchEnd:u}}const Coe=["builder","discover","agents","teams","skills","installed"],Aoe={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Hg(e){return!!e&&Coe.includes(e)}function Qk(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Hg(t)?t:"builder",installId:e}}function Toe({authUser:e}){const{t}=xt(["nav","store","common"]),n=k.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[a]=k.useState(Qk),[i,l]=k.useState(a.tab),[c,u]=k.useState(a.installId),m=Soe(n,i,l);k.useEffect(()=>{const g=Qk();g.installId&&(u(g.installId),Hg(g.tab)&&l(g.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const g=h=>{const v=h.detail,y=v.params?.storeTab??localStorage.getItem("markus_nav_storeTab");Hg(y)&&l(y);const w=v.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&u(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",g),()=>window.removeEventListener("markus:navigate",g)},[]);const f=(g,h)=>{h&&u(h),l(Aoe[g]??"agents")};return o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[o.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[o.jsx(V4,{className:"ml-2"}),n.map(g=>o.jsx("button",{onClick:()=>l(g.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${i===g.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:g.label},g.id))]}),o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i==="builder"&&o.jsx(jC,{authUser:e}),i==="discover"&&o.jsx(yoe,{onOpenType:f}),i==="agents"&&o.jsx(loe,{authUser:e,highlightItemId:c,onHighlightDone:()=>u(null)}),i==="teams"&&o.jsx(uoe,{highlightItemId:c,onHighlightDone:()=>u(null)}),i==="skills"&&o.jsx(hoe,{highlightItemId:c,onHighlightDone:()=>u(null)}),i==="installed"&&o.jsx(xoe,{})]})]})}const Xk="usageType",jh="profile";function Eoe({onComplete:e,theme:t,onThemeChange:n,skipProfile:a,onProfileUpdated:i}){const{t:l}=xt(["onboarding","common"]),[c,u]=k.useState(0),[m,f]=k.useState("local"),[g,h]=k.useState(""),[v,y]=k.useState(""),[w,T]=k.useState(""),[C,A]=k.useState(""),[M,I]=k.useState(!1),[B,K]=k.useState(""),[j,z]=k.useState(!1),[U,Y]=k.useState(null);k.useEffect(()=>{Te.auth.me().then(({user:Oe})=>{Oe.name&&h(Oe.name),Oe.email&&y(Oe.email),Oe.avatarUrl&&Y(Oe.avatarUrl);const Nt=Oe.name||Oe.email?.split("@")[0]||"";Nt&&X(Gt=>Gt||l("usageType.defaultOrgName",{name:Nt}))}).catch(()=>{}),Te.settings.getOrg().then(({org:Oe})=>{Oe?.name&&Oe.name!=="My Organization"&&X(Oe.name)}).catch(()=>{}),kn()&&Te.hubOrgs.invitations().then(Oe=>{Oe.invitations?.length>0&&V(Oe.invitations)}).catch(()=>{})},[]);const[$,D]=k.useState(null),[W,X]=k.useState(""),[H,se]=k.useState(!1),[R,re]=k.useState(!1),[ue,Ce]=k.useState(""),[q,V]=k.useState([]),[ce,P]=k.useState(null),[Ee,$e]=k.useState(null),qe=async()=>{const Oe=W.trim();if(Oe){se(!0),Ce("");try{if(await Te.settings.updateOrg(Oe),kn()){const Nt=await Te.hubOrgs.mine(),Gt=Nt.orgs?.find(ie=>ie.role==="owner")??Nt.orgs?.[0];Gt?.id?await Te.hubOrgs.update(Gt.id,{name:Oe}):await Te.hubOrgs.create(Oe)}re(!0)}catch{Ce(l("usageType.orgNameSaveFailed"))}finally{se(!1)}}},[Ze,Qe]=k.useState(!0),Re=async()=>{if(K(""),!g.trim()){K(l("profile.errors.nameRequired"));return}if(!v.trim()){K(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v.trim())){K(l("profile.errors.emailInvalid"));return}if(w&&w.length<6){K(l("profile.errors.passwordTooShort"));return}if(w&&w!==C){K(l("profile.errors.passwordMismatch"));return}I(!0);try{const{user:Oe}=await Te.auth.updateProfile(g.trim(),v.trim());w&&await Te.auth.changePassword("",w),i?.(Oe),z(!0)}catch{K(l("profile.errors.saveFailed"))}finally{I(!1)}},Xe=[{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")}],wt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:o.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:o.jsx($T,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:o.jsx("strong",{className:"text-fg-primary"})}})})},{id:Xk,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("button",{onClick:()=>{D("personal"),re(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${$==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:"👤"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),o.jsxs("button",{onClick:()=>{D("organization"),re(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${$==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:"🏢"}),o.jsxs("div",{children:[o.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),$==="organization"&&o.jsxs("div",{className:"space-y-4 mt-4",children:[q.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),q.map(Oe=>o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary",children:Oe.orgName}),o.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:Oe.invitedBy})})]}),o.jsx("button",{onClick:async()=>{P(Oe.orgId);try{await Te.hubOrgs.acceptInvitation(Oe.orgId),$e(Oe.orgId),re(!0)}catch{}finally{P(null)}},disabled:ce===Oe.orgId||Ee===Oe.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand transition-colors",children:Ee===Oe.orgId?l("usageType.accepted"):ce===Oe.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},Oe.orgId)),o.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),o.jsx("input",{type:"text",value:W,onChange:Oe=>{X(Oe.target.value),re(!1),Ce("")},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"})]}),ue&&o.jsx("p",{className:"text-xs text-red-500",children:ue}),o.jsx("button",{onClick:()=>{qe()},disabled:H||!W.trim()||R,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand text-sm rounded-xl transition-colors",children:l(H?"common:saving":R?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:jh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:j?o.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[o.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),o.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[g," · ",v]})]})]}):o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"flex justify-center",children:o.jsx(G4,{currentUrl:U,name:g,size:64,targetType:"user"})}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"text",value:g,onChange:Oe=>h(Oe.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})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",o.jsx("span",{className:"text-red-500",children:"*"})]}),o.jsx("input",{type:"email",value:v,onChange:Oe=>y(Oe.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"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),o.jsx("input",{type:"password",value:w,onChange:Oe=>T(Oe.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"})]}),w&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),o.jsx("input",{type:"password",value:C,onChange:Oe=>A(Oe.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"})]}),B&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:B}),o.jsx("button",{onClick:()=>{Re()},disabled:M||!g.trim()||!v.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand text-sm rounded-xl transition-colors",children:l(M?"common:saving":"profile.saveProfile")})]})},{id:"accessScope",title:l("settings:accessScope.title"),subtitle:l("settings:accessScope.description"),content:o.jsxs("div",{className:"space-y-3",children:[[{id:"local",label:l("settings:accessScope.localOnly"),desc:l("settings:accessScope.localOnlyHint"),host:"127.0.0.1"},{id:"lan",label:l("settings:accessScope.lan"),desc:l("settings:accessScope.lanHint"),host:"0.0.0.0"}].map(Oe=>o.jsxs("button",{onClick:()=>{f(Oe.id),fetch("/api/settings/network",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:Oe.host})}).catch(()=>{})},className:`w-full text-left p-3 rounded-lg border transition-colors ${m===Oe.id?"border-brand-500 bg-brand-500/10":"border-border-default bg-surface-elevated/30"}`,children:[o.jsx("div",{className:"text-sm text-fg-primary",children:Oe.label}),o.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:Oe.desc})]},Oe.id)),o.jsx("p",{className:"text-[11px] text-fg-muted",children:l("settings:accessScope.remoteNote")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"grid grid-cols-3 gap-3",children:Xe.map(Oe=>o.jsxs("button",{onClick:()=>n(Oe.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===Oe.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[o.jsx("span",{className:"text-2xl",children:Oe.icon}),o.jsx("span",{className:"text-sm font-medium text-fg-primary",children:Oe.label}),o.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:Oe.desc})]},Oe.value))}),o.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[o.jsx("input",{type:"checkbox",checked:Ze,onChange:Oe=>Qe(Oe.target.checked),className:"accent-brand-500 shrink-0"}),o.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],mt=a?wt.filter(Oe=>Oe.id!==jh):wt,kt=mt.findIndex(Oe=>Oe.id===Xk),lt=mt.findIndex(Oe=>Oe.id===jh),Dt=()=>{c===kt&&kt>=0&&!$||c===kt&&$==="organization"&&!R||c===lt&<>=0&&!j||(c<mt.length-1?u(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ze})}).catch(()=>{}),e()))},ht=mt[c];return o.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:o.jsx("div",{className:"w-full max-w-lg",children:o.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[o.jsx("div",{className:"flex gap-1.5 mb-8",children:mt.map((Oe,Nt)=>o.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Nt<=c?"bg-brand-500":"bg-surface-elevated"}`},Nt))}),o.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:ht.title}),o.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:ht.subtitle}),ht.content,o.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?o.jsx("button",{onClick:()=>u(c-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):o.jsx("span",{}),o.jsx("button",{onClick:Dt,disabled:lt>=0&&c===lt&&!j||kt>=0&&c===kt&&(!$||$==="organization"&&!R),className:`px-6 py-2.5 text-on-brand text-sm rounded-xl transition-colors ${lt>=0&&c===lt&&!j||kt>=0&&c===kt&&(!$||$==="organization"&&!R)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===mt.length-1?l("getStarted"):l("common:next")})]})]})})})}const Jk="markus:legal-consent",Noe="https://markus.global";function Moe({onLogin:e,hasOwner:t}){const{t:n,i18n:a}=xt("auth"),[i,l]=k.useState(null),[c,u]=k.useState(""),[m,f]=k.useState(!1),[g,h]=k.useState(""),[v,y]=k.useState(""),[w,T]=k.useState(!1),[C,A]=k.useState(!1),M=D=>{const W=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${Noe}${D}${W}`},I=()=>{try{localStorage.setItem(Jk,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},B=()=>C?(I(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),K=async()=>{const D=kn(),W=mr();if(!D||!W){u(n("login.hubUnavailable"));return}const X=await Te.auth.hubLogin(D,W);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),X.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",X.cloudAiError?n("login.cloudAiNotReady",{error:X.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(X.user,X.needsOnboarding??!1,{fromHub:!0})},j=async(D,W=!1)=>{if(!(!W&&!B())){u(""),l(D??"hub");try{if(W&&kn()&&mr()){await K();return}await Ia({method:D,force:!0}),await K()}catch(X){const H=X instanceof Error?X.message:"";if(!H.includes("cancelled")){if(!W&&kn())return j(D,!0);u(H||n("login.hubUnavailable"))}}finally{l(null)}}},z=()=>{dK(),l(null),u("")};k.useEffect(()=>{const D=window.markusDesktop;if(!D?.peekPendingDeepLinkAuth&&!D?.consumePendingDeepLinkAuth)return;let W=!1;return(async()=>{const X=D.peekPendingDeepLinkAuth?await D.peekPendingDeepLinkAuth():null;if(W||!X)return;let H=!1;try{H=!!localStorage.getItem(Jk)}catch{}if(!C&&!H){u(n("login.consentRequired"));return}H&&!C&&A(!0),I();const se=D.consumePendingDeepLinkAuth?await D.consumePendingDeepLinkAuth():X;if(!(W||!se)){u(""),l("hub");try{if(!await cK(se)||!kn()||!mr()){u(n("login.hubUnavailable"));return}await K()}catch{u(n("login.hubUnavailable"))}finally{W||l(null)}}})().catch(()=>{}),()=>{W=!0}},[C]);const U=async D=>{if(D.preventDefault(),!(!g.trim()||!v)&&B()){u(""),l("local");try{const{user:W,needsOnboarding:X}=await Te.auth.login(g.trim(),v);e(W,X??!1)}catch{u(n("login.invalidCredentials"))}finally{l(null)}}},Y=n(t?"login.welcomeBack":"login.getStarted"),$="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[o.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[o.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]"}),o.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),o.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),o.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.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"}),o.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:Y})]}),o.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?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),o.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),o.jsxs("form",{onSubmit:U,className:"space-y-3",children:[o.jsx("input",{type:"email",value:g,onChange:D=>h(D.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}),o.jsx("input",{type:"password",value:v,onChange:D=>y(D.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&&o.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&&o.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),o.jsx("button",{type:"submit",disabled:i==="local"||!g||!v,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(i==="local"?"login.signingIn":"login.signIn")})]}),o.jsx("div",{className:"text-center",children:o.jsx("button",{onClick:()=>{f(!1),u("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):o.jsxs("div",{className:"space-y-3",children:[o.jsxs("button",{onClick:()=>j("google"),disabled:!!i,className:$,children:[o.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[o.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"}),o.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"}),o.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"}),o.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),n(i==="google"?"login.connectingHub":"login.withGoogle")]}),o.jsxs("button",{onClick:()=>j("github"),disabled:!!i,className:$,children:[o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),n(i==="github"?"login.connectingHub":"login.withGithub")]}),o.jsxs("button",{onClick:()=>j("email"),disabled:!!i,className:$,children:[o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(i==="email"?"login.connectingHub":"login.withEmail")]}),i&&(i==="google"||i==="github"||i==="email"||i==="hub")&&o.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:[o.jsx("p",{children:n("login.browserOpened")}),o.jsx("button",{type:"button",onClick:z,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&o.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}),o.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[o.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),o.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),o.jsx("button",{onClick:()=>{f(!0),u("")},disabled:!!i,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),o.jsxs("label",{onAnimationEnd:()=>T(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[o.jsx("input",{type:"checkbox",checked:C,onChange:D=>{A(D.target.checked),D.target.checked&&T(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),o.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",o.jsx("a",{href:M("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",o.jsx("a",{href:M("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),o.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:[o.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),o.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function joe({token:e,onComplete:t}){const{t:n}=xt("auth"),[a,i]=k.useState(null),[l,c]=k.useState(""),[u,m]=k.useState(""),[f,g]=k.useState(""),[h,v]=k.useState(!1),[y,w]=k.useState(!1),[T,C]=k.useState(!1);k.useEffect(()=>{Te.auth.inviteInfo(e).then(M=>i(M)).catch(()=>C(!0))},[e]);const A=async M=>{if(M.preventDefault(),g(""),l.length<6){g(n("invite.passwordMinLength"));return}if(l!==u){g(n("invite.passwordsDoNotMatch"));return}v(!0);try{await Te.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{g(n("invite.error"))}finally{v(!1)}};return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),o.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),o.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),o.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:T?o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),o.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),o.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):a?o.jsxs("form",{onSubmit:A,className:"space-y-5",children:[o.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:a.name})}),o.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:a.email}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),o.jsx("input",{type:"password",value:l,onChange:M=>c(M.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})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),o.jsx("input",{type:"password",value:u,onChange:M=>m(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})]}),f&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:f}),o.jsx("button",{type:"submit",disabled:h||!l||!u,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(h?"invite.settingUp":"invite.setupAccount")})]}):o.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function Roe({onComplete:e,isFirstTime:t}){const{t:n}=xt("auth"),[a,i]=k.useState(""),[l,c]=k.useState(""),[u,m]=k.useState(""),[f,g]=k.useState(""),[h,v]=k.useState(!1),y=async w=>{if(w.preventDefault(),g(""),l.length<6){g(n("changePassword.passwordMinLength"));return}if(l!==u){g(n("changePassword.passwordsDoNotMatch"));return}v(!0);try{await Te.auth.changePassword(a,l),e()}catch{g(n("changePassword.failedToChange"))}finally{v(!1)}};return o.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),o.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),o.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),o.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),o.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:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&o.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),o.jsx("input",{type:"password",value:a,onChange:w=>i(w.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),o.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})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),o.jsx("input",{type:"password",value:u,onChange:w=>m(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),f&&o.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:f}),o.jsx("button",{type:"submit",disabled:h||!l||!u,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand text-sm font-medium rounded-xl transition-colors",children:n(h?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}const _oe=3e4;let sc=null,rc=null;function Zle(){sc=null}async function Doe(e){if(!e?.force&&sc&&Date.now()-sc.at<_oe)return sc.data;if(rc)return rc;const t=(async()=>{const n=await fetch("/api/settings/llm",{credentials:"include"});if(!n.ok)throw new Error(`HTTP ${n.status}`);const a=await n.json();return sc={at:Date.now(),data:a},a})();rc=t;try{return await t}finally{rc===t&&(rc=null)}}function Ioe({side:e,defaultWidth:t,minWidth:n,maxWidth:a,collapsedWidth:i=0,storageKey:l}){const[c,u]=k.useState(()=>{try{const T=localStorage.getItem(`${l}_w`);if(T)return Math.max(n,Math.min(a,parseInt(T,10)))}catch{}return t}),[m,f]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),g=k.useRef(!1),h=k.useRef(n),v=k.useRef(a);h.current=n,v.current=a,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{u(T=>Math.max(n,Math.min(a,T)))},[n,a]);const y=k.useCallback(T=>{T.preventDefault(),g.current=!0;const C=T.clientX,A=c,M=B=>{if(!g.current)return;const K=B.clientX-C;u(Math.max(h.current,Math.min(v.current,A+K)))},I=()=>{g.current=!1,document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",I),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",M),document.addEventListener("mouseup",I),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>f(T=>!T),[]);return{width:m?i:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:f,setWidth:u,onResizeStart:y}}const ece=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Bg="markus-theme";function Zk(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 Loe(){try{const e=localStorage.getItem(Bg);if(e==="midnight")return localStorage.setItem(Bg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function Poe(){const[e,t]=k.useState(Loe),n=k.useCallback(a=>{t(a);try{localStorage.setItem(Bg,a)}catch{}Zk(a)},[]);return k.useEffect(()=>{Zk(e)},[e]),{mode:e,setMode:n}}let $g=!1;const qg=new Set;function tce(e){if($g!==e){$g=e;for(const t of qg)t()}}function Ooe(e){return qg.add(e),()=>{qg.delete(e)}}function zoe(){return $g}const em={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},Hoe={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},Boe=["agents","tasks","requirements","projects","deliverables","workflows"];let e4="",t4="all",n4=em,a4=!1;function $oe({onClose:e,currentPage:t}){const{t:n}=xt(["common","home","work"]);Fs(!0);const[a,i]=k.useState(e4),[l,c]=k.useState(t4),[u,m]=k.useState(n4),[f,g]=k.useState(!1),[h,v]=k.useState(a4),[y,w]=k.useState(-1);k.useEffect(()=>{e4=a},[a]),k.useEffect(()=>{t4=l},[l]),k.useEffect(()=>{n4=u},[u]),k.useEffect(()=>{a4=h},[h]);const T=k.useRef(null),C=k.useRef(void 0),A=k.useRef(null),M=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{T.current?.focus(),T.current?.select()},100)},[]);const I=k.useCallback(async X=>{if(!X.trim()){m(em),v(!1),w(-1);return}g(!0),v(!0),w(-1);const H=X.toLowerCase();try{const[se,R,re,ue,Ce,q]=await Promise.allSettled([Te.agents.list({lean:!0}),Te.tasks.list({search:X,pageSize:20}),Te.requirements.list(),Te.projects.list(),Te.deliverables.search({q:X,limit:20}),Te.teams.list()]),V=se.status==="fulfilled"?se.value.agents.filter(Ze=>Ze.name?.toLowerCase().includes(H)||Ze.role?.toLowerCase().includes(H)):[],ce=R.status==="fulfilled"?R.value.tasks:[],P=re.status==="fulfilled"?re.value.requirements.filter(Ze=>Ze.title?.toLowerCase().includes(H)||Ze.description?.toLowerCase().includes(H)):[],Ee=ue.status==="fulfilled"?ue.value.projects.filter(Ze=>Ze.name?.toLowerCase().includes(H)||Ze.description?.toLowerCase().includes(H)):[],$e=Ce.status==="fulfilled"?Ce.value.results:[],qe=[];if(q.status==="fulfilled"){const Ze=await Promise.allSettled(q.value.teams.map(Qe=>Te.workflows.list(Qe.id)));for(const Qe of Ze)if(Qe.status==="fulfilled")for(const Re of Qe.value.workflows)(Re.name.toLowerCase().includes(H)||(Re.displayName||"").toLowerCase().includes(H)||Re.description?.toLowerCase().includes(H))&&qe.push(Re)}m({agents:V,tasks:ce,requirements:P,projects:Ee,deliverables:$e,workflows:qe})}catch{m(em)}finally{g(!1)}},[]),B=X=>{i(X),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>I(X),400)},K=k.useCallback((X,H)=>{e(),yt.navigate(X,H)},[e]),j=[{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:"工作流"})}],z=k.useMemo(()=>Hoe[t||""]||Boe,[t]),U=k.useMemo(()=>{const X=[],H=l==="all"?8:void 0,se=R=>{if(l!=="all"&&l!==R)return;const re=u[R].length;if(R==="workflows"){const ue=H?u.workflows.slice(0,H):u.workflows;for(const Ce of ue)X.push({id:Ce.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const ue=u[R],Ce=H?ue.slice(0,H):ue;for(const q of Ce)switch(R){case"agents":X.push({id:q.id,type:"agent",page:me.TEAM,params:{agentId:q.id}});break;case"tasks":X.push({id:q.id,type:"task",page:me.WORK,params:{openTask:q.id}});break;case"requirements":X.push({id:q.id,type:"requirement",page:me.WORK,params:{openRequirement:q.id}});break;case"projects":X.push({id:q.id,type:"project",page:me.WORK,params:{projectId:q.id}});break;case"deliverables":X.push({id:q.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:q.id}});break}}H&&re>H&&X.push({id:`more_${R}`,type:"showMore",page:"",expandCategory:R,totalCount:re})};for(const R of z)se(R);return X},[u,l,z]),Y=k.useCallback(X=>{if(X.type==="showMore"&&X.expandCategory){c(X.expandCategory),w(-1);return}K(X.page,X.params)},[K]);k.useEffect(()=>{const X=M.current;if(!X||y<0)return;const H=X.querySelector(`[data-idx="${y}"]`);H&&H.scrollIntoView({block:"nearest"})},[y]);const $=k.useCallback(X=>{if(X.key==="Escape"){e();return}if(X.key==="Tab"){X.preventDefault();const R=j.map(Ce=>Ce.id),re=R.indexOf(l),ue=X.shiftKey?re<=0?R.length-1:re-1:re>=R.length-1?0:re+1;c(R[ue]),w(-1);return}const H=X.ctrlKey&&X.key==="n"||X.key==="ArrowDown",se=X.ctrlKey&&X.key==="p"||X.key==="ArrowUp";if(H||se){X.preventDefault(),w(R=>{const re=U.length-1;return re<0?-1:H?R>=re?0:R+1:R<=0?re:R-1});return}X.key==="Enter"&&(X.preventDefault(),y>=0&&y<U.length&&Y(U[y]))},[e,U,y,Y,j,l]);k.useEffect(()=>(document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)),[$]);const D=U.length>0;let W=0;return o.jsx("div",{ref:A,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:X=>{X.target===A.current&&e()},children:o.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:[o.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[o.jsxs("div",{className:"relative",children:[o.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:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("input",{ref:T,value:a,onChange:X=>B(X.target.value),placeholder:n("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),a&&o.jsx("button",{onClick:()=>{i(""),m(em),v(!1),w(-1),T.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:j.map(X=>o.jsx("button",{onClick:()=>{c(X.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===X.id?"bg-brand-600 text-on-brand":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:X.label},X.id))})]}),o.jsxs("div",{ref:M,className:"flex-1 overflow-y-auto px-5 py-3",children:[f&&o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!f&&h&&!D&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.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:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!f&&D&&o.jsx("div",{className:"space-y-4",children:z.map(X=>{if(l!=="all"&&l!==X)return null;const H=l==="all"?8:void 0,se=R=>{const re=W++,ue=R==="agents"?u.agents.length:R==="tasks"?u.tasks.length:R==="requirements"?u.requirements.length:R==="projects"?u.projects.length:R==="workflows"?u.workflows.length:u.deliverables.length;return o.jsxs("button",{"data-idx":re,onClick:()=>{c(R),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${re===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:"查看全部"})," (",ue,")"]})};return X==="agents"&&u.agents.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.agents.slice(0,H):u.agents).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.TEAM,{agentId:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx(Fo,{name:R.name||"Agent",avatarUrl:R.avatarUrl,size:28}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:R.name}),o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:R.role||R.status})]}),o.jsx(qoe,{status:R.status})]},R.id)})}),H&&u.agents.length>H&&se("agents")]},"agents"):X==="tasks"&&u.tasks.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.tasks.slice(0,H):u.tasks).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.WORK,{openTask:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx(Foe,{status:R.status}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.status," · ",R.priority||""]})]})]},R.id)})}),H&&u.tasks.length>H&&se("tasks")]},"tasks"):X==="requirements"&&u.requirements.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.requirements.slice(0,H):u.requirements).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.WORK,{openRequirement:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${R.status==="approved"?"text-green-500 bg-green-500/15":R.status==="pending"?"text-amber-500 bg-amber-500/15":R.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"}),o.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),o.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.status," · ",R.priority||""]})]})]},R.id)})}),H&&u.requirements.length>H&&se("requirements")]},"requirements"):X==="projects"&&u.projects.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.projects.slice(0,H):u.projects).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.WORK,{projectId:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:o.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"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.name}),R.description&&o.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:R.description})]})]},R.id)})}),H&&u.projects.length>H&&se("projects")]},"projects"):X==="deliverables"&&u.deliverables.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.deliverables.slice(0,H):u.deliverables).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.DELIVERABLES,{openDeliverable:R.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.title}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.type," · ",R.status]})]})]},R.id)})}),H&&u.deliverables.length>H&&se("deliverables")]},"deliverables"):X==="workflows"&&u.workflows.length>0?o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),o.jsx("div",{className:"space-y-0.5",children:(H?u.workflows.slice(0,H):u.workflows).map(R=>{const re=W++;return o.jsxs("button",{"data-idx":re,onClick:()=>K(me.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${re===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[o.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.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"})]})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-fg-primary truncate",children:R.displayName||R.name}),o.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[R.stepCount," steps · v",R.version]})]})]},R.name)})}),H&&u.workflows.length>H&&se("workflows")]},"workflows"):null})}),!f&&!h&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.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:[o.jsx("circle",{cx:"11",cy:"11",r:"8"}),o.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),o.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),o.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:[o.jsxs("span",{children:[o.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:"唤起/关闭"})]}),o.jsxs("span",{children:[o.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:"切换分类"})]}),o.jsxs("span",{children:[o.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:"导航"})]}),o.jsxs("span",{children:[o.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:"打开"})]}),o.jsxs("span",{children:[o.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 qoe({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return o.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function Foe({status:e}){const t=Tn[Pc(e)].chip;return o.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M9 11l3 3L22 4"}),o.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const Uoe=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function Goe(e){return e===me.TEAM?"team":e===me.WORK?"work":e===me.DELIVERABLES?"deliverables":e===me.STORE?"store":"any"}function Koe({open:e,onClose:t,page:n}){const{t:a}=xt("common"),i=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=Goe(n);return k.useEffect(()=>{if(!e)return;const c=u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),t())};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,t]),e?o.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:c=>{c.target===c.currentTarget&&t()},role:"dialog","aria-modal":"true","aria-label":a("shortcuts.title"),children:o.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:[o.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:[o.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:a("shortcuts.title")}),o.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":a("shortcuts.close"),children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"px-4 py-3 space-y-4",children:Uoe.map(c=>{const u=TK.filter(m=>{if(m.group!==c)return!1;const f=m.page??"any";return f==="any"?!0:f===l});return u.length===0?null:o.jsxs("section",{children:[o.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:a(`shortcuts.groups.${c}`)}),o.jsx("ul",{className:"space-y-1.5",children:u.map(m=>o.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[o.jsx("span",{className:"text-fg-secondary min-w-0",children:a(m.labelKey??m.label,{defaultValue:m.label})}),o.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default text-[13px] font-medium leading-none text-fg-primary font-mono",children:Q4(m.keys,i,m.bare)})]},m.id))})]},c)})})]})}):null}function Voe({authUser:e,onClose:t,onSaved:n,onUserUpdated:a}){const{t:i}=xt("common");Fs(!0);const[l,c]=k.useState(e.name||""),[u,m]=k.useState(e.email||""),[f,g]=k.useState(!1),[h,v]=k.useState(""),[y,w]=k.useState(()=>F4(e.avatarUrl,mr()?.avatarUrl)),T=async C=>{if(C.preventDefault(),!l.trim()){v(i("profile.nameRequired"));return}if(u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u.trim())){v(i("profile.invalidEmail"));return}g(!0),v("");try{const{user:A}=await Te.auth.updateProfile(l.trim(),u.trim());n({...A,avatarUrl:y??A.avatarUrl})}catch{v(i("profile.failedToSave"))}finally{g(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:o.jsxs("form",{onSubmit:T,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:C=>C.stopPropagation(),children:[o.jsx("h3",{className:"text-base font-semibold mb-5",children:i("profile.editProfile")}),o.jsx("div",{className:"flex justify-center mb-5",children:o.jsx(G4,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:C=>{w(C),a?.({...e,avatarUrl:C})}})}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("profile.name")}),o.jsx("input",{value:l,onChange:C=>c(C.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:i("profile.email")}),o.jsx("input",{value:u,onChange:C=>m(C.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),h&&o.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:h})]}),o.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:i("cancel")}),o.jsx("button",{type:"submit",disabled:f,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand rounded-lg",children:i(f?"saving":"save")})]})]})})}const LC="markus_lan_notice_acked";let r4=null;function PC(){try{const t=globalThis.localStorage;if(t&&typeof t.getItem=="function"&&typeof t.setItem=="function"&&typeof t.removeItem=="function")return t}catch{}r4??=new Map;const e=r4;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}function Woe(e){return PC().getItem(LC)===e}function Yoe(e){PC().setItem(LC,e)}function Qoe(e,t){return e&&!Woe(t)}const i4=k.lazy(()=>Ca(()=>import("./Team-nfNyWj-s.js"),__vite__mapDeps([2,3,4,5,6,7,8,9,10])).then(e=>({default:e.TeamPage}))),s4=k.lazy(()=>Ca(()=>import("./Settings-BQDqf4q5.js"),__vite__mapDeps([11,6,9])).then(e=>({default:e.Settings}))),Xoe=k.lazy(()=>Ca(()=>import("./Store-BEsLd_RN.js"),[]).then(e=>({default:e.StorePage}))),Joe=k.lazy(()=>Ca(()=>Promise.resolve().then(()=>eoe),void 0).then(e=>({default:e.AgentBuilder}))),o4=k.lazy(()=>Ca(()=>import("./Work-BQvgkynj.js"),__vite__mapDeps([12,13,5,6,4,3,7,1,14,15])).then(e=>({default:e.WorkPage}))),l4=k.lazy(()=>Ca(()=>import("./Deliverables-CQnWqbTb.js"),__vite__mapDeps([16,3,7,8,13,5])).then(e=>({default:e.DeliverablesPage}))),Zoe=k.lazy(()=>Ca(()=>import("./Search-CVYQIy_D.js"),__vite__mapDeps([17,6])).then(e=>({default:e.SearchPage}))),ele={display:"none"};function tle(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,a=e.preferences??{};if(a.locale===t&&a.timezone===n)return;Te.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function nle({docScroll:e}={}){return o.jsx("div",{className:`flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse ${e?"min-h-[50dvh]":""}`,children:"Loading..."})}function ale({error:e,onRetry:t,docScroll:n}){const{t:a}=xt("common");return o.jsx("div",{className:`flex-1 flex items-center justify-center p-8 ${n?"min-h-[50dvh]":""}`,children:o.jsxs("div",{className:"max-w-md w-full text-center space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-fg-primary",children:a("pageErrorTitle")}),o.jsx("p",{className:"text-xs text-fg-tertiary leading-relaxed",children:a("pageErrorHint")}),o.jsx("pre",{className:"text-[11px] text-left whitespace-pre-wrap break-words bg-surface-elevated rounded-lg p-3 text-fg-secondary max-h-40 overflow-auto",children:e.message}),o.jsx("button",{type:"button",onClick:t,className:"px-3 py-1.5 text-[11px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg font-medium",children:a("pageErrorRetry")})]})})}const rle=k.memo(function({id:t,activePage:n,docScroll:a,children:i}){const l=t===n,c=k.useRef(null),u=k.useRef(l);return k.useEffect(()=>{l&&!u.current&&c.current&&c.current.dispatchEvent(new CustomEvent("markus:page-shown",{bubbles:!0})),u.current=l},[l]),o.jsx("div",{ref:c,"data-page-slot":!0,"data-page-active":l?"true":"false",className:a?"block overflow-hidden":"flex-1 overflow-hidden flex flex-col",style:l?void 0:ele,children:o.jsx(k.Suspense,{fallback:o.jsx(nle,{docScroll:a}),children:o.jsx(HV,{resetKeys:[t,l],fallback:(m,f)=>o.jsx(ale,{error:m,onRetry:f,docScroll:a}),children:i})})})},(e,t)=>{if(e.docScroll!==t.docScroll)return!1;const n=e.id===e.activePage,a=t.id===t.activePage;return n!==a?!1:a?e.children===t.children:!0}),Pu={};function OC(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?N4[e]??e:e}function c4(){return OC(Sc())}function ile(){const{t:e}=xt("common"),[t,n]=k.useState(c4),[a,i]=k.useState(!1),[l,c]=k.useState(!0),u=Yo(),m=k.useSyncExternalStore(Ooe,zoe,()=>!1),f=u&&!(t===me.TEAM&&m),g=k.useSyncExternalStore(CG,D4,AG),h=u&&t!==me.SETTINGS&&t!==me.SEARCH&&_4(g,t);k.useEffect(()=>{const Ae=document.documentElement;return Ae.classList.toggle("mobile-doc-scroll",f),()=>{Ae.classList.remove("mobile-doc-scroll")}},[f]),k.useLayoutEffect(()=>{f&&window.scrollTo(0,0)},[t,f]);const v=Poe(),y=Ioe({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[w,T]=k.useState(()=>new Set([c4()])),[C,A]=k.useState("loading"),[M,I]=k.useState(!1),[B,K]=k.useState(null),[j,z]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[U,Y]=k.useState(!1),[$,D]=k.useState(!1),[W,X]=k.useState(null),[H,se]=k.useState(!1),[R,re]=k.useState(null),[ue,Ce]=k.useState(!1),[q,V]=k.useState(null),[ce,P]=k.useState(()=>{const Ae=localStorage.getItem("markus_update_dismissed");return Ae||null}),[Ee,$e]=k.useState(!1),[qe,Ze]=k.useState(!1),Qe=pp(),Re=Qe?.leftCollapsed??!1,Xe=Qe?.toggleLeftCollapsed,wt=Qe?.setLeftCollapsed,mt=Qe?.keyboardPane??"l0",kt=Qe?.setKeyboardPane,lt=Qe?.l0FocusPageId??null,Dt=Qe?.setL0FocusPageId,ht=k.useRef(t);ht.current=t;const Oe=k.useRef(me.HOME),Nt=Qe?.toggleRightPanel,Gt=Qe?.toggleTerminalPanel,ie=Qe?.cycleRightPanelTab,et=Qe?.activateRightPanelTabAt,at=Qe?.openNewRightPanelTab,ye=Qe?.rightPanelOpen??!1,Ne=Qe?.activeRightPanelTabId??null,De=Qe?.openRightPanel,te=Qe?.closeRightPanelTab,F=Qe?.updateRightPanelBrowserTab,ae=Qe?.updateRightPanelTerminalTab,we=k.useRef(Qe?.rightPanelTabs);we.current=Qe?.rightPanelTabs,k.useEffect(()=>{const Ae=window.markusDesktop?.browser?.onPageEvent;if(!(!Ae||!De))return Ae(je=>{if(je.type==="closed"){const _e=we.current?.find(Q=>Q.payload.kind==="url"&&Q.payload.browserId===je.browserId);_e&&te&&te(_e.id);return}if(je.type==="navigated"){if(je.url&&Cc(je.url))return;je.browserId&&F&&F(je.browserId,{url:je.url,title:je.title||je.url});return}if(je.type==="opened"||je.type==="selected"){if(!je.url&&!je.browserId||je.browserId.startsWith("eb_")||gie(je.browserId)||je.url&&Cc(je.url))return;De({kind:"url",url:je.url||"about:blank",title:je.title||je.url||"Browser",browserId:je.browserId,pageId:je.pageId})}})},[De,te,F]),k.useEffect(()=>{const Ae=window.markusDesktop?.terminal?.onEvent;if(!(!Ae||!De))return Ae(je=>{if(je.type==="closed"){const _e=we.current?.find(Q=>Q.payload.kind==="terminal"&&Q.payload.terminalId===je.id);_e&&te&&te(_e.id);return}if(je.type==="cwd"){je.cwd&&ae?.(je.id,{cwd:je.cwd});return}if(je.type==="selected"){(je.title||je.cwd)&&ae?.(je.id,{title:je.title,cwd:je.cwd});return}if(je.type==="opened"){if(_b.has(je.id)){(je.title||je.cwd)&&ae?.(je.id,{title:je.title,cwd:je.cwd});return}Ds(je.id),De({kind:"terminal",terminalId:je.id,title:je.title||"Terminal",cwd:je.cwd})}})},[De,te,ae]);const Le=Qe?.handleTerminalExit;k.useEffect(()=>{const Ae=window.markusDesktop?.terminal?.onExit;if(!(!Ae||!Le))return Ae(je=>{Le(je.id)})},[Le]),k.useLayoutEffect(()=>{const Ae=t===me.TEAM&&ye&&Qe?.rightPanelMode==="browser";Nf(Ae)},[t,ye,Qe?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const He=k.useRef(!1);k.useEffect(()=>{if(!He.current){He.current=!0;return}y.setCollapsed(Re)},[Re,y.setCollapsed]),k.useEffect(()=>{if(u)return;const Ae=navigator.platform.toUpperCase().includes("MAC"),je=Q=>{Ae&&Q.metaKey&&!Q.ctrlKey&&Q.key==="p"?(Q.preventDefault(),$e(he=>!he)):!Ae&&Q.ctrlKey&&!Q.metaKey&&Q.key==="p"&&(Q.preventDefault(),$e(he=>!he))},_e=()=>$e(!0);return document.addEventListener("keydown",je),window.addEventListener("markus:open-search",_e),()=>{document.removeEventListener("keydown",je),window.removeEventListener("markus:open-search",_e)}},[u]);const de=k.useCallback(()=>!ye||!Ne||!te?!1:(te(Ne),!0),[ye,Ne,te]);k.useEffect(()=>{const Ae=window.markusDesktop?.onAppShortcut?.(je=>{if(je.type==="close-tab"){de();return}je.type==="new-tab"&&at?.()});return()=>{Ae?.()}},[de,at]),k.useEffect(()=>{if(u||!Xe||!Nt)return;const Ae=navigator.platform.toUpperCase().includes("MAC"),je=_e=>{if(!(Ae?_e.metaKey&&!_e.ctrlKey:_e.ctrlKey&&!_e.metaKey)||_e.altKey)return;if(!_e.shiftKey&&(_e.key==="/"||_e.code==="Slash")){_e.preventDefault(),Ze(Se=>!Se);return}if(_e.shiftKey&&(_e.key==="?"||_e.key==="/")){_e.preventDefault(),Ze(Se=>!Se);return}if(_e.shiftKey&&ye&&ie){if(_e.key==="]"||_e.code==="BracketRight"){_e.preventDefault(),ie(1);return}if(_e.key==="["||_e.code==="BracketLeft"){_e.preventDefault(),ie(-1);return}}if(!_e.shiftKey&&ye&&et){const Se=_e.key>="1"&&_e.key<="9"?Number(_e.key):0;if(Se>=1){_e.preventDefault(),et(Se-1);return}}if(_e.shiftKey)return;const he=_e.key.toLowerCase();if(he==="w"){_e.preventDefault(),_e.stopPropagation(),de();return}if(he==="t"){_e.preventDefault(),at?.();return}if(he==="b"){if(t===me.DELIVERABLES)return;_e.preventDefault(),Xe()}else if(t===me.TEAM&&he==="l"){if(!Ae&&s2(_e.target)||Ae&&s2(_e.target)&&_e.ctrlKey)return;_e.preventDefault(),Nt()}else t===me.TEAM&&he==="j"&&Gt&&(_e.preventDefault(),Gt())};return document.addEventListener("keydown",je,!0),()=>document.removeEventListener("keydown",je,!0)},[u,t,Xe,Nt,Gt,ie,et,ye,de,at]);const fe=k.useCallback((Ae,je)=>{let _e=kc(Ae);u&&(_e=N4[_e]??_e),_e!==me.TEAM&&Nf(!1);const Q=Sc(),he=window.location.hash.slice(1);he!==Ph(Q)?Pu[Q]=he:delete Pu[Q];const Se=ht.current;if(_e===me.SETTINGS&&Se!==me.SETTINGS&&(Oe.current=Se,yt.setSettingsReturnPage(Se),kt?.("l1"),Dt?.(me.SETTINGS)),Se===me.SETTINGS&&_e!==me.SETTINGS&&(kt?.("l0"),Dt?.(_e)),_e===me.SETTINGS&&je?.tab){const bt=`settings/${je.tab}`;Pu[_e]=bt,history.pushState(null,"","#"+bt),window.dispatchEvent(new HashChangeEvent("hashchange")),n(_e),T(Ot=>Ot.has(_e)?Ot:new Set([...Ot,_e]));return}const Ye=_e!==me.WORK?Pu[_e]:void 0;Ye&&Ye!==Ph(_e)?(history.pushState(null,"",Hs(_e)),history.pushState(null,"","#"+Ye)):history.pushState(null,"",Hs(_e)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(_e),T(bt=>bt.has(_e)?bt:new Set([...bt,_e]))},[u,kt,Dt]);k.useEffect(()=>{yt.setHandler((Ae,je)=>fe(Ae,je))},[fe]);const Ge=k.useCallback(Ae=>{const je=ht.current,_e=jG(je,NG(je),Ae);_e&&(_e.sub&&IG(_e.page,_e.sub),fe(_e.page))},[fe]);BG({enabled:u,activePage:()=>ht.current,onStep:Ge}),k.useEffect(()=>{mt==="l0"&&t!==me.SETTINGS&&Dt?.(t)},[mt,t,Dt]),k.useEffect(()=>{if(u||!kt||!Dt)return;const Ae=je=>{if(je.metaKey||je.ctrlKey||je.altKey||i2(je.target))return;const _e=je.key.length===1?je.key.toLowerCase():je.key;if(t===me.SETTINGS&&(_e==="h"||_e==="ArrowLeft")){je.preventDefault(),je.stopImmediatePropagation(),yt.leaveSettings();return}if(mt!=="l0"||t===me.SETTINGS)return;const Q=lt&&No.includes(lt)?lt:t,he=Math.max(0,No.indexOf(Q));if(_e==="j"||_e==="ArrowDown"){je.preventDefault(),je.stopImmediatePropagation();const Se=No[Math.min(No.length-1,he+1)];Dt(Se),Se!==t&&fe(Se),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Se}"]`)?.scrollIntoView({block:"nearest"})});return}if(_e==="k"||_e==="ArrowUp"){je.preventDefault(),je.stopImmediatePropagation();const Se=No[Math.max(0,he-1)];Dt(Se),Se!==t&&fe(Se),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Se}"]`)?.scrollIntoView({block:"nearest"})});return}if(_e==="l"||_e==="ArrowRight"||_e==="Enter"){const Se=lt&&No.includes(lt)?lt:t;if(!vG.has(Se)){je.preventDefault(),je.stopImmediatePropagation();return}je.preventDefault(),je.stopImmediatePropagation(),Se!==t&&fe(Se),wt?.(!1),kt("l1");return}(_e==="h"||_e==="ArrowLeft")&&(je.preventDefault(),je.stopImmediatePropagation())};return document.addEventListener("keydown",Ae,!0),()=>document.removeEventListener("keydown",Ae,!0)},[u,mt,lt,t,fe,kt,Dt,wt]),k.useEffect(()=>{const Ae=()=>I(!0);return window.addEventListener("markus:open-edit-profile",Ae),()=>window.removeEventListener("markus:open-edit-profile",Ae)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!u&&t!==me.SETTINGS&&!y.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[y.collapsed,t,u]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Ae=>{if(Ae.page){const je=kc(Ae.page);Ae.params&&Object.entries(Ae.params).forEach(([_e,Q])=>localStorage.setItem(`markus_nav_${_e}`,Q)),fe(je),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:je,params:Ae.params}}));return}Ae.openNotifications&&($G(),fe(me.HOME))})},[fe]);const ct=k.useCallback(()=>{Doe().then(Ae=>{if(Ae?.providers){const je=Object.values(Ae.providers).some(_e=>_e.configured);X(je)}}).catch(()=>{})},[]),We=k.useCallback((Ae,je)=>{if(!Ae)return;const Q=je&&{agent:"agents",team:"teams",skill:"skills"}[je]||"agents";localStorage.setItem("markus_nav_installItem",Ae),localStorage.setItem("markus_nav_storeTab",Q);const he=new URLSearchParams(window.location.search);he.get("install")||(he.set("install",Ae),je&&he.set("type",je));const Se=he.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Se}${Hs(me.STORE)}`);const Ye=()=>yt.navigate(me.STORE,{storeTab:Q,installItem:Ae});Ye(),setTimeout(Ye,500),setTimeout(Ye,1500)},[]);k.useEffect(()=>{const Ae=()=>A(null);return window.addEventListener($h,Ae),()=>window.removeEventListener($h,Ae)},[]),k.useEffect(()=>{const Ae=new URLSearchParams(window.location.search),je=Ae.get("install");je&&We(je,Ae.get("type"));const _e=window.markusDesktop;_e?.onDeepLinkInstall?.(({id:Se,type:Ye})=>We(Se,Ye)),_e?.consumePendingDeepLinkInstall?.().then(Se=>{Se?.id&&We(Se.id,Se.type)}),Te.auth.me().then(({user:Se})=>{e2(),A(Se),K(!0),i(!1),Se.preferences?.guideHidden===!0&&!Qh(Se.id)&&Xh(Se.id),tle(Se),_s.connect(Se.id),ct(),Te.health().then(bt=>{bt.updateAvailable&&bt.latestVersion&&V({latestVersion:bt.latestVersion,currentVersion:bt.version});const Ot=bt.bindHost??"0.0.0.0";Qoe(bt.lanExposed===!0,Ot)&&re({host:Ot})}).catch(()=>{});const Ye=()=>{As(La.builderArtifacts,()=>Te.builder.artifacts.list()),As(La.builderAgents,()=>Te.agents.list()),As(La.builderHubMyItems,()=>nt.myItems()),As(La.builderInstalled,()=>Te.builder.artifacts.installed()),As(La.hubAgents,()=>nt.search({type:"agent",limit:50})),As(La.hubTeams,()=>nt.search({type:"team",limit:50})),As(La.hubSkills,()=>nt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Ye,{timeout:5e3}):setTimeout(Ye,3e3)}).catch(()=>{A(null),Te.auth.status().then(({initialized:Se,hasOwner:Ye,hasMultipleUsers:bt})=>{K(Se),z({hasOwner:Ye,hasMultipleUsers:bt})}).catch(()=>K(!0))}),_s.connect();const Q=_s.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),he=()=>{const Se=OC(Sc());Se!==me.TEAM&&Nf(!1),n(Se),T(Ye=>Ye.has(Se)?Ye:new Set([...Ye,Se]))};return window.addEventListener("hashchange",he),window.addEventListener("popstate",he),()=>{Q(),_s.disconnect(),window.removeEventListener("hashchange",he),window.removeEventListener("popstate",he)}},[]),k.useEffect(()=>{const Ae=C!=="loading"&&C!==null?C.id:void 0;if(!Ae)return;const je=navigator.platform.toUpperCase().includes("MAC"),_e=Q=>{if(i2(Q.target))return;const he={key:Q.key,code:Q.code,metaKey:Q.metaKey,ctrlKey:Q.ctrlKey,altKey:Q.altKey,shiftKey:Q.shiftKey};CK(he,Ae,je)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",_e,!0),()=>window.removeEventListener("keydown",_e,!0)},[C]);const ut=C!=="loading"&&C!==null?C:void 0,Ft=k.useMemo(()=>u?{[me.HOME]:o.jsx(M2,{authUser:ut}),[me.TEAM]:o.jsx(i4,{authUser:ut}),[me.BUILDER]:o.jsx(Toe,{authUser:ut}),[me.SETTINGS]:o.jsx(s4,{theme:v.mode,onThemeChange:v.setMode,authUser:ut,onLogout:()=>{Te.auth.logout().catch(()=>{}),Ls(),A(null)},onUserUpdated:Ae=>A(Ae)}),[me.WORK]:o.jsx(o4,{authUser:ut}),[me.DELIVERABLES]:o.jsx(l4,{authUser:ut}),[me.SEARCH]:o.jsx(Zoe,{})}:{[me.HOME]:o.jsx(M2,{authUser:ut}),[me.TEAM]:o.jsx(i4,{authUser:ut}),[me.SETTINGS]:o.jsx(s4,{theme:v.mode,onThemeChange:v.setMode,authUser:ut,onLogout:()=>{Te.auth.logout().catch(()=>{}),Ls(),A(null)},onUserUpdated:Ae=>A(Ae)}),[me.STORE]:o.jsx(Xoe,{authUser:ut}),[me.BUILDER]:o.jsx(Joe,{authUser:ut}),[me.WORK]:o.jsx(o4,{authUser:ut}),[me.DELIVERABLES]:o.jsx(l4,{authUser:ut})},[ut?.id,ut?.role,v.mode,u]);if(C==="loading"||C===null&&B===null)return o.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:o.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Pt=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Pt?o.jsx(joe,{token:Pt[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),i(!0),Y(!0),A("loading"),Te.auth.me().then(Ae=>{C2(Ae.user.id),A(Ae.user)}).catch(()=>A(null))}}):C===null?o.jsx(Moe,{hasOwner:j.hasOwner,hasMultipleUsers:j.hasMultipleUsers,onLogin:(Ae,je,_e)=>{e2(),A(Ae),_s.connect(Ae.id),je?(C2(Ae.id),i(!0),_e?.fromHub&&Y(!0)):(i(!1),Qh(Ae.id)?(Xh(Ae.id),Te.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),A({...Ae,preferences:{...Ae.preferences,guideHidden:!0}})):A(Ae))}}):$?o.jsx(Roe,{onComplete:()=>D(!1),isFirstTime:!0}):a?o.jsx(Eoe,{theme:v.mode,onThemeChange:v.setMode,skipProfile:U,onProfileUpdated:Ae=>{const je={id:Ae.id,name:Ae.name,email:Ae.email,role:Ae.role,orgId:Ae.orgId??"default",avatarUrl:Ae.avatarUrl};A(je)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),i(!1),Y(!1),Te.auth.me().then(Ae=>A(Ae.user)).catch(()=>{}),ct(),fe(me.HOME)}}):o.jsxs("div",{className:`flex ${f?"min-h-dvh":"h-dvh overflow-x-hidden"} bg-surface-primary text-fg-primary ${u?"flex-col":""}`,children:[!u&&t!==me.SETTINGS&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative z-40 shrink-0",style:{width:y.width},children:o.jsx(QV,{currentPage:t,onNavigate:Ae=>{fe(Ae),c(!1),kt?.("l0"),Dt?.(Ae)},authUser:C,collapsed:y.collapsed,onToggleCollapse:y.toggle,onLogout:()=>{Te.auth.logout().catch(()=>{}),Ls(),A(null)},keyboardFocusPageId:lt,keyboardPaneActive:mt==="l0"})}),o.jsx("div",{className:`${y.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:y.collapsed?void 0:y.onResizeStart,children:!y.collapsed&&o.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"})})]}),o.jsxs("div",{className:`flex-1 ${f?"":"overflow-hidden"} flex flex-col min-w-0 ${h?"pb-14":""}`,children:[W===!1&&!H&&t!==me.SETTINGS&&o.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:[o.jsx("span",{className:u?"text-xs":"",children:e("llmBanner.message")}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.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")}),o.jsx("button",{onClick:()=>se(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),q&&ce!==q.latestVersion&&o.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:[o.jsx("span",{className:u?"text-xs":"",children:e("update.available",{latest:q.latestVersion,current:q.currentVersion})}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[o.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")}),o.jsx("button",{onClick:()=>{P(q.latestVersion),localStorage.setItem("markus_update_dismissed",q.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),R&&!ue&&t!==me.SETTINGS&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-emerald-500/10 border-b border-emerald-500/25 text-emerald-600 dark:text-emerald-400 text-sm shrink-0",children:[o.jsx("span",{className:u?"text-xs":"",children:e("lanNotice.message",{host:R.host})}),o.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[o.jsx("button",{onClick:()=>{window.location.hash="#settings/network"},className:"text-xs font-medium text-emerald-600 dark:text-emerald-400 hover:text-emerald-500 transition-colors",children:e("lanNotice.goToSettings")}),o.jsx("button",{onClick:()=>{Yoe(R.host),Ce(!0)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),o.jsx("main",{className:`flex-1 ${f?"":"overflow-hidden"} flex flex-col relative`,children:Object.keys(Ft).map(Ae=>w.has(Ae)?o.jsx(rle,{id:Ae,activePage:t,docScroll:f,children:Ft[Ae]},Ae):null)})]}),h&&o.jsx(uW,{currentPage:t,onNavigate:fe}),u&&o.jsx(wK,{authUser:ut,onNavigate:fe,onLogout:()=>{Te.auth.logout().catch(()=>{}),Ls(),A(null)}}),!u&&Ee&&o.jsx($oe,{onClose:()=>$e(!1),currentPage:t}),!u&&o.jsx(Koe,{open:qe,onClose:()=>Ze(!1),page:t}),o.jsx(sse,{}),M&&ut&&o.jsx(Voe,{authUser:ut,onClose:()=>I(!1),onUserUpdated:Ae=>A(Ae),onSaved:Ae=>{I(!1),A(Ae)}})]})}const d4="data-anim-paused",sle="data-anim-tick",u4=8,ole=250,zC=["animate-pulse","animate-spin","animate-bounce","activity-text-shimmer","exec-card-active"];zC.map(e=>`.${e}`).join(", ");function lle(){return document.visibilityState!=="visible"||document.hidden}let vc=null,oc=0;function cle(){vc===null&&(oc=oc%u4,m4(),vc=window.setInterval(()=>{oc=(oc+1)%u4,m4()},ole))}function m4(){const e=String(oc);for(const t of zC){const n=document.getElementsByClassName(t);for(let a=0;a<n.length;a++)n[a].setAttribute(sle,e)}}function dle(){vc!==null&&(window.clearInterval(vc),vc=null)}function Rh(){const e=document.documentElement;lle()?(e.setAttribute(d4,"true"),dle()):(e.removeAttribute(d4),cle())}let p4=!1;function ule(){p4||typeof document>"u"||(p4=!0,Rh(),document.addEventListener("visibilitychange",Rh,{passive:!0}),window.addEventListener("pageshow",Rh,{passive:!0}))}ule();YA.createRoot(document.getElementById("root")).render(o.jsx(k.StrictMode,{children:o.jsx(kie,{children:o.jsx(ile,{})})}));export{Ia as $,Fo as A,zre as B,SJ as C,Ure as D,HV as E,Hle as F,zle as G,$le as H,xoe as I,qle as J,Ble as K,Xre as L,vJ as M,TC as N,Qle as O,me as P,Ioe as Q,Qx as R,yoe as S,loe as T,_s as U,kn as V,kc as W,V4 as X,Oie as Y,Hie as Z,Ca as _,Yo as a,jle as a$,mle as a0,Ic as a1,c5 as a2,Lc as a3,vr as a4,Ele as a5,Cle as a6,L4 as a7,mr as a8,xle as a9,Kle as aA,Gle as aB,hle as aC,gle as aD,Ds as aE,Nu as aF,Ob as aG,die as aH,fC as aI,Or as aJ,Iu as aK,qk as aL,Jle as aM,mm as aN,Ile as aO,Wh as aP,oie as aQ,Ak as aR,Dle as aS,Mle as aT,Nle as aU,vle as aV,Zle as aW,tce as aX,sW as aY,Lle as aZ,rK as a_,Tle as aa,eK as ab,Ale as ac,Zx as ad,wle as ae,XG as af,Sle as ag,kle as ah,noe as ai,aoe as aj,Uo as ak,Doe as al,ece as am,fle as an,DC as ao,toe as ap,Fs as aq,$T as ar,uie as as,Ng as at,wG as au,Fle as av,Vle as aw,Ule as ax,Wle as ay,Yle as az,hK as b,G4 as b0,Q4 as b1,QK as b2,_le as b3,s2 as b4,$m as b5,FT as b6,ple as b7,ble as b8,yle as b9,Hs as ba,Rle as bb,cV as bc,e5 as bd,P4 as be,nV as bf,Ole as bg,pp as c,Soe as d,uoe as e,hoe as f,Os as g,nt as h,i2 as i,o as j,Te as k,Tn as l,Sk as m,yt as n,Lse as o,Fre as p,aae as q,k as r,_re as s,Pc as t,xt as u,jee as v,Sne as w,Tne as x,Xle as y,iC as z};
|