@markus-global/cli 0.9.0-rc.4 → 0.9.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/markus.mjs +20 -3
- package/dist/web-ui/assets/{CommentInput-CxLXcfcF.js → CommentInput-CqhYZNbT.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-CKNSYhv-.js → ContentRenderer-vHk6I1iG.js} +2 -2
- package/dist/web-ui/assets/{Deliverables-Bsyrqm3g.js → Deliverables-DIvdy1w0.js} +1 -1
- package/dist/web-ui/assets/{Notifications-BtdaN4ll.js → Notifications-CBB92VJG.js} +1 -1
- package/dist/web-ui/assets/{Search-D-RYozg1.js → Search-CQM1v92W.js} +1 -1
- package/dist/web-ui/assets/{Settings-Dj0A3wpa.js → Settings-C0L0uTkp.js} +1 -1
- package/dist/web-ui/assets/{Store-CVUJt0ed.js → Store-DgIScz2q.js} +1 -1
- package/dist/web-ui/assets/{Team-DqWZbYHu.js → Team-Dyhls1uE.js} +4 -4
- package/dist/web-ui/assets/{Work-DzPfAazv.js → Work-CEcYUxLY.js} +1 -1
- package/dist/web-ui/assets/{arc-CN2ppnle.js → arc-BfqkV_ZO.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-BCyCczcB.js → architectureDiagram-3BPJPVTR-pRY0Akq6.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-oBXH0x4j.js → blockDiagram-GPEHLZMM-CA1v12Vg.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-D3Ip70St.js → c4Diagram-AAUBKEIU-Cl6BlYGC.js} +1 -1
- package/dist/web-ui/assets/channel-CJHgftXS.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-Ck4V3tEp.js → chunk-2J33WTMH-CRf-fEBX.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-B8QQg0yE.js → chunk-4BX2VUAB-CPg0Im0K.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-Cd0KY7r4.js → chunk-55IACEB6-DGKOo_Lu.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-9Gb42NfR.js → chunk-727SXJPM-C7Jx2e_J.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-DIEqJ3xt.js → chunk-AQP2D5EJ-B2ALjhp9.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-DlsiWe1p.js → chunk-FMBD7UC4-CBb9b1_X.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-CPWWtS2P.js → chunk-ND2GUHAM-Cbu1yYgB.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-DpbnSryq.js → chunk-QZHKN3VN-CUwF0I6V.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DXf3WVDF.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DXf3WVDF.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-BbLhIFzT.js → cose-bilkent-S5V4N54A-JD9TF1Cy.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-B1F8dY05.js → dagre-BM42HDAG-Ds-WBUBB.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-SoHlvoIA.js → diagram-2AECGRRQ-CwVDVdx0.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-C-yU0oNm.js → diagram-5GNKFQAL-BVS45hu_.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-DBHo4u4H.js → diagram-KO2AKTUF-DNBBw2DA.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-kWuXHRtJ.js → diagram-LMA3HP47-BC4lJHzi.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-C7fnQWqu.js → diagram-OG6HWLK6-B0dwFT4I.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-CtZvL-SR.js → erDiagram-TEJ5UH35-D-J6vXjx.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-Cfs9kfZC.js → flowDiagram-I6XJVG4X-CX8qvJfv.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CEtKqB1y.js → ganttDiagram-6RSMTGT7-BZRVpZXC.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-B1cso-l5.js → gitGraphDiagram-PVQCEYII-DjAUpgXi.js} +1 -1
- package/dist/web-ui/assets/{index-CWj-HTc1.js → index-DI4HXCnx.js} +5 -5
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-AoyIrSgD.js → infoDiagram-5YYISTIA-BuAcI3ii.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-sywnNDjh.js → ishikawaDiagram-YF4QCWOH-HOfZ5OqB.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-DMX_psfV.js → journeyDiagram-JHISSGLW-BzUG_v9c.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-CynP2ux-.js → kanban-definition-UN3LZRKU-BS_-yDXa.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-IG3mSoE5.js → mermaid.core-CIbUmMmc.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-Bq0Mw40L.js → mindmap-definition-RKZ34NQL-DQMNZacS.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-DfbC7vUP.js → pieDiagram-4H26LBE5-DltubZmW.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-C_mx2tqI.js → quadrantDiagram-W4KKPZXB-Bj_q4efH.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-COVDJ5HF.js → requirementDiagram-4Y6WPE33-CgdjvrEP.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-GAdaKQXV.js → sankeyDiagram-5OEKKPKP-DvqjTg3Z.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-BKrhFrFu.js → sequenceDiagram-3UESZ5HK-Duj47jYu.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-zL0HV9yi.js → stateDiagram-AJRCARHV-M2wbCfnk.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-Cqw9kJsP.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-BCa0Jk4B.js → timeline-definition-PNZ67QCA-C9K3wWmk.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-vJulsDaq.js → vennDiagram-CIIHVFJN-Cz7NTW6t.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-vDZxOXVD.js → wardley-L42UT6IY-D4vnZv2v.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO--kkhcxI4.js → wardleyDiagram-YWT4CUSO-D06TeXz0.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-B7LGiZK_.js → xychartDiagram-2RQKCTM6-Bl49BZON.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-CLxiisWS.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-ptsaBziw.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-ptsaBziw.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CM37YYgm.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-CIbUmMmc.js","assets/transform-CpIVI4vC.js","assets/Team-Dyhls1uE.js","assets/CommentInput-CqhYZNbT.js","assets/ContentRenderer-vHk6I1iG.js","assets/ChatHelpers-DDWzuvqW.js","assets/Work-CEcYUxLY.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-DIvdy1w0.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function xc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $f={exports:{}},$l={};var uy;function RS(){if(uy)return $l;uy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,l){var u=null;if(l!==void 0&&(u=""+l),o.key!==void 0&&(u=""+o.key),"key"in o){l={};for(var d in o)d!=="key"&&(l[d]=o[d])}else l=o;return o=l.ref,{$$typeof:e,type:r,key:u,ref:o!==void 0?o:null,props:l}}return $l.Fragment=t,$l.jsx=n,$l.jsxs=n,$l}var dy;function OS(){return dy||(dy=1,$f.exports=RS()),$f.exports}var s=OS(),Hf={exports:{}},Ot={};var my;function DS(){if(my)return Ot;my=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.iterator;function y(G){return G===null||typeof G!="object"?null:(G=x&&G[x]||G["@@iterator"],typeof G=="function"?G:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,T={};function C(G,le,I){this.props=G,this.context=le,this.refs=T,this.updater=I||w}C.prototype.isReactComponent={},C.prototype.setState=function(G,le){if(typeof G!="object"&&typeof G!="function"&&G!=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,G,le,"setState")},C.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function j(){}j.prototype=C.prototype;function _(G,le,I){this.props=G,this.context=le,this.refs=T,this.updater=I||w}var O=_.prototype=new j;O.constructor=_,N(O,C.prototype),O.isPureReactComponent=!0;var z=Array.isArray;function D(){}var H={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function Z(G,le,I){var Ee=I.ref;return{$$typeof:e,type:G,key:le,ref:Ee!==void 0?Ee:null,props:I}}function U(G,le){return Z(G.type,le,G.props)}function Y(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function se(G){var le={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(I){return le[I]})}var X=/\/+/g;function F(G,le){return typeof G=="object"&&G!==null&&G.key!=null?se(""+G.key):le.toString(36)}function J(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(D,D):(G.status="pending",G.then(function(le){G.status==="pending"&&(G.status="fulfilled",G.value=le)},function(le){G.status==="pending"&&(G.status="rejected",G.reason=le)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function B(G,le,I,Ee,Ue){var Oe=typeof G;(Oe==="undefined"||Oe==="boolean")&&(G=null);var We=!1;if(G===null)We=!0;else switch(Oe){case"bigint":case"string":case"number":We=!0;break;case"object":switch(G.$$typeof){case e:case t:We=!0;break;case p:return We=G._init,B(We(G._payload),le,I,Ee,Ue)}}if(We)return Ue=Ue(G),We=Ee===""?"."+F(G,0):Ee,z(Ue)?(I="",We!=null&&(I=We.replace(X,"$&/")+"/"),B(Ue,le,I,"",function(Et){return Et})):Ue!=null&&(Y(Ue)&&(Ue=U(Ue,I+(Ue.key==null||G&&G.key===Ue.key?"":(""+Ue.key).replace(X,"$&/")+"/")+We)),le.push(Ue)),1;We=0;var st=Ee===""?".":Ee+":";if(z(G))for(var dt=0;dt<G.length;dt++)Ee=G[dt],Oe=st+F(Ee,dt),We+=B(Ee,le,I,Oe,Ue);else if(dt=y(G),typeof dt=="function")for(G=dt.call(G),dt=0;!(Ee=G.next()).done;)Ee=Ee.value,Oe=st+F(Ee,dt++),We+=B(Ee,le,I,Oe,Ue);else if(Oe==="object"){if(typeof G.then=="function")return B(J(G),le,I,Ee,Ue);throw le=String(G),Error("Objects are not valid as a React child (found: "+(le==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":le)+"). If you meant to render a collection of children, use an array instead.")}return We}function Q(G,le,I){if(G==null)return G;var Ee=[],Ue=0;return B(G,Ee,"","",function(Oe){return le.call(I,Oe,Ue++)}),Ee}function re(G){if(G._status===-1){var le=G._result;le=le(),le.then(function(I){(G._status===0||G._status===-1)&&(G._status=1,G._result=I)},function(I){(G._status===0||G._status===-1)&&(G._status=2,G._result=I)}),G._status===-1&&(G._status=0,G._result=le)}if(G._status===1)return G._result.default;throw G._result}var ke=typeof reportError=="function"?reportError:function(G){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var le=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof G=="object"&&G!==null&&typeof G.message=="string"?String(G.message):String(G),error:G});if(!window.dispatchEvent(le))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",G);return}console.error(G)},$={map:Q,forEach:function(G,le,I){Q(G,function(){le.apply(this,arguments)},I)},count:function(G){var le=0;return Q(G,function(){le++}),le},toArray:function(G){return Q(G,function(le){return le})||[]},only:function(G){if(!Y(G))throw Error("React.Children.only expected to receive a single React element child.");return G}};return Ot.Activity=g,Ot.Children=$,Ot.Component=C,Ot.Fragment=n,Ot.Profiler=o,Ot.PureComponent=_,Ot.StrictMode=r,Ot.Suspense=m,Ot.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=H,Ot.__COMPILER_RUNTIME={__proto__:null,c:function(G){return H.H.useMemoCache(G)}},Ot.cache=function(G){return function(){return G.apply(null,arguments)}},Ot.cacheSignal=function(){return null},Ot.cloneElement=function(G,le,I){if(G==null)throw Error("The argument must be a React element, but you passed "+G+".");var Ee=N({},G.props),Ue=G.key;if(le!=null)for(Oe in le.key!==void 0&&(Ue=""+le.key),le)!W.call(le,Oe)||Oe==="key"||Oe==="__self"||Oe==="__source"||Oe==="ref"&&le.ref===void 0||(Ee[Oe]=le[Oe]);var Oe=arguments.length-2;if(Oe===1)Ee.children=I;else if(1<Oe){for(var We=Array(Oe),st=0;st<Oe;st++)We[st]=arguments[st+2];Ee.children=We}return Z(G.type,Ue,Ee)},Ot.createContext=function(G){return G={$$typeof:u,_currentValue:G,_currentValue2:G,_threadCount:0,Provider:null,Consumer:null},G.Provider=G,G.Consumer={$$typeof:l,_context:G},G},Ot.createElement=function(G,le,I){var Ee,Ue={},Oe=null;if(le!=null)for(Ee in le.key!==void 0&&(Oe=""+le.key),le)W.call(le,Ee)&&Ee!=="key"&&Ee!=="__self"&&Ee!=="__source"&&(Ue[Ee]=le[Ee]);var We=arguments.length-2;if(We===1)Ue.children=I;else if(1<We){for(var st=Array(We),dt=0;dt<We;dt++)st[dt]=arguments[dt+2];Ue.children=st}if(G&&G.defaultProps)for(Ee in We=G.defaultProps,We)Ue[Ee]===void 0&&(Ue[Ee]=We[Ee]);return Z(G,Oe,Ue)},Ot.createRef=function(){return{current:null}},Ot.forwardRef=function(G){return{$$typeof:d,render:G}},Ot.isValidElement=Y,Ot.lazy=function(G){return{$$typeof:p,_payload:{_status:-1,_result:G},_init:re}},Ot.memo=function(G,le){return{$$typeof:h,type:G,compare:le===void 0?null:le}},Ot.startTransition=function(G){var le=H.T,I={};H.T=I;try{var Ee=G(),Ue=H.S;Ue!==null&&Ue(I,Ee),typeof Ee=="object"&&Ee!==null&&typeof Ee.then=="function"&&Ee.then(D,ke)}catch(Oe){ke(Oe)}finally{le!==null&&I.types!==null&&(le.types=I.types),H.T=le}},Ot.unstable_useCacheRefresh=function(){return H.H.useCacheRefresh()},Ot.use=function(G){return H.H.use(G)},Ot.useActionState=function(G,le,I){return H.H.useActionState(G,le,I)},Ot.useCallback=function(G,le){return H.H.useCallback(G,le)},Ot.useContext=function(G){return H.H.useContext(G)},Ot.useDebugValue=function(){},Ot.useDeferredValue=function(G,le){return H.H.useDeferredValue(G,le)},Ot.useEffect=function(G,le){return H.H.useEffect(G,le)},Ot.useEffectEvent=function(G){return H.H.useEffectEvent(G)},Ot.useId=function(){return H.H.useId()},Ot.useImperativeHandle=function(G,le,I){return H.H.useImperativeHandle(G,le,I)},Ot.useInsertionEffect=function(G,le){return H.H.useInsertionEffect(G,le)},Ot.useLayoutEffect=function(G,le){return H.H.useLayoutEffect(G,le)},Ot.useMemo=function(G,le){return H.H.useMemo(G,le)},Ot.useOptimistic=function(G,le){return H.H.useOptimistic(G,le)},Ot.useReducer=function(G,le,I){return H.H.useReducer(G,le,I)},Ot.useRef=function(G){return H.H.useRef(G)},Ot.useState=function(G){return H.H.useState(G)},Ot.useSyncExternalStore=function(G,le,I){return H.H.useSyncExternalStore(G,le,I)},Ot.useTransition=function(){return H.H.useTransition()},Ot.version="19.2.4",Ot}var fy;function p0(){return fy||(fy=1,Hf.exports=DS()),Hf.exports}var k=p0();const gW=xc(k);var Ff={exports:{}},Hl={},qf={exports:{}},Gf={};var hy;function LS(){return hy||(hy=1,(function(e){function t(B,Q){var re=B.length;B.push(Q);e:for(;0<re;){var ke=re-1>>>1,$=B[ke];if(0<o($,Q))B[ke]=Q,B[re]=$,re=ke;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var Q=B[0],re=B.pop();if(re!==Q){B[0]=re;e:for(var ke=0,$=B.length,G=$>>>1;ke<G;){var le=2*(ke+1)-1,I=B[le],Ee=le+1,Ue=B[Ee];if(0>o(I,re))Ee<$&&0>o(Ue,I)?(B[ke]=Ue,B[Ee]=re,ke=Ee):(B[ke]=I,B[le]=re,ke=le);else if(Ee<$&&0>o(Ue,re))B[ke]=Ue,B[Ee]=re,ke=Ee;else break e}}return Q}function o(B,Q){var re=B.sortIndex-Q.sortIndex;return re!==0?re:B.id-Q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,d=u.now();e.unstable_now=function(){return u.now()-d}}var m=[],h=[],p=1,g=null,x=3,y=!1,w=!1,N=!1,T=!1,C=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function O(B){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=B)r(h),Q.sortIndex=Q.expirationTime,t(m,Q);else break;Q=n(h)}}function z(B){if(N=!1,O(B),!w)if(n(m)!==null)w=!0,D||(D=!0,se());else{var Q=n(h);Q!==null&&J(z,Q.startTime-B)}}var D=!1,H=-1,W=5,Z=-1;function U(){return T?!0:!(e.unstable_now()-Z<W)}function Y(){if(T=!1,D){var B=e.unstable_now();Z=B;var Q=!0;try{e:{w=!1,N&&(N=!1,j(H),H=-1),y=!0;var re=x;try{t:{for(O(B),g=n(m);g!==null&&!(g.expirationTime>B&&U());){var ke=g.callback;if(typeof ke=="function"){g.callback=null,x=g.priorityLevel;var $=ke(g.expirationTime<=B);if(B=e.unstable_now(),typeof $=="function"){g.callback=$,O(B),Q=!0;break t}g===n(m)&&r(m),O(B)}else r(m);g=n(m)}if(g!==null)Q=!0;else{var G=n(h);G!==null&&J(z,G.startTime-B),Q=!1}}break e}finally{g=null,x=re,y=!1}Q=void 0}}finally{Q?se():D=!1}}}var se;if(typeof _=="function")se=function(){_(Y)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,F=X.port2;X.port1.onmessage=Y,se=function(){F.postMessage(null)}}else se=function(){C(Y,0)};function J(B,Q){H=C(function(){B(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(B){switch(x){case 1:case 2:case 3:var Q=3;break;default:Q=x}var re=x;x=Q;try{return B()}finally{x=re}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(B,Q){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var re=x;x=B;try{return Q()}finally{x=re}},e.unstable_scheduleCallback=function(B,Q,re){var ke=e.unstable_now();switch(typeof re=="object"&&re!==null?(re=re.delay,re=typeof re=="number"&&0<re?ke+re:ke):re=ke,B){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=re+$,B={id:p++,callback:Q,priorityLevel:B,startTime:re,expirationTime:$,sortIndex:-1},re>ke?(B.sortIndex=re,t(h,B),n(m)===null&&B===n(h)&&(N?(j(H),H=-1):N=!0,J(z,re-ke))):(B.sortIndex=$,t(m,B),w||y||(w=!0,D||(D=!0,se()))),B},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(B){var Q=x;return function(){var re=x;x=Q;try{return B.apply(this,arguments)}finally{x=re}}}})(Gf)),Gf}var py;function IS(){return py||(py=1,qf.exports=LS()),qf.exports}var Vf={exports:{}},nr={};var gy;function PS(){if(gy)return nr;gy=1;var e=p0();function t(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function l(m,h,p){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:h,implementation:p}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return nr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,nr.createPortal=function(m,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return l(m,h,null,p)},nr.flushSync=function(m){var h=u.T,p=r.p;try{if(u.T=null,r.p=2,m)return m()}finally{u.T=h,r.p=p,r.d.f()}},nr.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(m,h))},nr.prefetchDNS=function(m){typeof m=="string"&&r.d.D(m)},nr.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var p=h.as,g=d(p,h.crossOrigin),x=typeof h.integrity=="string"?h.integrity:void 0,y=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?r.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:g,integrity:x,fetchPriority:y}):p==="script"&&r.d.X(m,{crossOrigin:g,integrity:x,fetchPriority:y,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},nr.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=d(h.as,h.crossOrigin);r.d.M(m,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(m)},nr.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,g=d(p,h.crossOrigin);r.d.L(m,p,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},nr.preloadModule=function(m,h){if(typeof m=="string")if(h){var p=d(h.as,h.crossOrigin);r.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(m)},nr.requestFormReset=function(m){r.d.r(m)},nr.unstable_batchedUpdates=function(m,h){return m(h)},nr.useFormState=function(m,h,p){return u.H.useFormState(m,h,p)},nr.useFormStatus=function(){return u.H.useHostTransitionStatus()},nr.version="19.2.4",nr}var by;function P4(){if(by)return Vf.exports;by=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(),Vf.exports=PS(),Vf.exports}var xy;function zS(){if(xy)return Hl;xy=1;var e=IS(),t=p0(),n=P4();function r(a){var i="https://react.dev/errors/"+a;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var c=2;c<arguments.length;c++)i+="&args[]="+encodeURIComponent(arguments[c])}return"Minified React error #"+a+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function l(a){var i=a,c=a;if(a.alternate)for(;i.return;)i=i.return;else{a=i;do i=a,(i.flags&4098)!==0&&(c=i.return),a=i.return;while(a)}return i.tag===3?c:null}function u(a){if(a.tag===13){var i=a.memoizedState;if(i===null&&(a=a.alternate,a!==null&&(i=a.memoizedState)),i!==null)return i.dehydrated}return null}function d(a){if(a.tag===31){var i=a.memoizedState;if(i===null&&(a=a.alternate,a!==null&&(i=a.memoizedState)),i!==null)return i.dehydrated}return null}function m(a){if(l(a)!==a)throw Error(r(188))}function h(a){var i=a.alternate;if(!i){if(i=l(a),i===null)throw Error(r(188));return i!==a?null:a}for(var c=a,f=i;;){var b=c.return;if(b===null)break;var v=b.alternate;if(v===null){if(f=b.return,f!==null){c=f;continue}break}if(b.child===v.child){for(v=b.child;v;){if(v===c)return m(b),a;if(v===f)return m(b),i;v=v.sibling}throw Error(r(188))}if(c.return!==f.return)c=b,f=v;else{for(var A=!1,L=b.child;L;){if(L===c){A=!0,c=b,f=v;break}if(L===f){A=!0,f=b,c=v;break}L=L.sibling}if(!A){for(L=v.child;L;){if(L===c){A=!0,c=v,f=b;break}if(L===f){A=!0,f=v,c=b;break}L=L.sibling}if(!A)throw Error(r(189))}}if(c.alternate!==f)throw Error(r(190))}if(c.tag!==3)throw Error(r(188));return c.stateNode.current===c?a:i}function p(a){var i=a.tag;if(i===5||i===26||i===27||i===6)return a;for(a=a.child;a!==null;){if(i=p(a),i!==null)return i;a=a.sibling}return null}var g=Object.assign,x=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),_=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function se(a){return a===null||typeof a!="object"?null:(a=Y&&a[Y]||a["@@iterator"],typeof a=="function"?a:null)}var X=Symbol.for("react.client.reference");function F(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===X?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case N:return"Fragment";case C:return"Profiler";case T:return"StrictMode";case z:return"Suspense";case D:return"SuspenseList";case Z:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case w:return"Portal";case _:return a.displayName||"Context";case j:return(a._context.displayName||"Context")+".Consumer";case O:var i=a.render;return a=a.displayName,a||(a=i.displayName||i.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case H:return i=a.displayName||null,i!==null?i:F(a.type)||"Memo";case W:i=a._payload,a=a._init;try{return F(a(i))}catch{}}return null}var J=Array.isArray,B=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re={pending:!1,data:null,method:null,action:null},ke=[],$=-1;function G(a){return{current:a}}function le(a){0>$||(a.current=ke[$],ke[$]=null,$--)}function I(a,i){$++,ke[$]=a.current,a.current=i}var Ee=G(null),Ue=G(null),Oe=G(null),We=G(null);function st(a,i){switch(I(Oe,i),I(Ue,a),I(Ee,null),i.nodeType){case 9:case 11:a=(a=i.documentElement)&&(a=a.namespaceURI)?Ox(a):0;break;default:if(a=i.tagName,i=i.namespaceURI)i=Ox(i),a=Dx(i,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}le(Ee),I(Ee,a)}function dt(){le(Ee),le(Ue),le(Oe)}function Et(a){a.memoizedState!==null&&I(We,a);var i=Ee.current,c=Dx(i,a.type);i!==c&&(I(Ue,a),I(Ee,c))}function gt(a){Ue.current===a&&(le(Ee),le(Ue)),We.current===a&&(le(We),Pl._currentValue=re)}var jt,Jt;function Rt(a){if(jt===void 0)try{throw Error()}catch(c){var i=c.stack.trim().match(/\n( *(at )?)/);jt=i&&i[1]||"",Jt=-1<c.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<c.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+jt+a+Jt}var be=!1;function Me(a,i){if(!a||be)return"";be=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var f={DetermineComponentFrameRoot:function(){try{if(i){var je=function(){throw Error()};if(Object.defineProperty(je.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(je,[])}catch(Se){var we=Se}Reflect.construct(a,[],je)}else{try{je.call()}catch(Se){we=Se}a.call(je.prototype)}}else{try{throw Error()}catch(Se){we=Se}(je=a())&&typeof je.catch=="function"&&je.catch(function(){})}}catch(Se){if(Se&&we&&typeof Se.stack=="string")return[Se.stack,we.stack]}return[null,null]}};f.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(f.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(f.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var v=f.DetermineComponentFrameRoot(),A=v[0],L=v[1];if(A&&L){var ne=A.split(`
|
|
@@ -350,7 +350,7 @@ Web应用:2次SVG上传XSS(已修复)
|
|
|
350
350
|
|
|
351
351
|
**部署:** 灰度发布 → 5%流量 → 48小时监控 → 全量上线`,seoMatrix:"关键词研究矩阵,涵盖8个产品垂直领域的1,200+关键词。包含搜索量趋势、竞争分数、内容差距分析、SERP功能机会,以及6个月编辑日历和预计流量影响(+340%自然流量)。",financeReport:"2025年5月月度财务结算。营收:$2.4M(环比+18%)。关键亮点:SaaS ARR 突破 $24M 里程碑,CAC 回收期降至11个月,毛利率提升至78%。包含部门损益分析和现金流预测。",apiDocsV2:"API v2 开发者门户文档。涵盖认证(OAuth 2.0 + API Key)、86个端点(含5种语言代码示例)、Webhook集成指南、速率限制策略、版本控制策略及交互式API测试环境配置。",interviewNotes:"24个用户访谈的综合分析,覆盖4类用户画像(高级用户、管理员、新用户、流失用户)。关键发现:引导流程第3步存在阻力、仪表盘自定义是首要功能需求、移动端使用量超预期3倍。含亲和图和视频片段。",wireframes:"移动应用 v2.0 高保真线框图。涵盖5个用户流程共32个界面:引导、仪表盘、通知、设置和离线模式。包含手势标注、转场规格及 iOS/Android 平台适配。",patentAnalysis:"AI驱动工作流自动化领域847项专利的格局分析。识别12个自由实施风险、3个潜在许可机会和5个专有知识产权申请空白领域。包含权利要求映射和现有技术文献。",testFramework:"端到端测试自动化框架,支持API、UI和性能测试。跨8个模块共312个测试用例。包含并行执行(4倍加速)、Playwright视觉回归测试、负载测试场景(1万并发用户)及Slack集成报告。",socialAssets:"产品发布营销活动的60+社交媒体素材库。包含轮播模板、视频故事板、A/B标题变体、平台尺寸适配(LinkedIn、Twitter/X、Instagram)、品牌规范配色和发布排期。"},IO={general:"#综合频道",announcements:"#公告",watercooler:"#茶水间"},PO={general:{secretaryMorning:"早上好,团队。当前18个员工在线,12个任务进行中。今日重点:支付API审查、仪表盘组件开发、Q2调研截止日期。",alexReport:"进展不错。@研究主管——周五董事会需要竞争分析报告,周四前能完成吗?",researchLeadReply:"没问题,Alex。报告已完成90%。周四上午前会提交带有摘要的最终版本。",engLeadApi:"支付对账API已提交审查。@测试主管 请优先安排——涉及财务核心链路。",qaLeadReply:"收到,今天出测试报告。回归测试发现了回调处理器的2个边界情况——修复已提交。",pmStandup:"快速更新——引导流程重设计稿已由James审批通过。进入迭代规划。@前端开发 能评估一下仪表盘组件的工作量吗?",frontendEstimate:"仪表盘卡片:2天。图表组件:3天。今天下班前会把组件拆分方案放到交付物中。",chiefOfStaffSync:"跨团队同步:工程团队被产品团队的设计规范阻塞。@UI设计师 请今天将设计规范导出到共享仓库。",uiDesignerTokens:"完成!设计规范已导出到共享包。42个颜色变量、8个间距尺度、6个字体预设。PR链接已放入交付物。",sarahReview:"今天效率很高。3个PR已合并,2个交付物已验证。继续保持这个节奏冲刺Q2。",dataAnalystInsight:"仪表盘数据分析:89%的用户在3分钟内完成引导流程。移动端转化率仍偏低62%——优先进行移动端优化。",devopsDeployment:"预发布环境部署完成。所有健康检查通过。性能指标:API p99延迟180ms,较上周340ms大幅下降。",strategyMarket:"竞争情报更新:本周两家竞品发布了类似功能。我们的核心优势仍在于自主Agent协调——没有竞品具备多Agent任务委派能力。"},engineering:{sarahArchitecture:"团队,我审阅了支付架构文档。幂等方案看起来很扎实。一个顾虑:高负载下分布式锁过期的情况考虑了吗?",srBackendReply:"好问题。我加了滑动窗口续期机制——当操作还在进行且TTL达到80%时自动延期。PR已更新。",devopsCi:"CI流水线全绿。缓存优化后构建时间降至4分32秒,正在部署到预发布环境。",sarahBuildTime:"构建时间优化得不错。下个迭代目标3分钟。@运维工程师 能看看测试套件并行化吗?",frontendLib:"组件库完成80%。图表、表格、表单、弹窗均已完成,下一步是数据网格。",backendMigration:"Payment v2数据库迁移脚本已就绪。向后兼容的Schema设计——确认零停机部署。",engLeadCodeReview:"PR #127–#134 代码审查完毕,全部通过。@高级后端工程师 准备好后合并支付对账分支。",securityDep:"@高级后端工程师 注意——支付模块发现2个有CVE的传递依赖。jsonwebtoken需要升级到9.x。修补PR马上提交。",qaE2e:"端到端测试套件扩展至312个用例,通过率98.4%。5个不稳定测试是时序问题——已通过重试逻辑修复。全量回归测试已就绪。",sarahShipIt:"大家进展都很出色。目标周三冻结staging环境。发布吧!🚀",engLeadWrapUp:"收到。我已更新Sprint看板——23个任务已完成,4个在审查中,2个被支付模块阻塞。已将阻塞任务指派给高级后端开发优先处理。确认周三冻结staging环境,明天上午我来协调最后一轮代码审查。"},product:{jamesFunnel:"根据@数据分析师的漏斗分析,我们优先推进引导流程重设计。这是Q2的头号项目。",pmMockups:"@UI设计师 周四前能出设计稿吗?我今天准备PRD。",uiDesignerReply:"已经开始了!Figma链接会放到交付物中。新的设计规范也已就绪。",emilyA11y:"方向很好。确保达到无障碍标准——至少WCAG AA。我周四下午审查。",dataAnalystConversion:"新结账流程在A/B测试中转化率提升23%。完整报告已放入交付物。"},alpha:{engLeadSprint:"Alpha冲刺第3天。后端API完成,前端集成已启动。@移动端开发——支付接口已在预发布环境上线。",mobileIntegration:"立即开始集成。支付流程预计2天完成。",jamesTimeline:"时间紧但进度正常。@测试主管 周五前准备好端到端测试计划。这次发布董事会在关注。",qaLeadTestPlan:"测试计划将覆盖支付流程、异常恢复和压力测试。我会和@安全审计员协调上线前的安全扫描。"}},zO={humans:TO,agents:EO,teams:AO,projects:_O,tasks:jO,taskDesc:MO,requirements:RO,reqDesc:OO,deliverables:DO,delSummary:LO,channels:IO,messages:PO},bW=[{code:"en",label:"English"},{code:"zh-CN",label:"中文"}],BO="common",UO=["common","nav","auth","home","team","work","settings","onboarding","builder","store","agent","deliverables","reports","showcase"];hr.use(Y4).use(j7).init({resources:{en:{common:VN,nav:sC,auth:uC,home:RC,team:qC,work:rT,settings:DT,onboarding:FT,builder:w9,store:I9,agent:Y9,deliverables:kE,reports:LE,showcase:WE},"zh-CN":{common:$_,nav:ej,auth:sj,home:Ej,team:Bj,work:Zj,settings:_M,onboarding:zM,builder:gR,store:MR,agent:qR,deliverables:mO,reports:CO,showcase:zO}},fallbackLng:"en",defaultNS:BO,ns:[...UO],interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],lookupLocalStorage:"markus-language",caches:["localStorage"]}});const $O="modulepreload",HO=function(e){return"/"+e},Hy={},qr=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let m=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),d=u?.nonce||u?.getAttribute("nonce");o=m(n.map(h=>{if(h=HO(h),h in Hy)return;Hy[h]=!0;const p=h.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":$O,p||(x.as="script"),x.crossOrigin="",x.href=h,d&&x.setAttribute("nonce",d),document.head.appendChild(x),p)return new Promise((y,w)=>{x.addEventListener("load",y),x.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(u){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=u,window.dispatchEvent(d),!d.defaultPrevented)throw u}return o.then(u=>{for(const d of u||[])d.status==="rejected"&&l(d.reason);return t().catch(l)})},me={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",SETTINGS:"settings",NOTIFICATIONS:"notifications",SEARCH:"search"},FO=new Set(Object.values(me)),qO={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},X4={[me.HOME]:"overview",[me.TEAM]:"team",[me.WORK]:"tasks",[me.STORE]:"explore",[me.BUILDER]:"assets",[me.DELIVERABLES]:"output",[me.SETTINGS]:"settings",[me.NOTIFICATIONS]:"notifications",[me.SEARCH]:"search"},Fy=Object.fromEntries(Object.entries(X4).map(([e,t])=>[t,e]));function ap(e){return X4[e]??e}function oc(e){return Fy[e]?Fy[e]:FO.has(e)?e:qO[e]??me.HOME}function lc(){const e=window.location.hash.slice(1).split("/")[0];return oc(e)}function Si(e,t){const n=ap(e);return t?`#${n}/${t}`:`#${n}`}const Q4={[me.STORE]:me.BUILDER},cc={[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",[me.NOTIFICATIONS]:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0"},GO=[{key:"quick",label:"QUICK"},{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],VO=[{id:me.NOTIFICATIONS,label:"Notifications",section:"quick"},{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"}],KO=[{id:me.HOME,label:"Overview",group:[me.HOME]},{id:me.TEAM,label:"Team",group:[me.TEAM]},{id:me.NOTIFICATIONS,label:"Notifications",group:[me.NOTIFICATIONS]},{id:me.WORK,label:"Tasks",group:[me.WORK]},{id:me.DELIVERABLES,label:"Output",group:[me.DELIVERABLES]}];let bi=0,Ud=!0;function Z4(){return typeof window<"u"?window.markusDesktop?.browser:void 0}function xW(){return bi>0}function yW(){return Ud}function Jf(e){Ud!==e&&(Ud=e,e||Z4()?.hideAll?.(),window.dispatchEvent(new CustomEvent("markus:native-browser-page",{detail:{allowed:e}})),e&&bi===0&&window.dispatchEvent(new CustomEvent("markus:embedded-browser-resync")))}function WO(){bi+=1,bi===1&&(Z4()?.hideAll?.(),window.dispatchEvent(new CustomEvent("markus:native-browser-overlay",{detail:{active:!0}})));let e=!1;return()=>{e||(e=!0,bi=Math.max(0,bi-1),bi===0&&(window.dispatchEvent(new CustomEvent("markus:native-browser-overlay",{detail:{active:!1}})),Ud&&window.dispatchEvent(new CustomEvent("markus:embedded-browser-resync"))))}}const xi="/api";class YO extends Error{code;constructor(t,n){super(t),this.code=n}}const Is=new Map,XO=3e3;function Wa(e){if(!e){Is.clear();return}for(const t of Is.keys())t.startsWith(e)&&Is.delete(t)}async function K(e,t){const r=(t?.method?.toUpperCase()??"GET")==="GET"&&!t?.body;if(r){const l=Is.get(e);if(l&&Date.now()-l.ts<XO)return l.promise}else{const l=e.replace(/\/[^/]+$/,"");for(const u of Is.keys())(u===e||u.startsWith(l))&&Is.delete(u)}const o=(async()=>{const l=await fetch(`${xi}${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 u="",d;try{const m=await l.json();u=m.error??m.message??"",d=m.code}catch{}throw new YO(u||`API error: ${l.status}`,d)}return l.json()})();return r&&(Is.set(e,{promise:o,ts:Date.now()}),o.catch(()=>Is.delete(e))),o}const Ce={agents:{list:()=>K("/agents").then(e=>({...e,agents:e.agents.filter(t=>t.name)})),get:e=>K(`/agents/${e}`),create:(e,t,n,r)=>K("/agents",{method:"POST",body:JSON.stringify({name:e,...t?{roleName:t}:{},agentRole:n,teamId:r})}),start:e=>K(`/agents/${e}/start`,{method:"POST"}),stop:e=>K(`/agents/${e}/stop`,{method:"POST"}),pause:(e,t)=>K(`/agents/${e}/stop`,{method:"POST"}),resume:e=>K(`/agents/${e}/start`,{method:"POST"}),cancelProcessing:e=>K(`/agents/${e}/cancel-processing`,{method:"POST"}),remove:(e,t)=>K(`/agents/${e}${t?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,t)=>K(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(t)}),getMemory:e=>K(`/agents/${e}/memory`),getMemorySession:(e,t)=>K(`/agents/${e}/memory/sessions/${encodeURIComponent(t)}`),updateDailyMemory:(e,t)=>K(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:t})}),updateLongTermMemory:(e,t,n)=>K(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:t,content:n})}),getFiles:e=>K(`/agents/${e}/files`),getFilesMap:e=>K(`/agents/${e}/files`),updateFile:(e,t,n)=>K(`/agents/${e}/files/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:n})}),updateSystemPrompt:(e,t)=>K(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:t})}),roleStatus:e=>K(`/agents/${e}/role-status`),roleDiff:(e,t="ROLE.md")=>K(`/agents/${e}/role-diff?file=${encodeURIComponent(t)}`),roleSync:(e,t)=>K(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(t?{files:t}:{})}),roleSmartSync:(e,t)=>K(`/agents/${e}/role-smart-sync`,{method:"POST",body:JSON.stringify({file:t})}),roleUpdates:()=>K("/agents/role-updates"),addSkill:(e,t)=>K(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:t})}),removeSkill:(e,t)=>K(`/agents/${e}/skills/${encodeURIComponent(t)}`,{method:"DELETE"}),getHeartbeat:e=>K(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>K(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),cancelWakeup:(e,t)=>K(`/agents/${e}/wakeups/${t}`,{method:"DELETE"}),getRecentActivities:e=>K(`/agents/${e}/recent-activities`),getActivityLogs:(e,t)=>K(`/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 r=n.toString();return K(`/agents/${e}/activities${r?"?"+r:""}`)},getMindState:e=>K(`/agents/${e}/mind`),sendCommand:(e,t,n)=>K(`/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 r=n.toString();return K(`/agents/${e}/mailbox${r?"?"+r:""}`)},getDecisions:(e,t=50)=>K(`/agents/${e}/decisions?limit=${t}`),messageStream:(e,t,n,r,o,l,u,d,m,h,p,g,x)=>new Promise(async(y,w)=>{let N="",T,C;try{const j=await fetch(`${xi}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:t,stream:!0,images:l,fileNames:p,sessionId:u??void 0,isRetry:d||void 0,isResume:m||void 0,replyTo:g||void 0,...x?.provider&&x?.model?{provider:x.provider,model:x.model}:{}}),signal:o});if(!j.ok){w(new Error(`API error: ${j.status}`));return}const _=j.body?.getReader();if(!_){w(new Error("No reader"));return}const O=new TextDecoder;let z="";for(;;){const{done:D,value:H}=await _.read();if(D)break;z+=O.decode(H,{stream:!0});const W=z.split(`
|
|
352
352
|
`);z=W.pop()??"";for(const Z of W){const U=Z.trim();if(U.startsWith("data: "))try{const Y=JSON.parse(U.slice(6));if(Y.type==="session_start"&&Y.sessionId){T=Y.sessionId;const se=Y.userMessageId;h?.({type:"session_start",content:"",createdAt:new Date().toISOString(),sessionId:Y.sessionId,userMessageId:se})}else if(Y.type==="text_delta"&&Y.text)N+=Y.text,n(Y.text);else if(Y.type==="thinking_delta"&&Y.thinking)n?.(`<think>${Y.thinking}</think>`);else if(Y.type==="done"){N=Y.content||N,Y.sessionId&&(T=Y.sessionId);const se=Y.segments;se&&(C=se);const X=!!Y.merged;y({content:N,sessionId:T,segments:C,merged:X}),_.cancel().catch(()=>{});return}else if(Y.type==="error"){const se=Y;se.sessionId&&(T=se.sessionId);const X=new Error(se.message??se.error??"Unknown stream error");X.sessionId=se.sessionId,w(X),_.cancel().catch(()=>{});return}else Y.type==="thinking_commit"&&Y.thinking?h?.({type:"thinking_commit",content:Y.thinking,createdAt:Y.createdAt??new Date().toISOString()}):Y.type==="text_commit"&&Y.text?h?.({type:"text_commit",content:Y.text,createdAt:Y.createdAt??new Date().toISOString()}):Y.type==="tool_call_start"&&Y.toolCall?.name?r?.({tool:Y.toolCall.name,phase:"start"}):Y.type==="agent_tool"&&Y.tool&&Y.phase?Y.phase==="start"?r?.({tool:Y.tool,phase:"start",arguments:Y.arguments}):Y.phase==="end"&&r?.({tool:Y.tool,phase:"end",success:Y.success,arguments:Y.arguments,result:Y.result,error:Y.error,durationMs:Y.durationMs}):Y.type==="tool_output"&&Y.tool?r?.({tool:Y.tool,phase:"output",output:Y.text}):Y.type==="subagent_progress"&&Y.tool?r?.({tool:Y.tool,phase:"subagent_progress",subagentEvent:Y.subagentEvent}):Y.type==="heartbeat"&&r?.({tool:"",phase:"heartbeat"})}catch{}}}y({content:N,sessionId:T,segments:C})}catch(j){j instanceof Error&&j.name==="AbortError"?y({content:N,sessionId:T,segments:C}):w(j)}})},roles:{list:()=>K("/roles")},teams:{list:e=>K(`/teams?orgId=${e??"default"}`),create:(e,t)=>K("/teams",{method:"POST",body:JSON.stringify({name:e,description:t})}),update:(e,t)=>K(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:(e,t,n)=>K(`/teams/${e}?deleteMembers=${t?"true":"false"}${n?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,t,n)=>K(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n})}),removeMember:(e,t)=>K(`/teams/${e}/members/${t}`,{method:"DELETE"}),startAll:e=>K(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>K(`/teams/${e}/stop`,{method:"POST"}),pauseAll:(e,t)=>K(`/teams/${e}/stop`,{method:"POST"}),resumeAll:e=>K(`/teams/${e}/start`,{method:"POST"}),status:e=>K(`/teams/${e}/status`),getFiles:e=>K(`/teams/${e}/files`),getFile:(e,t)=>K(`/teams/${e}/files/${encodeURIComponent(t)}`),updateFile:(e,t,n)=>K(`/teams/${e}/files/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:n})}),exportTeam:e=>K(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>K(`/teams/${e}/export`)},externalAgents:{list:e=>K(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const t=new URLSearchParams;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 K(`/tasks${n?`?${n}`:""}`)},get:e=>K(`/tasks/${e}`),create:(e,t,n,r,o,l,u,d,m,h,p)=>K("/tasks",{method:"POST",body:JSON.stringify({title:e,description:t,assignedAgentId:n,reviewerId:r,priority:o,projectId:l,blockedBy:u,requirementId:d,taskType:m,scheduleConfig:h,reviewerType:p})}),update:(e,t)=>K(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),updateStatus:(e,t)=>K(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:t})}),assign:(e,t)=>K(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:t})}),approve:(e,t)=>K(`/tasks/${e}/approve`,{method:"POST",body:JSON.stringify({runNow:t??void 0})}),reject:e=>K(`/tasks/${e}/reject`,{method:"POST"}),cancel:(e,t=!1)=>K(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:t})}),getDependentCount:e=>K(`/tasks/${e}/dependents`),board:e=>{const t=new URLSearchParams;e?.projectId&&t.set("projectId",e.projectId);const n=t.toString();return K(`/taskboard${n?`?${n}`:""}`)},listSubtasks:e=>K(`/tasks/${e}/subtasks`),createSubtask:(e,t)=>K(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:t})}),completeSubtask:(e,t)=>K(`/tasks/${e}/subtasks/${t}/complete`,{method:"POST"}),cancelSubtask:(e,t)=>K(`/tasks/${e}/subtasks/${t}/cancel`,{method:"POST"}),deleteSubtask:(e,t)=>K(`/tasks/${e}/subtasks/${t}`,{method:"DELETE"}),run:e=>K(`/tasks/${e}/run`,{method:"POST"}),getLogs:(e,t)=>K(`/tasks/${e}/logs${t!=null?`?round=${t}`:""}`),getLogsSummary:e=>K(`/tasks/${e}/logs/summary`),accept:(e,t)=>K(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerId:t??"human"})}),revision:(e,t,n)=>K(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:t,reviewerId:n??"human"})}),archive:e=>K(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>K(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>K(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>K(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>K(`/tasks/${e}/comments`),getHistory:e=>K(`/tasks/${e}/history`),addComment:(e,t,n,r,o,l,u)=>K(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:t,authorId:o??"human",authorName:n??"User",authorType:"human",attachments:r,mentions:l,replyTo:u})}),pauseSchedule:e=>K(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>K(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>K(`/tasks/${e}/schedule/run-now`,{method:"POST"}),updateSchedule:(e,t)=>K(`/tasks/${e}/schedule`,{method:"PUT",body:JSON.stringify(t)}),deliverables:e=>{const t=e?`?projectId=${encodeURIComponent(e)}`:"";return K(`/tasks/deliverables${t}`)}},files:{preview:e=>K(`/files/preview?path=${encodeURIComponent(e)}`),streamUrl:e=>`${xi}/files/stream?path=${encodeURIComponent(e)}`,reveal:e=>K("/files/reveal",{method:"POST",body:JSON.stringify({path:e})}),check:e=>K("/files/check",{method:"POST",body:JSON.stringify({paths:e})}),write:(e,t)=>K("/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);const n=t.toString();return K(`/requirements${n?`?${n}`:""}`)},get:e=>K(`/requirements/${e}`),create:e=>K("/requirements",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>K(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(t)}),updateStatus:(e,t)=>K(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:t})}),approve:e=>K(`/requirements/${e}/approve`,{method:"POST"}),reject:(e,t)=>K(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:t})}),cancel:e=>K(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>K(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>K(`/requirements/${e}/comments`),getHistory:e=>K(`/requirements/${e}/history`),addComment:(e,t,n,r,o,l,u)=>K(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:t,authorId:o??"human",authorName:n??"User",authorType:"human",attachments:r,mentions:l,replyTo:u})})},users:{list:e=>K(`/users?orgId=${e??"default"}`),create:(e,t,n,r,o,l)=>K("/users",{method:"POST",body:JSON.stringify({name:e,role:t,orgId:n,email:r,password:o,teamId:l})}),update:(e,t)=>K(`/users/${e}`,{method:"PATCH",body:JSON.stringify(t)}),resetPassword:(e,t)=>K(`/users/${e}/reset-password`,{method:"POST",body:JSON.stringify({password:t})}),reinvite:e=>K(`/users/${e}/reinvite`,{method:"POST"}),remove:e=>K(`/users/${e}`,{method:"DELETE"})},teamTemplates:{list:e=>{const t=e?`?q=${encodeURIComponent(e)}`:"";return K(`/team-templates${t}`)},get:e=>K(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>K(`/ops/dashboard?period=${e}`)},agentMetrics:(e,t="24h")=>K(`/agents/${e}/metrics?period=${t}`),usage:{summary:(e="default",t)=>{const n=new URLSearchParams({orgId:e});return t&&n.set("period",t),K(`/usage?${n}`)},agents:(e="default")=>K(`/usage/agents?orgId=${e}`)},cu:{status:()=>K("/cu/status")},health:()=>K("/health"),system:{openPath:e=>K("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>K("/system/storage"),orphans:()=>K("/system/storage/orphans"),purgeOrphans:e=>K("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},settings:{getLlm:()=>K("/settings/llm"),getOrg:()=>K("/settings/org"),updateOrg:e=>K("/settings/org",{method:"PUT",body:JSON.stringify({name:e})}),syncOpenRouter:()=>K("/settings/llm/sync-openrouter",{method:"POST",body:JSON.stringify({})}),getRouting:()=>K("/settings/llm/routing"),updateRouting:e=>K("/settings/llm",{method:"POST",body:JSON.stringify(e)}),getAgent:()=>K("/settings/agent"),updateAgent:e=>K("/settings/agent",{method:"POST",body:JSON.stringify(e)}),getBrowser:()=>K("/settings/browser"),updateBrowser:e=>K("/settings/browser",{method:"POST",body:JSON.stringify(e)}),testAutoClick:()=>K("/settings/browser/test-auto-click",{method:"POST"}),downloadExtensionZip:()=>{const e=`${xi}/settings/browser/extension.zip`,t={},n=localStorage.getItem("markus_token");return n&&(t.Authorization=`Bearer ${n}`),fetch(e,{headers:t}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.blob()}).then(r=>{const o=document.createElement("a");o.href=URL.createObjectURL(r),o.download="markus-browser-extension.zip",o.click(),URL.revokeObjectURL(o.href)})},openExtensionsPage:()=>K("/settings/browser/open-extensions-page",{method:"POST"}),testConcurrentBrowserQuick:()=>K("/settings/browser/test-concurrent",{method:"POST",body:JSON.stringify({mode:"quick"})}),testConcurrentBrowserChaos:async(e,t)=>{const n={"Content-Type":"application/json"},r=localStorage.getItem("markus_token");r&&(n.Authorization=`Bearer ${r}`);const o=await fetch(`${xi}/settings/browser/test-concurrent`,{method:"POST",headers:n,body:JSON.stringify({mode:"chaos",durationSec:e.durationSec??120,agents:e.agents??3})});if(!o.ok)throw new Error(`HTTP ${o.status}`);const l=o.body.getReader(),u=new TextDecoder;let d="";for(;;){const{done:m,value:h}=await l.read();if(m)break;d+=u.decode(h,{stream:!0});const p=d.split(`
|
|
353
|
-
`);d=p.pop()??"";let g="";for(const x of p)if(x.startsWith("event: "))g=x.slice(7).trim();else if(x.startsWith("data: ")){try{t({type:g||"unknown",...JSON.parse(x.slice(6))})}catch{}g=""}}},stopConcurrentBrowserTest:()=>K("/settings/browser/test-concurrent",{method:"DELETE"}),getSearch:()=>K("/settings/search"),updateSearch:e=>K("/settings/search",{method:"POST",body:JSON.stringify(e)}),testSearch:(e,t)=>K("/settings/search/test",{method:"POST",body:JSON.stringify({provider:e,...t})}),getRemote:()=>K("/settings/remote"),enableRemote:()=>K("/settings/remote/enable",{method:"POST"}),disableRemote:()=>K("/settings/remote/disable",{method:"POST"}),getFeishuIntegration:()=>K("/settings/integrations/feishu"),saveFeishuIntegration:e=>K("/settings/integrations/feishu",{method:"POST",body:JSON.stringify(e)}),testFeishuConnection:e=>K("/settings/integrations/feishu/test",{method:"POST",body:JSON.stringify(e)}),sendFeishuTestMessage:e=>K("/settings/integrations/feishu/test-message",{method:"POST",body:JSON.stringify(e)}),deleteFeishuIntegration:()=>K("/settings/integrations/feishu",{method:"DELETE"}),listFeishuChats:()=>K("/settings/integrations/feishu/chats"),registerFeishuApp:()=>K("/settings/integrations/feishu/register",{method:"POST"}),getFeishuRegisterStatus:()=>K("/settings/integrations/feishu/register/status"),getCodingTools:()=>K("/settings/coding-tools"),updateCodingTools:e=>K("/settings/coding-tools",{method:"POST",body:JSON.stringify(e)}),detectCodingTools:()=>K("/settings/coding-tools/detect"),detectCodingTool:e=>K(`/settings/coding-tools/detect/${e}`),authCodingTool:(e,t,n)=>K(`/settings/coding-tools/${e}/auth`,{method:"POST",body:JSON.stringify({method:t,apiKey:n})}),listCodingToolModels:e=>K(`/settings/coding-tools/${e}/models`),testCodingTool:e=>K(`/settings/coding-tools/${e}/test`,{method:"POST"})},modelCatalog:{getByProvider:e=>K(`/models/catalog/${e}`),getLive:e=>K(`/models/live/${e}`),getAll:e=>{const t=e?`?provider=${e}`:"";return K(`/models/catalog${t}`)},getStatus:()=>K("/models/catalog/status"),refresh:()=>K("/models/catalog/refresh",{method:"POST"}),validateKey:(e,t,n)=>K("/models/validate-key",{method:"POST",body:JSON.stringify({provider:e,apiKey:t,baseUrl:n})})},skills:{list:()=>K("/skills"),builtin:()=>K("/skills/builtin"),updates:()=>K("/skills/updates"),registry:e=>K(`/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 K(`/skills/registry/skillhub${n?`?${n}`:""}`)},registrySkillssh:e=>K(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,t,n,r)=>K("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:t,description:n,category:r})}),install:e=>K("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>K(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>K(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>K("/builder/artifacts"),get:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`),save:(e,t)=>K("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:t})}),import:(e,t,n,r)=>K("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:t,files:n,source:r})}),install:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/install`,{method:"POST"}),uninstall:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/uninstall`,{method:"POST"}),delete:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`,{method:"DELETE"}),ensureSlug:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/ensure-slug`,{method:"POST"}),ensureSlugSafe:async(e,t,n)=>{const r=dc(t);if(r&&r===t)return{converted:!1,type:e,name:t,slug:r,displayName:n,path:""};try{return await Ce.builder.artifacts.ensureSlug(e,t)}catch(o){if(r)return{converted:!1,type:e,name:r,slug:r,displayName:n,path:""};throw o}},installed:()=>K("/builder/artifacts/installed")}},auth:{status:()=>K("/auth/status"),init:(e,t,n)=>K("/auth/init",{method:"POST",body:JSON.stringify({name:e,email:t,password:n})}),login:(e,t)=>K("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})}),hubLogin:(e,t)=>K("/auth/hub-login",{method:"POST",body:JSON.stringify({hubToken:e,hubUser:t})}),logout:()=>K("/auth/logout",{method:"POST"}),me:()=>K("/auth/me"),changePassword:(e,t)=>K("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:t})}),updateProfile:(e,t)=>K("/auth/profile",{method:"PUT",body:JSON.stringify({name:e,email:t})}),updatePreferences:e=>K("/auth/me/preferences",{method:"PUT",body:JSON.stringify(e)}),setup:(e,t)=>K("/auth/setup",{method:"POST",body:JSON.stringify({token:e,password:t})}),inviteInfo:e=>K(`/auth/invite-info?token=${encodeURIComponent(e)}`),uploadAvatar:(e,t="user",n)=>K("/avatars/upload",{method:"POST",body:JSON.stringify({image:e,type:t,id:n})})},license:{get:()=>K("/license"),refresh:()=>K("/license/refresh",{method:"POST"}),activate:e=>K("/license/activate",{method:"POST",body:JSON.stringify({licenseKey:e})}),trial:()=>K("/license/trial",{method:"POST"})},sessions:{hasAny:()=>K("/sessions/has-any"),listByAgent:(e,t=20)=>K(`/agents/${e}/sessions?limit=${t}`),getMessages:(e,t=50,n)=>K(`/sessions/${e}/messages?limit=${t}${n?`&before=${n}`:""}`),delete:e=>K(`/sessions/${e}`,{method:"DELETE"}),setModelOverride:(e,t)=>K(`/sessions/${e}/model-override`,{method:"PUT",body:JSON.stringify(t??{provider:"",model:""})}),streamStatus:(e,t)=>K(`/agents/${e}/sessions/${t}/stream/status`),reattachStream:(e,t,n,r,o=0)=>new Promise(async(l,u)=>{let d="",m=t,h;try{const p=await fetch(`${xi}/agents/${e}/sessions/${t}/stream?afterSeq=${o}`,{method:"GET",credentials:"include",signal:r});if(p.status===204){l({content:"",sessionId:t,attached:!1});return}if(!p.ok){u(new Error(`API error: ${p.status}`));return}const g=p.body?.getReader();if(!g){u(new Error("No reader"));return}const x=new TextDecoder;let y="";for(;;){const{done:w,value:N}=await g.read();if(w)break;y+=x.decode(N,{stream:!0});const T=y.split(`
|
|
353
|
+
`);d=p.pop()??"";let g="";for(const x of p)if(x.startsWith("event: "))g=x.slice(7).trim();else if(x.startsWith("data: ")){try{t({type:g||"unknown",...JSON.parse(x.slice(6))})}catch{}g=""}}},stopConcurrentBrowserTest:()=>K("/settings/browser/test-concurrent",{method:"DELETE"}),getSearch:()=>K("/settings/search"),updateSearch:e=>K("/settings/search",{method:"POST",body:JSON.stringify(e)}),testSearch:(e,t)=>K("/settings/search/test",{method:"POST",body:JSON.stringify({provider:e,...t})}),getRemote:()=>K("/settings/remote"),enableRemote:()=>K("/settings/remote/enable",{method:"POST"}),disableRemote:()=>K("/settings/remote/disable",{method:"POST"}),getFeishuIntegration:()=>K("/settings/integrations/feishu"),saveFeishuIntegration:e=>K("/settings/integrations/feishu",{method:"POST",body:JSON.stringify(e)}),testFeishuConnection:e=>K("/settings/integrations/feishu/test",{method:"POST",body:JSON.stringify(e)}),sendFeishuTestMessage:e=>K("/settings/integrations/feishu/test-message",{method:"POST",body:JSON.stringify(e)}),deleteFeishuIntegration:()=>K("/settings/integrations/feishu",{method:"DELETE"}),listFeishuChats:()=>K("/settings/integrations/feishu/chats"),registerFeishuApp:()=>K("/settings/integrations/feishu/register",{method:"POST"}),getFeishuRegisterStatus:()=>K("/settings/integrations/feishu/register/status"),getCodingTools:()=>K("/settings/coding-tools"),updateCodingTools:e=>K("/settings/coding-tools",{method:"POST",body:JSON.stringify(e)}),detectCodingTools:()=>K("/settings/coding-tools/detect"),detectCodingTool:e=>K(`/settings/coding-tools/detect/${e}`),authCodingTool:(e,t,n)=>K(`/settings/coding-tools/${e}/auth`,{method:"POST",body:JSON.stringify({method:t,apiKey:n})}),listCodingToolModels:e=>K(`/settings/coding-tools/${e}/models`),testCodingTool:e=>K(`/settings/coding-tools/${e}/test`,{method:"POST"})},modelCatalog:{getByProvider:e=>K(`/models/catalog/${e}`),getLive:e=>K(`/models/live/${e}`),getAll:e=>{const t=e?`?provider=${e}`:"";return K(`/models/catalog${t}`)},getStatus:()=>K("/models/catalog/status"),refresh:()=>K("/models/catalog/refresh",{method:"POST"}),validateKey:(e,t,n)=>K("/models/validate-key",{method:"POST",body:JSON.stringify({provider:e,apiKey:t,baseUrl:n})})},skills:{list:()=>K("/skills"),builtin:()=>K("/skills/builtin"),updates:()=>K("/skills/updates"),registry:e=>K(`/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 K(`/skills/registry/skillhub${n?`?${n}`:""}`)},registrySkillssh:e=>K(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,t,n,r)=>K("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:t,description:n,category:r})}),install:e=>K("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>K(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>K(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>K("/builder/artifacts"),get:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`),save:(e,t)=>K("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:t})}),import:(e,t,n,r,o)=>K("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:t,files:n,source:r,version:o})}),install:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/install`,{method:"POST"}),uninstall:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/uninstall`,{method:"POST"}),delete:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}`,{method:"DELETE"}),ensureSlug:(e,t)=>K(`/builder/artifacts/${e}s/${encodeURIComponent(t)}/ensure-slug`,{method:"POST"}),ensureSlugSafe:async(e,t,n)=>{const r=dc(t);if(r&&r===t)return{converted:!1,type:e,name:t,slug:r,displayName:n,path:""};try{return await Ce.builder.artifacts.ensureSlug(e,t)}catch(o){if(r)return{converted:!1,type:e,name:r,slug:r,displayName:n,path:""};throw o}},installed:()=>K("/builder/artifacts/installed")}},auth:{status:()=>K("/auth/status"),init:(e,t,n)=>K("/auth/init",{method:"POST",body:JSON.stringify({name:e,email:t,password:n})}),login:(e,t)=>K("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})}),hubLogin:(e,t)=>K("/auth/hub-login",{method:"POST",body:JSON.stringify({hubToken:e,hubUser:t})}),logout:()=>K("/auth/logout",{method:"POST"}),me:()=>K("/auth/me"),changePassword:(e,t)=>K("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:t})}),updateProfile:(e,t)=>K("/auth/profile",{method:"PUT",body:JSON.stringify({name:e,email:t})}),updatePreferences:e=>K("/auth/me/preferences",{method:"PUT",body:JSON.stringify(e)}),setup:(e,t)=>K("/auth/setup",{method:"POST",body:JSON.stringify({token:e,password:t})}),inviteInfo:e=>K(`/auth/invite-info?token=${encodeURIComponent(e)}`),uploadAvatar:(e,t="user",n)=>K("/avatars/upload",{method:"POST",body:JSON.stringify({image:e,type:t,id:n})})},license:{get:()=>K("/license"),refresh:()=>K("/license/refresh",{method:"POST"}),activate:e=>K("/license/activate",{method:"POST",body:JSON.stringify({licenseKey:e})}),trial:()=>K("/license/trial",{method:"POST"})},sessions:{hasAny:()=>K("/sessions/has-any"),listByAgent:(e,t=20)=>K(`/agents/${e}/sessions?limit=${t}`),getMessages:(e,t=50,n)=>K(`/sessions/${e}/messages?limit=${t}${n?`&before=${n}`:""}`),delete:e=>K(`/sessions/${e}`,{method:"DELETE"}),setModelOverride:(e,t)=>K(`/sessions/${e}/model-override`,{method:"PUT",body:JSON.stringify(t??{provider:"",model:""})}),streamStatus:(e,t)=>K(`/agents/${e}/sessions/${t}/stream/status`),reattachStream:(e,t,n,r,o=0)=>new Promise(async(l,u)=>{let d="",m=t,h;try{const p=await fetch(`${xi}/agents/${e}/sessions/${t}/stream?afterSeq=${o}`,{method:"GET",credentials:"include",signal:r});if(p.status===204){l({content:"",sessionId:t,attached:!1});return}if(!p.ok){u(new Error(`API error: ${p.status}`));return}const g=p.body?.getReader();if(!g){u(new Error("No reader"));return}const x=new TextDecoder;let y="";for(;;){const{done:w,value:N}=await g.read();if(w)break;y+=x.decode(N,{stream:!0});const T=y.split(`
|
|
354
354
|
`);y=T.pop()??"";for(const C of T){const j=C.trim();if(j.startsWith("data: "))try{const _=JSON.parse(j.slice(6)),O=_.type;if(O==="snapshot"){const z=_.segments??[],D=typeof _.content=="string"?_.content:"";d=D,z.length&&(h=z),n.onSnapshot?.({content:D,segments:z})}else if(O==="text_delta"&&typeof _.text=="string")d+=_.text,n.onChunk?.(_.text);else if(O==="thinking_delta"&&typeof _.thinking=="string")n.onChunk?.(`<think>${_.thinking}</think>`);else if(O==="done"){d=_.content||d,typeof _.sessionId=="string"&&(m=_.sessionId);const z=_.segments;z&&(h=z),l({content:d,sessionId:m,segments:h,attached:!0}),g.cancel().catch(()=>{});return}else if(O==="error"){u(new Error(_.message??_.error??"Stream error")),g.cancel().catch(()=>{});return}else O==="thinking_commit"&&typeof _.thinking=="string"?n.onCommit?.({type:"thinking_commit",content:_.thinking,createdAt:_.createdAt??new Date().toISOString()}):O==="text_commit"&&typeof _.text=="string"?n.onCommit?.({type:"text_commit",content:_.text,createdAt:_.createdAt??new Date().toISOString()}):O==="agent_tool"&&_.tool&&_.phase?_.phase==="start"?n.onActivity?.({tool:_.tool,phase:"start",arguments:_.arguments}):_.phase==="end"&&n.onActivity?.({tool:_.tool,phase:"end",success:_.success,arguments:_.arguments,result:_.result,error:_.error,durationMs:_.durationMs}):O==="subagent_progress"&&_.tool?n.onActivity?.({tool:_.tool,phase:"subagent_progress",subagentEvent:_.subagentEvent}):O==="heartbeat"&&n.onActivity?.({tool:"",phase:"heartbeat"})}catch{}}}l({content:d,sessionId:m,segments:h,attached:!0})}catch(p){u(p)}})},channels:{getMessages:(e,t=50,n)=>K(`/channels/${encodeURIComponent(e)}/messages?limit=${t}${n?`&before=${n}`:""}`),sendMessage:(e,t)=>K(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(t)})},governance:{getSystemStatus:()=>K("/system/status"),pauseAll:e=>K("/system/pause-all",{method:"POST",body:JSON.stringify({reason:e})}),resumeAll:()=>K("/system/resume-all",{method:"POST"}),emergencyStop:e=>K("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>K("/system/announcements"),createAnnouncement:e=>K("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>K("/governance/policy"),setPolicy:e=>K("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:e=>{const t=e?`?status=${e}`:"";return K(`/approvals${t}`)},respond:(e,t,n,r,o,l)=>K(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:t,respondedBy:n,comment:r,selectedOption:o,answers:l})})},notifications:{list:(e,t,n)=>{const r=new URLSearchParams;return e&&r.set("userId",e),t&&r.set("unread","true"),n?.type&&r.set("type",n.type),n?.limit&&r.set("limit",String(n.limit)),n?.offset&&r.set("offset",String(n.offset)),K(`/notifications?${r}`)},create:e=>K("/notifications",{method:"POST",body:JSON.stringify(e)}),markRead:e=>K(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>K("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},unread:{getCounts:()=>K("/unread"),markRead:(e,t,n)=>K("/unread/mark-read",{method:"POST",body:JSON.stringify({conversationKey:e,lastReadAt:t,lastReadId:n})}),markAllRead:()=>K("/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)),K(`/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 K(`/activity${n?`?${n}`:""}`)}},projects:{list:e=>{const t=e?`?orgId=${e}`:"";return K(`/projects${t}`)},get:e=>K(`/projects/${e}`),create:e=>K("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>K(`/projects/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>K(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,t,n)=>{const r=new URLSearchParams;return e&&r.set("query",e),t&&r.set("scope",t),n&&r.set("category",n),K(`/knowledge/search?${r}`)},contribute:e=>K("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,t)=>K(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:t})}),verify:e=>K(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>K(`/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?.offset&&t.set("offset",String(e.offset)),e?.limit&&t.set("limit",String(e.limit)),K(`/deliverables?${t}`)},get:e=>K(`/deliverables/${e}`),create:e=>K("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>K(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(t)}),remove:e=>K(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>K(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})}),checkHealth:e=>{const t=new URLSearchParams;return e&&t.set("agentId",e),K(`/deliverables/health?${t}`)}},codeReviews:{list:(e,t=20)=>{const n=new URLSearchParams;return e&&n.set("taskId",e),n.set("limit",String(t)),K(`/reviews?${n}`)},get:e=>K(`/reviews/${e}`),run:e=>K("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>K("/reports"),get:e=>K(`/reports/${e}`),generate:e=>K("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,t)=>K(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(t)}),rejectPlan:(e,t)=>K(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(t)}),addFeedback:(e,t)=>K(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(t)}),getFeedback:e=>K(`/reports/${e}/feedback`)},executionLogs:{get:(e,t)=>K(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(t)}`)},groupChats:{list:()=>K("/group-chats"),create:e=>K("/group-chats",{method:"POST",body:JSON.stringify(e)}),getById:e=>K(`/group-chats/${e}`),update:(e,t)=>K(`/group-chats/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>K(`/group-chats/${e}`,{method:"DELETE"}),addMember:(e,t,n,r)=>K(`/group-chats/${e}/members`,{method:"POST",body:JSON.stringify({memberId:t,memberType:n,memberName:r})}),removeMember:(e,t)=>K(`/group-chats/${e}/members/${t}`,{method:"DELETE"})},uploads:{upload:(e,t)=>K("/uploads",{method:"POST",body:JSON.stringify({files:e,prefix:t})})},hubOrgs:{mine:()=>$t("/orgs/mine"),get:e=>$t(`/orgs/${e}`),update:(e,t)=>$t(`/orgs/${e}`,{method:"PUT",body:JSON.stringify(t)}),create:e=>$t("/orgs",{method:"POST",body:JSON.stringify({name:e})}),members:e=>$t(`/orgs/${e}/members`),invite:(e,t)=>$t(`/orgs/${e}/members`,{method:"POST",body:JSON.stringify(t)}),removeMember:(e,t)=>$t(`/orgs/${e}/members/${t}`,{method:"DELETE"}),updateMemberRole:(e,t,n)=>$t(`/orgs/${e}/members/${t}`,{method:"PATCH",body:JSON.stringify({role:n})}),invitations:()=>$t("/orgs/invitations"),acceptInvitation:e=>$t(`/orgs/${e}/members/accept`,{method:"POST"}),leave:e=>$t(`/orgs/${e}/leave`,{method:"POST"})},workflows:{list:e=>K(`/teams/${e}/workflows`),get:(e,t)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}`),create:(e,t,n)=>K(`/teams/${e}/workflows`,{method:"POST",body:JSON.stringify({name:t,yaml:n})}),update:(e,t,n)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({yaml:n})}),remove:(e,t)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),roles:(e,t)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}/roles`),listRuns:(e,t,n)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs${n?`?limit=${n}`:""}`),startRun:(e,t,n,r,o)=>K(`/teams/${e}/workflows/${encodeURIComponent(t)}/runs`,{method:"POST",body:JSON.stringify({projectId:n,params:r,roleMapping:o})}),getRun:e=>K(`/workflow-runs/${e}`),cancelRun:e=>K(`/workflow-runs/${e}`,{method:"DELETE"}),pauseRun:e=>K(`/workflow-runs/${e}/pause`,{method:"POST"}),resumeRun:e=>K(`/workflow-runs/${e}/resume`,{method:"POST"})}};function vW(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 wW(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 Zl{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:",r=new URLSearchParams;this.currentUserId&&r.set("userId",this.currentUserId),this.lastEventTimestamp&&r.set("since",this.lastEventTimestamp);const o=r.toString(),l=`${n}//${window.location.host}/ws${o?`?${o}`:""}`,u=new WebSocket(l);this.ws=u,u.onopen=()=>{this.reconnectAttempts=0,this.startHeartbeat(u)},u.onmessage=d=>{if(this.ws===u)try{const m=JSON.parse(d.data);if(m.timestamp&&(this.lastEventTimestamp=m.timestamp),m.type==="pong")return;const h=this.handlers.get(m.type);if(h)for(const g of h)g(m);const p=this.handlers.get("*");if(p)for(const g of p)g(m)}catch{}},u.onclose=()=>{if(this.stopHeartbeat(),this.intentionalClose)return;const d=Math.min(Zl.BACKOFF_BASE*Math.pow(2,this.reconnectAttempts),Zl.BACKOFF_MAX);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(this.currentUserId),d)},u.onerror=()=>{u.close()}}startHeartbeat(t){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"ping"}))},Zl.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 va=new Zl;let b0=window.__MARKUS_HUB_URL__??"https://markus.global";async function sp(){if(!yn())return null;try{const e=await $t("/auth/me");if(e?.user?.id){const t=yn();return Fd(t,e.user),e.user}}catch{}return ua()}window.__MARKUS_PREVIEW__||K("/settings/hub").then(async e=>{e.hubUrl&&(b0=e.hubUrl);const t=localStorage.getItem("markus_hub_token");if(t)K("/settings/hub-token",{method:"POST",body:JSON.stringify({token:t})}).catch(()=>{}),sp();else try{const n=await K("/settings/hub-token");n.token&&(localStorage.setItem("markus_hub_token",n.token),await sp())}catch{}}).catch(()=>{});const uc="markus_hub_token",$d="markus_hub_user";function yn(){return localStorage.getItem(uc)}async function QO(){const e=yn();if(e)return e;try{const t=await K("/settings/hub-token");if(t.token)return localStorage.setItem(uc,t.token),sp(),t.token}catch{}return null}function ua(){try{const e=localStorage.getItem($d);return e?JSON.parse(e):null}catch{return null}}function Hd(e,t){if(e.purchasedByCurrentUser||t?.has(e.id))return!0;const n=ua();if(!n?.id)return!1;const r=e.author?.id??e.authorId;return!!r&&r===n.id}function Ni(){localStorage.removeItem(uc),localStorage.removeItem($d),J4(null),window.dispatchEvent(new CustomEvent("markus:hub-auth"))}function Fd(e,t){const n=localStorage.getItem(uc),r=localStorage.getItem($d),o=JSON.stringify(t);n===e&&r===o||(localStorage.setItem(uc,e),localStorage.setItem($d,o),J4(e),window.dispatchEvent(new CustomEvent("markus:hub-auth")))}function J4(e){K("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}function ZO(e){e.openrouter?.key&&K("/settings/subscription-key",{method:"POST",body:JSON.stringify({openrouter:e.openrouter})}).catch(()=>{})}async function Wp(e){try{return await K(`/hub/auth/connect-status?session=${encodeURIComponent(e)}&_t=${Date.now()}`)}catch{return null}}function Yp(e){!e.token||!e.user||(Fd(e.token,e.user),e.openrouter?.key&&ZO({openrouter:e.openrouter}),JO())}async function JO(){if(yn())try{const{org:e}=await K("/settings/org"),t=e?.name?.trim();if(!t||t==="My Organization")return;const r=((await $t("/orgs/mine")).orgs??[]).find(o=>o.role==="owner");if(!r||r.name===t)return;await $t(`/orgs/${r.id}`,{method:"PUT",body:JSON.stringify({name:t})})}catch{}}function e5(){return window.markusDesktop}async function eD(e,t=12e4){if(yn())return!0;const n=Date.now()+t;for(;Date.now()<n;){const r=await Wp(e);if(r?.ready&&r.token&&r.user)return Yp(r),!0;await new Promise(o=>setTimeout(o,1200))}return!1}let Ad=null;e5()?.onDeepLinkAuth?.(e=>{Ad?.(e?.session??"")});function tD(e,t,n){return new Promise((r,o)=>{let l=!1;const u=(x,y)=>{l||(l=!0,clearInterval(p),clearTimeout(g),Ad===m&&(Ad=null),x?r():o(y))},d=async()=>{if(l)return;const x=await Wp(e);x?.ready&&x.token&&x.user&&(Yp(x),u(!0))},m=x=>{(!x||x===e)&&d()};Ad=m;let h=`${b0}/auth/connect?session=${encodeURIComponent(e)}&redirect=${encodeURIComponent("markus://auth")}`;t&&(h+=`&method=${encodeURIComponent(t)}`),n.openExternal(h);const p=setInterval(()=>{d()},1500),g=setTimeout(()=>u(!1,new Error("Hub login timed out")),5*6e4)})}function nD(e,t){return new Promise((n,r)=>{let o=`${b0}/auth/connect?session=${encodeURIComponent(e)}`;t&&(o+=`&method=${encodeURIComponent(t)}`);const l=460,u=580,d=Math.round(window.screenX+(window.outerWidth-l)/2),m=Math.round(window.screenY+(window.outerHeight-u)/2),h=window.open(o,"markus_hub_auth",`popup=yes,width=${l},height=${u},left=${d},top=${m}`);if(!h){r(new Error("Popup blocked by browser. Please allow popups for this site."));return}let p=!1,g=null;const x=()=>{clearInterval(w),clearInterval(T),g&&clearInterval(g),document.removeEventListener("visibilitychange",N)},y=async()=>{if(p)return;const C=await Wp(e);C?.ready&&C.token&&C.user&&(p=!0,Yp(C),x(),h?.close(),n())},w=setInterval(()=>{y()},1500),N=()=>{!p&&document.visibilityState==="visible"&&y()};document.addEventListener("visibilitychange",N);const T=setInterval(()=>{if(!p&&h?.closed){clearInterval(T);let C=0;g=setInterval(async()=>{if(p){clearInterval(g);return}C++,await y(),C>=5&&!p&&(p=!0,x(),yn()?n():r(new Error("Hub login cancelled")))},1e3)}},500)})}let bo=null;function na(e){const t=typeof e=="string"?{method:e}:e??{};if(t.force)bo=null,(yn()||ua())&&Ni();else if(yn())return Promise.resolve();if(bo)return bo;const n=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`,r=e5(),o=r?tD(n,t.method,r):nD(n,t.method);return bo=o,o.catch(()=>{}).finally(()=>{bo===o&&(bo=null)}),o}async function $t(e,t){const n=yn(),r={"Content-Type":"application/json",...t?.headers};n&&(r.Authorization=`Bearer ${n}`);const o=await fetch(`${xi}/hub${e}`,{...t,headers:r,credentials:"include"}),l=await o.json();if(o.status===401&&n&&Ni(),!o.ok){const u=new Error(l.error??`Hub HTTP ${o.status}`);throw u.code=typeof l.code=="string"?l.code:void 0,u.retryAfterSeconds=typeof l.retryAfterSeconds=="number"?l.retryAfterSeconds:void 0,u.status=o.status,u}return l}async function t5(){if(!yn())return!1;try{return await $t("/user/plan"),!0}catch{return!1}}const it={getUrl:()=>b0,isAuthenticated:()=>!!yn(),getUser:ua,logout:()=>{Ni()},ensureAuth:na,validateSession:t5,login:async(e,t)=>{const n=await $t("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})});return Fd(n.token,n.user),n},register:async(e,t,n)=>{const r=await $t("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:t,password:n})});return Fd(r.token,r.user),r},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 $t(`/items${n?`?${n}`:""}`)},getItem:e=>$t(`/items/${e}`),download:async e=>{await na();try{return await $t(`/items/${e}/download`,{method:"POST"})}catch(t){if(!yn())return await na(),$t(`/items/${e}/download`,{method:"POST"});throw t}},publish:async e=>{await na();try{return await $t("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!yn())return await na(),$t("/items",{method:"POST",body:JSON.stringify(e)});throw t}},uploadImage:async e=>{await na();try{const t=new FormData;t.append("file",e);const n=await fetch("/api/hub/upload",{method:"POST",credentials:"include",headers:{Authorization:`Bearer ${yn()}`},body:t});return n.ok?await n.json():null}catch{return null}},publishViaProxy:async e=>{await na();try{return await $t("/items",{method:"POST",body:JSON.stringify(e)})}catch(t){if(!yn())return await na(),$t("/items",{method:"POST",body:JSON.stringify(e)});throw t}},updateItem:async(e,t)=>(await na(),$t(`/items/${e}`,{method:"PUT",body:JSON.stringify(t)})),myItems:async()=>yn()?$t("/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 $t(`/items${n?`?${n}`:""}`)},myOrgs:async()=>yn()?$t("/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 na(),$t(`/items/${e}`,{method:"DELETE"})),purchases:{checkout:e=>$t("/purchases/checkout",{method:"POST",body:JSON.stringify({itemId:e})}),payWithEarnings:e=>$t("/purchases/pay-with-earnings",{method:"POST",body:JSON.stringify({itemId:e})}),mine:()=>$t("/purchases/mine")},creator:{getBalance:()=>$t("/creator/balance")},user:{plan:()=>$t("/user/plan"),cuStats:(e=30,t="day")=>$t(`/user/cu/stats?days=${e}&granularity=${t}`),claimFreeCreditsStatus:()=>$t("/user/claim-free-credits"),claimFreeCredits:()=>$t("/user/claim-free-credits",{method:"POST"})}},rD=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function n5(e){return typeof e=="string"&&e.length>=2&&e.length<=64&&rD.test(e)}function dc(e){const t=e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-+|-+$/g,"");return n5(t)?t:null}function qd(e,t){const n=dc(e);if(n)return n;if(t){const o=dc(t);if(o)return o;if(n5(t))return t}let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return`pkg-${Math.abs(r).toString(36)}`}let qy=null;const at={setHandler(e){qy=e},navigate(e,t){t&&Object.entries(t).forEach(([n,r])=>localStorage.setItem(`markus_nav_${n}`,r)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:t}})),qy?.(e,t)}};let r5=lc();const ip=new Set;function Gy(){r5=lc(),ip.forEach(e=>e())}typeof window<"u"&&(window.addEventListener("hashchange",Gy),window.addEventListener("popstate",Gy));function aD(e){return ip.add(e),()=>ip.delete(e)}function sD(e){return k.useSyncExternalStore(aD,()=>r5===e,()=>!1)}var Ja=P4();function zo(e){k.useEffect(()=>WO(),[e])}function dr({title:e,message:t,confirmLabel:n,cancelLabel:r,variant:o="danger",alertOnly:l=!1,checkboxes:u,onConfirm:d,onCancel:m,onCancelClick:h}){const{t:p}=ft("common");zo(!0);const[g,x]=k.useState(()=>{const N={};for(const T of u??[])N[T.id]=T.defaultChecked??!1;return N}),y=o==="primary",w=y?"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 text-white 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 Ja.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:m,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[360px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:N=>N.stopPropagation(),children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.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?s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("path",{d:"M12 8h.01"})]}):s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),s.jsxs("div",{className:"min-w-0 pt-0.5",children:[s.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:e}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:t})]})]}),u&&u.length>0&&s.jsx("div",{className:"mb-4 space-y-2",children:u.map(N=>s.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:g[N.id]??!1,onChange:T=>x(C=>({...C,[N.id]:T.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),N.label]},N.id))}),s.jsxs("div",{className:"flex justify-end gap-2",children:[!l&&s.jsx("button",{type:"button",onClick:()=>{h?h(u?g: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:r??p("cancel")}),s.jsx("button",{type:"button",onClick:()=>d(u?g:void 0),className:w,children:n??p(l?"ok":"confirm")})]})]})}),document.body)}function a5(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 r=it.getUrl()?.replace(/\/$/,"")||"";return r?`${r}${n}`:n}return n}function s5({size:e,className:t=""}){const n=Math.max(12,Math.round(e*.55));return s.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:s.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"12",cy:"7",r:"4"})]})})}function Us({name:e,avatarUrl:t,size:n=28,className:r="",bgClass:o="bg-brand-600",fallback:l="initials"}){const[u,d]=k.useState(!1);if(k.useEffect(()=>{d(!1)},[t]),!!t&&!u)return s.jsx("img",{src:t,alt:e??"",className:`rounded-full object-cover shrink-0 ${r}`,style:{width:n,height:n},onError:()=>d(!0)});if(l==="icon")return s.jsx(s5,{size:n,className:r});const h=e?.[0]?.toUpperCase()??"?",p=n<=20?"text-[8px]":n<=28?"text-xs":n<=40?"text-sm":"text-lg",g=/\btext-(?!white\b)/.test(o);return s.jsx("div",{className:`rounded-full ${o} flex items-center justify-center ${g?"":"text-white"} ${p} font-bold shrink-0 ${r}`,style:{width:n,height:n},children:h})}function i5({currentUrl:e,name:t,size:n=64,targetType:r="user",targetId:o,onUploaded:l}){const{t:u}=ft("common"),[d,m]=k.useState(null),[h,p]=k.useState(!1),[g,x]=k.useState(!1),[y,w]=k.useState(null),N=k.useRef(null),T=d??e;k.useEffect(()=>{x(!1)},[T]);const C=!!T&&!g,j=k.useCallback(async _=>{if(!_.type.startsWith("image/"))return;if(_.size>2*1024*1024){w(u("imageTooLarge"));return}const O=new FileReader;O.onload=async()=>{const z=O.result;m(z),x(!1),p(!0);try{const{avatarUrl:D}=await Ce.auth.uploadAvatar(z,r,o);l?.(D)}catch{m(null)}finally{p(!1)}},O.readAsDataURL(_)},[r,o,l,u]);return s.jsxs("div",{className:"relative inline-block group",children:[s.jsx("input",{ref:N,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden",onChange:_=>{const O=_.target.files?.[0];O&&j(O)}}),s.jsxs("button",{type:"button",onClick:()=>N.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:"Click to set avatar",children:[C?s.jsx("img",{src:T,alt:t??"",className:"w-full h-full object-cover",onError:()=>x(!0)}):s.jsx(s5,{size:n}),s.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:h?s.jsx("div",{className:"w-5 h-5 border-2 border-white/60 border-t-white rounded-full animate-spin"}):s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.jsx("circle",{cx:"12",cy:"13",r:"4"})]})})]}),y&&s.jsx(dr,{alertOnly:!0,variant:"danger",title:u("error",{defaultValue:"Error"}),message:y,onConfirm:()=>w(null),onCancel:()=>w(null)})]})}function iD({authUser:e,onNavigate:t}){const{t:n}=ft(["settings","common","nav"]),[r,o]=k.useState(!1);k.useEffect(()=>{const u=()=>o(!0);return window.addEventListener("markus:open-drawer",u),()=>window.removeEventListener("markus:open-drawer",u)},[]),k.useEffect(()=>(r?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[r]);const l=u=>{if(o(!1),u==="__edit_profile"){window.dispatchEvent(new CustomEvent("markus:open-edit-profile"));return}t(u)};return r?s.jsxs("div",{className:"fixed inset-0 z-[100]",children:[s.jsx("div",{className:"absolute inset-0 bg-black/40 animate-fadeIn",onClick:()=>o(!1)}),s.jsxs("aside",{className:"absolute inset-y-0 left-0 w-72 bg-surface-secondary shadow-2xl flex flex-col animate-slideInLeft",children:[s.jsx("div",{className:"px-5 pt-6 pb-4 border-b border-border-default",children:e?s.jsxs("button",{onClick:()=>l("__edit_profile"),className:"flex items-center gap-3 w-full text-left",children:[s.jsx(Us,{name:e.name||"User",avatarUrl:e.avatarUrl,size:40}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:e.name||n("common:userPlaceholder")}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:e.email||e.role})]}),s.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:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]}):s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("common:loading")})}),s.jsxs("nav",{className:"flex-1 overflow-y-auto py-3 px-3 space-y-1",children:[s.jsx(eh,{icon:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),label:n("common:home",{defaultValue:"Home"}),onClick:()=>l(me.HOME)}),s.jsx(eh,{icon:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:cc[me.BUILDER]})}),label:n("nav:builder"),onClick:()=>l(me.BUILDER)}),s.jsx(eh,{icon:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 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:n("settings:title"),onClick:()=>l(me.SETTINGS)})]})]})]}):null}function eh({icon:e,label:t,onClick:n}){return s.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,s.jsx("span",{children:t})]})}function oD(){window.dispatchEvent(new CustomEvent("markus:open-drawer"))}function o5({className:e=""}){return s.jsx("button",{onClick:oD,className:`p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 ${e}`,"aria-label":"Menu",children:s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),s.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),s.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})})}function Gd(){return!!window.markusDesktop}function Ro(e){window.markusDesktop?window.markusDesktop.openExternal(e):window.open(e,"_blank","noopener,noreferrer")}function lD({onClose:e,onClaimed:t}){const{t:n}=ft(["home","common"]);zo(!0);const[r,o]=k.useState("loading"),[l,u]=k.useState(1e3),[d,m]=k.useState(""),h=k.useRef(t);h.current=t;const p=k.useRef(!1),g=()=>`${it.getUrl().replace(/\/$/,"")}/settings?tab=overview&claim=1`,x=k.useCallback(async()=>{o("loading"),m("");try{yn()||await na();const w=await it.user.claimFreeCreditsStatus();if(typeof w.amountCu=="number"&&w.amountCu>0&&u(w.amountCu),w.claimed){o("already"),h.current();return}o("open_hub")}catch(w){m(w instanceof Error?w.message:n("claim.loadFailed")),o("error")}},[n]);k.useEffect(()=>{p.current||(p.current=!0,x())},[x]);const y=()=>{const w=g();Gd()?Ro(w):window.open(w,"_blank","noopener,noreferrer")};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60] p-4",onClick:e,children:s.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:[s.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold text-lg text-fg-primary",children:n("claim.title")}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 leading-relaxed",children:n("claim.subtitle")})]}),s.jsx("button",{type:"button",onClick:e,className:"text-fg-tertiary hover:text-fg-primary text-lg leading-none",children:"×"})]}),r==="loading"&&s.jsx("p",{className:"text-sm text-fg-tertiary mb-5",children:n("claim.loading")}),r==="already"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-emerald-400",children:n("claim.success",{amount:l.toLocaleString()})}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("claim.startUsing")}),s.jsx("button",{type:"button",onClick:e,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-white hover:bg-brand-600",children:n("common:close")})]}),r==="open_hub"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:n("claim.openHubHint",{amount:l.toLocaleString()})}),s.jsx("button",{type:"button",onClick:y,className:"w-full py-2.5 text-sm font-medium rounded-xl bg-brand-500 text-white hover:bg-brand-600",children:n("claim.openHub")})]}),r==="error"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-red-400",children:d}),s.jsx("button",{type:"button",onClick:()=>{x()},className:"w-full py-2 text-sm rounded-xl border border-border-default",children:n("claim.retry")})]})]})})}function l5(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 Vd(e){return e.toLocaleString(void 0,{maximumFractionDigits:0})}function cD(e,t,n){const[r,o]=k.useState([]),[l,u]=k.useState(null),[d,m]=k.useState(it.isAuthenticated()),h=k.useCallback(async()=>{try{const x=await Ce.usage.agents();o(x.agents)}catch{}},[]),p=k.useCallback(async()=>{if(!it.isAuthenticated()){m(!1);return}m(!0);try{const x=await it.user.plan();u(x)}catch{}},[]);return k.useEffect(()=>{if(!e)return;h(),p();const x=setInterval(h,3e4),y=()=>{h(),p()};return window.addEventListener("markus:data-changed",y),()=>{clearInterval(x),window.removeEventListener("markus:data-changed",y)}},[e,h,p]),{contributors:k.useMemo(()=>{const x=[],y=new Map;for(const N of n)for(const T of N.members)y.set(T.id,N.name);const w=new Map((t?.agentEfficiency??[]).map(N=>[N.agentId,N]));for(const N of r){const T=w.get(N.agentId),C=N.cuUsed??0,j=N.totalTokens,_=T?.taskMetrics.completed??0,O=j>0?_/j*1e3:_>0?1/0:0;x.push({id:N.agentId,name:N.agentName,type:"agent",role:N.role,teamName:y.get(N.agentId),status:N.status,tasksCompleted:_,tasksFailed:T?.taskMetrics.failed??0,cuUsed:C,cuUsedToday:N.cuUsedToday??0,totalTokens:j,tokensToday:N.tokensUsedToday,requestCount:N.requestCount,toolCalls:N.toolCalls,healthScore:T?.healthScore??0,efficiency:O,provider:N.provider})}return x.sort((N,T)=>T.cuUsed+T.tasksCompleted*100-(N.cuUsed+N.tasksCompleted*100)===0?T.totalTokens-N.totalTokens:T.cuUsed+T.tasksCompleted*100-(N.cuUsed+N.tasksCompleted*100)),x},[r,t,n]),hubPlan:l,hubConnected:d}}function op({title:e,badge:t,children:n}){const{t:r}=ft("home"),[o,l]=k.useState(!1);return s.jsxs("section",{className:`bg-surface-elevated shadow-sm rounded-2xl ${o?"overflow-visible":"overflow-hidden"}`,children:[s.jsxs("button",{type:"button",onClick:()=>l(u=>!u),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":o,children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate",children:e}),t]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-fg-tertiary shrink-0",children:[s.jsx("span",{className:"hidden sm:inline",children:r(o?"usage.trends.collapse":"usage.trends.expand")}),s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${o?"rotate-180":""}`,children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),o&&s.jsx("div",{className:"rounded-b-2xl overflow-visible",children:n})]})}function uD({hubConnected:e,hubPlan:t}){const{t:n}=ft("home"),r=ua();if(!e)return s.jsxs("div",{className:"px-4 sm:px-5 pb-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-500 shrink-0"}),s.jsx("span",{className:"text-sm text-fg-tertiary",children:n("usage.quota.notConnected")})]}),s.jsx("button",{onClick:()=>it.ensureAuth().catch(()=>{}),className:"px-3 py-1.5 text-xs font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-500 transition-colors shrink-0",children:n("usage.quota.connect")})]});if(!t)return s.jsx("div",{className:"px-4 sm:px-5 pb-4 text-sm text-fg-tertiary",children:n("usage.trends.noData")});const o=t.memberCuLimit!=null&&t.memberCuLimit>0,l=o?t.memberCuLimit:(t.monthlyQuotaCu??0)+(t.bonusCu??0)+(t.purchasedCu??0),u=o?t.memberCuUsed??0:t.totalConsumedThisPeriod??(t.monthlyQuotaCu??0)+(t.bonusCu??0)+(t.purchasedCu??0)-Math.max(0,(t.monthlyQuotaCu??0)-(t.cuUsed??0))-(t.bonusCu??0)-(t.purchasedCu??0),d=l>0?Math.min(100,Math.round(u/l*100)):0,m=d>90?"bg-red-500":d>70?"bg-amber-500":"bg-brand-500",h=()=>{Ro(`${it.getUrl().replace(/\/$/,"")}/settings?tab=billing`)};return s.jsxs("div",{className:"px-4 sm:px-5 pb-4",children:[o&&s.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:n("usage.quota.personalLimit")}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:n(o?"usage.quota.personalLimitLabel":"usage.quota.title")}),s.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}),r?.username&&s.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:n("usage.quota.connectedAs",{username:r.username})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 text-[10px] text-fg-tertiary",children:[s.jsx("span",{children:t.cuResetAt?n("usage.quota.resetsAt",{date:new Date(t.cuResetAt).toLocaleDateString()}):""}),s.jsx("button",{type:"button",className:"px-2 py-1 bg-brand-600 text-white rounded hover:bg-brand-500 transition-colors font-medium",onClick:p=>{p.stopPropagation(),h()},children:n("usage.quota.topUp")})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex-1 h-2 bg-surface-overlay rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all ${m}`,style:{width:`${d}%`}})}),s.jsxs("span",{className:"text-xs text-fg-secondary tabular-nums shrink-0",children:[Vd(u)," / ",Vd(l)]})]})]})}function dD({contributors:e}){const{t}=ft("home"),[n,r]=k.useState("totalTokens"),[o,l]=k.useState(!0),[u,d]=k.useState(!1),m=10,h=C=>{n===C?l(!o):(r(C),l(!0))},p=k.useMemo(()=>[...e].sort((C,j)=>{const _=C[n]===1/0?999999:C[n],O=j[n]===1/0?999999:j[n];return o?O-_:_-O}),[e,n,o]),g=u?p:p.slice(0,m),x=Math.max(1,...e.map(C=>C.totalTokens)),y=e.some(C=>C.cuUsed>0),w=new Set(e.filter(C=>C.provider).map(C=>C.provider)),T=w.size>1||w.size===1&&!w.has("markus")?s.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?s.jsx(op,{title:t("usage.agents.title"),children:s.jsx("div",{className:"px-4 sm:px-5 pb-6 text-center",children:s.jsx("p",{className:"text-sm text-fg-tertiary",children:t("usage.agents.noData")})})}):s.jsxs(op,{title:t("usage.agents.title"),badge:T,children:[s.jsx("div",{className:"overflow-x-auto scrollbar-thin border-t border-border-default",children:s.jsxs("table",{className:"w-full min-w-[520px]",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[s.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium w-8",children:"#"}),s.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium",children:t("usage.agents.name")}),s.jsx("th",{className:"px-3 sm:px-4 py-3 text-left font-medium hidden sm:table-cell",children:t("usage.agents.team")}),s.jsx(Hu,{label:t("usage.agents.tasks"),col:"tasksCompleted",current:n,desc:o,onSort:h}),s.jsx(Hu,{label:t("usage.agents.tokens"),col:"totalTokens",current:n,desc:o,onSort:h}),y&&s.jsx(Hu,{label:t("usage.agents.cuUsed"),col:"cuUsed",current:n,desc:o,onSort:h}),s.jsx(Hu,{label:t("usage.agents.efficiency"),col:"efficiency",current:n,desc:o,onSort:h,align:"right"})]})}),s.jsx("tbody",{children:g.map((C,j)=>s.jsx(mD,{contributor:C,rank:j+1,maxTokens:x,showCu:y},C.id))}),s.jsx("tfoot",{children:s.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[s.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})}),s.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})}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:e.reduce((C,j)=>C+j.tasksCompleted,0)}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:l5(e.reduce((C,j)=>C+j.totalTokens,0))}),y&&s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Vd(e.reduce((C,j)=>C+j.cuUsed,0))}),s.jsx("td",{})]})})]})}),p.length>m&&s.jsx("button",{type:"button",onClick:()=>d(C=>!C),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:u?t("usage.agents.showLess"):t("usage.agents.showAll",{count:p.length})})]})}function mD({contributor:e,rank:t,maxTokens:n,showCu:r}){const o=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",u=e.tasksCompleted===0?"—":e.totalTokens>0?`${e.efficiency.toFixed(1)}`:"∞",d=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 s.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>at.navigate(me.TEAM,{selectAgent:e.id}),children:[s.jsx("td",{className:`px-3 sm:px-4 py-3 text-sm tabular-nums ${d}`,children:t}),s.jsx("td",{className:"px-3 sm:px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${l} shrink-0`}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:e.name}),m&&s.jsx("span",{className:"px-1 py-0.5 rounded text-[8px] font-medium bg-surface-overlay text-fg-tertiary shrink-0",children:m})]}),s.jsxs("div",{className:"text-[10px] text-fg-tertiary truncate",children:[e.role,s.jsx("span",{className:"sm:hidden",children:e.teamName?` · ${e.teamName}`:""})]})]})]})}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-xs text-fg-tertiary hidden sm:table-cell",children:e.teamName||"—"}),s.jsx("td",{className:"px-3 sm:px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:e.tasksCompleted}),e.tasksFailed>0&&s.jsxs("span",{className:"text-[10px] text-red-500 tabular-nums",children:["(",e.tasksFailed,")"]})]})}),s.jsx("td",{className:"px-3 sm:px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 h-1.5 bg-surface-overlay rounded-full overflow-hidden max-w-[80px] hidden md:block",children:s.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${o}%`}})}),s.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:l5(e.totalTokens)})]})}),r&&s.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.cuUsed>0?Vd(e.cuUsed):s.jsx("span",{className:"text-fg-tertiary",children:"—"})}),s.jsx("td",{className:"px-3 sm:px-4 py-3 text-right",children:s.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:u})})]})}function Hu({label:e,col:t,current:n,desc:r,onSort:o,align:l}){const u=n===t?r?"↓":"↑":"↕",d=n===t?"text-brand-500":"text-fg-muted";return s.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:()=>o(t),children:[e,s.jsx("span",{className:`ml-1 ${d}`,children:u})]})}function fD({contributors:e,hubPlan:t,hubConnected:n,showMarkusUsage:r}){const{t:o}=ft("home");return s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-tertiary px-0.5",children:o("usage.sectionTitle")}),r&&s.jsx(op,{title:o("usage.creditsTitle"),children:s.jsx(uD,{hubConnected:n,hubPlan:t})}),s.jsx(dD,{contributors:e})]})}const hD="(max-width: 767px)";let th=null;function c5(){return th||(th=window.matchMedia(hD)),th}function pD(e){const t=c5();return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function gD(){return c5().matches}function bD(){return!1}const xD=k.createContext(!1);function Bo(){const e=k.useContext(xD),t=k.useSyncExternalStore(pD,gD,bD);return e?!1:t}const yD={completed:"#22c55e",in_progress:"#8b5cf6",review:"#3b82f6",pending:"#f59e0b",failed:"#ef4444",blocked:"#f59e0b",rejected:"#fb7185",cancelled:"#6b7280"},vD={completed:"bg-green-500",in_progress:"bg-brand-500",review:"bg-blue-500",pending:"bg-amber-500",failed:"bg-red-500",blocked:"bg-amber-500",rejected:"bg-rose-400",cancelled:"bg-gray-500"},wD={pending:"common:status.pending",in_progress:"common:status.inProgress",blocked:"common:status.blocked",review:"common:status.review",completed:"common:status.completed",failed:"common:status.failed",rejected:"common:status.rejected",cancelled:"common:status.cancelled"},u5=["completed","in_progress","review","pending","failed","blocked","rejected","cancelled"],kD={completed:"bg-green-500/15",in_progress:"bg-brand-500/15",pending:"bg-amber-500/15",review:"bg-blue-500/15",failed:"bg-red-500/15",blocked:"bg-amber-500/15",rejected:"bg-red-500/15",cancelled:"bg-gray-500/15"},Vy={"Heartbeat check-in":"agentFocus.heartbeatCheckIn","Heartbeat check-in (idle skip)":"agentFocus.heartbeatSkip"};function Ky({authUser:e,previewMode:t,previewData:n}={}){const{t:r}=ft(["home","common","team"]),o=Bo(),l=sD(me.HOME),[u,d]=k.useState(n?.agents??[]),[m,h]=k.useState(n?.teams??[]),[p,g]=k.useState(n?.board??{}),[x,y]=k.useState(n?.ops??null),w="7d",[N,T]=k.useState(n?.requirements??[]),[C,j]=k.useState(n?.projects??[]),[_,O]=k.useState(n?.deliverableTotal??0),[z,D]=k.useState([]),[H,W]=k.useState(n?.storageInfo??null),[Z,U]=k.useState(n?.usageInfo??null),[Y,se]=k.useState(null),[X,F]=k.useState(!1),[J,B]=k.useState(!1),[Q,re]=k.useState(!1),[ke,$]=k.useState(null),[G,le]=k.useState(!1),[I,Ee]=k.useState(!1),[Ue,Oe]=k.useState(null),[We,st]=k.useState(!1),dt=k.useRef(!1);dt.current=We;const[Et,gt]=k.useState(()=>localStorage.getItem("markus_checklist_dismissed")==="true"),[jt,Jt]=k.useState(!1),[Rt,be]=k.useState(!1),Me=k.useRef(null),Ge=k.useCallback(()=>{Ee(!0),Ce.cu.status().then(se).catch(()=>{}),Ce.settings.getLlm().then(R=>{$(Object.values(R.providers).some(oe=>oe.configured)),le(!!R.providers.markus?.configured)}).catch(()=>{}),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("markus:data-changed"))},800)},[]);k.useEffect(()=>{if(!X)return;const R=oe=>{Me.current&&!Me.current.contains(oe.target)&&F(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[X]),k.useEffect(()=>{!t||!n||(n.agents&&d(n.agents),n.teams&&h(n.teams),n.board&&g(n.board),y(n.ops??null),T(n.requirements??[]),j(n.projects??[]),O(n.deliverableTotal??0),n.storageInfo&&W(n.storageInfo),n.usageInfo&&U(n.usageInfo))},[t,n]);const ot=k.useCallback(()=>{const R=Ce.agents.list().then(ie=>{d(ie.agents);const Ne=ie.agents.find(Le=>Le.role==="secretary")??ie.agents.find(Le=>Le.name?.toLowerCase().includes("secretary"));Ne&&Ce.sessions.listByAgent(Ne.id,1).then(async Le=>{if(Le.sessions.length===0)return;const Je=await Ce.sessions.getMessages(Le.sessions[0].id,1);Jt(Je.messages.length>0)}).catch(()=>{})}).catch(()=>{}),oe=Ce.teams.list().then(ie=>h(ie.teams)).catch(()=>{});Ce.tasks.board().then(ie=>g(ie.board)).catch(()=>{}),Ce.ops.dashboard(w).then(y).catch(()=>{});const _e=Ce.requirements.list().then(ie=>T(ie.requirements)).catch(()=>{}),de=Ce.projects.list().then(ie=>j(ie.projects)).catch(()=>{});Ce.deliverables.search({limit:18}).then(ie=>{O(ie.total);const Ne=new Map;for(const Le of ie.results){const Je=Le.reference,vt=Ne.get(Je);(!vt||Le.updatedAt>vt.updatedAt)&&Ne.set(Je,Le)}D([...Ne.values()].sort((Le,Je)=>Je.updatedAt.localeCompare(Le.updatedAt)).slice(0,6))}).catch(()=>{}),Ce.system.storage().then(W).catch(()=>{}),Ce.usage.summary().then(ie=>U(ie.usage)).catch(()=>{}),Ce.cu.status().then(se).catch(()=>{});const $e=Ce.settings.getLlm().then(ie=>{$(Object.values(ie.providers).some(Ne=>Ne.configured)),le(!!ie.providers.markus?.configured)}).catch(()=>{}),qe=Ce.settings.getBrowser().then(ie=>{Oe(ie.extensionConnected)}).catch(()=>{}),q=QO().then(ie=>{if(!ie&&!yn()){Ee(!1);return}return it.user.claimFreeCreditsStatus().then(Ne=>Ee(!!Ne.claimed)).catch(()=>{})}).catch(()=>{});Promise.allSettled([R,oe,_e,de,$e,qe,q]).then(()=>{be(!0)})},[w]);k.useEffect(()=>{if(t||!l)return;ot();const R=setInterval(ot,6e4),oe=()=>ot(),_e=()=>{if(dt.current){it.user.claimFreeCreditsStatus().then(de=>Ee(!!de.claimed)).catch(()=>{});return}ot()};return window.addEventListener("markus:data-changed",oe),window.addEventListener("markus:hub-auth",_e),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",oe),window.removeEventListener("markus:hub-auth",_e)}},[t,w,l,ot]);const mt={};for(const[R,oe]of Object.entries(p))R!=="archived"&&oe.length>0&&(mt[R]=oe.length);const ae=mt.completed??0,ze=Object.values(mt).reduce((R,oe)=>R+oe,0),Xe=u.filter(R=>R.status==="working").length,Ve=C.filter(R=>R.status==="active").length,et=ze>0?Math.round(ae/ze*100):0,yt=u5.filter(R=>(mt[R]??0)>0).map(R=>({status:R,count:mt[R]})),pe=k.useMemo(()=>{const R={};return N.forEach(oe=>{R[oe.status]=(R[oe.status]??0)+1}),R},[N]),V=k.useMemo(()=>{const R=new Map(u.map(oe=>[oe.id,oe]));return m.map(oe=>{const _e=oe.members.filter(de=>de.type==="agent").map(de=>R.get(de.id)).filter(de=>!!de);return{team:oe,agents:_e,working:_e.filter(de=>de.status==="working").length,total:_e.length}})},[m,u]),ye=u.filter(R=>R.status==="working"),Qe=!(ke===!0&&!G),he=cD(!t&&l,x,m),ve=k.useMemo(()=>{const R=new Map;for(const oe of Object.values(p))for(const _e of oe)R.set(_e.id,_e);return R},[p]),Ye=k.useCallback(R=>!R.blockedBy||R.blockedBy.length===0?!0:R.blockedBy.every(oe=>{const _e=ve.get(oe);return _e&&_e.status==="completed"}),[ve]),nt=k.useMemo(()=>{const R=[],oe=(p.review??[]).filter(Ne=>Ne.reviewerType==="human");if(oe.length>0){const Ne=oe.filter(Le=>Le.priority==="urgent"||Le.priority==="high").length;R.push({type:"review",count:oe.length,tasks:oe,urgent:Ne})}const _e=N.filter(Ne=>Ne.status==="pending");_e.length>0&&R.push({type:"approval",count:_e.length});const de=[...p.blocked??[]],$e=[...p.failed??[]],qe=de.filter(Ne=>Ye(Ne)),q=de.filter(Ne=>!Ye(Ne)),ie=[...qe,...$e];if(ie.length>0){const Ne=ie.filter(Le=>Le.priority==="urgent"||Le.priority==="high").length;R.push({type:"blocked_abnormal",count:ie.length,tasks:ie,urgent:Ne})}return q.length>0&&R.push({type:"blocked",count:q.length,tasks:q}),R},[p,N,Ye]),xt=k.useMemo(()=>{const R=new Map;for(const oe of Object.values(p))for(const _e of oe)_e.priority&&R.set(_e.id,_e.priority);return R},[p]),Dt=k.useMemo(()=>{const R=new Map;for(const oe of u)R.set(oe.id,oe.name);return R},[u]),{activityLimit:ct,teamsLimit:Xt}=k.useMemo(()=>{const R=(C.length>0?1:0)+(N.length>0?1:0)+(_>0?1:0),oe=ze>0?6+R:0,_e=oe>0?2:0,$e=oe+_e+2,qe=V.length>0?2+V.length:0,q=Math.max(qe,4),ie=ye.length,Ne=ie>0?8:12,Le=Math.max(0,q-$e);let Je=ie>0?Math.max(ie,Le):Le;Je=Math.max(3,Math.min(Ne,Je));const vt=$e+Math.max(ie,Je);let Ie=V.length;if(q>vt+2){const tt=q-vt;Ie=Math.max(2,V.length-tt)}else if(vt>q+2){const tt=vt-q;Je=Math.max(3,Je-tt)}return{activityLimit:Je,teamsLimit:Ie}},[V,ze,C,N,_,ye]);return s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:[s.jsxs("div",{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:[s.jsxs("div",{className:"flex items-center gap-2",children:[o&&s.jsx(o5,{}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-base sm:text-lg font-bold",children:r("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary hidden sm:block",children:r("subtitle")})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{onClick:()=>t?void 0:o?at.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:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}),s.jsx(MD,{ref:Me,show:X,onToggle:()=>F(!X),onClose:()=>F(!1),t:r,isMobile:o})]})]}),s.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:[s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsx(Fu,{label:r("metricCards.working"),value:String(Xe),sub:`/${u.length}`,icon:s.jsx(qu,{type:"working"}),pulse:Xe>0,onClick:()=>B(!0)}),s.jsx(Fu,{label:r("metricCards.tasksDone"),value:`${ae}`,sub:`/${ze}`,icon:s.jsx(qu,{type:"tasks"}),onClick:()=>at.navigate(me.WORK)}),s.jsx(Fu,{label:r("metricCards.projects"),value:String(Ve),icon:s.jsx(qu,{type:"projects"}),onClick:()=>at.navigate(me.WORK)}),s.jsx(Fu,{label:r("metricCards.health"),value:`${ke===!1?100:x?.systemHealth.overallScore??"—"}`,sub:ke===!1||x?"%":void 0,icon:s.jsx(qu,{type:"health"}),color:ke===!1?"green":x?x.systemHealth.overallScore>=80?"green":x.systemHealth.overallScore>=50?"amber":"red":void 0,onClick:()=>re(!0)})]}),!t&&nt.length>0&&s.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:[s.jsx("div",{className:"flex items-center justify-between px-5 pt-4 pb-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("attention.title")})]})}),s.jsx("div",{className:"px-3 pb-3 space-y-1",children:nt.map(R=>{const oe=R.type==="blocked_abnormal",_e=R.type==="blocked"||oe,de=R.type==="review"?"bg-blue-500/15":R.type==="approval"?"bg-amber-500/15":oe?"bg-red-500/15":"bg-amber-500/15",$e=R.type==="review"?"bg-blue-500/10 text-blue-500 hover:bg-blue-500/20":R.type==="approval"?"bg-amber-500/10 text-amber-600 hover:bg-amber-500/20":oe?"bg-red-500/10 text-red-500 hover:bg-red-500/20":"bg-amber-500/10 text-amber-600 hover:bg-amber-500/20",qe=R.type==="review"?r("attention.tasksReview"):R.type==="approval"?r("attention.requirements"):r(oe?"attention.blockedAbnormal":"attention.blockedNormal"),q=R.type==="review"?r("attention.goReview"):R.type==="approval"?r("attention.goApprove"):r("attention.viewDetails");return s.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>{R.type==="review"?at.navigate(me.WORK,{statusFilter:"review"}):R.type==="approval"?at.navigate(me.WORK):_e&&R.tasks&&R.tasks.length>0?at.navigate(me.WORK,{openTask:R.tasks[0].id}):at.navigate(me.WORK)},children:[s.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${de}`,children:s.jsx(TD,{type:_e?"blocked":R.type})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("span",{className:"text-xs font-medium text-fg-primary",children:[R.count," ",qe]}),(R.urgent??0)>0&&s.jsxs("span",{className:"ml-2 inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-red-500/15 text-red-500",children:[R.urgent," urgent"]})]}),s.jsx("button",{className:`text-[11px] font-medium px-3 py-1 rounded-lg transition-colors shrink-0 ${$e}`,children:q})]},R.type)})})]}),z.length>0&&s.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("recentDeliverables.title")}),s.jsx("button",{onClick:()=>at.navigate(me.DELIVERABLES),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsx("div",{className:"px-3 pb-3",children:s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-1",children:z.map(R=>s.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:()=>at.navigate(me.DELIVERABLES,{openDeliverable:R.id}),children:[s.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 ${R.artifactType?"bg-brand-500/10":R.type==="directory"?"bg-blue-500/10":"bg-green-500/10"}`,children:s.jsx(AD,{type:R.type,artifactType:R.artifactType})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:R.title}),s.jsx("div",{className:"text-[11px] text-fg-tertiary truncate mt-0.5",children:R.summary}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[R.agentId&&Dt.get(R.agentId)&&s.jsx("span",{className:"text-[10px] text-fg-muted",children:Dt.get(R.agentId)}),s.jsx("span",{className:"text-[10px] text-fg-muted",children:Yy(R.updatedAt,r)}),R.status==="verified"&&s.jsx("span",{className:"text-[10px] text-blue-500 font-medium",children:"Verified"})]})]}),R.diffStats&&s.jsxs("div",{className:"text-[10px] text-fg-muted shrink-0 mt-1 tabular-nums",children:[s.jsxs("span",{className:"text-green-500",children:["+",R.diffStats.additions]})," ",s.jsxs("span",{className:"text-red-500",children:["-",R.diffStats.deletions]})]})]},R.id))})})]}),Rt&&(()=>{const R=Ie=>{const tt=u.find(St=>St.role==="secretary")??u.find(St=>St.name?.toLowerCase().includes("secretary"));at.navigate(me.TEAM,{...tt?{agentId:tt.id}:{},prefillMessage:Ie})},_e=!!yn()||G,de=ke===!0||G,$e=[..._e?[{id:"claim",done:I,isSetup:!0,label:r("checklist.setup.claim"),desc:r("checklist.setup.claimDesc"),action:r("checklist.setup.claimAction"),onClick:()=>{st(!0)}}]:[],{id:"llm",done:de,isSetup:!0,label:r("checklist.setup.llm"),desc:r(_e?"checklist.setup.llmDescHub":"checklist.setup.llmDesc"),action:r("checklist.setup.llmAction"),onClick:()=>{window.location.hash="#settings/providers"}},{id:"browser",done:Ue===!0,isSetup:!0,optional:!0,label:r("checklist.setup.browser"),desc:r("checklist.setup.browserDesc"),action:r("checklist.setup.browserAction"),onClick:()=>{window.location.hash="#settings/browser"}}],qe=[{id:"greet",done:jt,label:r("checklist.explore.greet"),desc:r("checklist.explore.greetDesc"),action:r("checklist.explore.greetAction"),onClick:()=>R("你好!我是新用户,请简单介绍一下你能帮我做什么?")},{id:"project",done:C.length>0,label:r("checklist.explore.project"),desc:r("checklist.explore.projectDesc"),action:r("checklist.explore.projectAction"),onClick:()=>R("帮我创建一个名为「Markus探索」的项目,用于了解和体验Markus的各项能力")},{id:"requirements",done:N.length>0,label:r("checklist.explore.requirements"),desc:r("checklist.explore.requirementsDesc"),action:r("checklist.explore.requirementsAction"),onClick:()=>R("在「Markus探索」项目中创建两个需求:1. 了解Markus开源项目的架构和设计理念 2. 探索Markus智能体的能力和使用方式")},{id:"team",done:m.length>0,label:r("checklist.explore.team"),desc:r("checklist.explore.teamDesc"),action:r("checklist.explore.teamAction"),onClick:()=>R("帮我组建一个名为「科技前沿智库」的团队,成员包括4位科技领袖角色的智能体:埃隆·马斯克(关注太空、电动车、AI安全)、史蒂夫·乔布斯(关注产品设计与用户体验)、山姆·奥特曼(关注AGI与AI创业生态)、黄仁勋(关注GPU、AI算力与数据中心)。团队目标是从不同视角分析科技前沿趋势。")}],q=[...$e,...qe],ie=q.filter(Ie=>Ie.done).length,Ne=q.length,Le=$e.filter(Ie=>!Ie.optional).every(Ie=>Ie.done)&&qe.every(Ie=>Ie.done),Je=$e.some(Ie=>!Ie.optional&&!Ie.done);if(Le||Et&&!Je)return null;const vt=Ie=>s.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg hover:bg-surface-elevated/50 transition-colors group",children:[s.jsx("div",{className:`mt-0.5 shrink-0 w-5 h-5 rounded-full flex items-center justify-center ${Ie.done?"bg-green-500":"border-2 border-border-default"}`,children:Ie.done&&s.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-xs font-medium ${Ie.done?"text-fg-tertiary line-through":"text-fg-primary"}`,children:Ie.label}),"optional"in Ie&&Ie.optional&&s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-fg-muted font-medium",children:r("checklist.setup.optional")})]}),s.jsx("p",{className:`text-[11px] mt-0.5 ${Ie.done?"text-fg-muted":"text-fg-tertiary"}`,children:Ie.desc})]}),Ie.done&&Ie.isSetup?s.jsx("button",{onClick:Ie.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:r("checklist.setup.update")}):Ie.done?null:s.jsx("button",{onClick:Ie.onClick,className:"shrink-0 text-[11px] px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium transition-colors opacity-80 group-hover:opacity-100",children:Ie.action})]},Ie.id);return s.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:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:r("checklist.title")}),s.jsx("p",{className:"text-xs text-fg-secondary",children:r("checklist.subtitle")})]}),s.jsx("button",{onClick:()=>{gt(!0),localStorage.setItem("markus_checklist_dismissed","true")},className:"text-fg-muted hover:text-fg-secondary transition-colors p-1 -mr-1 -mt-1",title:"Dismiss",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[s.jsx("div",{className:"flex-1 h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-brand-500 rounded-full transition-all duration-500",style:{width:`${ie/Ne*100}%`}})}),s.jsx("span",{className:"text-[11px] text-fg-secondary font-medium shrink-0",children:r("checklist.progress",{done:ie,total:Ne})})]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:r("checklist.setup.title")}),s.jsx("div",{className:"space-y-0.5",children:$e.map(vt)})]}),s.jsx("div",{className:"border-t border-border-default/50 my-3"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-3",children:r("checklist.explore.title")}),s.jsx("div",{className:"space-y-0.5",children:qe.map(vt)})]})]})})(),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[ze>0&&s.jsxs("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("globalOverview.title")}),s.jsx("button",{onClick:()=>at.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsxs("div",{className:"px-5 py-4 flex flex-col sm:flex-row items-center gap-6 border-t border-border-subtle/50",children:[s.jsx(ND,{statusCounts:mt,total:ze,completionRate:et,completed:ae}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("div",{className:"grid grid-cols-2 gap-x-5 gap-y-2.5",children:yt.map(({status:R,count:oe})=>s.jsxs("button",{onClick:()=>at.navigate(me.WORK,{statusFilter:R}),className:"flex items-center gap-2 group cursor-pointer text-left",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${vD[R]??"bg-gray-500"}`}),s.jsx("span",{className:"text-xs text-fg-tertiary group-hover:text-fg-secondary transition-colors",children:r(wD[R]??R)}),s.jsx("span",{className:"text-sm font-semibold text-fg-primary ml-auto tabular-nums",children:oe})]},R))})})]}),s.jsxs("div",{className:"divide-y divide-border-subtle/50",children:[C.length>0&&s.jsx(nh,{icon:"folder",label:r("globalOverview.projects"),value:C.length,onClick:()=>at.navigate(me.WORK),children:s.jsxs(Wy,{children:[Ve," ",r("globalOverview.active")]})}),N.length>0&&s.jsx(nh,{icon:"edit",label:r("globalOverview.requirements"),value:N.length,onClick:()=>at.navigate(me.WORK),children:["in_progress","pending","completed"].map(R=>(pe[R]??0)>0&&s.jsxs(Wy,{children:[pe[R]," ",r(`common:status.${R==="in_progress"?"inProgress":R}`)]},R))}),_>0&&s.jsx(nh,{icon:"book",label:r("globalOverview.deliverables"),value:_,onClick:()=>at.navigate(me.DELIVERABLES)})]})]}),(ye.length>0||x&&x.taskKPI.recentActivity.length>0)&&s.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:s.jsxs("div",{className:`grid grid-cols-1 ${ye.length>0&&x&&x.taskKPI.recentActivity.length>0?"sm:grid-cols-2 divide-y sm:divide-y-0 sm:divide-x divide-border-subtle/50":""}`,children:[ye.length>0&&s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),s.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:r("liveActivity.whosWorking")})]}),s.jsx("div",{className:"space-y-1",children:ye.map(R=>s.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:()=>at.navigate(me.TEAM,{agentId:R.id}),children:[s.jsx(Us,{name:R.name,avatarUrl:R.avatarUrl,size:24,bgClass:"bg-brand-600/30 text-brand-300"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:R.name}),s.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:RD(R.currentActivity?.label,r)??r("agentFocus.working")})]})]},R.id))})]}),x&&x.taskKPI.recentActivity.length>0&&s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h4",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:r("liveActivity.recentChanges")}),s.jsx("button",{onClick:()=>at.navigate(me.WORK),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsx("div",{className:`${ye.length>0?"":"grid grid-cols-1 sm:grid-cols-2 gap-x-4"}`,children:x.taskKPI.recentActivity.slice(0,ct).map(R=>{const oe=xt.get(R.taskId);return s.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:()=>at.navigate(me.WORK,{openTask:R.taskId}),children:[s.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 ${kD[R.status]??"bg-gray-500/15"}`,children:s.jsx(CD,{status:R.status})}),s.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1",children:R.title}),(oe==="urgent"||oe==="high")&&s.jsx(ED,{priority:oe}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Yy(R.updatedAt,r)})]},R.taskId)})})]})]})})]}),s.jsx("div",{className:"space-y-6",children:V.length>0&&s.jsx("div",{className:"bg-surface-elevated shadow-sm rounded-2xl overflow-hidden",children:s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:r("teamOverview.title")}),s.jsx("button",{onClick:()=>at.navigate(me.TEAM),className:"text-[11px] text-brand-400 hover:text-brand-300 font-medium",children:r("common:viewAll")})]}),s.jsxs("div",{className:"space-y-0.5",children:[V.slice(0,Xt).map(R=>s.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-surface-overlay/40 cursor-pointer transition-colors",onClick:()=>at.navigate(me.TEAM,{selectTeam:R.team.id}),children:[s.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:R.team.name.charAt(0)}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:R.team.name})}),s.jsx("div",{className:"flex items-center -space-x-1 shrink-0",children:R.agents.slice(0,3).map(oe=>s.jsx(Us,{name:oe.name,avatarUrl:oe.avatarUrl,size:18,bgClass:"bg-surface-overlay text-fg-secondary ring-1 ring-surface-elevated"},oe.id))}),R.working>0&&s.jsxs("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:[R.working,"/",R.total]})]},R.team.id)),Xt<V.length&&s.jsxs("button",{onClick:()=>at.navigate(me.TEAM),className:"w-full text-center text-[11px] text-brand-400 hover:text-brand-300 font-medium py-1.5",children:["+",V.length-Xt," more"]})]})]})})})]}),!t&&ke!==null&&s.jsx(fD,{contributors:he.contributors,hubPlan:he.hubPlan,hubConnected:he.hubConnected,showMarkusUsage:Qe})]}),J&&s.jsx(_D,{workingAgents:ye,onClose:()=>B(!1),t:r}),Q&&s.jsx(jD,{ops:x,completed:ae,totalRootTasks:ze,workingAgents:Xe,totalAgents:u.length,usageInfo:Z,storageInfo:H,cuQuota:Y,onClose:()=>re(!1),t:r}),We&&s.jsx(lD,{onClose:()=>st(!1),onClaimed:Ge})]})}function Fu({label:e,value:t,sub:n,icon:r,pulse:o,color:l,badge:u,onClick:d}){const m=l==="green"?"text-green-500":l==="amber"?"text-amber-500":l==="red"?"text-red-500":"text-fg-primary";return s.jsxs("div",{onClick:d,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:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[11px] text-fg-tertiary mb-2",children:e}),s.jsxs("div",{className:"flex items-baseline gap-0.5",children:[s.jsx("span",{className:`text-2xl sm:text-3xl font-bold ${m} leading-none`,children:t}),n&&s.jsx("span",{className:"text-sm text-fg-muted font-medium",children:n})]}),u&&s.jsx("div",{className:"text-[10px] text-amber-500 font-medium mt-1.5",children:u})]}),s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-overlay/60 flex items-center justify-center text-fg-tertiary",children:r}),o&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 rounded-full bg-green-500 animate-pulse"})]})]})}function qu({type:e}){const t={working:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})}),tasks:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),s.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),projects:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),health:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})};return s.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 nh({icon:e,label:t,value:n,onClick:r,children:o}){return s.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 hover:bg-surface-overlay/30 cursor-pointer transition-colors",onClick:r,children:[s.jsx("span",{className:"text-fg-muted",children:s.jsx(SD,{type:e})}),s.jsx("span",{className:"text-xs text-fg-secondary",children:t}),s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:n}),s.jsx("div",{className:"flex items-center gap-2 ml-auto text-[11px] text-fg-tertiary",children:o})]})}function Wy({children:e}){return s.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-overlay/60 text-[11px] text-fg-secondary",children:e})}function SD({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 s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:t[e]})})}function ND({statusCounts:e,total:t,completionRate:n,completed:r}){const d=2*Math.PI*42,m=u5.filter(g=>(e[g]??0)>0).map(g=>({status:g,value:e[g],color:yD[g]??"#6b7280"}));let h=0;const p=m.map(g=>{const x=g.value/t*d,y={len:Math.max(x-.8,.5),offset:h,color:g.color,status:g.status};return h+=x,y});return s.jsxs("div",{className:"relative shrink-0",style:{width:120,height:120},children:[s.jsx("svg",{width:120,height:120,viewBox:"0 0 120 120",children:p.map((g,x)=>s.jsx("circle",{cx:"60",cy:"60",r:42,fill:"none",stroke:g.color,strokeWidth:12,strokeDasharray:`${g.len} ${d-g.len}`,strokeDashoffset:-g.offset,transform:"rotate(-90 60 60)",className:"transition-all duration-500 cursor-pointer",onClick:()=>at.navigate(me.WORK,{statusFilter:g.status})},x))}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:"text-2xl font-bold text-fg-primary leading-none",children:[n,"%"]}),s.jsxs("span",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[r,"/",t]})]})]})}function CD({status:e}){const n={completed:"#22c55e",in_progress:"#8b5cf6",pending:"#f59e0b",review:"#3b82f6",failed:"#ef4444",blocked:"#f59e0b",rejected:"#ef4444",cancelled:"#6b7280"}[e]??"#6b7280";return s.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"&&s.jsx("polyline",{points:"20 6 9 17 4 12"}),e==="in_progress"&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e==="pending"&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e==="review"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),(e==="failed"||e==="rejected")&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),e==="blocked"&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"4.93",y1:"4.93",x2:"19.07",y2:"19.07"})]}),e==="cancelled"&&s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})]})}function TD({type:e}){const t=e==="review"?"#3b82f6":e==="approval"?"#f59e0b":"#ef4444";return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e==="review"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),e==="approval"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),s.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),e==="blocked"&&s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),s.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),s.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})]})}function ED({priority:e}){return e==="urgent"?s.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"?s.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 AD({type:e,artifactType:t}){if(t){const r=t==="agent"?"#8b5cf6":t==="team"?"#3b82f6":"#f59e0b";return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),s.jsx("path",{d:"M2 17l10 5 10-5"}),s.jsx("path",{d:"M2 12l10 5 10-5"})]})}const n=e==="directory"?"#3b82f6":"#22c55e";return s.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"?s.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}):s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})})}function _D({workingAgents:e,onClose:t,t:n}){return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.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:r=>r.stopPropagation(),children:[s.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between shrink-0",children:[s.jsx("h3",{className:"text-sm font-semibold",children:n("ranking.workingNow")}),s.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 scrollbar-thin px-5 py-4",children:e.length>0?s.jsx("div",{className:"space-y-0.5",children:e.map(r=>s.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(),at.navigate(me.TEAM,{agentId:r.id})},children:[s.jsx(Us,{name:r.name,avatarUrl:r.avatarUrl,size:26,bgClass:"bg-brand-600/30 text-brand-300"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary truncate",children:r.name}),s.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:r.currentActivity?.label??"—"})]}),s.jsx("span",{className:"text-[10px] text-green-500 font-medium shrink-0",children:"Working"})]},r.id))}):s.jsx("div",{className:"py-8 text-center text-xs text-fg-tertiary",children:n("ranking.noData")})})]})})}function jD({ops:e,completed:t,totalRootTasks:n,workingAgents:r,totalAgents:o,usageInfo:l,storageInfo:u,cuQuota:d,onClose:m,t:h}){return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:m,children:s.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] overflow-hidden",onClick:p=>p.stopPropagation(),children:[s.jsxs("div",{className:"px-5 py-4 border-b border-border-default flex items-center justify-between",children:[s.jsx("h3",{className:"text-sm font-semibold",children:h("systemHealth.title")}),s.jsx("button",{onClick:m,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"p-5 space-y-4",children:[e&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:h("systemHealth.successRate")}),s.jsxs("span",{className:"text-sm font-bold text-fg-primary",children:[Math.round(e.taskKPI.successRate),"%"]})]}),s.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:s.jsx("div",{className:"h-full rounded-full bg-green-500 transition-all duration-500",style:{width:`${Math.round(e.taskKPI.successRate)}%`}})})]}),e&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:h("metricCards.health")}),s.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,"%"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:h("systemHealth.tasksTotal")}),s.jsxs("span",{className:"text-xs font-semibold text-fg-primary",children:[t,"/",n]})]}),l&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:h("systemHealth.tokenUsage")}),s.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:Vu(l.llmTokens)})]}),d?.available&&d.cuLimit>0&&(()=>{const p=d.cuLimit-d.cuRemaining,g=Math.min(100,Math.round(p/d.cuLimit*100)),x=g>=95?"text-red-500":g>=80?"text-amber-500":"text-green-500",y=g>=95?"bg-red-500":g>=80?"bg-amber-500":"bg-green-500";return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:"CU Quota"}),s.jsxs("span",{className:`text-xs font-semibold ${x}`,children:[Vu(p)," / ",Vu(d.cuLimit)," (",g,"%)"]})]}),s.jsx("div",{className:"h-2 rounded-full bg-surface-overlay/60 overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full ${y} transition-all duration-500`,style:{width:`${g}%`}})}),d.cuUsedToday!=null&&d.cuUsedToday>0&&s.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[s.jsx("span",{className:"text-xs text-fg-tertiary",children:"Today's CU Used"}),s.jsx("span",{className:"text-xs font-semibold text-fg-secondary",children:Vu(d.cuUsedToday)})]})]})})(),r>0&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:h("systemHealth.currentWorking")}),s.jsxs("span",{className:"text-xs font-semibold text-green-500",children:[r,"/",o]})]}),u&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-fg-secondary",children:h("systemHealth.storage")}),s.jsx("span",{className:"text-xs font-semibold text-fg-primary",children:OD(u.totalSize)})]})]})]})})}const MD=k.forwardRef(({show:e,onToggle:t,onClose:n,t:r,isMobile:o},l)=>s.jsxs("div",{ref:l,className:"relative",children:[s.jsx("button",{onClick:t,className:"p-2 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary","aria-label":"Create",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e&&s.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:s.jsxs("div",{className:"py-1",children:[s.jsx(Gu,{onClick:()=>{n(),at.navigate(me.BUILDER,o?{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:r("home:createMenu.agent")}),s.jsx(Gu,{onClick:()=>{n(),at.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:r("home:createMenu.team")}),s.jsx(Gu,{onClick:()=>{n(),at.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:r("home:createMenu.skill")}),s.jsx("div",{className:"border-t border-border-default my-1"}),s.jsx(Gu,{onClick:()=>{n(),at.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:r("home:createMenu.discover")})]})})]}));function Gu({onClick:e,icon:t,children:n}){return s.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:[s.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:t})}),n]})}function Yy(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}function RD(e,t){return e?Vy[e]?t(Vy[e]):e:null}function Vu(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 OD(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]}`}function Xy(e){const t=[],n=String(e||"");let r=n.indexOf(","),o=0,l=!1;for(;!l;){r===-1&&(r=n.length,l=!0);const u=n.slice(o,r).trim();(u||!l)&&t.push(u),o=r+1,r=n.indexOf(",",o)}return t}function DD(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const LD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ID=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,PD={};function Qy(e,t){return(PD.jsx?ID:LD).test(e)}const zD=/[ \t\n\f\r]/g;function BD(e){return typeof e=="object"?e.type==="text"?Zy(e.value):!1:Zy(e)}function Zy(e){return e.replace(zD,"")===""}class yc{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}yc.prototype.normal={};yc.prototype.property={};yc.prototype.space=void 0;function d5(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new yc(n,r,t)}function mc(e){return e.toLowerCase()}class jr{constructor(t,n){this.attribute=n,this.property=t}}jr.prototype.attribute="";jr.prototype.booleanish=!1;jr.prototype.boolean=!1;jr.prototype.commaOrSpaceSeparated=!1;jr.prototype.commaSeparated=!1;jr.prototype.defined=!1;jr.prototype.mustUseProperty=!1;jr.prototype.number=!1;jr.prototype.overloadedBoolean=!1;jr.prototype.property="";jr.prototype.spaceSeparated=!1;jr.prototype.space=void 0;let UD=0;const zt=_i(),$n=_i(),lp=_i(),Fe=_i(),gn=_i(),_o=_i(),Ur=_i();function _i(){return 2**++UD}const cp=Object.freeze(Object.defineProperty({__proto__:null,boolean:zt,booleanish:$n,commaOrSpaceSeparated:Ur,commaSeparated:_o,number:Fe,overloadedBoolean:lp,spaceSeparated:gn},Symbol.toStringTag,{value:"Module"})),rh=Object.keys(cp);class Xp extends jr{constructor(t,n,r,o){let l=-1;if(super(t,n),Jy(this,"space",o),typeof r=="number")for(;++l<rh.length;){const u=rh[l];Jy(this,rh[l],(r&cp[u])===cp[u])}}}Xp.prototype.defined=!0;function Jy(e,t,n){n&&(e[t]=n)}function Uo(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const l=new Xp(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[mc(r)]=r,n[mc(l.attribute)]=r}return new yc(t,n,e.space)}const m5=Uo({properties:{ariaActiveDescendant:null,ariaAtomic:$n,ariaAutoComplete:null,ariaBusy:$n,ariaChecked:$n,ariaColCount:Fe,ariaColIndex:Fe,ariaColSpan:Fe,ariaControls:gn,ariaCurrent:null,ariaDescribedBy:gn,ariaDetails:null,ariaDisabled:$n,ariaDropEffect:gn,ariaErrorMessage:null,ariaExpanded:$n,ariaFlowTo:gn,ariaGrabbed:$n,ariaHasPopup:null,ariaHidden:$n,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:gn,ariaLevel:Fe,ariaLive:null,ariaModal:$n,ariaMultiLine:$n,ariaMultiSelectable:$n,ariaOrientation:null,ariaOwns:gn,ariaPlaceholder:null,ariaPosInSet:Fe,ariaPressed:$n,ariaReadOnly:$n,ariaRelevant:null,ariaRequired:$n,ariaRoleDescription:gn,ariaRowCount:Fe,ariaRowIndex:Fe,ariaRowSpan:Fe,ariaSelected:$n,ariaSetSize:Fe,ariaSort:null,ariaValueMax:Fe,ariaValueMin:Fe,ariaValueNow:Fe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function f5(e,t){return t in e?e[t]:t}function h5(e,t){return f5(e,t.toLowerCase())}const $D=Uo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:_o,acceptCharset:gn,accessKey:gn,action:null,allow:null,allowFullScreen:zt,allowPaymentRequest:zt,allowUserMedia:zt,alt:null,as:null,async:zt,autoCapitalize:null,autoComplete:gn,autoFocus:zt,autoPlay:zt,blocking:gn,capture:null,charSet:null,checked:zt,cite:null,className:gn,cols:Fe,colSpan:null,content:null,contentEditable:$n,controls:zt,controlsList:gn,coords:Fe|_o,crossOrigin:null,data:null,dateTime:null,decoding:null,default:zt,defer:zt,dir:null,dirName:null,disabled:zt,download:lp,draggable:$n,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:zt,formTarget:null,headers:gn,height:Fe,hidden:lp,high:Fe,href:null,hrefLang:null,htmlFor:gn,httpEquiv:gn,id:null,imageSizes:null,imageSrcSet:null,inert:zt,inputMode:null,integrity:null,is:null,isMap:zt,itemId:null,itemProp:gn,itemRef:gn,itemScope:zt,itemType:gn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:zt,low:Fe,manifest:null,max:null,maxLength:Fe,media:null,method:null,min:null,minLength:Fe,multiple:zt,muted:zt,name:null,nonce:null,noModule:zt,noValidate:zt,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:zt,optimum:Fe,pattern:null,ping:gn,placeholder:null,playsInline:zt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:zt,referrerPolicy:null,rel:gn,required:zt,reversed:zt,rows:Fe,rowSpan:Fe,sandbox:gn,scope:null,scoped:zt,seamless:zt,selected:zt,shadowRootClonable:zt,shadowRootDelegatesFocus:zt,shadowRootMode:null,shape:null,size:Fe,sizes:null,slot:null,span:Fe,spellCheck:$n,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Fe,step:null,style:null,tabIndex:Fe,target:null,title:null,translate:null,type:null,typeMustMatch:zt,useMap:null,value:$n,width:Fe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:gn,axis:null,background:null,bgColor:null,border:Fe,borderColor:null,bottomMargin:Fe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:zt,declare:zt,event:null,face:null,frame:null,frameBorder:null,hSpace:Fe,leftMargin:Fe,link:null,longDesc:null,lowSrc:null,marginHeight:Fe,marginWidth:Fe,noResize:zt,noHref:zt,noShade:zt,noWrap:zt,object:null,profile:null,prompt:null,rev:null,rightMargin:Fe,rules:null,scheme:null,scrolling:$n,standby:null,summary:null,text:null,topMargin:Fe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Fe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:zt,disableRemotePlayback:zt,prefix:null,property:null,results:Fe,security:null,unselectable:null},space:"html",transform:h5}),HD=Uo({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:Ur,accentHeight:Fe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Fe,amplitude:Fe,arabicForm:null,ascent:Fe,attributeName:null,attributeType:null,azimuth:Fe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Fe,by:null,calcMode:null,capHeight:Fe,className:gn,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:Fe,diffuseConstant:Fe,direction:null,display:null,dur:null,divisor:Fe,dominantBaseline:null,download:zt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Fe,enableBackground:null,end:null,event:null,exponent:Fe,externalResourcesRequired:null,fill:null,fillOpacity:Fe,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:_o,g2:_o,glyphName:_o,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Fe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Fe,horizOriginX:Fe,horizOriginY:Fe,id:null,ideographic:Fe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Fe,k:Fe,k1:Fe,k2:Fe,k3:Fe,k4:Fe,kernelMatrix:Ur,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Fe,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:Fe,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:Fe,overlineThickness:Fe,paintOrder:null,panose1:null,path:null,pathLength:Fe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:gn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Fe,pointsAtY:Fe,pointsAtZ:Fe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ur,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ur,rev:Ur,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ur,requiredFeatures:Ur,requiredFonts:Ur,requiredFormats:Ur,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:Fe,specularExponent:Fe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Fe,strikethroughThickness:Fe,string:null,stroke:null,strokeDashArray:Ur,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Fe,strokeOpacity:Fe,strokeWidth:null,style:null,surfaceScale:Fe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ur,tabIndex:Fe,tableValues:null,target:null,targetX:Fe,targetY:Fe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ur,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Fe,underlineThickness:Fe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Fe,values:null,vAlphabetic:Fe,vMathematical:Fe,vectorEffect:null,vHanging:Fe,vIdeographic:Fe,version:null,vertAdvY:Fe,vertOriginX:Fe,vertOriginY:Fe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Fe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:f5}),p5=Uo({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()}}),g5=Uo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:h5}),b5=Uo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),FD={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"},qD=/[A-Z]/g,ev=/-[a-z]/g,GD=/^data[-\w.:]+$/i;function x5(e,t){const n=mc(t);let r=t,o=jr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&GD.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(ev,KD);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!ev.test(l)){let u=l.replace(qD,VD);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}o=Xp}return new o(r,t)}function VD(e){return"-"+e.toLowerCase()}function KD(e){return e.charAt(1).toUpperCase()}const y5=d5([m5,$D,p5,g5,b5],"html"),x0=d5([m5,HD,p5,g5,b5],"svg");function tv(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function WD(e){return e.join(" ").trim()}var xo={},ah,nv;function YD(){if(nv)return ah;nv=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,d=/^\s+|\s+$/g,m=`
|
|
355
355
|
`,h="/",p="*",g="",x="comment",y="declaration";function w(T,C){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];C=C||{};var j=1,_=1;function O(F){var J=F.match(t);J&&(j+=J.length);var B=F.lastIndexOf(m);_=~B?F.length-B:_+F.length}function z(){var F={line:j,column:_};return function(J){return J.position=new D(F),Z(),J}}function D(F){this.start=F,this.end={line:j,column:_},this.source=C.source}D.prototype.content=T;function H(F){var J=new Error(C.source+":"+j+":"+_+": "+F);if(J.reason=F,J.filename=C.source,J.line=j,J.column=_,J.source=T,!C.silent)throw J}function W(F){var J=F.exec(T);if(J){var B=J[0];return O(B),T=T.slice(B.length),J}}function Z(){W(n)}function U(F){var J;for(F=F||[];J=Y();)J!==!1&&F.push(J);return F}function Y(){var F=z();if(!(h!=T.charAt(0)||p!=T.charAt(1))){for(var J=2;g!=T.charAt(J)&&(p!=T.charAt(J)||h!=T.charAt(J+1));)++J;if(J+=2,g===T.charAt(J-1))return H("End of comment missing");var B=T.slice(2,J-2);return _+=2,O(B),T=T.slice(J),_+=2,F({type:x,comment:B})}}function se(){var F=z(),J=W(r);if(J){if(Y(),!W(o))return H("property missing ':'");var B=W(l),Q=F({type:y,property:N(J[0].replace(e,g)),value:B?N(B[0].replace(e,g)):g});return W(u),Q}}function X(){var F=[];U(F);for(var J;J=se();)J!==!1&&(F.push(J),U(F));return F}return Z(),X()}function N(T){return T?T.replace(d,g):g}return ah=w,ah}var rv;function XD(){if(rv)return xo;rv=1;var e=xo&&xo.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(xo,"__esModule",{value:!0}),xo.default=n;const t=e(YD());function n(r,o){let l=null;if(!r||typeof r!="string")return l;const u=(0,t.default)(r),d=typeof o=="function";return u.forEach(m=>{if(m.type!=="declaration")return;const{property:h,value:p}=m;d?o(h,p,m):p&&(l=l||{},l[h]=p)}),l}return xo}var ql={},av;function QD(){if(av)return ql;av=1,Object.defineProperty(ql,"__esModule",{value:!0}),ql.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,l=function(h){return!h||n.test(h)||e.test(h)},u=function(h,p){return p.toUpperCase()},d=function(h,p){return"".concat(p,"-")},m=function(h,p){return p===void 0&&(p={}),l(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(o,d):h=h.replace(r,d),h.replace(t,u))};return ql.camelCase=m,ql}var Gl,sv;function ZD(){if(sv)return Gl;sv=1;var e=Gl&&Gl.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(XD()),n=QD();function r(o,l){var u={};return!o||typeof o!="string"||(0,t.default)(o,function(d,m){d&&m&&(u[(0,n.camelCase)(d,l)]=m)}),u}return r.default=r,Gl=r,Gl}var JD=ZD();const eL=xc(JD),v5=w5("end"),Qp=w5("start");function w5(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function tL(e){const t=Qp(e),n=v5(e);if(t&&n)return{start:t,end:n}}function Jl(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?iv(e.position):"start"in e||"end"in e?iv(e):"line"in e||"column"in e?up(e):""}function up(e){return ov(e&&e.line)+":"+ov(e&&e.column)}function iv(e){return up(e&&e.start)+"-"+up(e&&e.end)}function ov(e){return e&&typeof e=="number"?e:1}class sr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",l={},u=!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"?o=t:!l.cause&&t&&(u=!0,o=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof r=="string"){const m=r.indexOf(":");m===-1?l.ruleId=r:(l.source=r.slice(0,m),l.ruleId=r.slice(m+1))}if(!l.place&&l.ancestors&&l.ancestors){const m=l.ancestors[l.ancestors.length-1];m&&(l.place=m.position)}const d=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=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=d?d.line:void 0,this.name=Jl(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=u&&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}}sr.prototype.file="";sr.prototype.name="";sr.prototype.reason="";sr.prototype.message="";sr.prototype.stack="";sr.prototype.column=void 0;sr.prototype.line=void 0;sr.prototype.ancestors=void 0;sr.prototype.cause=void 0;sr.prototype.fatal=void 0;sr.prototype.place=void 0;sr.prototype.ruleId=void 0;sr.prototype.source=void 0;const Zp={}.hasOwnProperty,nL=new Map,rL=/[A-Z]/g,aL=new Set(["table","tbody","thead","tfoot","tr"]),sL=new Set(["td","th"]),k5="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function iL(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=hL(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");r=fL(n,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,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"?x0:y5,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=S5(o,e,void 0);return l&&typeof l!="string"?l:o.create(e,o.Fragment,{children:l||void 0},void 0)}function S5(e,t,n){if(t.type==="element")return oL(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return lL(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return uL(e,t,n);if(t.type==="mdxjsEsm")return cL(e,t);if(t.type==="root")return dL(e,t,n);if(t.type==="text")return mL(e,t)}function oL(e,t,n){const r=e.schema;let o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=x0,e.schema=o),e.ancestors.push(t);const l=C5(e,t.tagName,!1),u=pL(e,t);let d=eg(e,t);return aL.has(t.tagName)&&(d=d.filter(function(m){return typeof m=="string"?!BD(m):!0})),N5(e,u,l,t),Jp(u,d),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function lL(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}fc(e,t.position)}function cL(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);fc(e,t.position)}function uL(e,t,n){const r=e.schema;let o=r;t.name==="svg"&&r.space==="html"&&(o=x0,e.schema=o),e.ancestors.push(t);const l=t.name===null?e.Fragment:C5(e,t.name,!0),u=gL(e,t),d=eg(e,t);return N5(e,u,l,t),Jp(u,d),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function dL(e,t,n){const r={};return Jp(r,eg(e,t)),e.create(t,e.Fragment,r,n)}function mL(e,t){return t.value}function N5(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Jp(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function fL(e,t,n){return r;function r(o,l,u,d){const h=Array.isArray(u.children)?n:t;return d?h(l,u,d):h(l,u)}}function hL(e,t){return n;function n(r,o,l,u){const d=Array.isArray(l.children),m=Qp(r);return t(o,l,u,d,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function pL(e,t){const n={};let r,o;for(o in t.properties)if(o!=="children"&&Zp.call(t.properties,o)){const l=bL(e,o,t.properties[o]);if(l){const[u,d]=l;e.tableCellAlignToStyle&&u==="align"&&typeof d=="string"&&sL.has(t.tagName)?r=d:n[u]=d}}if(r){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function gL(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];l.type;const u=l.expression;u.type;const d=u.properties[0];d.type,Object.assign(n,e.evaluater.evaluateExpression(d.argument))}else fc(e,t.position);else{const o=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const d=r.value.data.estree.body[0];d.type,l=e.evaluater.evaluateExpression(d.expression)}else fc(e,t.position);else l=r.value===null?!0:r.value;n[o]=l}return n}function eg(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:nL;for(;++r<t.children.length;){const l=t.children[r];let u;if(e.passKeys){const m=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(m){const h=o.get(m)||0;u=m+"-"+h,o.set(m,h+1)}}const d=S5(e,l,u);d!==void 0&&n.push(d)}return n}function bL(e,t,n){const r=x5(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?DD(n):WD(n)),r.property==="style"){let o=typeof n=="object"?n:xL(e,String(n));return e.stylePropertyNameCase==="css"&&(o=yL(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?FD[r.property]||r.property:r.attribute,n]}}function xL(e,t){try{return eL(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,o=new sr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=k5+"#cannot-parse-style-attribute",o}}function C5(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let l=-1,u;for(;++l<o.length;){const d=Qy(o[l])?{type:"Identifier",name:o[l]}:{type:"Literal",value:o[l]};u=u?{type:"MemberExpression",object:u,property:d,computed:!!(l&&d.type==="Literal"),optional:!1}:d}r=u}else r=Qy(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const o=r.value;return Zp.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);fc(e)}function fc(e,t){const n=new sr("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=k5+"#cannot-handle-mdx-estrees-without-createevaluater",n}function yL(e){const t={};let n;for(n in e)Zp.call(e,n)&&(t[vL(n)]=e[n]);return t}function vL(e){let t=e.replace(rL,wL);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function wL(e){return"-"+e.toLowerCase()}const sh={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"]},kL={};function tg(e,t){const n=kL,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return T5(e,r,o)}function T5(e,t,n){if(SL(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 lv(e.children,t,n)}return Array.isArray(e)?lv(e,t,n):""}function lv(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=T5(e[o],t,n);return r.join("")}function SL(e){return!!(e&&typeof e=="object")}const cv=document.createElement("i");function ng(e){const t="&"+e+";";cv.innerHTML=t;const n=cv.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function $r(e,t,n,r){const o=e.length;let l=0,u;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)u=Array.from(r),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);l<r.length;)u=r.slice(l,l+1e4),u.unshift(t,0),e.splice(...u),l+=1e4,t+=1e4}function ra(e,t){return e.length>0?($r(e,e.length,0,t),e):t}const uv={}.hasOwnProperty;function E5(e){const t={};let n=-1;for(;++n<e.length;)NL(t,e[n]);return t}function NL(e,t){let n;for(n in t){const o=(uv.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){uv.call(o,u)||(o[u]=[]);const d=l[u];CL(o[u],Array.isArray(d)?d:d?[d]:[])}}}function CL(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);$r(e,0,0,r)}function A5(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 da(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const mr=Gs(/[A-Za-z]/),rr=Gs(/[\dA-Za-z]/),TL=Gs(/[#-'*+\--9=?A-Z^-~]/);function Kd(e){return e!==null&&(e<32||e===127)}const dp=Gs(/\d/),EL=Gs(/[\dA-Fa-f]/),AL=Gs(/[!-/:-@[-`{-~]/);function bt(e){return e!==null&&e<-2}function fn(e){return e!==null&&(e<0||e===32)}function Gt(e){return e===-2||e===-1||e===32}const y0=Gs(new RegExp("\\p{P}|\\p{S}","u")),Ei=Gs(/\s/);function Gs(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function $o(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const l=e.charCodeAt(n);let u="";if(l===37&&rr(e.charCodeAt(n+1))&&rr(e.charCodeAt(n+2)))o=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(u=String.fromCharCode(l));else if(l>55295&&l<57344){const d=e.charCodeAt(n+1);l<56320&&d>56319&&d<57344?(u=String.fromCharCode(l,d),o=1):u="�"}else u=String.fromCharCode(l);u&&(t.push(e.slice(r,n),encodeURIComponent(u)),r=n+o+1,u=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Ht(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(m){return Gt(m)?(e.enter(n),d(m)):t(m)}function d(m){return Gt(m)&&l++<o?(e.consume(m),d):(e.exit(n),t(m))}}const _L={tokenize:jL};function jL(e){const t=e.attempt(this.parser.constructs.contentInitial,r,o);let n;return t;function r(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Ht(e,t,"linePrefix")}function o(d){return e.enter("paragraph"),l(d)}function l(d){const m=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=m),n=m,u(d)}function u(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return bt(d)?(e.consume(d),e.exit("chunkText"),l):(e.consume(d),u)}}const ML={tokenize:RL},dv={tokenize:OL};function RL(e){const t=this,n=[];let r=0,o,l,u;return d;function d(_){if(r<n.length){const O=n[r];return t.containerState=O[1],e.attempt(O[0].continuation,m,h)(_)}return h(_)}function m(_){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&j();const O=t.events.length;let z=O,D;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){D=t.events[z][1].end;break}C(r);let H=O;for(;H<t.events.length;)t.events[H][1].end={...D},H++;return $r(t.events,z+1,0,t.events.slice(O)),t.events.length=H,h(_)}return d(_)}function h(_){if(r===n.length){if(!o)return x(_);if(o.currentConstruct&&o.currentConstruct.concrete)return w(_);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(dv,p,g)(_)}function p(_){return o&&j(),C(r),x(_)}function g(_){return t.parser.lazy[t.now().line]=r!==n.length,u=t.now().offset,w(_)}function x(_){return t.containerState={},e.attempt(dv,y,w)(_)}function y(_){return r++,n.push([t.currentConstruct,t.containerState]),x(_)}function w(_){if(_===null){o&&j(),C(0),e.consume(_);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:l}),N(_)}function N(_){if(_===null){T(e.exit("chunkFlow"),!0),C(0),e.consume(_);return}return bt(_)?(e.consume(_),T(e.exit("chunkFlow")),r=0,t.interrupt=void 0,d):(e.consume(_),N)}function T(_,O){const z=t.sliceStream(_);if(O&&z.push(null),_.previous=l,l&&(l.next=_),l=_,o.defineSkip(_.start),o.write(z),t.parser.lazy[_.start.line]){let D=o.events.length;for(;D--;)if(o.events[D][1].start.offset<u&&(!o.events[D][1].end||o.events[D][1].end.offset>u))return;const H=t.events.length;let W=H,Z,U;for(;W--;)if(t.events[W][0]==="exit"&&t.events[W][1].type==="chunkFlow"){if(Z){U=t.events[W][1].end;break}Z=!0}for(C(r),D=H;D<t.events.length;)t.events[D][1].end={...U},D++;$r(t.events,W+1,0,t.events.slice(H)),t.events.length=D}}function C(_){let O=n.length;for(;O-- >_;){const z=n[O];t.containerState=z[1],z[0].exit.call(t,e)}n.length=_}function j(){o.write([null]),l=void 0,o=void 0,t.containerState._closeFlow=void 0}}function OL(e,t,n){return Ht(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Oo(e){if(e===null||fn(e)||Ei(e))return 1;if(y0(e))return 2}function v0(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const l=e[o].resolveAll;l&&!r.includes(l)&&(t=l(t,n),r.push(l))}return t}const mp={name:"attention",resolveAll:DL,tokenize:LL};function DL(e,t){let n=-1,r,o,l,u,d,m,h,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;m=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const g={...e[r][1].end},x={...e[n][1].start};mv(g,-m),mv(x,m),u={type:m>1?"strongSequence":"emphasisSequence",start:g,end:{...e[r][1].end}},d={type:m>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},l={type:m>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:m>1?"strong":"emphasis",start:{...u.start},end:{...d.end}},e[r][1].end={...u.start},e[n][1].start={...d.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=ra(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=ra(h,[["enter",o,t],["enter",u,t],["exit",u,t],["enter",l,t]]),h=ra(h,v0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=ra(h,[["exit",l,t],["enter",d,t],["exit",d,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,h=ra(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,$r(e,r-1,n-r+3,h),n=r+h.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function LL(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Oo(r);let l;return u;function u(m){return l=m,e.enter("attentionSequence"),d(m)}function d(m){if(m===l)return e.consume(m),d;const h=e.exit("attentionSequence"),p=Oo(m),g=!p||p===2&&o||n.includes(m),x=!o||o===2&&p||n.includes(r);return h._open=!!(l===42?g:g&&(o||!x)),h._close=!!(l===42?x:x&&(p||!g)),t(m)}}function mv(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const IL={name:"autolink",tokenize:PL};function PL(e,t,n){let r=0;return o;function o(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(y){return mr(y)?(e.consume(y),u):y===64?n(y):h(y)}function u(y){return y===43||y===45||y===46||rr(y)?(r=1,d(y)):h(y)}function d(y){return y===58?(e.consume(y),r=0,m):(y===43||y===45||y===46||rr(y))&&r++<32?(e.consume(y),d):(r=0,h(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||Kd(y)?n(y):(e.consume(y),m)}function h(y){return y===64?(e.consume(y),p):TL(y)?(e.consume(y),h):n(y)}function p(y){return rr(y)?g(y):n(y)}function g(y){return y===46?(e.consume(y),r=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):x(y)}function x(y){if((y===45||rr(y))&&r++<63){const w=y===45?x:g;return e.consume(y),w}return n(y)}}const vc={partial:!0,tokenize:zL};function zL(e,t,n){return r;function r(l){return Gt(l)?Ht(e,o,"linePrefix")(l):o(l)}function o(l){return l===null||bt(l)?t(l):n(l)}}const _5={continuation:{tokenize:UL},exit:$L,name:"blockQuote",tokenize:BL};function BL(e,t,n){const r=this;return o;function o(u){if(u===62){const d=r.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),l}return n(u)}function l(u){return Gt(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function UL(e,t,n){const r=this;return o;function o(u){return Gt(u)?Ht(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(_5,t,n)(u)}}function $L(e){e.exit("blockQuote")}const j5={name:"characterEscape",tokenize:HL};function HL(e,t,n){return r;function r(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),o}function o(l){return AL(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const M5={name:"characterReference",tokenize:FL};function FL(e,t,n){const r=this;let o=0,l,u;return d;function d(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),l=31,u=rr,p(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=EL,p):(e.enter("characterReferenceValue"),l=7,u=dp,p(g))}function p(g){if(g===59&&o){const x=e.exit("characterReferenceValue");return u===rr&&!ng(r.sliceSerialize(x))?n(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(g)&&o++<l?(e.consume(g),p):n(g)}}const fv={partial:!0,tokenize:GL},hv={concrete:!0,name:"codeFenced",tokenize:qL};function qL(e,t,n){const r=this,o={partial:!0,tokenize:z};let l=0,u=0,d;return m;function m(D){return h(D)}function h(D){const H=r.events[r.events.length-1];return l=H&&H[1].type==="linePrefix"?H[2].sliceSerialize(H[1],!0).length:0,d=D,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(D)}function p(D){return D===d?(u++,e.consume(D),p):u<3?n(D):(e.exit("codeFencedFenceSequence"),Gt(D)?Ht(e,g,"whitespace")(D):g(D))}function g(D){return D===null||bt(D)?(e.exit("codeFencedFence"),r.interrupt?t(D):e.check(fv,N,O)(D)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(D))}function x(D){return D===null||bt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(D)):Gt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ht(e,y,"whitespace")(D)):D===96&&D===d?n(D):(e.consume(D),x)}function y(D){return D===null||bt(D)?g(D):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(D))}function w(D){return D===null||bt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(D)):D===96&&D===d?n(D):(e.consume(D),w)}function N(D){return e.attempt(o,O,T)(D)}function T(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),C}function C(D){return l>0&&Gt(D)?Ht(e,j,"linePrefix",l+1)(D):j(D)}function j(D){return D===null||bt(D)?e.check(fv,N,O)(D):(e.enter("codeFlowValue"),_(D))}function _(D){return D===null||bt(D)?(e.exit("codeFlowValue"),j(D)):(e.consume(D),_)}function O(D){return e.exit("codeFenced"),t(D)}function z(D,H,W){let Z=0;return U;function U(J){return D.enter("lineEnding"),D.consume(J),D.exit("lineEnding"),Y}function Y(J){return D.enter("codeFencedFence"),Gt(J)?Ht(D,se,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(J):se(J)}function se(J){return J===d?(D.enter("codeFencedFenceSequence"),X(J)):W(J)}function X(J){return J===d?(Z++,D.consume(J),X):Z>=u?(D.exit("codeFencedFenceSequence"),Gt(J)?Ht(D,F,"whitespace")(J):F(J)):W(J)}function F(J){return J===null||bt(J)?(D.exit("codeFencedFence"),H(J)):W(J)}}}function GL(e,t,n){const r=this;return o;function o(u){return u===null?n(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}const ih={name:"codeIndented",tokenize:KL},VL={partial:!0,tokenize:WL};function KL(e,t,n){const r=this;return o;function o(h){return e.enter("codeIndented"),Ht(e,l,"linePrefix",5)(h)}function l(h){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?u(h):n(h)}function u(h){return h===null?m(h):bt(h)?e.attempt(VL,u,m)(h):(e.enter("codeFlowValue"),d(h))}function d(h){return h===null||bt(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),d)}function m(h){return e.exit("codeIndented"),t(h)}}function WL(e,t,n){const r=this;return o;function o(u){return r.parser.lazy[r.now().line]?n(u):bt(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o):Ht(e,l,"linePrefix",5)(u)}function l(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(u):bt(u)?o(u):n(u)}}const YL={name:"codeText",previous:QL,resolve:XL,tokenize:ZL};function XL(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function QL(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ZL(e,t,n){let r=0,o,l;return u;function u(g){return e.enter("codeText"),e.enter("codeTextSequence"),d(g)}function d(g){return g===96?(e.consume(g),r++,d):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(l=e.enter("codeTextSequence"),o=0,p(g)):bt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),m):(e.enter("codeTextData"),h(g))}function h(g){return g===null||g===32||g===96||bt(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),h)}function p(g){return g===96?(e.consume(g),o++,p):o===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(l.type="codeTextData",h(g))}}class JL{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 r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const o=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&Vl(this.left,r),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),Vl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Vl(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);Vl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Vl(this.left,n.reverse())}}}function Vl(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 R5(e){const t={};let n=-1,r,o,l,u,d,m,h;const p=new JL(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(m=r[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(r[0]==="enter")r[1].contentType&&(Object.assign(t,eI(p,n)),n=t[n],h=!0);else if(r[1]._container){for(l=n,o=void 0;l--;)if(u=p.get(l),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(o&&(p.get(o)[1].type="lineEndingBlank"),u[1].type="lineEnding",o=l);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;o&&(r[1].end={...p.get(o)[1].start},d=p.slice(o,n),d.unshift(r),p.splice(o,n-o+1,d))}}return $r(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function eI(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const l=[];let u=n._tokenizer;u||(u=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const d=u.events,m=[],h={};let p,g,x=-1,y=n,w=0,N=0;const T=[N];for(;y;){for(;e.get(++o)[1]!==y;);l.push(o),y._tokenizer||(p=r.sliceStream(y),y.next||p.push(null),g&&u.defineSkip(y.start),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(p),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),g=y,y=y.next}for(y=n;++x<d.length;)d[x][0]==="exit"&&d[x-1][0]==="enter"&&d[x][1].type===d[x-1][1].type&&d[x][1].start.line!==d[x][1].end.line&&(N=x+1,T.push(N),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(u.events=[],y?(y._tokenizer=void 0,y.previous=void 0):T.pop(),x=T.length;x--;){const C=d.slice(T[x],T[x+1]),j=l.pop();m.push([j,j+C.length-1]),e.splice(j,2,C)}for(m.reverse(),x=-1;++x<m.length;)h[w+m[x][0]]=w+m[x][1],w+=m[x][1]-m[x][0]-1;return h}const tI={resolve:rI,tokenize:aI},nI={partial:!0,tokenize:sI};function rI(e){return R5(e),e}function aI(e,t){let n;return r;function r(d){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(d)}function o(d){return d===null?l(d):bt(d)?e.check(nI,u,l)(d):(e.consume(d),o)}function l(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function u(d){return e.consume(d),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function sI(e,t,n){const r=this;return o;function o(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Ht(e,l,"linePrefix")}function l(u){if(u===null||bt(u))return n(u);const d=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(u):e.interrupt(r.parser.constructs.flow,n,t)(u)}}function O5(e,t,n,r,o,l,u,d,m){const h=m||Number.POSITIVE_INFINITY;let p=0;return g;function g(C){return C===60?(e.enter(r),e.enter(o),e.enter(l),e.consume(C),e.exit(l),x):C===null||C===32||C===41||Kd(C)?n(C):(e.enter(r),e.enter(u),e.enter(d),e.enter("chunkString",{contentType:"string"}),N(C))}function x(C){return C===62?(e.enter(l),e.consume(C),e.exit(l),e.exit(o),e.exit(r),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===62?(e.exit("chunkString"),e.exit(d),x(C)):C===null||C===60||bt(C)?n(C):(e.consume(C),C===92?w:y)}function w(C){return C===60||C===62||C===92?(e.consume(C),y):y(C)}function N(C){return!p&&(C===null||C===41||fn(C))?(e.exit("chunkString"),e.exit(d),e.exit(u),e.exit(r),t(C)):p<h&&C===40?(e.consume(C),p++,N):C===41?(e.consume(C),p--,N):C===null||C===32||C===40||Kd(C)?n(C):(e.consume(C),C===92?T:N)}function T(C){return C===40||C===41||C===92?(e.consume(C),N):N(C)}}function D5(e,t,n,r,o,l){const u=this;let d=0,m;return h;function h(y){return e.enter(r),e.enter(o),e.consume(y),e.exit(o),e.enter(l),p}function p(y){return d>999||y===null||y===91||y===93&&!m||y===94&&!d&&"_hiddenFootnoteSupport"in u.parser.constructs?n(y):y===93?(e.exit(l),e.enter(o),e.consume(y),e.exit(o),e.exit(r),t):bt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),g(y))}function g(y){return y===null||y===91||y===93||bt(y)||d++>999?(e.exit("chunkString"),p(y)):(e.consume(y),m||(m=!Gt(y)),y===92?x:g)}function x(y){return y===91||y===92||y===93?(e.consume(y),d++,g):g(y)}}function L5(e,t,n,r,o,l){let u;return d;function d(x){return x===34||x===39||x===40?(e.enter(r),e.enter(o),e.consume(x),e.exit(o),u=x===40?41:x,m):n(x)}function m(x){return x===u?(e.enter(o),e.consume(x),e.exit(o),e.exit(r),t):(e.enter(l),h(x))}function h(x){return x===u?(e.exit(l),m(u)):x===null?n(x):bt(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Ht(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===u||x===null||bt(x)?(e.exit("chunkString"),h(x)):(e.consume(x),x===92?g:p)}function g(x){return x===u||x===92?(e.consume(x),p):p(x)}}function ec(e,t){let n;return r;function r(o){return bt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Gt(o)?Ht(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}const iI={name:"definition",tokenize:lI},oI={partial:!0,tokenize:cI};function lI(e,t,n){const r=this;let o;return l;function l(y){return e.enter("definition"),u(y)}function u(y){return D5.call(r,e,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function d(y){return o=da(r.sliceSerialize(r.events[r.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 fn(y)?ec(e,h)(y):h(y)}function h(y){return O5(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(oI,g,g)(y)}function g(y){return Gt(y)?Ht(e,x,"whitespace")(y):x(y)}function x(y){return y===null||bt(y)?(e.exit("definition"),r.parser.defined.push(o),t(y)):n(y)}}function cI(e,t,n){return r;function r(d){return fn(d)?ec(e,o)(d):n(d)}function o(d){return L5(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function l(d){return Gt(d)?Ht(e,u,"whitespace")(d):u(d)}function u(d){return d===null||bt(d)?t(d):n(d)}}const uI={name:"hardBreakEscape",tokenize:dI};function dI(e,t,n){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),o}function o(l){return bt(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const mI={name:"headingAtx",resolve:fI,tokenize:hI};function fI(e,t){let n=e.length-2,r=3,o,l;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},l={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},$r(e,r,n-r+1,[["enter",o,t],["enter",l,t],["exit",l,t],["exit",o,t]])),e}function hI(e,t,n){let r=0;return o;function o(p){return e.enter("atxHeading"),l(p)}function l(p){return e.enter("atxHeadingSequence"),u(p)}function u(p){return p===35&&r++<6?(e.consume(p),u):p===null||fn(p)?(e.exit("atxHeadingSequence"),d(p)):n(p)}function d(p){return p===35?(e.enter("atxHeadingSequence"),m(p)):p===null||bt(p)?(e.exit("atxHeading"),t(p)):Gt(p)?Ht(e,d,"whitespace")(p):(e.enter("atxHeadingText"),h(p))}function m(p){return p===35?(e.consume(p),m):(e.exit("atxHeadingSequence"),d(p))}function h(p){return p===null||p===35||fn(p)?(e.exit("atxHeadingText"),d(p)):(e.consume(p),h)}}const pI=["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"],pv=["pre","script","style","textarea"],gI={concrete:!0,name:"htmlFlow",resolveTo:yI,tokenize:vI},bI={partial:!0,tokenize:kI},xI={partial:!0,tokenize:wI};function yI(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 vI(e,t,n){const r=this;let o,l,u,d,m;return h;function h(I){return p(I)}function p(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),g}function g(I){return I===33?(e.consume(I),x):I===47?(e.consume(I),l=!0,N):I===63?(e.consume(I),o=3,r.interrupt?t:$):mr(I)?(e.consume(I),u=String.fromCharCode(I),T):n(I)}function x(I){return I===45?(e.consume(I),o=2,y):I===91?(e.consume(I),o=5,d=0,w):mr(I)?(e.consume(I),o=4,r.interrupt?t:$):n(I)}function y(I){return I===45?(e.consume(I),r.interrupt?t:$):n(I)}function w(I){const Ee="CDATA[";return I===Ee.charCodeAt(d++)?(e.consume(I),d===Ee.length?r.interrupt?t:se:w):n(I)}function N(I){return mr(I)?(e.consume(I),u=String.fromCharCode(I),T):n(I)}function T(I){if(I===null||I===47||I===62||fn(I)){const Ee=I===47,Ue=u.toLowerCase();return!Ee&&!l&&pv.includes(Ue)?(o=1,r.interrupt?t(I):se(I)):pI.includes(u.toLowerCase())?(o=6,Ee?(e.consume(I),C):r.interrupt?t(I):se(I)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(I):l?j(I):_(I))}return I===45||rr(I)?(e.consume(I),u+=String.fromCharCode(I),T):n(I)}function C(I){return I===62?(e.consume(I),r.interrupt?t:se):n(I)}function j(I){return Gt(I)?(e.consume(I),j):U(I)}function _(I){return I===47?(e.consume(I),U):I===58||I===95||mr(I)?(e.consume(I),O):Gt(I)?(e.consume(I),_):U(I)}function O(I){return I===45||I===46||I===58||I===95||rr(I)?(e.consume(I),O):z(I)}function z(I){return I===61?(e.consume(I),D):Gt(I)?(e.consume(I),z):_(I)}function D(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),m=I,H):Gt(I)?(e.consume(I),D):W(I)}function H(I){return I===m?(e.consume(I),m=null,Z):I===null||bt(I)?n(I):(e.consume(I),H)}function W(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||fn(I)?z(I):(e.consume(I),W)}function Z(I){return I===47||I===62||Gt(I)?_(I):n(I)}function U(I){return I===62?(e.consume(I),Y):n(I)}function Y(I){return I===null||bt(I)?se(I):Gt(I)?(e.consume(I),Y):n(I)}function se(I){return I===45&&o===2?(e.consume(I),B):I===60&&o===1?(e.consume(I),Q):I===62&&o===4?(e.consume(I),G):I===63&&o===3?(e.consume(I),$):I===93&&o===5?(e.consume(I),ke):bt(I)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(bI,le,X)(I)):I===null||bt(I)?(e.exit("htmlFlowData"),X(I)):(e.consume(I),se)}function X(I){return e.check(xI,F,le)(I)}function F(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),J}function J(I){return I===null||bt(I)?X(I):(e.enter("htmlFlowData"),se(I))}function B(I){return I===45?(e.consume(I),$):se(I)}function Q(I){return I===47?(e.consume(I),u="",re):se(I)}function re(I){if(I===62){const Ee=u.toLowerCase();return pv.includes(Ee)?(e.consume(I),G):se(I)}return mr(I)&&u.length<8?(e.consume(I),u+=String.fromCharCode(I),re):se(I)}function ke(I){return I===93?(e.consume(I),$):se(I)}function $(I){return I===62?(e.consume(I),G):I===45&&o===2?(e.consume(I),$):se(I)}function G(I){return I===null||bt(I)?(e.exit("htmlFlowData"),le(I)):(e.consume(I),G)}function le(I){return e.exit("htmlFlow"),t(I)}}function wI(e,t,n){const r=this;return o;function o(u){return bt(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):n(u)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}function kI(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(vc,t,n)}}const SI={name:"htmlText",tokenize:NI};function NI(e,t,n){const r=this;let o,l,u;return d;function d($){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume($),m}function m($){return $===33?(e.consume($),h):$===47?(e.consume($),z):$===63?(e.consume($),_):mr($)?(e.consume($),W):n($)}function h($){return $===45?(e.consume($),p):$===91?(e.consume($),l=0,w):mr($)?(e.consume($),j):n($)}function p($){return $===45?(e.consume($),y):n($)}function g($){return $===null?n($):$===45?(e.consume($),x):bt($)?(u=g,Q($)):(e.consume($),g)}function x($){return $===45?(e.consume($),y):g($)}function y($){return $===62?B($):$===45?x($):g($)}function w($){const G="CDATA[";return $===G.charCodeAt(l++)?(e.consume($),l===G.length?N:w):n($)}function N($){return $===null?n($):$===93?(e.consume($),T):bt($)?(u=N,Q($)):(e.consume($),N)}function T($){return $===93?(e.consume($),C):N($)}function C($){return $===62?B($):$===93?(e.consume($),C):N($)}function j($){return $===null||$===62?B($):bt($)?(u=j,Q($)):(e.consume($),j)}function _($){return $===null?n($):$===63?(e.consume($),O):bt($)?(u=_,Q($)):(e.consume($),_)}function O($){return $===62?B($):_($)}function z($){return mr($)?(e.consume($),D):n($)}function D($){return $===45||rr($)?(e.consume($),D):H($)}function H($){return bt($)?(u=H,Q($)):Gt($)?(e.consume($),H):B($)}function W($){return $===45||rr($)?(e.consume($),W):$===47||$===62||fn($)?Z($):n($)}function Z($){return $===47?(e.consume($),B):$===58||$===95||mr($)?(e.consume($),U):bt($)?(u=Z,Q($)):Gt($)?(e.consume($),Z):B($)}function U($){return $===45||$===46||$===58||$===95||rr($)?(e.consume($),U):Y($)}function Y($){return $===61?(e.consume($),se):bt($)?(u=Y,Q($)):Gt($)?(e.consume($),Y):Z($)}function se($){return $===null||$===60||$===61||$===62||$===96?n($):$===34||$===39?(e.consume($),o=$,X):bt($)?(u=se,Q($)):Gt($)?(e.consume($),se):(e.consume($),F)}function X($){return $===o?(e.consume($),o=void 0,J):$===null?n($):bt($)?(u=X,Q($)):(e.consume($),X)}function F($){return $===null||$===34||$===39||$===60||$===61||$===96?n($):$===47||$===62||fn($)?Z($):(e.consume($),F)}function J($){return $===47||$===62||fn($)?Z($):n($)}function B($){return $===62?(e.consume($),e.exit("htmlTextData"),e.exit("htmlText"),t):n($)}function Q($){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),re}function re($){return Gt($)?Ht(e,ke,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):ke($)}function ke($){return e.enter("htmlTextData"),u($)}}const rg={name:"labelEnd",resolveAll:AI,resolveTo:_I,tokenize:jI},CI={tokenize:MI},TI={tokenize:RI},EI={tokenize:OI};function AI(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&$r(e,0,e.length,n),e}function _I(e,t){let n=e.length,r=0,o,l,u,d;for(;n--;)if(o=e[n][1],l){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(l=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(u=n);const m={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[l][1].start},end:{...e[u][1].end}},p={type:"labelText",start:{...e[l+r+2][1].end},end:{...e[u-2][1].start}};return d=[["enter",m,t],["enter",h,t]],d=ra(d,e.slice(l+1,l+r+3)),d=ra(d,[["enter",p,t]]),d=ra(d,v0(t.parser.constructs.insideSpan.null,e.slice(l+r+4,u-3),t)),d=ra(d,[["exit",p,t],e[u-2],e[u-1],["exit",h,t]]),d=ra(d,e.slice(u+1)),d=ra(d,[["exit",m,t]]),$r(e,l,e.length,d),e}function jI(e,t,n){const r=this;let o=r.events.length,l,u;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){l=r.events[o][1];break}return d;function d(x){return l?l._inactive?g(x):(u=r.parser.defined.includes(da(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),m):n(x)}function m(x){return x===40?e.attempt(CI,p,u?p:g)(x):x===91?e.attempt(TI,p,u?h:g)(x):u?p(x):g(x)}function h(x){return e.attempt(EI,p,g)(x)}function p(x){return t(x)}function g(x){return l._balanced=!0,n(x)}}function MI(e,t,n){return r;function r(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return fn(g)?ec(e,l)(g):l(g)}function l(g){return g===41?p(g):O5(e,u,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function u(g){return fn(g)?ec(e,m)(g):p(g)}function d(g){return n(g)}function m(g){return g===34||g===39||g===40?L5(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):p(g)}function h(g){return fn(g)?ec(e,p)(g):p(g)}function p(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):n(g)}}function RI(e,t,n){const r=this;return o;function o(d){return D5.call(r,e,l,u,"reference","referenceMarker","referenceString")(d)}function l(d){return r.parser.defined.includes(da(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(d):n(d)}function u(d){return n(d)}}function OI(e,t,n){return r;function r(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),o}function o(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const DI={name:"labelStartImage",resolveAll:rg.resolveAll,tokenize:LI};function LI(e,t,n){const r=this;return o;function o(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),l}function l(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),u):n(d)}function u(d){return d===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(d):t(d)}}const II={name:"labelStartLink",resolveAll:rg.resolveAll,tokenize:PI};function PI(e,t,n){const r=this;return o;function o(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),l}function l(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const oh={name:"lineEnding",tokenize:zI};function zI(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ht(e,t,"linePrefix")}}const _d={name:"thematicBreak",tokenize:BI};function BI(e,t,n){let r=0,o;return l;function l(h){return e.enter("thematicBreak"),u(h)}function u(h){return o=h,d(h)}function d(h){return h===o?(e.enter("thematicBreakSequence"),m(h)):r>=3&&(h===null||bt(h))?(e.exit("thematicBreak"),t(h)):n(h)}function m(h){return h===o?(e.consume(h),r++,m):(e.exit("thematicBreakSequence"),Gt(h)?Ht(e,d,"whitespace")(h):d(h))}}const Nr={continuation:{tokenize:FI},exit:GI,name:"list",tokenize:HI},UI={partial:!0,tokenize:VI},$I={partial:!0,tokenize:qI};function HI(e,t,n){const r=this,o=r.events[r.events.length-1];let l=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,u=0;return d;function d(y){const w=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:dp(y)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(_d,n,h)(y):h(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(y)}return n(y)}function m(y){return dp(y)&&++u<10?(e.consume(y),m):(!r.interrupt||u<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(vc,r.interrupt?n:p,e.attempt(UI,x,g))}function p(y){return r.containerState.initialBlankLine=!0,l++,x(y)}function g(y){return Gt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),x):n(y)}function x(y){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function FI(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(vc,o,l);function o(d){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ht(e,t,"listItemIndent",r.containerState.size+1)(d)}function l(d){return r.containerState.furtherBlankLines||!Gt(d)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,u(d)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt($I,t,u)(d))}function u(d){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ht(e,e.attempt(Nr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function qI(e,t,n){const r=this;return Ht(e,o,"listItemIndent",r.containerState.size+1);function o(l){const u=r.events[r.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===r.containerState.size?t(l):n(l)}}function GI(e){e.exit(this.containerState.type)}function VI(e,t,n){const r=this;return Ht(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(l){const u=r.events[r.events.length-1];return!Gt(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const gv={name:"setextUnderline",resolveTo:KI,tokenize:WI};function KI(e,t){let n=e.length,r,o,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const u={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",l?(e.splice(o,0,["enter",u,t]),e.splice(l+1,0,["exit",e[r][1],t]),e[r][1].end={...e[l][1].end}):e[r][1]=u,e.push(["exit",u,t]),e}function WI(e,t,n){const r=this;let o;return l;function l(h){let p=r.events.length,g;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){g=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||g)?(e.enter("setextHeadingLine"),o=h,u(h)):n(h)}function u(h){return e.enter("setextHeadingLineSequence"),d(h)}function d(h){return h===o?(e.consume(h),d):(e.exit("setextHeadingLineSequence"),Gt(h)?Ht(e,m,"lineSuffix")(h):m(h))}function m(h){return h===null||bt(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const YI={tokenize:XI};function XI(e){const t=this,n=e.attempt(vc,r,e.attempt(this.parser.constructs.flowInitial,o,Ht(e,e.attempt(this.parser.constructs.flow,o,e.attempt(tI,o)),"linePrefix")));return n;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const QI={resolveAll:P5()},ZI=I5("string"),JI=I5("text");function I5(e){return{resolveAll:P5(e==="text"?eP:void 0),tokenize:t};function t(n){const r=this,o=this.parser.constructs[e],l=n.attempt(o,u,d);return u;function u(p){return h(p)?l(p):d(p)}function d(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),m}function m(p){return h(p)?(n.exit("data"),l(p)):(n.consume(p),m)}function h(p){if(p===null)return!0;const g=o[p];let x=-1;if(g)for(;++x<g.length;){const y=g[x];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function P5(e){return t;function t(n,r){let o=-1,l;for(;++o<=n.length;)l===void 0?n[o]&&n[o][1].type==="data"&&(l=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==l+2&&(n[l][1].end=n[o-1][1].end,n.splice(l+2,o-l-2),o=l+2),l=void 0);return e?e(n,r):n}}function eP(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 r=e[n-1][1],o=t.sliceStream(r);let l=o.length,u=-1,d=0,m;for(;l--;){const h=o[l];if(typeof h=="string"){for(u=h.length;h.charCodeAt(u-1)===32;)d++,u--;if(u)break;u=-1}else if(h===-2)m=!0,d++;else if(h!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(d=0),d){const h={type:n===e.length||m||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?u:r.start._bufferIndex+u,_index:r.start._index+l,line:r.end.line,column:r.end.column-d,offset:r.end.offset-d},end:{...r.end}};r.end={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const tP={42:Nr,43:Nr,45:Nr,48:Nr,49:Nr,50:Nr,51:Nr,52:Nr,53:Nr,54:Nr,55:Nr,56:Nr,57:Nr,62:_5},nP={91:iI},rP={[-2]:ih,[-1]:ih,32:ih},aP={35:mI,42:_d,45:[gv,_d],60:gI,61:gv,95:_d,96:hv,126:hv},sP={38:M5,92:j5},iP={[-5]:oh,[-4]:oh,[-3]:oh,33:DI,38:M5,42:mp,60:[IL,SI],91:II,92:[uI,j5],93:rg,95:mp,96:YL},oP={null:[mp,QI]},lP={null:[42,95]},cP={null:[]},uP=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:lP,contentInitial:nP,disable:cP,document:tP,flow:aP,flowInitial:rP,insideSpan:oP,string:sP,text:iP},Symbol.toStringTag,{value:"Module"}));function dP(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},l=[];let u=[],d=[];const m={attempt:H(z),check:H(D),consume:j,enter:_,exit:O,interrupt:H(D,{interrupt:!0})},h={code:null,containerState:{},defineSkip:N,events:[],now:w,parser:e,previous:null,sliceSerialize:x,sliceStream:y,write:g};let p=t.tokenize.call(h,m);return t.resolveAll&&l.push(t),h;function g(Y){return u=ra(u,Y),T(),u[u.length-1]!==null?[]:(W(t,0),h.events=v0(l,h.events,h),h.events)}function x(Y,se){return fP(y(Y),se)}function y(Y){return mP(u,Y)}function w(){const{_bufferIndex:Y,_index:se,line:X,column:F,offset:J}=r;return{_bufferIndex:Y,_index:se,line:X,column:F,offset:J}}function N(Y){o[Y.line]=Y.column,U()}function T(){let Y;for(;r._index<u.length;){const se=u[r._index];if(typeof se=="string")for(Y=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===Y&&r._bufferIndex<se.length;)C(se.charCodeAt(r._bufferIndex));else C(se)}}function C(Y){p=p(Y)}function j(Y){bt(Y)?(r.line++,r.column=1,r.offset+=Y===-3?2:1,U()):Y!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===u[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=Y}function _(Y,se){const X=se||{};return X.type=Y,X.start=w(),h.events.push(["enter",X,h]),d.push(X),X}function O(Y){const se=d.pop();return se.end=w(),h.events.push(["exit",se,h]),se}function z(Y,se){W(Y,se.from)}function D(Y,se){se.restore()}function H(Y,se){return X;function X(F,J,B){let Q,re,ke,$;return Array.isArray(F)?le(F):"tokenize"in F?le([F]):G(F);function G(Oe){return We;function We(st){const dt=st!==null&&Oe[st],Et=st!==null&&Oe.null,gt=[...Array.isArray(dt)?dt:dt?[dt]:[],...Array.isArray(Et)?Et:Et?[Et]:[]];return le(gt)(st)}}function le(Oe){return Q=Oe,re=0,Oe.length===0?B:I(Oe[re])}function I(Oe){return We;function We(st){return $=Z(),ke=Oe,Oe.partial||(h.currentConstruct=Oe),Oe.name&&h.parser.constructs.disable.null.includes(Oe.name)?Ue():Oe.tokenize.call(se?Object.assign(Object.create(h),se):h,m,Ee,Ue)(st)}}function Ee(Oe){return Y(ke,$),J}function Ue(Oe){return $.restore(),++re<Q.length?I(Q[re]):B}}}function W(Y,se){Y.resolveAll&&!l.includes(Y)&&l.push(Y),Y.resolve&&$r(h.events,se,h.events.length-se,Y.resolve(h.events.slice(se),h)),Y.resolveTo&&(h.events=Y.resolveTo(h.events,h))}function Z(){const Y=w(),se=h.previous,X=h.currentConstruct,F=h.events.length,J=Array.from(d);return{from:F,restore:B};function B(){r=Y,h.previous=se,h.currentConstruct=X,h.events.length=F,d=J,U()}}function U(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function mP(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,l=t.end._bufferIndex;let u;if(n===o)u=[e[n].slice(r,l)];else{if(u=e.slice(n,o),r>-1){const d=u[0];typeof d=="string"?u[0]=d.slice(r):u.shift()}l>0&&u.push(e[o].slice(0,l))}return u}function fP(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const l=e[n];let u;if(typeof l=="string")u=l;else switch(l){case-5:{u="\r";break}case-4:{u=`
|
|
356
356
|
`;break}case-3:{u=`\r
|
|
@@ -645,7 +645,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
645
645
|
`},h]}}const XF=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_-]*/}}),QF=["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"],ZF=["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"],JF=[...QF,...ZF],eq=["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(),Lk=["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(),Ik=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),tq=["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(),nq=Lk.concat(Ik).sort().reverse();function rq(e){const t=XF(e),n=nq,r="and or not only",o="[\\w-]+",l="("+o+"|@\\{"+o+"\\})",u=[],d=[],m=function(_){return{className:"string",begin:"~?"+_+".*?"+_}},h=function(_,O,z){return{className:_,begin:O,relevance:z}},p={$pattern:/[a-z-]+/,keyword:r,attribute:eq.join(" ")},g={begin:"\\(",end:"\\)",contains:d,keywords:p,relevance:0};d.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,m("'"),m('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,g,h("variable","@@?"+o,10),h("variable","@\\{"+o+"\\}"),h("built_in","~?`[^`]*?`"),{className:"attribute",begin:o+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const x=d.concat({begin:/\{/,end:/\}/,contains:u}),y={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(d)},w={begin:l+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+tq.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:d}}]},N={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:p,returnEnd:!0,contains:d,relevance:0}},T={className:"variable",variants:[{begin:"@"+o+"\\s*:",relevance:15},{begin:"@"+o}],starts:{end:"[;}]",returnEnd:!0,contains:x}},C={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,h("keyword","all\\b"),h("variable","@\\{"+o+"\\}"),{begin:"\\b("+JF.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,h("selector-tag",l,0),h("selector-id","#"+l),h("selector-class","\\."+l,0),h("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+Lk.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+Ik.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:x},{begin:"!important"},t.FUNCTION_DISPATCH]},j={begin:o+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[C]};return u.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,N,T,j,w,C,y,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:u}}function aq(e){const t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},o=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:o.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:o}].concat(o)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}}function sq(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},o={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},l={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},u={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,r,o,l,u]}}function iq(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},o={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},l={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},u={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},d=/[A-Za-z][A-Za-z0-9+.-]*/,m={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,d,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(h,{contains:[]}),x=e.inherit(p,{contains:[]});h.contains.push(x),p.contains.push(g);let y=[n,m];return[h,p,g,x].forEach(C=>{C.contains=C.contains.concat(y)}),y=y.concat(h,p),{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,h,p,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},o,r,m,u,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function oq(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,d={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},m={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:d,illegal:"</",contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+m.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:m,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function lq(e){const t=e.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,o={$pattern:/[\w.]+/,keyword:n.join(" ")},l={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:o},u={begin:/->\{/,end:/\}/},d={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},m={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[d]},h={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},p=[e.BACKSLASH_ESCAPE,l,m],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],x=(N,T,C="\\1")=>{const j=C==="\\1"?C:t.concat(C,T);return t.concat(t.concat("(?:",N,")"),T,/(?:\\.|[^\\\/])*?/,j,/(?:\\.|[^\\\/])*?/,C,r)},y=(N,T,C)=>t.concat(t.concat("(?:",N,")"),T,/(?:\\.|[^\\\/])*?/,C,r),w=[m,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),u,{className:"string",contains:p,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}]},h,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:x("s|tr|y",t.either(...g,{capture:!0}))},{begin:x("s|tr|y","\\(","\\)")},{begin:x("s|tr|y","\\[","\\]")},{begin:x("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:y("(?:m|qr)?",/\//,/\//)},{begin:y("m|qr",t.either(...g,{capture:!0}),/\1/)},{begin:y("m|qr",/\(/,/\)/)},{begin:y("m|qr",/\[/,/\]/)},{begin:y("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,d]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,d,h]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return l.contains=w,u.contains=w,{name:"Perl",aliases:["pl","pm"],keywords:o,contains:w}}function cq(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),o=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),l=t.concat(/[A-Z]+/,n),u={scope:"variable",match:"\\$+"+r},d={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},m={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},h=e.inherit(e.APOS_STRING_MODE,{illegal:null}),p=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(m)}),g={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(m),"on:begin":(F,J)=>{J.data._beginMatch=F[1]||F[2]},"on:end":(F,J)=>{J.data._beginMatch!==F[1]&&J.ignoreMatch()}},x=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),y=`[
|
|
646
646
|
]`,w={scope:"string",variants:[p,h,g,x]},N={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},T=["false","null","true"],C=["__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"],j=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],O={keyword:C,literal:(F=>{const J=[];return F.forEach(B=>{J.push(B),B.toLowerCase()===B?J.push(B.toUpperCase()):J.push(B.toLowerCase())}),J})(T),built_in:j},z=F=>F.map(J=>J.replace(/\|\d+$/,"")),D={variants:[{match:[/new/,t.concat(y,"+"),t.concat("(?!",z(j).join("\\b|"),"\\b)"),o],scope:{1:"keyword",4:"title.class"}}]},H=t.concat(r,"\\b(?!\\()"),W={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),H],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[o,t.concat(/::/,t.lookahead(/(?!class\b)/)),H],scope:{1:"title.class",3:"variable.constant"}},{match:[o,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[o,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},Z={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},U={relevance:0,begin:/\(/,end:/\)/,keywords:O,contains:[Z,u,W,e.C_BLOCK_COMMENT_MODE,w,N,D]},Y={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",z(C).join("\\b|"),"|",z(j).join("\\b|"),"\\b)"),r,t.concat(y,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[U]};U.contains.push(Y);const se=[Z,W,e.C_BLOCK_COMMENT_MODE,w,N,D],X={begin:t.concat(/#\[\s*\\?/,t.either(o,l)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:T,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:T,keyword:["new","array"]},contains:["self",...se]},...se,{scope:"meta",variants:[{match:o},{match:l}]}]};return{case_insensitive:!1,keywords:O,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}]}},d,{scope:"variable.language",match:/\$this\b/},u,Y,W,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},D,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:O,contains:["self",X,u,W,e.C_BLOCK_COMMENT_MODE,w,N]}]},{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,N]}}function uq(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 dq(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function mq(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],d={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},m={className:"meta",begin:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:d,illegal:/#/},p={begin:/\{\{/,relevance:0},g={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,m],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,m,p,h]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m,p,h]},{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,p,h]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},x="[0-9](_?[0-9])*",y=`(\\b(${x}))?\\.(${x})|\\b(${x})\\.`,w=`\\b|${r.join("|")}`,N={className:"number",relevance:0,variants:[{begin:`(\\b(${x})|(${y}))[eE][+-]?(${x})[jJ]?(?=${w})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${w})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${w})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${w})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${w})`},{begin:`\\b(${x})[jJ](?=${w})`}]},T={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:d,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},C={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:["self",m,N,g,e.HASH_COMMENT_MODE]}]};return h.contains=[g,N,m],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:d,illegal:/(<\/|\?)|=>/,contains:[m,N,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,T,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[C]},{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:[N,C,g]}]}}function fq(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function hq(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),o=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,l=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[o,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[l,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:o},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:l},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function pq(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),o=t.concat(r,/(::\w+)*/),u={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},d={className:"doctag",begin:"@[A-Za-z]+"},m={begin:"#<",end:">"},h=[e.COMMENT("#","$",{contains:[d]}),e.COMMENT("^=begin","^=end",{contains:[d],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],p={className:"subst",begin:/#\{/,end:/\}/,keywords:u},g={className:"string",contains:[e.BACKSLASH_ESCAPE,p],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,p]})]}]},x="[1-9](_?[0-9])*|0",y="[0-9](_?[0-9])*",w={className:"number",relevance:0,variants:[{begin:`\\b(${x})(\\.(${y}))?([eE][+-]?(${y})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},N={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:u}]},D=[g,{variants:[{match:[/class\s+/,o,/\s+<\s+/,o]},{match:[/\b(class|module)\s+/,o]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:u},{match:[/(include|extend)\s+/,o],scope:{2:"title.class"},keywords:u},{relevance:0,match:[o,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[N]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[g,{begin:n}],relevance:0},w,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:u},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,p],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,h),relevance:0}].concat(m,h);p.contains=D,N.contains=D;const U=[{begin:/^\s*=>/,starts:{end:"$",contains:D}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:u,contains:D}}];return h.unshift(m),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:u,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(U).concat(h).concat(D)}}function gq(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),l={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,o,t.lookahead(/\s*\(/))},u="([ui](8|16|32|64|128|size)|f(32|64))?",d=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],m=["true","false","Some","None","Ok","Err"],h=["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!"],p=["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:p,keyword:d,literal:m,built_in:h},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_]+)"+u},{begin:"\\b0o([0-7_]+)"+u},{begin:"\\b0x([A-Fa-f0-9_]+)"+u},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+u}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:p}},{className:"punctuation",begin:"->"},l]}}const bq=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_-]*/}}),xq=["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"],yq=["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"],vq=[...xq,...yq],wq=["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(),kq=["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(),Sq=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Nq=["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 Cq(e){const t=bq(e),n=Sq,r=kq,o="@[a-z-]+",l="and or not only",d={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+vq.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},d,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Nq.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,d,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:o,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:l,attribute:wq.join(" ")},contains:[{begin:o,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},d,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function Tq(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Eq(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},o={begin:/"/,end:/"/,contains:[{match:/""/}]},l=["true","false","unknown"],u=["double precision","large object","with timezone","without timezone"],d=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],m=["add","asc","collation","desc","final","first","last","view"],h=["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"],p=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],g=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],x=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],y=p,w=[...h,...m].filter(z=>!p.includes(z)),N={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},T={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},C={match:t.concat(/\b/,t.either(...y),/\s*\(/),relevance:0,keywords:{built_in:y}};function j(z){return t.concat(/\b/,t.either(...z.map(D=>D.replace(/\s+/,"\\s+"))),/\b/)}const _={scope:"keyword",match:j(x),relevance:0};function O(z,{exceptions:D,when:H}={}){const W=H;return D=D||[],z.map(Z=>Z.match(/\|\d+$/)||D.includes(Z)?Z:W(Z)?`${Z}|0`:Z)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:O(w,{when:z=>z.length<3}),literal:l,type:d,built_in:g},contains:[{scope:"type",match:j(u)},_,C,N,r,o,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,T]}}function Pk(e){return e?typeof e=="string"?e:e.source:null}function Wl(e){return dn("(?=",e,")")}function dn(...e){return e.map(n=>Pk(n)).join("")}function Aq(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function cr(...e){return"("+(Aq(e).capture?"":"?:")+e.map(r=>Pk(r)).join("|")+")"}const jg=e=>dn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),_q=["Protocol","Type"].map(jg),j2=["init","self"].map(jg),jq=["Any","Self"],Ph=["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"],M2=["false","nil","true"],Mq=["assignment","associativity","higherThan","left","lowerThan","none","right"],Rq=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],R2=["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"],zk=cr(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),Bk=cr(zk,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),zh=dn(zk,Bk,"*"),Uk=cr(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),r0=cr(Uk,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),ba=dn(Uk,r0,"*"),ud=dn(/[A-Z]/,r0,"*"),Oq=["attached","autoclosure",dn(/convention\(/,cr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",dn(/objc\(/,ba,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],Dq=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function Lq(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],o={match:[/\./,cr(..._q,...j2)],className:{2:"keyword"}},l={match:dn(/\./,cr(...Ph)),relevance:0},u=Ph.filter(Me=>typeof Me=="string").concat(["_|0"]),d=Ph.filter(Me=>typeof Me!="string").concat(jq).map(jg),m={variants:[{className:"keyword",match:cr(...d,...j2)}]},h={$pattern:cr(/\b\w+/,/#\w+/),keyword:u.concat(Rq),literal:M2},p=[o,l,m],g={match:dn(/\./,cr(...R2)),relevance:0},x={className:"built_in",match:dn(/\b/,cr(...R2),/(?=\()/)},y=[g,x],w={match:/->/,relevance:0},N={className:"operator",relevance:0,variants:[{match:zh},{match:`\\.(\\.|${Bk})+`}]},T=[w,N],C="([0-9]_*)+",j="([0-9a-fA-F]_*)+",_={className:"number",relevance:0,variants:[{match:`\\b(${C})(\\.(${C}))?([eE][+-]?(${C}))?\\b`},{match:`\\b0x(${j})(\\.(${j}))?([pP][+-]?(${C}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},O=(Me="")=>({className:"subst",variants:[{match:dn(/\\/,Me,/[0\\tnr"']/)},{match:dn(/\\/,Me,/u\{[0-9a-fA-F]{1,8}\}/)}]}),z=(Me="")=>({className:"subst",match:dn(/\\/,Me,/[\t ]*(?:[\r\n]|\r\n)/)}),D=(Me="")=>({className:"subst",label:"interpol",begin:dn(/\\/,Me,/\(/),end:/\)/}),H=(Me="")=>({begin:dn(Me,/"""/),end:dn(/"""/,Me),contains:[O(Me),z(Me),D(Me)]}),W=(Me="")=>({begin:dn(Me,/"/),end:dn(/"/,Me),contains:[O(Me),D(Me)]}),Z={className:"string",variants:[H(),H("#"),H("##"),H("###"),W(),W("#"),W("##"),W("###")]},U=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],Y={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:U},se=Me=>{const Ge=dn(Me,/\//),ot=dn(/\//,Me);return{begin:Ge,end:ot,contains:[...U,{scope:"comment",begin:`#(?!.*${ot})`,end:/$/}]}},X={scope:"regexp",variants:[se("###"),se("##"),se("#"),Y]},F={match:dn(/`/,ba,/`/)},J={className:"variable",match:/\$\d+/},B={className:"variable",match:`\\$${r0}+`},Q=[F,J,B],re={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:Dq,contains:[...T,_,Z]}]}},ke={scope:"keyword",match:dn(/@/,cr(...Oq),Wl(cr(/\(/,/\s+/)))},$={scope:"meta",match:dn(/@/,ba)},G=[re,ke,$],le={match:Wl(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:dn(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,r0,"+")},{className:"type",match:ud,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:dn(/\s+&\s+/,Wl(ud)),relevance:0}]},I={begin:/</,end:/>/,keywords:h,contains:[...r,...p,...G,w,le]};le.contains.push(I);const Ee={match:dn(ba,/\s*:/),keywords:"_|0",relevance:0},Ue={begin:/\(/,end:/\)/,relevance:0,keywords:h,contains:["self",Ee,...r,X,...p,...y,...T,_,Z,...Q,...G,le]},Oe={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,le]},We={begin:cr(Wl(dn(ba,/\s*:/)),Wl(dn(ba,/\s+/,ba,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:ba}]},st={begin:/\(/,end:/\)/,keywords:h,contains:[We,...r,...p,...T,_,Z,...G,le,Ue],endsParent:!0,illegal:/["']/},dt={match:[/(func|macro)/,/\s+/,cr(F.match,ba,zh)],className:{1:"keyword",3:"title.function"},contains:[Oe,st,t],illegal:[/\[/,/%/]},Et={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Oe,st,t],illegal:/\[|%/},gt={match:[/operator/,/\s+/,zh],className:{1:"keyword",3:"title"}},jt={begin:[/precedencegroup/,/\s+/,ud],className:{1:"keyword",3:"title"},contains:[le],keywords:[...Mq,...M2],end:/}/},Jt={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Rt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},be={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,ba,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:h,contains:[Oe,...p,{begin:/:/,end:/\{/,keywords:h,contains:[{scope:"title.class.inherited",match:ud},...p],relevance:0}]};for(const Me of Z.variants){const Ge=Me.contains.find(mt=>mt.label==="interpol");Ge.keywords=h;const ot=[...p,...y,...T,_,Z,...Q];Ge.contains=[...ot,{begin:/\(/,end:/\)/,contains:["self",...ot]}]}return{name:"Swift",keywords:h,contains:[...r,dt,Et,Jt,Rt,be,gt,jt,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},X,...p,...y,...T,_,Z,...Q,...G,le,Ue]}}const a0="[A-Za-z$_][0-9A-Za-z$_]*",$k=["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"],Hk=["true","false","null","undefined","NaN","Infinity"],Fk=["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"],qk=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Gk=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Vk=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Kk=[].concat(Gk,Fk,qk);function Iq(e){const t=e.regex,n=(re,{after:ke})=>{const $="</"+re[0].slice(1);return re.input.indexOf($,ke)!==-1},r=a0,o={begin:"<>",end:"</>"},l=/<[A-Za-z0-9\\._:-]+\s*\/>/,u={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(re,ke)=>{const $=re[0].length+re.index,G=re.input[$];if(G==="<"||G===","){ke.ignoreMatch();return}G===">"&&(n(re,{after:$})||ke.ignoreMatch());let le;const I=re.input.substring($);if(le=I.match(/^\s*=/)){ke.ignoreMatch();return}if((le=I.match(/^\s+extends\s+/))&&le.index===0){ke.ignoreMatch();return}}},d={$pattern:a0,keyword:$k,literal:Hk,built_in:Kk,"variable.language":Vk},m="[0-9](_?[0-9])*",h=`\\.(${m})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${m})\\b`},{begin:`\\b(${p})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},x={className:"subst",begin:"\\$\\{",end:"\\}",keywords:d,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"css"}},N={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"graphql"}},T={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,x]},j={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},_=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,N,T,{match:/\$\d+/},g];x.contains=_.concat({begin:/\{/,end:/\}/,keywords:d,contains:["self"].concat(_)});const O=[].concat(j,x.contains),z=O.concat([{begin:/(\s*)\(/,end:/\)/,keywords:d,contains:["self"].concat(O)}]),D={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:z},H={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},W={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:{_:[...Fk,...qk]}},Z={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[D],illegal:/%/},Y={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function se(re){return t.concat("(?!",re.join("|"),")")}const X={match:t.concat(/\b/,se([...Gk,"super","import"].map(re=>`${re}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},F={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},J={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},D]},B="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Q={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(B)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[D]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:d,exports:{PARAMS_CONTAINS:z,CLASS_REFERENCE:W},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),Z,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,N,T,j,{match:/\$\d+/},g,W,{scope:"attr",match:r+t.lookahead(":"),relevance:0},Q,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[j,e.REGEXP_MODE,{className:"function",begin:B,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:z}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:l},{begin:u.begin,"on:begin":u.isTrulyOpeningTag,end:u.end}],subLanguage:"xml",contains:[{begin:u.begin,end:u.end,skip:!0,contains:["self"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[D,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},F,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[D]},X,Y,H,J,{match:/\$[(.]/}]}}function Pq(e){const t=e.regex,n=Iq(e),r=a0,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],l={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},u={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},d={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},m=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:a0,keyword:$k.concat(m),literal:Hk,built_in:Kk.concat(o),"variable.language":Vk},p={className:"meta",begin:"@"+r},g=(N,T,C)=>{const j=N.contains.findIndex(_=>_.label===T);if(j===-1)throw new Error("can not find mode to replace");N.contains.splice(j,1,C)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(p);const x=n.contains.find(N=>N.scope==="attr"),y=Object.assign({},x,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,x,y]),n.contains=n.contains.concat([p,l,u,y]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",d);const w=n.contains.find(N=>N.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function zq(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},o=/\d{1,2}\/\d{1,2}\/\d{4}/,l=/\d{4}-\d{1,2}-\d{1,2}/,u=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,d=/\d{1,2}(:\d{1,2}){1,2}/,m={className:"literal",variants:[{begin:t.concat(/# */,t.either(l,o),/ *#/)},{begin:t.concat(/# */,d,/ *#/)},{begin:t.concat(/# */,u,/ *#/)},{begin:t.concat(/# */,t.either(l,o),/ +/,t.either(u,d),/ *#/)}]},h={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])|[%&])?/}]},p={className:"label",begin:/^\w+:/},g=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),x=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,m,h,p,g,x,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[x]}]}}function Bq(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],o={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},l={className:"variable",begin:/\$[\w_]+/},u={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},d={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},m={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},h={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},l,u,o,e.QUOTE_STRING_MODE,m,h,d]}}function Uq(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,o={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},l={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},u=e.inherit(l,{begin:/\(/,end:/\)/}),d=e.inherit(e.APOS_STRING_MODE,{className:"string"}),m=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),h={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[l,m,d,u,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[l,u,m,d]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[m]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[h],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[h],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:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function $q(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},l={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},u={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},d=e.inherit(u,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),x={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},w={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},N={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},T=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},x,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,N,l,u],C=[...T];return C.pop(),C.push(d),y.contains=C,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:T}}const Hq={arduino:SF,bash:NF,c:CF,cpp:TF,csharp:EF,css:IF,diff:PF,go:zF,graphql:BF,ini:UF,java:$F,javascript:VF,json:KF,kotlin:YF,less:rq,lua:aq,makefile:sq,markdown:iq,objectivec:oq,perl:lq,php:cq,"php-template":uq,plaintext:dq,python:mq,"python-repl":fq,r:hq,ruby:pq,rust:gq,scss:Cq,shell:Tq,sql:Eq,swift:Lq,typescript:Pq,vbnet:zq,wasm:Bq,xml:Uq,yaml:$q};var Bh,O2;function Fq(){if(O2)return Bh;O2=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(ie=>{const Ne=q[ie],Le=typeof Ne;(Le==="object"||Le==="function")&&!Object.isFrozen(Ne)&&e(Ne)}),q}class t{constructor(ie){ie.data===void 0&&(ie.data={}),this.data=ie.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(q){return q.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(q,...ie){const Ne=Object.create(null);for(const Le in q)Ne[Le]=q[Le];return ie.forEach(function(Le){for(const Je in Le)Ne[Je]=Le[Je]}),Ne}const o="</span>",l=q=>!!q.scope,u=(q,{prefix:ie})=>{if(q.startsWith("language:"))return q.replace("language:","language-");if(q.includes(".")){const Ne=q.split(".");return[`${ie}${Ne.shift()}`,...Ne.map((Le,Je)=>`${Le}${"_".repeat(Je+1)}`)].join(" ")}return`${ie}${q}`};class d{constructor(ie,Ne){this.buffer="",this.classPrefix=Ne.classPrefix,ie.walk(this)}addText(ie){this.buffer+=n(ie)}openNode(ie){if(!l(ie))return;const Ne=u(ie.scope,{prefix:this.classPrefix});this.span(Ne)}closeNode(ie){l(ie)&&(this.buffer+=o)}value(){return this.buffer}span(ie){this.buffer+=`<span class="${ie}">`}}const m=(q={})=>{const ie={children:[]};return Object.assign(ie,q),ie};class h{constructor(){this.rootNode=m(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ie){this.top.children.push(ie)}openNode(ie){const Ne=m({scope:ie});this.add(Ne),this.stack.push(Ne)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ie){return this.constructor._walk(ie,this.rootNode)}static _walk(ie,Ne){return typeof Ne=="string"?ie.addText(Ne):Ne.children&&(ie.openNode(Ne),Ne.children.forEach(Le=>this._walk(ie,Le)),ie.closeNode(Ne)),ie}static _collapse(ie){typeof ie!="string"&&ie.children&&(ie.children.every(Ne=>typeof Ne=="string")?ie.children=[ie.children.join("")]:ie.children.forEach(Ne=>{h._collapse(Ne)}))}}class p extends h{constructor(ie){super(),this.options=ie}addText(ie){ie!==""&&this.add(ie)}startScope(ie){this.openNode(ie)}endScope(){this.closeNode()}__addSublanguage(ie,Ne){const Le=ie.root;Ne&&(Le.scope=`language:${Ne}`),this.add(Le)}toHTML(){return new d(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(q){return q?typeof q=="string"?q:q.source:null}function x(q){return N("(?=",q,")")}function y(q){return N("(?:",q,")*")}function w(q){return N("(?:",q,")?")}function N(...q){return q.map(Ne=>g(Ne)).join("")}function T(q){const ie=q[q.length-1];return typeof ie=="object"&&ie.constructor===Object?(q.splice(q.length-1,1),ie):{}}function C(...q){return"("+(T(q).capture?"":"?:")+q.map(Le=>g(Le)).join("|")+")"}function j(q){return new RegExp(q.toString()+"|").exec("").length-1}function _(q,ie){const Ne=q&&q.exec(ie);return Ne&&Ne.index===0}const O=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function z(q,{joinWith:ie}){let Ne=0;return q.map(Le=>{Ne+=1;const Je=Ne;let vt=g(Le),Ie="";for(;vt.length>0;){const tt=O.exec(vt);if(!tt){Ie+=vt;break}Ie+=vt.substring(0,tt.index),vt=vt.substring(tt.index+tt[0].length),tt[0][0]==="\\"&&tt[1]?Ie+="\\"+String(Number(tt[1])+Je):(Ie+=tt[0],tt[0]==="("&&Ne++)}return Ie}).map(Le=>`(${Le})`).join(ie)}const D=/\b\B/,H="[a-zA-Z]\\w*",W="[a-zA-Z_]\\w*",Z="\\b\\d+(\\.\\d+)?",U="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Y="\\b(0b[01]+)",se="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",X=(q={})=>{const ie=/^#![ ]*\//;return q.binary&&(q.begin=N(ie,/.*\b/,q.binary,/\b.*/)),r({scope:"meta",begin:ie,end:/$/,relevance:0,"on:begin":(Ne,Le)=>{Ne.index!==0&&Le.ignoreMatch()}},q)},F={begin:"\\\\[\\s\\S]",relevance:0},J={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[F]},B={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[F]},Q={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},re=function(q,ie,Ne={}){const Le=r({scope:"comment",begin:q,end:ie,contains:[]},Ne);Le.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 Je=C("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 Le.contains.push({begin:N(/[ ]+/,"(",Je,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Le},ke=re("//","$"),$=re("/\\*","\\*/"),G=re("#","$"),le={scope:"number",begin:Z,relevance:0},I={scope:"number",begin:U,relevance:0},Ee={scope:"number",begin:Y,relevance:0},Ue={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[F,{begin:/\[/,end:/\]/,relevance:0,contains:[F]}]},Oe={scope:"title",begin:H,relevance:0},We={scope:"title",begin:W,relevance:0},st={begin:"\\.\\s*"+W,relevance:0};var Et=Object.freeze({__proto__:null,APOS_STRING_MODE:J,BACKSLASH_ESCAPE:F,BINARY_NUMBER_MODE:Ee,BINARY_NUMBER_RE:Y,COMMENT:re,C_BLOCK_COMMENT_MODE:$,C_LINE_COMMENT_MODE:ke,C_NUMBER_MODE:I,C_NUMBER_RE:U,END_SAME_AS_BEGIN:function(q){return Object.assign(q,{"on:begin":(ie,Ne)=>{Ne.data._beginMatch=ie[1]},"on:end":(ie,Ne)=>{Ne.data._beginMatch!==ie[1]&&Ne.ignoreMatch()}})},HASH_COMMENT_MODE:G,IDENT_RE:H,MATCH_NOTHING_RE:D,METHOD_GUARD:st,NUMBER_MODE:le,NUMBER_RE:Z,PHRASAL_WORDS_MODE:Q,QUOTE_STRING_MODE:B,REGEXP_MODE:Ue,RE_STARTERS_RE:se,SHEBANG:X,TITLE_MODE:Oe,UNDERSCORE_IDENT_RE:W,UNDERSCORE_TITLE_MODE:We});function gt(q,ie){q.input[q.index-1]==="."&&ie.ignoreMatch()}function jt(q,ie){q.className!==void 0&&(q.scope=q.className,delete q.className)}function Jt(q,ie){ie&&q.beginKeywords&&(q.begin="\\b("+q.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",q.__beforeBegin=gt,q.keywords=q.keywords||q.beginKeywords,delete q.beginKeywords,q.relevance===void 0&&(q.relevance=0))}function Rt(q,ie){Array.isArray(q.illegal)&&(q.illegal=C(...q.illegal))}function be(q,ie){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 Me(q,ie){q.relevance===void 0&&(q.relevance=1)}const Ge=(q,ie)=>{if(!q.beforeMatch)return;if(q.starts)throw new Error("beforeMatch cannot be used with starts");const Ne=Object.assign({},q);Object.keys(q).forEach(Le=>{delete q[Le]}),q.keywords=Ne.keywords,q.begin=N(Ne.beforeMatch,x(Ne.begin)),q.starts={relevance:0,contains:[Object.assign(Ne,{endsParent:!0})]},q.relevance=0,delete Ne.beforeMatch},ot=["of","and","for","in","not","or","if","then","parent","list","value"],mt="keyword";function ae(q,ie,Ne=mt){const Le=Object.create(null);return typeof q=="string"?Je(Ne,q.split(" ")):Array.isArray(q)?Je(Ne,q):Object.keys(q).forEach(function(vt){Object.assign(Le,ae(q[vt],ie,vt))}),Le;function Je(vt,Ie){ie&&(Ie=Ie.map(tt=>tt.toLowerCase())),Ie.forEach(function(tt){const St=tt.split("|");Le[St[0]]=[vt,ze(St[0],St[1])]})}}function ze(q,ie){return ie?Number(ie):Xe(q)?0:1}function Xe(q){return ot.includes(q.toLowerCase())}const Ve={},et=q=>{console.error(q)},yt=(q,...ie)=>{console.log(`WARN: ${q}`,...ie)},pe=(q,ie)=>{Ve[`${q}/${ie}`]||(console.log(`Deprecated as of ${q}. ${ie}`),Ve[`${q}/${ie}`]=!0)},V=new Error;function ye(q,ie,{key:Ne}){let Le=0;const Je=q[Ne],vt={},Ie={};for(let tt=1;tt<=ie.length;tt++)Ie[tt+Le]=Je[tt],vt[tt+Le]=!0,Le+=j(ie[tt-1]);q[Ne]=Ie,q[Ne]._emit=vt,q[Ne]._multi=!0}function Qe(q){if(Array.isArray(q.begin)){if(q.skip||q.excludeBegin||q.returnBegin)throw et("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),V;if(typeof q.beginScope!="object"||q.beginScope===null)throw et("beginScope must be object"),V;ye(q,q.begin,{key:"beginScope"}),q.begin=z(q.begin,{joinWith:""})}}function he(q){if(Array.isArray(q.end)){if(q.skip||q.excludeEnd||q.returnEnd)throw et("skip, excludeEnd, returnEnd not compatible with endScope: {}"),V;if(typeof q.endScope!="object"||q.endScope===null)throw et("endScope must be object"),V;ye(q,q.end,{key:"endScope"}),q.end=z(q.end,{joinWith:""})}}function ve(q){q.scope&&typeof q.scope=="object"&&q.scope!==null&&(q.beginScope=q.scope,delete q.scope)}function Ye(q){ve(q),typeof q.beginScope=="string"&&(q.beginScope={_wrap:q.beginScope}),typeof q.endScope=="string"&&(q.endScope={_wrap:q.endScope}),Qe(q),he(q)}function nt(q){function ie(Ie,tt){return new RegExp(g(Ie),"m"+(q.case_insensitive?"i":"")+(q.unicodeRegex?"u":"")+(tt?"g":""))}class Ne{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+=j(tt)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const tt=this.regexes.map(St=>St[1]);this.matcherRe=ie(z(tt,{joinWith:"|"}),!0),this.lastIndex=0}exec(tt){this.matcherRe.lastIndex=this.lastIndex;const St=this.matcherRe.exec(tt);if(!St)return null;const jn=St.findIndex((Ea,Ri)=>Ri>0&&Ea!==void 0),vn=this.matchIndexes[jn];return St.splice(0,jn),Object.assign(St,vn)}}class Le{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 Ne;return this.rules.slice(tt).forEach(([jn,vn])=>St.addRule(jn,vn)),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 jn=St.exec(tt);if(this.resumingScanAtSamePosition()&&!(jn&&jn.index===this.lastIndex)){const vn=this.getMatcher(0);vn.lastIndex=this.lastIndex+1,jn=vn.exec(tt)}return jn&&(this.regexIndex+=jn.position+1,this.regexIndex===this.count&&this.considerAll()),jn}}function Je(Ie){const tt=new Le;return Ie.contains.forEach(St=>tt.addRule(St.begin,{rule:St,type:"begin"})),Ie.terminatorEnd&&tt.addRule(Ie.terminatorEnd,{type:"end"}),Ie.illegal&&tt.addRule(Ie.illegal,{type:"illegal"}),tt}function vt(Ie,tt){const St=Ie;if(Ie.isCompiled)return St;[jt,be,Ye,Ge].forEach(vn=>vn(Ie,tt)),q.compilerExtensions.forEach(vn=>vn(Ie,tt)),Ie.__beforeBegin=null,[Jt,Rt,Me].forEach(vn=>vn(Ie,tt)),Ie.isCompiled=!0;let jn=null;return typeof Ie.keywords=="object"&&Ie.keywords.$pattern&&(Ie.keywords=Object.assign({},Ie.keywords),jn=Ie.keywords.$pattern,delete Ie.keywords.$pattern),jn=jn||/\w+/,Ie.keywords&&(Ie.keywords=ae(Ie.keywords,q.case_insensitive)),St.keywordPatternRe=ie(jn,!0),tt&&(Ie.begin||(Ie.begin=/\B|\b/),St.beginRe=ie(St.begin),!Ie.end&&!Ie.endsWithParent&&(Ie.end=/\B|\b/),Ie.end&&(St.endRe=ie(St.end)),St.terminatorEnd=g(St.end)||"",Ie.endsWithParent&&tt.terminatorEnd&&(St.terminatorEnd+=(Ie.end?"|":"")+tt.terminatorEnd)),Ie.illegal&&(St.illegalRe=ie(Ie.illegal)),Ie.contains||(Ie.contains=[]),Ie.contains=[].concat(...Ie.contains.map(function(vn){return Dt(vn==="self"?Ie:vn)})),Ie.contains.forEach(function(vn){vt(vn,St)}),Ie.starts&&vt(Ie.starts,tt),St.matcher=Je(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=r(q.classNameAliases||{}),vt(q)}function xt(q){return q?q.endsWithParent||xt(q.starts):!1}function Dt(q){return q.variants&&!q.cachedVariants&&(q.cachedVariants=q.variants.map(function(ie){return r(q,{variants:null},ie)})),q.cachedVariants?q.cachedVariants:xt(q)?r(q,{starts:q.starts?r(q.starts):null}):Object.isFrozen(q)?r(q):q}var ct="11.11.1";class Xt extends Error{constructor(ie,Ne){super(ie),this.name="HTMLInjectionError",this.html=Ne}}const R=n,oe=r,_e=Symbol("nomatch"),de=7,$e=function(q){const ie=Object.create(null),Ne=Object.create(null),Le=[];let Je=!0;const vt="Could not find the language '{}', did you forget to load/include a language module?",Ie={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:p};function St(Pe){return tt.noHighlightRe.test(Pe)}function jn(Pe){let wt=Pe.className+" ";wt+=Pe.parentNode?Pe.parentNode.className:"";const Ut=tt.languageDetectRe.exec(wt);if(Ut){const rn=ir(Ut[1]);return rn||(yt(vt.replace("{}",Ut[1])),yt("Falling back to no-highlight mode for this block.",Pe)),rn?Ut[1]:"no-highlight"}return wt.split(/\s+/).find(rn=>St(rn)||ir(rn))}function vn(Pe,wt,Ut){let rn="",Rn="";typeof wt=="object"?(rn=Pe,Ut=wt.ignoreIllegals,Rn=wt.language):(pe("10.7.0","highlight(lang, code, ...args) has been deprecated."),pe("10.7.0",`Please use highlight(code, options) instead.
|
|
647
647
|
https://github.com/highlightjs/highlight.js/issues/2277`),Rn=Pe,rn=wt),Ut===void 0&&(Ut=!0);const tr={code:rn,language:Rn};Ws("before:highlight",tr);const Mr=tr.result?tr.result:Ea(tr.language,tr.code,Ut);return Mr.code=tr.code,Ws("after:highlight",Mr),Mr}function Ea(Pe,wt,Ut,rn){const Rn=Object.create(null);function tr(Ze,ht){return Ze.keywords[ht]}function Mr(){if(!Tt.keywords){In.addText(an);return}let Ze=0;Tt.keywordPatternRe.lastIndex=0;let ht=Tt.keywordPatternRe.exec(an),Lt="";for(;ht;){Lt+=an.substring(Ze,ht.index);const Vt=Yn.case_insensitive?ht[0].toLowerCase():ht[0],Nn=tr(Tt,Vt);if(Nn){const[Kr,Jo]=Nn;if(In.addText(Lt),Lt="",Rn[Vt]=(Rn[Vt]||0)+1,Rn[Vt]<=de&&(ls+=Jo),Kr.startsWith("_"))Lt+=ht[0];else{const Rc=Yn.classNameAliases[Kr]||Kr;Rr(ht[0],Rc)}}else Lt+=ht[0];Ze=Tt.keywordPatternRe.lastIndex,ht=Tt.keywordPatternRe.exec(an)}Lt+=an.substring(Ze),In.addText(Lt)}function gr(){if(an==="")return;let Ze=null;if(typeof Tt.subLanguage=="string"){if(!ie[Tt.subLanguage]){In.addText(an);return}Ze=Ea(Tt.subLanguage,an,!0,Mc[Tt.subLanguage]),Mc[Tt.subLanguage]=Ze._top}else Ze=Oi(an,Tt.subLanguage.length?Tt.subLanguage:null);Tt.relevance>0&&(ls+=Ze.relevance),In.__addSublanguage(Ze._emitter,Ze.language)}function pn(){Tt.subLanguage!=null?gr():Mr(),an=""}function Rr(Ze,ht){Ze!==""&&(In.startScope(ht),In.addText(Ze),In.endScope())}function _c(Ze,ht){let Lt=1;const Vt=ht.length-1;for(;Lt<=Vt;){if(!Ze._emit[Lt]){Lt++;continue}const Nn=Yn.classNameAliases[Ze[Lt]]||Ze[Lt],Kr=ht[Lt];Nn?Rr(Kr,Nn):(an=Kr,Mr(),an=""),Lt++}}function Li(Ze,ht){return Ze.scope&&typeof Ze.scope=="string"&&In.openNode(Yn.classNameAliases[Ze.scope]||Ze.scope),Ze.beginScope&&(Ze.beginScope._wrap?(Rr(an,Yn.classNameAliases[Ze.beginScope._wrap]||Ze.beginScope._wrap),an=""):Ze.beginScope._multi&&(_c(Ze.beginScope,ht),an="")),Tt=Object.create(Ze,{parent:{value:Tt}}),Tt}function Xo(Ze,ht,Lt){let Vt=_(Ze.endRe,Lt);if(Vt){if(Ze["on:end"]){const Nn=new t(Ze);Ze["on:end"](ht,Nn),Nn.isMatchIgnored&&(Vt=!1)}if(Vt){for(;Ze.endsParent&&Ze.parent;)Ze=Ze.parent;return Ze}}if(Ze.endsWithParent)return Xo(Ze.parent,ht,Lt)}function Ii(Ze){return Tt.matcher.regexIndex===0?(an+=Ze[0],1):(cs=!0,0)}function B0(Ze){const ht=Ze[0],Lt=Ze.rule,Vt=new t(Lt),Nn=[Lt.__beforeBegin,Lt["on:begin"]];for(const Kr of Nn)if(Kr&&(Kr(Ze,Vt),Vt.isMatchIgnored))return Ii(ht);return Lt.skip?an+=ht:(Lt.excludeBegin&&(an+=ht),pn(),!Lt.returnBegin&&!Lt.excludeBegin&&(an=ht)),Li(Lt,Ze),Lt.returnBegin?0:ht.length}function br(Ze){const ht=Ze[0],Lt=wt.substring(Ze.index),Vt=Xo(Tt,Ze,Lt);if(!Vt)return _e;const Nn=Tt;Tt.endScope&&Tt.endScope._wrap?(pn(),Rr(ht,Tt.endScope._wrap)):Tt.endScope&&Tt.endScope._multi?(pn(),_c(Tt.endScope,Ze)):Nn.skip?an+=ht:(Nn.returnEnd||Nn.excludeEnd||(an+=ht),pn(),Nn.excludeEnd&&(an=ht));do Tt.scope&&In.closeNode(),!Tt.skip&&!Tt.subLanguage&&(ls+=Tt.relevance),Tt=Tt.parent;while(Tt!==Vt.parent);return Vt.starts&&Li(Vt.starts,Ze),Nn.returnEnd?0:ht.length}function Qo(){const Ze=[];for(let ht=Tt;ht!==Yn;ht=ht.parent)ht.scope&&Ze.unshift(ht.scope);Ze.forEach(ht=>In.openNode(ht))}let Ys={};function Pi(Ze,ht){const Lt=ht&&ht[0];if(an+=Ze,Lt==null)return pn(),0;if(Ys.type==="begin"&&ht.type==="end"&&Ys.index===ht.index&&Lt===""){if(an+=wt.slice(ht.index,ht.index+1),!Je){const Vt=new Error(`0 width match regex (${Pe})`);throw Vt.languageName=Pe,Vt.badRule=Ys.rule,Vt}return 1}if(Ys=ht,ht.type==="begin")return B0(ht);if(ht.type==="illegal"&&!Ut){const Vt=new Error('Illegal lexeme "'+Lt+'" for mode "'+(Tt.scope||"<unnamed>")+'"');throw Vt.mode=Tt,Vt}else if(ht.type==="end"){const Vt=br(ht);if(Vt!==_e)return Vt}if(ht.type==="illegal"&&Lt==="")return an+=`
|
|
648
|
-
`,1;if(Zo>1e5&&Zo>ht.index*3)throw new Error("potential infinite loop, way more iterations than matches");return an+=Lt,Lt.length}const Yn=ir(Pe);if(!Yn)throw et(vt.replace("{}",Pe)),new Error('Unknown language: "'+Pe+'"');const jc=nt(Yn);let zi="",Tt=rn||jc;const Mc={},In=new tt.__emitter(tt);Qo();let an="",ls=0,ja=0,Zo=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(wt,In);else{for(Tt.matcher.considerAll();;){Zo++,cs?cs=!1:Tt.matcher.considerAll(),Tt.matcher.lastIndex=ja;const Ze=Tt.matcher.exec(wt);if(!Ze)break;const ht=wt.substring(ja,Ze.index),Lt=Pi(ht,Ze);ja=Ze.index+Lt}Pi(wt.substring(ja))}return In.finalize(),zi=In.toHTML(),{language:Pe,value:zi,relevance:ls,illegal:!1,_emitter:In,_top:Tt}}catch(Ze){if(Ze.message&&Ze.message.includes("Illegal"))return{language:Pe,value:R(wt),illegal:!0,relevance:0,_illegalBy:{message:Ze.message,index:ja,context:wt.slice(ja-100,ja+100),mode:Ze.mode,resultSoFar:zi},_emitter:In};if(Je)return{language:Pe,value:R(wt),illegal:!1,relevance:0,errorRaised:Ze,_emitter:In,_top:Tt};throw Ze}}function Ri(Pe){const wt={value:R(Pe),illegal:!1,relevance:0,_top:Ie,_emitter:new tt.__emitter(tt)};return wt._emitter.addText(Pe),wt}function Oi(Pe,wt){wt=wt||tt.languages||Object.keys(ie);const Ut=Ri(Pe),rn=wt.filter(ir).filter(is).map(pn=>Ea(pn,Pe,!1));rn.unshift(Ut);const Rn=rn.sort((pn,Rr)=>{if(pn.relevance!==Rr.relevance)return Rr.relevance-pn.relevance;if(pn.language&&Rr.language){if(ir(pn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===pn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(Pe,wt,Ut){const rn=wt&&Ne[wt]||Ut;Pe.classList.add("hljs"),Pe.classList.add(`language-${rn}`)}function Mn(Pe){let wt=null;const Ut=jn(Pe);if(St(Ut))return;if(Ws("before:highlightElement",{el:Pe,language:Ut}),Pe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Pe);return}if(Pe.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(Pe)),tt.throwUnescapedHTML))throw new Xt("One of your code blocks includes unescaped HTML.",Pe.innerHTML);wt=Pe;const rn=wt.textContent,Rn=Ut?vn(rn,{language:Ut,ignoreIllegals:!0}):Oi(rn);Pe.innerHTML=Rn.value,Pe.dataset.highlighted="yes",ma(Pe,Ut,Rn.language),Pe.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(Pe.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ws("after:highlightElement",{el:Pe,result:Rn,text:rn})}function er(Pe){tt=oe(tt,Pe)}const ss=()=>{Di(),pe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Wo(){Di(),pe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Tc=!1;function Di(){function Pe(){Di()}if(document.readyState==="loading"){Tc||window.addEventListener("DOMContentLoaded",Pe,!1),Tc=!0;return}document.querySelectorAll(tt.cssSelector).forEach(Mn)}function Ec(Pe,wt){let Ut=null;try{Ut=wt(q)}catch(rn){if(et("Language definition for '{}' could not be registered.".replace("{}",Pe)),Je)et(rn);else throw rn;Ut=Ie}Ut.name||(Ut.name=Pe),ie[Pe]=Ut,Ut.rawDefinition=wt.bind(null,q),Ut.aliases&&Aa(Ut.aliases,{languageName:Pe})}function Ks(Pe){delete ie[Pe];for(const wt of Object.keys(Ne))Ne[wt]===Pe&&delete Ne[wt]}function Yo(){return Object.keys(ie)}function ir(Pe){return Pe=(Pe||"").toLowerCase(),ie[Pe]||ie[Ne[Pe]]}function Aa(Pe,{languageName:wt}){typeof Pe=="string"&&(Pe=[Pe]),Pe.forEach(Ut=>{Ne[Ut.toLowerCase()]=wt})}function is(Pe){const wt=ir(Pe);return wt&&!wt.disableAutodetect}function os(Pe){Pe["before:highlightBlock"]&&!Pe["before:highlightElement"]&&(Pe["before:highlightElement"]=wt=>{Pe["before:highlightBlock"](Object.assign({block:wt.el},wt))}),Pe["after:highlightBlock"]&&!Pe["after:highlightElement"]&&(Pe["after:highlightElement"]=wt=>{Pe["after:highlightBlock"](Object.assign({block:wt.el},wt))})}function Ln(Pe){os(Pe),Le.push(Pe)}function Ac(Pe){const wt=Le.indexOf(Pe);wt!==-1&&Le.splice(wt,1)}function Ws(Pe,wt){const Ut=Pe;Le.forEach(function(rn){rn[Ut]&&rn[Ut](wt)})}function _a(Pe){return pe("10.7.0","highlightBlock will be removed entirely in v12.0"),pe("10.7.0","Please use highlightElement now."),Mn(Pe)}Object.assign(q,{highlight:vn,highlightAuto:Oi,highlightAll:Di,highlightElement:Mn,highlightBlock:_a,configure:er,initHighlighting:ss,initHighlightingOnLoad:Wo,registerLanguage:Ec,unregisterLanguage:Ks,listLanguages:Yo,getLanguage:ir,registerAliases:Aa,autoDetection:is,inherit:oe,addPlugin:Ln,removePlugin:Ac}),q.debugMode=function(){Je=!1},q.safeMode=function(){Je=!0},q.versionString=ct,q.regex={concat:N,lookahead:x,either:C,optional:w,anyNumberOfTimes:y};for(const Pe in Et)typeof Et[Pe]=="object"&&e(Et[Pe]);return Object.assign(q,Et),q},qe=$e({});return qe.newInstance=()=>$e({}),Bh=qe,qe.HighlightJS=qe,qe.default=qe,Bh}var qq=Fq();const Gq=xc(qq),D2={},Vq="hljs-";function Kq(e){const t=Gq.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:u,registered:d};function n(m,h,p){const g=p||D2,x=typeof g.prefix=="string"?g.prefix:Vq;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:Wq,classPrefix:x});const y=t.highlight(h,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,N=w.data;return N.language=y.language,N.relevance=y.relevance,w}function r(m,h){const g=(h||D2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const N=g[x];if(!t.getLanguage(N))continue;const T=n(N,m,h);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function l(m,h){if(typeof m=="string")t.registerLanguage(m,h);else{let p;for(p in m)Object.hasOwn(m,p)&&t.registerLanguage(p,m[p])}}function u(m,h){if(typeof m=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:m});else{let p;for(p in m)if(Object.hasOwn(m,p)){const g=m[p];t.registerAliases(typeof g=="string"?g:[...g],{languageName:p})}}}function d(m){return!!t.getLanguage(m)}}class Wq{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(u,d){return d?u+"_".repeat(d):n.options.classPrefix+u}),o=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Yq={};function Wk(e){const t=e||Yq,n=t.aliases,r=t.detect||!1,o=t.languages||Hq,l=t.plainText,u=t.prefix,d=t.subset;let m="hljs";const h=Kq(o);if(n&&h.registerAlias(n),u){const p=u.indexOf("-");m=p===-1?u:u.slice(0,p)}return function(p,g){S0(p,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const N=Xq(x);if(N===!1||!N&&!r||N&&l&&l.includes(N))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=Ek(x,{whitespace:"pre"});let C;try{C=N?h.highlight(N,T,{prefix:u}):h.highlightAuto(T,{prefix:u,subset:d})}catch(j){const _=j;if(N&&/Unknown language/.test(_.message)){g.message("Cannot highlight as `"+N+"`, it’s not registered",{ancestors:[w,x],cause:_,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw _}!N&&C.data&&C.data.language&&x.properties.className.push("language-"+C.data.language),C.children.length>0&&(x.children=C.children)})}}function Xq(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const o=String(t[n]);if(o==="no-highlight"||o==="nohighlight")return!1;!r&&o.slice(0,5)==="lang-"&&(r=o.slice(5)),!r&&o.slice(0,9)==="language-"&&(r=o.slice(9))}return r}const Qq=10;function L2(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function Zq(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.title||e.path.split(/[/\\]/).pop()||e.path}const Yk=k.createContext(null);function Jq({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),[r,o]=k.useState([]),[l,u]=k.useState(null),[d,m]=k.useState(!1),[h,p]=k.useState(!1),g=k.useRef([]),x=k.useRef(null),y=k.useRef(null);y.current=l;const w=k.useCallback(X=>n(X),[]),N=k.useCallback(()=>n(X=>!X),[]),T=k.useCallback(X=>{const F=L2(X),J=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let B=null;o(Q=>{const re=Q.find(G=>L2(G.payload)===F);if(re)return B=re.id,g.current=Q,Q;let $=[{id:J,title:Zq(X),payload:X},...Q];for(;$.length>Qq;){let G=-1;for(let le=$.length-1;le>=0;le--)if(!$[le].pinned){G=le;break}if(G<0)break;$=$.filter((le,I)=>I!==G)}return B=J,g.current=$,$}),B&&(u(B),x.current=B),n(!0)},[]),C=X=>{X?.kind==="url"&&X.browserId&&window.markusDesktop?.browser?.destroy(X.browserId)},j=k.useCallback(X=>{let F,J,B=!1;o(Q=>{const re=Q.findIndex($=>$.id===X);if(re<0)return Q;F=Q[re]?.payload;const ke=Q.filter($=>$.id!==X);return g.current=ke,B=ke.length===0,J=void 0,(x.current===X||ke.length===0)&&(J=ke[Math.min(re,ke.length-1)]?.id??null),ke}),B&&m(!1),J!==void 0&&(u(J),x.current=J),C(F)},[]),_=k.useCallback(()=>{let X=[];o(F=>(X=F.map(J=>J.payload),[])),u(null),m(!1),g.current=[],x.current=null;for(const F of X)C(F)},[]),O=k.useCallback(X=>{u(X),x.current=X},[]),z=k.useCallback((X,F)=>{o(J=>{let B=!1;const Q=J.map(re=>{if(re.payload.kind!=="url"||re.payload.browserId!==X)return re;B=!0;const ke=F.url??re.payload.url,$=F.title||re.payload.title||ke;return{...re,title:$,payload:{...re.payload,url:ke,title:$}}});return B&&(g.current=Q),B?Q:J})},[]),D=k.useCallback(()=>{o(X=>X.length===0?X:(g.current=X,y.current&&(x.current=y.current),[])),u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()},[]),H=k.useCallback(()=>{const X=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,F=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let J,B=!1,Q=!1;o(re=>{if(re.length>0)return g.current=re,y.current&&(x.current=y.current),Q=!0,J=null,[];if(g.current.length>0){B=!0;const $=g.current;return J=x.current&&$.some(le=>le.id===x.current)?x.current:$[0].id,$}B=!0;const ke={id:X,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:F}};return g.current=[ke],J=ke.id,[ke]}),B&&n(!0),Q?(u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()):J!=null&&(u(J),x.current=J)},[]),W=k.useCallback(X=>m(X),[]),Z=k.useCallback(()=>m(X=>!X),[]),U=r.find(X=>X.id===l)??r[0]??null,Y=U?.payload??null,se=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:w,toggleLeftCollapsed:N,rightPanel:Y,rightPanelOpen:r.length>0,rightPanelTabs:r,activeRightPanelTabId:U?.id??null,openRightPanel:T,closeRightPanel:_,closeRightPanelTab:j,setActiveRightPanelTab:O,updateRightPanelBrowserTab:z,toggleRightPanel:H,collapseRightPanelOnly:D,rightPanelFullscreen:d,setRightPanelFullscreen:W,toggleRightPanelFullscreen:Z,hostAvailable:h,setHostAvailable:p}),[t,w,N,Y,r,U,T,_,j,O,z,H,D,d,W,Z,h]);return s.jsx(Yk.Provider,{value:se,children:e})}function z0(){return k.useContext(Yk)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>l3),void 0).then(e=>({default:e.MarkdownMessage})));const eG=k.lazy(()=>qr(()=>import("./ContentRenderer-CKNSYhv-.js"),[]).then(e=>({default:e.ContentRenderer})));let wo=[],I2=60;function tG(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++I2);return k.useEffect(()=>{const r=()=>t.current();wo.push(r);const o=l=>{l.key==="Escape"&&wo[wo.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),wo=wo.filter(l=>l!==r),wo.length===0&&(I2=60)}},[]),n}const P2=500,Bs=new Map,s0=new Set,Rd=new Map;let Od=null;function nG(){if(Bs.size<=P2)return;const e=Bs.size-P2,t=Bs.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;Bs.delete(r)}}function z2(e,t){Bs.delete(e),Bs.set(e,t),nG()}function B2(e){const t=Rd.get(e);if(t)for(const n of t)n()}function rG(){Od=null;const e=[...s0];s0.clear(),e.length!==0&&Ce.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))z2(n,r),B2(n)}).catch(()=>{for(const t of e)z2(t,{exists:!1,isFile:!1,type:"unknown"}),B2(t)})}function aG(e){Bs.has(e)||s0.has(e)||(s0.add(e),Od&&clearTimeout(Od),Od=setTimeout(rG,30))}function sG(e,t){let n=Rd.get(e);return n||(n=new Set,Rd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Rd.delete(e)}}function iG(e){const t=k.useCallback(o=>sG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{aG(e)},[e]),r}const oG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function lG(e){return e.length<2||e.length>500?!1:oG.test(e)}function cG({filePath:e,onClose:t}){const n=tG(t),[r,o]=k.useState(!0),[l,u]=k.useState(null),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[N,T]=k.useState("");k.useEffect(()=>{o(!0),u(null),Ce.files.preview(e).then(j=>{m(typeof j.content=="string"?j.content:""),p(j.type),x(j.name),w(j.mimeType||""),T(j.streamUrl||(j.path?Ce.files.streamUrl(j.path):"")||(j.type==="audio"||j.type==="video"?Ce.files.streamUrl(e):""))}).catch(j=>{u(String(j?.message||j))}).finally(()=>{o(!1)})},[e]);const C=g||e.split(/[/\\]/).pop()||e;return Ja.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:j=>j.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:C}),s.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Ce.files.reveal(e),title:"Reveal in file explorer",children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{d:"M4.5 17a2.5 2.5 0 01-2.5-2.5v-9A2.5 2.5 0 014.5 3h3.672a1.5 1.5 0 011.06.44L10.56 4.77a.5.5 0 00.354.147H15.5A2.5 2.5 0 0118 7.417v7.083A2.5 2.5 0 0115.5 17h-11z"})})}),s.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[r&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),l&&s.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[s.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:l})]}),!r&&!l&&h==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${y||"image/png"};base64,${d}`,alt:C,className:"max-w-full rounded"})}),!r&&!l&&h==="audio"&&N&&s.jsx("audio",{controls:!0,preload:"metadata",src:N,className:"w-full"}),!r&&!l&&h==="video"&&N&&s.jsx("video",{controls:!0,preload:"metadata",src:N,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(h==="binary"||!d&&h!=="image"&&h!=="audio"&&h!=="video")&&s.jsxs("div",{className:"text-center py-8 space-y-3",children:[s.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),s.jsx("button",{className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",onClick:()=>{Ce.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&h!=="image"&&h!=="audio"&&h!=="video"&&h!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(eG,{content:d,format:h==="text"?"text":h,className:"text-sm"})})]})]})}),document.body)}function uG({path:e}){const t=iG(e),[n,r]=k.useState(null),o=z0(),l=t?.exists??!1,u=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(p=>{if(p.preventDefault(),p.stopPropagation(),!!l)if(u){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Ce.files.reveal(e)},[l,u,e,o]),m="inline w-3 h-3 align-[-0.125em]",h=u?s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}):s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})});return t?l?s.jsxs(s.Fragment,{children:[s.jsxs("code",{className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:d,title:u?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[h,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(cG,{filePath:n,onClose:()=>r(null)})]}):s.jsx("code",{className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:"File not found",children:e}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let Uh=null;function dG(){return Uh||(Uh=qr(()=>import("./mermaid.core-IG3mSoE5.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Uh}function mG(){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 fG(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 hG(){return mG()}function pG(){return k.useSyncExternalStore(fG,hG)}function Xk({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),u=k.useId(),d=k.useRef(0),m=k.useRef(null),h=pG();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===h)return;let p=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await dG();if(p)return;g.default.initialize({startOnLoad:!1,theme:h?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const x=`mermaid-${u.replace(/:/g,"")}-${d.current}`,{svg:y}=await g.default.render(x,e.trim());if(p)return;t.current&&(t.current.innerHTML=y,m.current={code:e,dark:h})}catch(g){p||r(g instanceof Error?g.message:String(g))}finally{p||l(!1)}})(),()=>{p=!0}},[e,u,h]),n?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[o&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),s.jsx("div",{ref:t,className:`flex justify-center [&>svg]:max-w-full${o?" hidden":""}`})]})}const gG="/assets/viz-global-C_AyN6D9.js";let dd=!1,$h=null;function bG(){return dd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(dd=!0,e()):(n.addEventListener("load",()=>{dd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const r=document.createElement("script");r.setAttribute("data-plantuml-viz",""),r.src=gG,r.onload=()=>{dd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function xG(){return $h||($h=bG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),$h}let U2=Promise.resolve();function yG(e,t){const n=U2.then(()=>new Promise((r,o)=>{xG().then(({renderToString:l})=>{const u=e.split(/\r\n|\r|\n/);l(u,r,o,{dark:t})}).catch(o)}));return U2=n.then(()=>{},()=>{}),n}function vG(){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 wG(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 kG(){return k.useSyncExternalStore(wG,()=>vG())}function Qk({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,u]=k.useState(!0),d=k.useRef(null),m=kG();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let h=!1;return u(!0),o(null),yG(e.trim(),m).then(p=>{h||(n(p),d.current={code:e,dark:m})}).catch(p=>{h||o(p instanceof Error?p.message:String(p))}).finally(()=>{h||u(!1)}),()=>{h=!0}},[e,m]),r?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t&&s.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`,dangerouslySetInnerHTML:{__html:t}})]})}function SG(e,t,n){const r=e.cloneNode(!0),o=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",u=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},d=t==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},m={p:`margin:0 0 10px;color:${d.text};line-height:1.7;`,h1:`font-size:${u.h1}em;font-weight:700;color:${d.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${d.border};padding-bottom:6px;`,h2:`font-size:${u.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${u.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${u.h4}em;font-weight:600;color:${d.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${d.strong};`,em:"font-style:italic;",a:`color:${d.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${d.text};`,blockquote:`border-left:3px solid ${d.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${d.blockquoteText};`,hr:`border:none;border-top:1px solid ${d.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${d.tableHeaderBg};`,th:`border:1px solid ${d.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${d.tableHeaderText};`,td:`border:1px solid ${d.tableBorder};padding:8px 12px;color:${d.text};`,img:"max-width:100%;height:auto;"};function h(p){p.removeAttribute("class");const g=p.tagName.toLowerCase();if(g==="pre"){p.setAttribute("style",`background:${d.preBg};color:${d.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${d.preBorder};`);const x=p.querySelector("code");x&&(x.removeAttribute("class"),x.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}g==="code"?p.setAttribute("style",`background:${d.codeBg};color:${d.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[g]&&p.setAttribute("style",m[g]),Array.from(p.children).forEach(h)}return r.removeAttribute("class"),Array.from(r.children).forEach(p=>h(p)),`<div style="background:${d.bg};color:${d.text};padding:20px 24px;font-family:${o};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function Mg(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 NG(e,t,n,r){const o=SG(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Mg(n),method:"text"}}}function Lp({code:e,language:t,children:n}){const{t:r}=ft("common"),[o,l]=k.useState("rendered"),[u,d]=k.useState(!1),m=k.useCallback(async()=>{await Mg(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return s.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),r("markdown.viewRendered")]})}),s.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),r("markdown.viewSource")]})})]})]}),o==="rendered"?s.jsx("div",{children:n}):s.jsxs("div",{className:"relative group/source",children:[s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary bg-surface-secondary leading-relaxed whitespace-pre-wrap break-words",children:e}),s.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:r("markdown.copyContent"),children:u?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}function md(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,o="";for(const l of e.matchAll(n))o+=t(e.slice(r,l.index)),o+=l[0],r=l.index+l[0].length;return o+=t(e.slice(r)),o}function CG(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const fd="#mention:";function TG(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,u,d)=>{const m=u??d;return`[@${m}](${fd}${encodeURIComponent(m)})`});const n=[...t].sort((l,u)=>u.length-l.length);let r="",o=0;for(;o<e.length;){const l=e.indexOf("@",o);if(l<0){r+=e.slice(o);break}if(r+=e.slice(o,l),e[l+1]==="["){const p=e.indexOf("]",l+2);if(p>l+2){const g=e.slice(l+2,p);r+=`[@${g}](${fd}${encodeURIComponent(g)})`,o=p+1;continue}}const u=e.slice(l+1),d=u.toLowerCase(),m=n.find(p=>d.startsWith(p.toLowerCase()));if(m){const p=u.slice(0,m.length);r+=`[@${p}](${fd}${encodeURIComponent(p)})`,o=l+1+m.length;continue}const h=u.match(/^([\w\p{L}\p{N}]+)/u);if(h){const p=h[1];r+=`[@${p}](${fd}${encodeURIComponent(p)})`,o=l+1+p.length;continue}r+="@",o=l+1}return r}const Zk="#entity:",EG=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),AG=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function _G(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function jG(e){return e.replace(AG,(t,n,r)=>`[${n}](${Zk}${r})`)}function MG(e){return e.replace(EG,(t,n,r)=>_G(e,r)?t:`[${t}](${Zk}${t})`)}function RG(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const OG=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function DG(e){return OG.test(e.trim())}const LG={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 IG(e){return LG[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function PG(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const zG=[Xk,Qk];function BG(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return PG(n)}return null}function rc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(rc).join("");if(k.isValidElement(e)){const t=e.props;return rc(t.children)}return""}function UG({children:e}){const{t}=ft("common"),n=BG(e),r=k.useRef(null),[o,l]=k.useState(!1),[u,d]=k.useState("rendered"),m=k.useCallback(async()=>{let p;u==="source"?p=rc(e):p=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[u,e]);if(k.Children.toArray(e).some(p=>k.isValidElement(p)&&zG.includes(p.type))){const p=rc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Lp,{code:p,language:g,children:e})}return n==="mermaid"||n==="plantuml"?s.jsx(s.Fragment,{children:e}):s.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:IG(n)}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>d("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${u==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),s.jsx("button",{onClick:()=>d("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${u==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),s.jsxs("div",{className:"relative",children:[u==="rendered"?s.jsx("pre",{ref:r,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,p=>k.isValidElement(p)?k.cloneElement(p,{style:{background:"transparent",padding:0}}):p)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:rc(e)}),s.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:t("markdown.copyContent"),children:o?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const Jk="markus-copy-typography",$2={fontFamily:"default",fontSize:15,headingScale:"standard"};function e3(){try{const e=localStorage.getItem(Jk);if(e)return{...$2,...JSON.parse(e)}}catch{}return $2}function $G(e){localStorage.setItem(Jk,JSON.stringify(e))}function HG(e){const t={default:"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif",serif:"Georgia, 'Times New Roman', Times, serif","sans-serif":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif",mono:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"},n={compact:{h1:1.3,h2:1.15,h3:1.05,h4:1},standard:{h1:1.6,h2:1.35,h3:1.15,h4:1},large:{h1:2,h2:1.6,h3:1.3,h4:1.1}};return{fontFamily:t[e.fontFamily]??t.default,fontSize:`${e.fontSize}px`,headingScales:n[e.headingScale]??n.standard}}function FG({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(e3);k.useEffect(()=>{$G(n)},[n]);const o=k.useCallback((l,u)=>{r(d=>({...d,[l]:u}))},[]);return s.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:t("markdown.typographySettings")}),s.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("markdown.typographyDesc")}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.fontFamily")}),s.jsxs("select",{value:n.fontFamily,onChange:l=>o("fontFamily",l.target.value),className:"w-full px-2 py-1 text-xs rounded bg-surface-primary border border-border-subtle text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50",children:[s.jsx("option",{value:"default",children:t("markdown.fontDefault")}),s.jsx("option",{value:"serif",children:t("markdown.fontSerif")}),s.jsx("option",{value:"sans-serif",children:t("markdown.fontSansSerif")}),s.jsx("option",{value:"mono",children:t("markdown.fontMono")})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[t("markdown.fontSize"),": ",n.fontSize,"px"]}),s.jsx("input",{type:"range",min:10,max:24,step:1,value:n.fontSize,onChange:l=>o("fontSize",Number(l.target.value)),className:"w-full h-1 rounded-full appearance-none bg-border-subtle [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-brand-500"}),s.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[s.jsx("span",{children:"10px"}),s.jsx("span",{children:"24px"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.headingScale")}),s.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(l=>s.jsx("button",{onClick:()=>o("headingScale",l),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${n.headingScale===l?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:t(`markdown.scale${l.charAt(0).toUpperCase()+l.slice(1)}`)},l))})]})]})}const qG=k.lazy(()=>qr(()=>Promise.resolve().then(()=>l3),void 0).then(e=>({default:e.MarkdownMessage}))),GG={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},H2={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 VG({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=GG[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=H2[e.status]??H2.active,u=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),s.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-start gap-3 rounded-t-2xl z-10",children:[s.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${o.color}`,children:o.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),s.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.summary")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(k.Suspense,{fallback:s.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:s.jsx(qG,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.reference")}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),u?s.jsx("button",{onClick:()=>window.open(e.reference,"_blank","noopener,noreferrer"),className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")}):s.jsx("button",{onClick:()=>{Ce.files.reveal(e.reference).catch(()=>{})},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")})]})]}),e.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),s.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),s.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),s.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&s.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&s.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>s.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),s.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[s.jsxs("span",{children:[r("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),s.jsxs("span",{children:[r("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&s.jsx("span",{children:r("agent:deliverables.accessed",{count:e.accessCount})})]})]}),s.jsxs("div",{className:"sticky bottom-0 bg-surface-primary/95 backdrop-blur-sm border-t border-border-default px-5 py-3 flex items-center justify-end gap-2 rounded-b-2xl",children:[s.jsxs("button",{onClick:()=>n(e.id),className:"px-3 py-1.5 text-xs font-medium text-brand-500 hover:bg-brand-500/10 rounded-lg transition-colors flex items-center gap-1.5",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),r("agent:deliverables.openInPage")]}),s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs font-medium text-fg-secondary bg-surface-elevated hover:bg-surface-overlay rounded-lg transition-colors",children:r("common:close")})]})]})]});return typeof document<"u"?Ja.createPortal(d,document.body):d}const KG={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function t3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const n3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},r3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},WG=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function Ip(e){return WG.test(e.trim())}function YG(e){const t=e.split("_")[0]?.toLowerCase();return t?KG[t]:void 0}function a3(e){e.startsWith("tsk_")?at.navigate(me.WORK,{openTask:e}):e.startsWith("req_")?at.navigate(me.WORK,{openRequirement:e}):e.startsWith("proj_")?at.navigate(me.WORK,{projectId:e}):e.startsWith("dlv_")?at.navigate(me.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?at.navigate(me.TEAM,{agentId:e}):e.startsWith("team_")&&at.navigate(me.TEAM,{selectTeam:e})}const Hh=new Map,hd=new Map;async function XG(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Ce.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Ce.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Ce.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Ce.deliverables.get(e);return{...n,title:r.deliverable.title,status:r.deliverable.status,summary:r.deliverable.summary,deliverable:r.deliverable}}case"agent":{const r=await Ce.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Ce.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function s3(e,t){const n=t??YG(e),[r,o]=k.useState(()=>Hh.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){o({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Hh.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let u=!0,d=hd.get(e);return d||(d=XG(e,n),hd.set(e,d)),d.then(m=>{Hh.set(e,m),hd.delete(e),u&&o(m)}).catch(()=>{hd.delete(e),u&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{u=!1}},[e,n]),r}function i3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function i0({id:e,type:t,label:n}){const r=s3(e,t),o=z0(),l=n3[r.type]??"🔗",u=n??(r.loading||r.notFound?i3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&o?.hostAvailable){o.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}a3(e)};return s.jsxs("span",{"data-entity-link":e,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors align-baseline",onClick:d,title:`${r3[r.type]}: ${r.notFound?e:r.title} (${e})`,children:[s.jsx("span",{className:"text-[10px]",children:l}),s.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:u})]})}function QG({id:e,type:t,label:n}){const r=s3(e,t),[o,l]=k.useState(!1),u=z0(),d=n3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}a3(e)},h=r.loading?i3(e):n||(r.notFound?e:r.title);return s.jsxs("span",{className:"not-prose block my-2",children:[s.jsxs("button",{type:"button",onClick:m,className:"w-full max-w-md text-left rounded-xl border border-border-default bg-surface-elevated/30 hover:border-brand-500/40 hover:bg-surface-elevated/50 transition-colors px-3 py-2.5 flex items-start gap-2.5",children:[s.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:d}),s.jsxs("span",{className:"flex-1 min-w-0 block",children:[s.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:r3[r.type]}),r.status&&s.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded font-medium bg-brand-500/10 text-brand-500",children:r.status})]}),s.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${r.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:h}),r.summary&&r.summary.trim()!==r.title.trim()&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:r.summary})]}),s.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),o&&r.deliverable&&s.jsx(VG,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:p=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:p})}})]})}class ZG extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!JG(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 JG(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 eV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function F2(e){return eV.test(e)?e:W5(e)}const q2=[vw,HH,kk],G2=[[wF,{strict:"ignore"}],[Wk,{detect:!0,ignoreMissing:!0}]],tV=/<think>([\s\S]*?)(<\/think>|$)/g;function nV(e){const t=[];let n=e.replace(tV,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:t,rest:n.trim()}}const V2="#mention:",o0="#entity:",rV=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,o3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Pp(e){return e.type==="text"?e.value??"":(e.children??[]).map(Pp).join("")}function aV(e){return e.type==="text"&&(e.value??"").trim()===""}function sV(e){if(!e?.children)return null;const t=e.children.filter(r=>!aV(r));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const r=n.properties?.href;if(!r)return null;const o=Pp(n);if(r.startsWith(o0))return{id:r.slice(o0.length)};const l=r.match(o3);return l&&l[1]!=="workflow"?{id:l[2],type:t3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Pp(n).trim();if(Ip(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(Ip(r))return{id:r}}return null}const iV={p:({children:e})=>s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>s.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>s.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>s.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>s.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>s.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>s.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>s.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>s.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>s.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),r=n.trim();if(t?.includes("language-plantuml")||RG(r))return s.jsx(Lp,{code:r,language:"plantuml",children:s.jsx(Qk,{code:r})});if(t?.includes("language-mermaid")||!t&&DG(r))return s.jsx(Lp,{code:r,language:"mermaid",children:s.jsx(Xk,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Ip(n))return s.jsx(i0,{id:n.trim()});const o=n.match(rV);return o?s.jsx(i0,{id:o[2],label:o[1]}):lG(n)?s.jsx(uG,{path:n}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e})},pre:({children:e})=>s.jsx(UG,{children:e}),strong:({children:e})=>s.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>s.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>s.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>s.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:t}),hr:()=>s.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>s.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>s.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>s.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>s.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold text-fg-primary border border-border-default",children:e}),td:({children:e})=>s.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},oV=/^(?:\/[\w.\-@+ ]|~\/|\.\.?\/|[A-Z]:\\)/,lV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function cV(e){return oV.test(e)&&lV.test(e)}function uV(e,t){if(e.startsWith("/")||e.startsWith("~/")||/^[A-Z]:\\/.test(e))return e;if((e.startsWith("./")||e.startsWith("../"))&&t){const r=((t.endsWith("/")?t:t+"/")+e).split("/"),o=[];for(const l of r)l===".."?o.pop():l!=="."&&l!==""&&o.push(l);return"/"+o.join("/")}return e}function dV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const ko=new Map;function mV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>cV(e)?dV(uV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),u=ko.get(o),[d,m]=k.useState(u??(l?null:o)),[h,p]=k.useState(!!u),[g,x]=k.useState(!1),[y,w]=k.useState(null),[N,T]=k.useState(0),C=k.useRef(0),j=k.useCallback(()=>{ko.delete(o),x(!1),w(null),p(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(_=>_+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const _=ko.get(o);if(_){m(_),p(!0),x(!1),w(null);return}const O=++C.current;x(!1),w(null),p(!1),m(null),(async()=>{try{const z=await fetch(o,{credentials:"same-origin"});if(O!==C.current)return;if(!z.ok){let W=`HTTP ${z.status}`;try{const Z=await z.json();Z.error&&(W=Z.error)}catch{}throw new Error(W)}const D=await z.blob();if(O!==C.current)return;if(D.size===0)throw new Error("Empty image response");if(D.type&&!D.type.startsWith("image/")&&!D.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${D.type}`);const H=URL.createObjectURL(D);ko.set(o,H),m(H),p(!0),x(!1),w(null)}catch(z){if(O!==C.current)return;const D=z instanceof Error?z.message:String(z);console.warn("[MarkdownImage] failed to load local image",o,z),w(D),x(!0),p(!1)}})()},[l,o,N]),k.useEffect(()=>{l||(m(o),p(!!ko.get(o)),x(!1),w(null))},[o,l,N]),g?s.jsxs("button",{type:"button",onClick:j,title:y??"Click to retry",className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[s.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",y?` (${y})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!h&&s.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),d?s.jsx("img",{src:d,alt:t??"",onLoad:()=>{l||ko.set(o,o),p(!0)},onError:()=>{w("Image decode failed"),x(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${h?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function K2(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function fV(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const r=n.getContext("2d");if(!r)throw new Error("Canvas unavailable");return r.drawImage(t,0,0),t.close(),new Promise((o,l)=>{n.toBlob(u=>u?o(u):l(new Error("PNG encode failed")),"image/png")})}function hV(e,t){try{const o=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(o&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(o))return decodeURIComponent(o)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function pV({src:e,onClose:t}){const{t:n}=ft("common"),[r,o]=k.useState(null),[l,u]=k.useState(null);zo(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{o(g),window.setTimeout(()=>o(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){u("copy");try{const x=await K2(e),y=await fV(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{u(null)}}},[l,d,e,n]),h=k.useCallback(async g=>{if(g.stopPropagation(),!l){u("download");try{const x=await K2(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=hV(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{u(null)}}},[l,d,e,n]),p="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 Ja.createPortal(s.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[s.jsxs("button",{type:"button",className:p,onClick:m,disabled:!!l,title:n("copyImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),s.jsxs("button",{type:"button",className:p,onClick:h,disabled:!!l,title:n("downloadImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),s.jsx("button",{type:"button",onClick:t,className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",title:n("close"),children:s.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r&&s.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:r}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function gV(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),o=l=>n(l.matches);return r.addEventListener("change",o),n(r.matches),()=>r.removeEventListener("change",o)},[e]),t}function bV({content:e,contentRef:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),[l,u]=k.useState(!1),[d,m]=k.useState(!1),[h,p]=k.useState(null),g=k.useRef(null),x=gV();k.useEffect(()=>{if(!r)return;const T=C=>{g.current&&!g.current.contains(C.target)&&(o(!1),u(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const y=k.useCallback(T=>{p(T),setTimeout(()=>p(null),1500)},[]),w=async()=>{const T=await Mg(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},N=async T=>{const C=t.current?.firstElementChild;if(!C)return;const j=e3(),_=HG(j),O=await NG(C,T,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),z=n(T==="light"?"markdown.themeLight":"markdown.themeDark");y(O.ok?O.method==="html"?n("markdown.htmlCopied",{theme:z}):n("markdown.textCopied"):n("markdown.failed")),o(!1)};return s.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[h&&s.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 px-2 py-0.5 rounded bg-surface-elevated border border-border-default text-[10px] text-fg-secondary whitespace-nowrap shadow-lg",children:h}),s.jsx("button",{onClick:()=>o(T=>!T),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:n("markdown.copyContent"),children:s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),r&&s.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:d?s.jsx(FG,{onClose:()=>m(!1)}):l?s.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),s.jsx("button",{onClick:()=>u(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),s.jsx("button",{onClick:()=>u(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),s.jsxs("button",{onClick:w,className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.jsxs("button",{onClick:()=>N("light"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.jsxs("button",{onClick:()=>N("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Ar=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:u,rest:d}=nV(t),m=k.useRef(null),[h,p]=k.useState(null),g=k.useCallback(w=>{let N=md(w,CG);return N=md(N,jG),N=md(N,MG),N=md(N,T=>TG(T,o)),N},[o]),x=k.useMemo(()=>g(d),[d,g]),y=k.useMemo(()=>({...iV,img:({src:w,alt:N})=>s.jsx(mV,{src:w??"",alt:N,onPreview:p,basePath:l},w??""),p:({children:w,node:N})=>{const T=sV(N);return T?s.jsx(QG,{id:T.id,type:T.type,label:T.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:w})},a:({href:w,children:N})=>{if(w?.startsWith(V2)){const T=decodeURIComponent(w.slice(V2.length));return s.jsx("span",{className:`text-brand-500 font-medium${r?" cursor-pointer hover:underline":""}`,onClick:r?C=>{C.preventDefault(),C.stopPropagation(),r(T,C)}:void 0,title:T,children:N})}if(w?.startsWith(o0))return s.jsx(i0,{id:w.slice(o0.length)});{const T=w?.match(o3);if(T){const[,C,j]=T;if(C==="workflow")return s.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:O=>{O.preventDefault(),O.stopPropagation(),at.navigate(me.WORK,{boardType:"workflows"})},title:`workflow: ${j}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:N})]});const _=t3(C);if(_)return s.jsx(i0,{id:j,type:_,label:N})}}return s.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:N})}}),[r,l]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(bV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(ZG,{resetKeys:[x],fallback:s.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:s.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${n}`,children:[u.length>0&&(()=>{const w=u.join(`
|
|
648
|
+
`,1;if(Zo>1e5&&Zo>ht.index*3)throw new Error("potential infinite loop, way more iterations than matches");return an+=Lt,Lt.length}const Yn=ir(Pe);if(!Yn)throw et(vt.replace("{}",Pe)),new Error('Unknown language: "'+Pe+'"');const jc=nt(Yn);let zi="",Tt=rn||jc;const Mc={},In=new tt.__emitter(tt);Qo();let an="",ls=0,ja=0,Zo=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(wt,In);else{for(Tt.matcher.considerAll();;){Zo++,cs?cs=!1:Tt.matcher.considerAll(),Tt.matcher.lastIndex=ja;const Ze=Tt.matcher.exec(wt);if(!Ze)break;const ht=wt.substring(ja,Ze.index),Lt=Pi(ht,Ze);ja=Ze.index+Lt}Pi(wt.substring(ja))}return In.finalize(),zi=In.toHTML(),{language:Pe,value:zi,relevance:ls,illegal:!1,_emitter:In,_top:Tt}}catch(Ze){if(Ze.message&&Ze.message.includes("Illegal"))return{language:Pe,value:R(wt),illegal:!0,relevance:0,_illegalBy:{message:Ze.message,index:ja,context:wt.slice(ja-100,ja+100),mode:Ze.mode,resultSoFar:zi},_emitter:In};if(Je)return{language:Pe,value:R(wt),illegal:!1,relevance:0,errorRaised:Ze,_emitter:In,_top:Tt};throw Ze}}function Ri(Pe){const wt={value:R(Pe),illegal:!1,relevance:0,_top:Ie,_emitter:new tt.__emitter(tt)};return wt._emitter.addText(Pe),wt}function Oi(Pe,wt){wt=wt||tt.languages||Object.keys(ie);const Ut=Ri(Pe),rn=wt.filter(ir).filter(is).map(pn=>Ea(pn,Pe,!1));rn.unshift(Ut);const Rn=rn.sort((pn,Rr)=>{if(pn.relevance!==Rr.relevance)return Rr.relevance-pn.relevance;if(pn.language&&Rr.language){if(ir(pn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===pn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(Pe,wt,Ut){const rn=wt&&Ne[wt]||Ut;Pe.classList.add("hljs"),Pe.classList.add(`language-${rn}`)}function Mn(Pe){let wt=null;const Ut=jn(Pe);if(St(Ut))return;if(Ws("before:highlightElement",{el:Pe,language:Ut}),Pe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Pe);return}if(Pe.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(Pe)),tt.throwUnescapedHTML))throw new Xt("One of your code blocks includes unescaped HTML.",Pe.innerHTML);wt=Pe;const rn=wt.textContent,Rn=Ut?vn(rn,{language:Ut,ignoreIllegals:!0}):Oi(rn);Pe.innerHTML=Rn.value,Pe.dataset.highlighted="yes",ma(Pe,Ut,Rn.language),Pe.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(Pe.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ws("after:highlightElement",{el:Pe,result:Rn,text:rn})}function er(Pe){tt=oe(tt,Pe)}const ss=()=>{Di(),pe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Wo(){Di(),pe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Tc=!1;function Di(){function Pe(){Di()}if(document.readyState==="loading"){Tc||window.addEventListener("DOMContentLoaded",Pe,!1),Tc=!0;return}document.querySelectorAll(tt.cssSelector).forEach(Mn)}function Ec(Pe,wt){let Ut=null;try{Ut=wt(q)}catch(rn){if(et("Language definition for '{}' could not be registered.".replace("{}",Pe)),Je)et(rn);else throw rn;Ut=Ie}Ut.name||(Ut.name=Pe),ie[Pe]=Ut,Ut.rawDefinition=wt.bind(null,q),Ut.aliases&&Aa(Ut.aliases,{languageName:Pe})}function Ks(Pe){delete ie[Pe];for(const wt of Object.keys(Ne))Ne[wt]===Pe&&delete Ne[wt]}function Yo(){return Object.keys(ie)}function ir(Pe){return Pe=(Pe||"").toLowerCase(),ie[Pe]||ie[Ne[Pe]]}function Aa(Pe,{languageName:wt}){typeof Pe=="string"&&(Pe=[Pe]),Pe.forEach(Ut=>{Ne[Ut.toLowerCase()]=wt})}function is(Pe){const wt=ir(Pe);return wt&&!wt.disableAutodetect}function os(Pe){Pe["before:highlightBlock"]&&!Pe["before:highlightElement"]&&(Pe["before:highlightElement"]=wt=>{Pe["before:highlightBlock"](Object.assign({block:wt.el},wt))}),Pe["after:highlightBlock"]&&!Pe["after:highlightElement"]&&(Pe["after:highlightElement"]=wt=>{Pe["after:highlightBlock"](Object.assign({block:wt.el},wt))})}function Ln(Pe){os(Pe),Le.push(Pe)}function Ac(Pe){const wt=Le.indexOf(Pe);wt!==-1&&Le.splice(wt,1)}function Ws(Pe,wt){const Ut=Pe;Le.forEach(function(rn){rn[Ut]&&rn[Ut](wt)})}function _a(Pe){return pe("10.7.0","highlightBlock will be removed entirely in v12.0"),pe("10.7.0","Please use highlightElement now."),Mn(Pe)}Object.assign(q,{highlight:vn,highlightAuto:Oi,highlightAll:Di,highlightElement:Mn,highlightBlock:_a,configure:er,initHighlighting:ss,initHighlightingOnLoad:Wo,registerLanguage:Ec,unregisterLanguage:Ks,listLanguages:Yo,getLanguage:ir,registerAliases:Aa,autoDetection:is,inherit:oe,addPlugin:Ln,removePlugin:Ac}),q.debugMode=function(){Je=!1},q.safeMode=function(){Je=!0},q.versionString=ct,q.regex={concat:N,lookahead:x,either:C,optional:w,anyNumberOfTimes:y};for(const Pe in Et)typeof Et[Pe]=="object"&&e(Et[Pe]);return Object.assign(q,Et),q},qe=$e({});return qe.newInstance=()=>$e({}),Bh=qe,qe.HighlightJS=qe,qe.default=qe,Bh}var qq=Fq();const Gq=xc(qq),D2={},Vq="hljs-";function Kq(e){const t=Gq.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:u,registered:d};function n(m,h,p){const g=p||D2,x=typeof g.prefix=="string"?g.prefix:Vq;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:Wq,classPrefix:x});const y=t.highlight(h,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,N=w.data;return N.language=y.language,N.relevance=y.relevance,w}function r(m,h){const g=(h||D2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const N=g[x];if(!t.getLanguage(N))continue;const T=n(N,m,h);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function l(m,h){if(typeof m=="string")t.registerLanguage(m,h);else{let p;for(p in m)Object.hasOwn(m,p)&&t.registerLanguage(p,m[p])}}function u(m,h){if(typeof m=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:m});else{let p;for(p in m)if(Object.hasOwn(m,p)){const g=m[p];t.registerAliases(typeof g=="string"?g:[...g],{languageName:p})}}}function d(m){return!!t.getLanguage(m)}}class Wq{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(u,d){return d?u+"_".repeat(d):n.options.classPrefix+u}),o=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Yq={};function Wk(e){const t=e||Yq,n=t.aliases,r=t.detect||!1,o=t.languages||Hq,l=t.plainText,u=t.prefix,d=t.subset;let m="hljs";const h=Kq(o);if(n&&h.registerAlias(n),u){const p=u.indexOf("-");m=p===-1?u:u.slice(0,p)}return function(p,g){S0(p,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const N=Xq(x);if(N===!1||!N&&!r||N&&l&&l.includes(N))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=Ek(x,{whitespace:"pre"});let C;try{C=N?h.highlight(N,T,{prefix:u}):h.highlightAuto(T,{prefix:u,subset:d})}catch(j){const _=j;if(N&&/Unknown language/.test(_.message)){g.message("Cannot highlight as `"+N+"`, it’s not registered",{ancestors:[w,x],cause:_,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw _}!N&&C.data&&C.data.language&&x.properties.className.push("language-"+C.data.language),C.children.length>0&&(x.children=C.children)})}}function Xq(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const o=String(t[n]);if(o==="no-highlight"||o==="nohighlight")return!1;!r&&o.slice(0,5)==="lang-"&&(r=o.slice(5)),!r&&o.slice(0,9)==="language-"&&(r=o.slice(9))}return r}const Qq=10;function L2(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function Zq(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.title||e.path.split(/[/\\]/).pop()||e.path}const Yk=k.createContext(null);function Jq({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),[r,o]=k.useState([]),[l,u]=k.useState(null),[d,m]=k.useState(!1),[h,p]=k.useState(!1),g=k.useRef([]),x=k.useRef(null),y=k.useRef(null);y.current=l;const w=k.useCallback(X=>n(X),[]),N=k.useCallback(()=>n(X=>!X),[]),T=k.useCallback(X=>{const F=L2(X),J=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let B=null;o(Q=>{const re=Q.find(G=>L2(G.payload)===F);if(re)return B=re.id,g.current=Q,Q;let $=[{id:J,title:Zq(X),payload:X},...Q];for(;$.length>Qq;){let G=-1;for(let le=$.length-1;le>=0;le--)if(!$[le].pinned){G=le;break}if(G<0)break;$=$.filter((le,I)=>I!==G)}return B=J,g.current=$,$}),B&&(u(B),x.current=B),n(!0)},[]),C=X=>{X?.kind==="url"&&X.browserId&&window.markusDesktop?.browser?.destroy(X.browserId)},j=k.useCallback(X=>{let F,J,B=!1;o(Q=>{const re=Q.findIndex($=>$.id===X);if(re<0)return Q;F=Q[re]?.payload;const ke=Q.filter($=>$.id!==X);return g.current=ke,B=ke.length===0,J=void 0,(x.current===X||ke.length===0)&&(J=ke[Math.min(re,ke.length-1)]?.id??null),ke}),B&&m(!1),J!==void 0&&(u(J),x.current=J),C(F)},[]),_=k.useCallback(()=>{let X=[];o(F=>(X=F.map(J=>J.payload),[])),u(null),m(!1),g.current=[],x.current=null;for(const F of X)C(F)},[]),O=k.useCallback(X=>{u(X),x.current=X},[]),z=k.useCallback((X,F)=>{o(J=>{let B=!1;const Q=J.map(re=>{if(re.payload.kind!=="url"||re.payload.browserId!==X)return re;B=!0;const ke=F.url??re.payload.url,$=F.title||re.payload.title||ke;return{...re,title:$,payload:{...re.payload,url:ke,title:$}}});return B&&(g.current=Q),B?Q:J})},[]),D=k.useCallback(()=>{o(X=>X.length===0?X:(g.current=X,y.current&&(x.current=y.current),[])),u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()},[]),H=k.useCallback(()=>{const X=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,F=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let J,B=!1,Q=!1;o(re=>{if(re.length>0)return g.current=re,y.current&&(x.current=y.current),Q=!0,J=null,[];if(g.current.length>0){B=!0;const $=g.current;return J=x.current&&$.some(le=>le.id===x.current)?x.current:$[0].id,$}B=!0;const ke={id:X,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:F}};return g.current=[ke],J=ke.id,[ke]}),B&&n(!0),Q?(u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()):J!=null&&(u(J),x.current=J)},[]),W=k.useCallback(X=>m(X),[]),Z=k.useCallback(()=>m(X=>!X),[]),U=r.find(X=>X.id===l)??r[0]??null,Y=U?.payload??null,se=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:w,toggleLeftCollapsed:N,rightPanel:Y,rightPanelOpen:r.length>0,rightPanelTabs:r,activeRightPanelTabId:U?.id??null,openRightPanel:T,closeRightPanel:_,closeRightPanelTab:j,setActiveRightPanelTab:O,updateRightPanelBrowserTab:z,toggleRightPanel:H,collapseRightPanelOnly:D,rightPanelFullscreen:d,setRightPanelFullscreen:W,toggleRightPanelFullscreen:Z,hostAvailable:h,setHostAvailable:p}),[t,w,N,Y,r,U,T,_,j,O,z,H,D,d,W,Z,h]);return s.jsx(Yk.Provider,{value:se,children:e})}function z0(){return k.useContext(Yk)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>l3),void 0).then(e=>({default:e.MarkdownMessage})));const eG=k.lazy(()=>qr(()=>import("./ContentRenderer-vHk6I1iG.js"),[]).then(e=>({default:e.ContentRenderer})));let wo=[],I2=60;function tG(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++I2);return k.useEffect(()=>{const r=()=>t.current();wo.push(r);const o=l=>{l.key==="Escape"&&wo[wo.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),wo=wo.filter(l=>l!==r),wo.length===0&&(I2=60)}},[]),n}const P2=500,Bs=new Map,s0=new Set,Rd=new Map;let Od=null;function nG(){if(Bs.size<=P2)return;const e=Bs.size-P2,t=Bs.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;Bs.delete(r)}}function z2(e,t){Bs.delete(e),Bs.set(e,t),nG()}function B2(e){const t=Rd.get(e);if(t)for(const n of t)n()}function rG(){Od=null;const e=[...s0];s0.clear(),e.length!==0&&Ce.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))z2(n,r),B2(n)}).catch(()=>{for(const t of e)z2(t,{exists:!1,isFile:!1,type:"unknown"}),B2(t)})}function aG(e){Bs.has(e)||s0.has(e)||(s0.add(e),Od&&clearTimeout(Od),Od=setTimeout(rG,30))}function sG(e,t){let n=Rd.get(e);return n||(n=new Set,Rd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Rd.delete(e)}}function iG(e){const t=k.useCallback(o=>sG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{aG(e)},[e]),r}const oG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function lG(e){return e.length<2||e.length>500?!1:oG.test(e)}function cG({filePath:e,onClose:t}){const n=tG(t),[r,o]=k.useState(!0),[l,u]=k.useState(null),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[N,T]=k.useState("");k.useEffect(()=>{o(!0),u(null),Ce.files.preview(e).then(j=>{m(typeof j.content=="string"?j.content:""),p(j.type),x(j.name),w(j.mimeType||""),T(j.streamUrl||(j.path?Ce.files.streamUrl(j.path):"")||(j.type==="audio"||j.type==="video"?Ce.files.streamUrl(e):""))}).catch(j=>{u(String(j?.message||j))}).finally(()=>{o(!1)})},[e]);const C=g||e.split(/[/\\]/).pop()||e;return Ja.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:j=>j.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:C}),s.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Ce.files.reveal(e),title:"Reveal in file explorer",children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{d:"M4.5 17a2.5 2.5 0 01-2.5-2.5v-9A2.5 2.5 0 014.5 3h3.672a1.5 1.5 0 011.06.44L10.56 4.77a.5.5 0 00.354.147H15.5A2.5 2.5 0 0118 7.417v7.083A2.5 2.5 0 0115.5 17h-11z"})})}),s.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[r&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),l&&s.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[s.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:l})]}),!r&&!l&&h==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${y||"image/png"};base64,${d}`,alt:C,className:"max-w-full rounded"})}),!r&&!l&&h==="audio"&&N&&s.jsx("audio",{controls:!0,preload:"metadata",src:N,className:"w-full"}),!r&&!l&&h==="video"&&N&&s.jsx("video",{controls:!0,preload:"metadata",src:N,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(h==="binary"||!d&&h!=="image"&&h!=="audio"&&h!=="video")&&s.jsxs("div",{className:"text-center py-8 space-y-3",children:[s.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),s.jsx("button",{className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",onClick:()=>{Ce.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&h!=="image"&&h!=="audio"&&h!=="video"&&h!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(eG,{content:d,format:h==="text"?"text":h,className:"text-sm"})})]})]})}),document.body)}function uG({path:e}){const t=iG(e),[n,r]=k.useState(null),o=z0(),l=t?.exists??!1,u=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(p=>{if(p.preventDefault(),p.stopPropagation(),!!l)if(u){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Ce.files.reveal(e)},[l,u,e,o]),m="inline w-3 h-3 align-[-0.125em]",h=u?s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}):s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})});return t?l?s.jsxs(s.Fragment,{children:[s.jsxs("code",{className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:d,title:u?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[h,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(cG,{filePath:n,onClose:()=>r(null)})]}):s.jsx("code",{className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:"File not found",children:e}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let Uh=null;function dG(){return Uh||(Uh=qr(()=>import("./mermaid.core-CIbUmMmc.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Uh}function mG(){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 fG(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 hG(){return mG()}function pG(){return k.useSyncExternalStore(fG,hG)}function Xk({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),u=k.useId(),d=k.useRef(0),m=k.useRef(null),h=pG();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===h)return;let p=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await dG();if(p)return;g.default.initialize({startOnLoad:!1,theme:h?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const x=`mermaid-${u.replace(/:/g,"")}-${d.current}`,{svg:y}=await g.default.render(x,e.trim());if(p)return;t.current&&(t.current.innerHTML=y,m.current={code:e,dark:h})}catch(g){p||r(g instanceof Error?g.message:String(g))}finally{p||l(!1)}})(),()=>{p=!0}},[e,u,h]),n?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[o&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),s.jsx("div",{ref:t,className:`flex justify-center [&>svg]:max-w-full${o?" hidden":""}`})]})}const gG="/assets/viz-global-C_AyN6D9.js";let dd=!1,$h=null;function bG(){return dd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(dd=!0,e()):(n.addEventListener("load",()=>{dd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const r=document.createElement("script");r.setAttribute("data-plantuml-viz",""),r.src=gG,r.onload=()=>{dd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function xG(){return $h||($h=bG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),$h}let U2=Promise.resolve();function yG(e,t){const n=U2.then(()=>new Promise((r,o)=>{xG().then(({renderToString:l})=>{const u=e.split(/\r\n|\r|\n/);l(u,r,o,{dark:t})}).catch(o)}));return U2=n.then(()=>{},()=>{}),n}function vG(){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 wG(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 kG(){return k.useSyncExternalStore(wG,()=>vG())}function Qk({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,u]=k.useState(!0),d=k.useRef(null),m=kG();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let h=!1;return u(!0),o(null),yG(e.trim(),m).then(p=>{h||(n(p),d.current={code:e,dark:m})}).catch(p=>{h||o(p instanceof Error?p.message:String(p))}).finally(()=>{h||u(!1)}),()=>{h=!0}},[e,m]),r?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t&&s.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`,dangerouslySetInnerHTML:{__html:t}})]})}function SG(e,t,n){const r=e.cloneNode(!0),o=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",u=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},d=t==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},m={p:`margin:0 0 10px;color:${d.text};line-height:1.7;`,h1:`font-size:${u.h1}em;font-weight:700;color:${d.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${d.border};padding-bottom:6px;`,h2:`font-size:${u.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${u.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${u.h4}em;font-weight:600;color:${d.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${d.strong};`,em:"font-style:italic;",a:`color:${d.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${d.text};`,blockquote:`border-left:3px solid ${d.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${d.blockquoteText};`,hr:`border:none;border-top:1px solid ${d.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${d.tableHeaderBg};`,th:`border:1px solid ${d.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${d.tableHeaderText};`,td:`border:1px solid ${d.tableBorder};padding:8px 12px;color:${d.text};`,img:"max-width:100%;height:auto;"};function h(p){p.removeAttribute("class");const g=p.tagName.toLowerCase();if(g==="pre"){p.setAttribute("style",`background:${d.preBg};color:${d.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${d.preBorder};`);const x=p.querySelector("code");x&&(x.removeAttribute("class"),x.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}g==="code"?p.setAttribute("style",`background:${d.codeBg};color:${d.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[g]&&p.setAttribute("style",m[g]),Array.from(p.children).forEach(h)}return r.removeAttribute("class"),Array.from(r.children).forEach(p=>h(p)),`<div style="background:${d.bg};color:${d.text};padding:20px 24px;font-family:${o};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function Mg(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 NG(e,t,n,r){const o=SG(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Mg(n),method:"text"}}}function Lp({code:e,language:t,children:n}){const{t:r}=ft("common"),[o,l]=k.useState("rendered"),[u,d]=k.useState(!1),m=k.useCallback(async()=>{await Mg(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return s.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),r("markdown.viewRendered")]})}),s.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),r("markdown.viewSource")]})})]})]}),o==="rendered"?s.jsx("div",{children:n}):s.jsxs("div",{className:"relative group/source",children:[s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary bg-surface-secondary leading-relaxed whitespace-pre-wrap break-words",children:e}),s.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:r("markdown.copyContent"),children:u?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}function md(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,o="";for(const l of e.matchAll(n))o+=t(e.slice(r,l.index)),o+=l[0],r=l.index+l[0].length;return o+=t(e.slice(r)),o}function CG(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const fd="#mention:";function TG(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,u,d)=>{const m=u??d;return`[@${m}](${fd}${encodeURIComponent(m)})`});const n=[...t].sort((l,u)=>u.length-l.length);let r="",o=0;for(;o<e.length;){const l=e.indexOf("@",o);if(l<0){r+=e.slice(o);break}if(r+=e.slice(o,l),e[l+1]==="["){const p=e.indexOf("]",l+2);if(p>l+2){const g=e.slice(l+2,p);r+=`[@${g}](${fd}${encodeURIComponent(g)})`,o=p+1;continue}}const u=e.slice(l+1),d=u.toLowerCase(),m=n.find(p=>d.startsWith(p.toLowerCase()));if(m){const p=u.slice(0,m.length);r+=`[@${p}](${fd}${encodeURIComponent(p)})`,o=l+1+m.length;continue}const h=u.match(/^([\w\p{L}\p{N}]+)/u);if(h){const p=h[1];r+=`[@${p}](${fd}${encodeURIComponent(p)})`,o=l+1+p.length;continue}r+="@",o=l+1}return r}const Zk="#entity:",EG=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),AG=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function _G(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function jG(e){return e.replace(AG,(t,n,r)=>`[${n}](${Zk}${r})`)}function MG(e){return e.replace(EG,(t,n,r)=>_G(e,r)?t:`[${t}](${Zk}${t})`)}function RG(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const OG=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function DG(e){return OG.test(e.trim())}const LG={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 IG(e){return LG[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function PG(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const zG=[Xk,Qk];function BG(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return PG(n)}return null}function rc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(rc).join("");if(k.isValidElement(e)){const t=e.props;return rc(t.children)}return""}function UG({children:e}){const{t}=ft("common"),n=BG(e),r=k.useRef(null),[o,l]=k.useState(!1),[u,d]=k.useState("rendered"),m=k.useCallback(async()=>{let p;u==="source"?p=rc(e):p=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[u,e]);if(k.Children.toArray(e).some(p=>k.isValidElement(p)&&zG.includes(p.type))){const p=rc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Lp,{code:p,language:g,children:e})}return n==="mermaid"||n==="plantuml"?s.jsx(s.Fragment,{children:e}):s.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:IG(n)}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>d("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${u==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),s.jsx("button",{onClick:()=>d("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${u==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),s.jsxs("div",{className:"relative",children:[u==="rendered"?s.jsx("pre",{ref:r,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,p=>k.isValidElement(p)?k.cloneElement(p,{style:{background:"transparent",padding:0}}):p)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:rc(e)}),s.jsx("button",{onClick:m,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:t("markdown.copyContent"),children:o?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const Jk="markus-copy-typography",$2={fontFamily:"default",fontSize:15,headingScale:"standard"};function e3(){try{const e=localStorage.getItem(Jk);if(e)return{...$2,...JSON.parse(e)}}catch{}return $2}function $G(e){localStorage.setItem(Jk,JSON.stringify(e))}function HG(e){const t={default:"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif",serif:"Georgia, 'Times New Roman', Times, serif","sans-serif":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif",mono:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"},n={compact:{h1:1.3,h2:1.15,h3:1.05,h4:1},standard:{h1:1.6,h2:1.35,h3:1.15,h4:1},large:{h1:2,h2:1.6,h3:1.3,h4:1.1}};return{fontFamily:t[e.fontFamily]??t.default,fontSize:`${e.fontSize}px`,headingScales:n[e.headingScale]??n.standard}}function FG({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(e3);k.useEffect(()=>{$G(n)},[n]);const o=k.useCallback((l,u)=>{r(d=>({...d,[l]:u}))},[]);return s.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:t("markdown.typographySettings")}),s.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("markdown.typographyDesc")}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.fontFamily")}),s.jsxs("select",{value:n.fontFamily,onChange:l=>o("fontFamily",l.target.value),className:"w-full px-2 py-1 text-xs rounded bg-surface-primary border border-border-subtle text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50",children:[s.jsx("option",{value:"default",children:t("markdown.fontDefault")}),s.jsx("option",{value:"serif",children:t("markdown.fontSerif")}),s.jsx("option",{value:"sans-serif",children:t("markdown.fontSansSerif")}),s.jsx("option",{value:"mono",children:t("markdown.fontMono")})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[t("markdown.fontSize"),": ",n.fontSize,"px"]}),s.jsx("input",{type:"range",min:10,max:24,step:1,value:n.fontSize,onChange:l=>o("fontSize",Number(l.target.value)),className:"w-full h-1 rounded-full appearance-none bg-border-subtle [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-brand-500"}),s.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[s.jsx("span",{children:"10px"}),s.jsx("span",{children:"24px"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.headingScale")}),s.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(l=>s.jsx("button",{onClick:()=>o("headingScale",l),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${n.headingScale===l?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:t(`markdown.scale${l.charAt(0).toUpperCase()+l.slice(1)}`)},l))})]})]})}const qG=k.lazy(()=>qr(()=>Promise.resolve().then(()=>l3),void 0).then(e=>({default:e.MarkdownMessage}))),GG={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},H2={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 VG({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=GG[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=H2[e.status]??H2.active,u=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),s.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-start gap-3 rounded-t-2xl z-10",children:[s.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${o.color}`,children:o.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),s.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.summary")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(k.Suspense,{fallback:s.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:s.jsx(qG,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.reference")}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),u?s.jsx("button",{onClick:()=>window.open(e.reference,"_blank","noopener,noreferrer"),className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")}):s.jsx("button",{onClick:()=>{Ce.files.reveal(e.reference).catch(()=>{})},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")})]})]}),e.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),s.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),s.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),s.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&s.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&s.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>s.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),s.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[s.jsxs("span",{children:[r("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),s.jsxs("span",{children:[r("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&s.jsx("span",{children:r("agent:deliverables.accessed",{count:e.accessCount})})]})]}),s.jsxs("div",{className:"sticky bottom-0 bg-surface-primary/95 backdrop-blur-sm border-t border-border-default px-5 py-3 flex items-center justify-end gap-2 rounded-b-2xl",children:[s.jsxs("button",{onClick:()=>n(e.id),className:"px-3 py-1.5 text-xs font-medium text-brand-500 hover:bg-brand-500/10 rounded-lg transition-colors flex items-center gap-1.5",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),r("agent:deliverables.openInPage")]}),s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs font-medium text-fg-secondary bg-surface-elevated hover:bg-surface-overlay rounded-lg transition-colors",children:r("common:close")})]})]})]});return typeof document<"u"?Ja.createPortal(d,document.body):d}const KG={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function t3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const n3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},r3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},WG=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function Ip(e){return WG.test(e.trim())}function YG(e){const t=e.split("_")[0]?.toLowerCase();return t?KG[t]:void 0}function a3(e){e.startsWith("tsk_")?at.navigate(me.WORK,{openTask:e}):e.startsWith("req_")?at.navigate(me.WORK,{openRequirement:e}):e.startsWith("proj_")?at.navigate(me.WORK,{projectId:e}):e.startsWith("dlv_")?at.navigate(me.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?at.navigate(me.TEAM,{agentId:e}):e.startsWith("team_")&&at.navigate(me.TEAM,{selectTeam:e})}const Hh=new Map,hd=new Map;async function XG(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Ce.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Ce.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Ce.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Ce.deliverables.get(e);return{...n,title:r.deliverable.title,status:r.deliverable.status,summary:r.deliverable.summary,deliverable:r.deliverable}}case"agent":{const r=await Ce.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Ce.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function s3(e,t){const n=t??YG(e),[r,o]=k.useState(()=>Hh.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){o({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Hh.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let u=!0,d=hd.get(e);return d||(d=XG(e,n),hd.set(e,d)),d.then(m=>{Hh.set(e,m),hd.delete(e),u&&o(m)}).catch(()=>{hd.delete(e),u&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{u=!1}},[e,n]),r}function i3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function i0({id:e,type:t,label:n}){const r=s3(e,t),o=z0(),l=n3[r.type]??"🔗",u=n??(r.loading||r.notFound?i3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&o?.hostAvailable){o.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}a3(e)};return s.jsxs("span",{"data-entity-link":e,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors align-baseline",onClick:d,title:`${r3[r.type]}: ${r.notFound?e:r.title} (${e})`,children:[s.jsx("span",{className:"text-[10px]",children:l}),s.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:u})]})}function QG({id:e,type:t,label:n}){const r=s3(e,t),[o,l]=k.useState(!1),u=z0(),d=n3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}a3(e)},h=r.loading?i3(e):n||(r.notFound?e:r.title);return s.jsxs("span",{className:"not-prose block my-2",children:[s.jsxs("button",{type:"button",onClick:m,className:"w-full max-w-md text-left rounded-xl border border-border-default bg-surface-elevated/30 hover:border-brand-500/40 hover:bg-surface-elevated/50 transition-colors px-3 py-2.5 flex items-start gap-2.5",children:[s.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:d}),s.jsxs("span",{className:"flex-1 min-w-0 block",children:[s.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:r3[r.type]}),r.status&&s.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded font-medium bg-brand-500/10 text-brand-500",children:r.status})]}),s.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${r.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:h}),r.summary&&r.summary.trim()!==r.title.trim()&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:r.summary})]}),s.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),o&&r.deliverable&&s.jsx(VG,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:p=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:p})}})]})}class ZG extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!JG(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 JG(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 eV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function F2(e){return eV.test(e)?e:W5(e)}const q2=[vw,HH,kk],G2=[[wF,{strict:"ignore"}],[Wk,{detect:!0,ignoreMissing:!0}]],tV=/<think>([\s\S]*?)(<\/think>|$)/g;function nV(e){const t=[];let n=e.replace(tV,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:t,rest:n.trim()}}const V2="#mention:",o0="#entity:",rV=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,o3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Pp(e){return e.type==="text"?e.value??"":(e.children??[]).map(Pp).join("")}function aV(e){return e.type==="text"&&(e.value??"").trim()===""}function sV(e){if(!e?.children)return null;const t=e.children.filter(r=>!aV(r));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const r=n.properties?.href;if(!r)return null;const o=Pp(n);if(r.startsWith(o0))return{id:r.slice(o0.length)};const l=r.match(o3);return l&&l[1]!=="workflow"?{id:l[2],type:t3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Pp(n).trim();if(Ip(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(Ip(r))return{id:r}}return null}const iV={p:({children:e})=>s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>s.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>s.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>s.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>s.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>s.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>s.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>s.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>s.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>s.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),r=n.trim();if(t?.includes("language-plantuml")||RG(r))return s.jsx(Lp,{code:r,language:"plantuml",children:s.jsx(Qk,{code:r})});if(t?.includes("language-mermaid")||!t&&DG(r))return s.jsx(Lp,{code:r,language:"mermaid",children:s.jsx(Xk,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Ip(n))return s.jsx(i0,{id:n.trim()});const o=n.match(rV);return o?s.jsx(i0,{id:o[2],label:o[1]}):lG(n)?s.jsx(uG,{path:n}):s.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e})},pre:({children:e})=>s.jsx(UG,{children:e}),strong:({children:e})=>s.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>s.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>s.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>s.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:t}),hr:()=>s.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>s.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>s.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>s.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>s.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold text-fg-primary border border-border-default",children:e}),td:({children:e})=>s.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},oV=/^(?:\/[\w.\-@+ ]|~\/|\.\.?\/|[A-Z]:\\)/,lV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function cV(e){return oV.test(e)&&lV.test(e)}function uV(e,t){if(e.startsWith("/")||e.startsWith("~/")||/^[A-Z]:\\/.test(e))return e;if((e.startsWith("./")||e.startsWith("../"))&&t){const r=((t.endsWith("/")?t:t+"/")+e).split("/"),o=[];for(const l of r)l===".."?o.pop():l!=="."&&l!==""&&o.push(l);return"/"+o.join("/")}return e}function dV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const ko=new Map;function mV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>cV(e)?dV(uV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),u=ko.get(o),[d,m]=k.useState(u??(l?null:o)),[h,p]=k.useState(!!u),[g,x]=k.useState(!1),[y,w]=k.useState(null),[N,T]=k.useState(0),C=k.useRef(0),j=k.useCallback(()=>{ko.delete(o),x(!1),w(null),p(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(_=>_+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const _=ko.get(o);if(_){m(_),p(!0),x(!1),w(null);return}const O=++C.current;x(!1),w(null),p(!1),m(null),(async()=>{try{const z=await fetch(o,{credentials:"same-origin"});if(O!==C.current)return;if(!z.ok){let W=`HTTP ${z.status}`;try{const Z=await z.json();Z.error&&(W=Z.error)}catch{}throw new Error(W)}const D=await z.blob();if(O!==C.current)return;if(D.size===0)throw new Error("Empty image response");if(D.type&&!D.type.startsWith("image/")&&!D.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${D.type}`);const H=URL.createObjectURL(D);ko.set(o,H),m(H),p(!0),x(!1),w(null)}catch(z){if(O!==C.current)return;const D=z instanceof Error?z.message:String(z);console.warn("[MarkdownImage] failed to load local image",o,z),w(D),x(!0),p(!1)}})()},[l,o,N]),k.useEffect(()=>{l||(m(o),p(!!ko.get(o)),x(!1),w(null))},[o,l,N]),g?s.jsxs("button",{type:"button",onClick:j,title:y??"Click to retry",className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[s.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",y?` (${y})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!h&&s.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),d?s.jsx("img",{src:d,alt:t??"",onLoad:()=>{l||ko.set(o,o),p(!0)},onError:()=>{w("Image decode failed"),x(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${h?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function K2(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function fV(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const r=n.getContext("2d");if(!r)throw new Error("Canvas unavailable");return r.drawImage(t,0,0),t.close(),new Promise((o,l)=>{n.toBlob(u=>u?o(u):l(new Error("PNG encode failed")),"image/png")})}function hV(e,t){try{const o=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(o&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(o))return decodeURIComponent(o)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function pV({src:e,onClose:t}){const{t:n}=ft("common"),[r,o]=k.useState(null),[l,u]=k.useState(null);zo(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{o(g),window.setTimeout(()=>o(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){u("copy");try{const x=await K2(e),y=await fV(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{u(null)}}},[l,d,e,n]),h=k.useCallback(async g=>{if(g.stopPropagation(),!l){u("download");try{const x=await K2(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=hV(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{u(null)}}},[l,d,e,n]),p="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 Ja.createPortal(s.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[s.jsxs("button",{type:"button",className:p,onClick:m,disabled:!!l,title:n("copyImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),s.jsxs("button",{type:"button",className:p,onClick:h,disabled:!!l,title:n("downloadImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),s.jsx("button",{type:"button",onClick:t,className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",title:n("close"),children:s.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r&&s.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:r}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function gV(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),o=l=>n(l.matches);return r.addEventListener("change",o),n(r.matches),()=>r.removeEventListener("change",o)},[e]),t}function bV({content:e,contentRef:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),[l,u]=k.useState(!1),[d,m]=k.useState(!1),[h,p]=k.useState(null),g=k.useRef(null),x=gV();k.useEffect(()=>{if(!r)return;const T=C=>{g.current&&!g.current.contains(C.target)&&(o(!1),u(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const y=k.useCallback(T=>{p(T),setTimeout(()=>p(null),1500)},[]),w=async()=>{const T=await Mg(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},N=async T=>{const C=t.current?.firstElementChild;if(!C)return;const j=e3(),_=HG(j),O=await NG(C,T,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),z=n(T==="light"?"markdown.themeLight":"markdown.themeDark");y(O.ok?O.method==="html"?n("markdown.htmlCopied",{theme:z}):n("markdown.textCopied"):n("markdown.failed")),o(!1)};return s.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[h&&s.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 px-2 py-0.5 rounded bg-surface-elevated border border-border-default text-[10px] text-fg-secondary whitespace-nowrap shadow-lg",children:h}),s.jsx("button",{onClick:()=>o(T=>!T),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:n("markdown.copyContent"),children:s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),r&&s.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:d?s.jsx(FG,{onClose:()=>m(!1)}):l?s.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),s.jsx("button",{onClick:()=>u(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),s.jsx("button",{onClick:()=>u(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),s.jsxs("button",{onClick:w,className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.jsxs("button",{onClick:()=>N("light"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.jsxs("button",{onClick:()=>N("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Ar=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:u,rest:d}=nV(t),m=k.useRef(null),[h,p]=k.useState(null),g=k.useCallback(w=>{let N=md(w,CG);return N=md(N,jG),N=md(N,MG),N=md(N,T=>TG(T,o)),N},[o]),x=k.useMemo(()=>g(d),[d,g]),y=k.useMemo(()=>({...iV,img:({src:w,alt:N})=>s.jsx(mV,{src:w??"",alt:N,onPreview:p,basePath:l},w??""),p:({children:w,node:N})=>{const T=sV(N);return T?s.jsx(QG,{id:T.id,type:T.type,label:T.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:w})},a:({href:w,children:N})=>{if(w?.startsWith(V2)){const T=decodeURIComponent(w.slice(V2.length));return s.jsx("span",{className:`text-brand-500 font-medium${r?" cursor-pointer hover:underline":""}`,onClick:r?C=>{C.preventDefault(),C.stopPropagation(),r(T,C)}:void 0,title:T,children:N})}if(w?.startsWith(o0))return s.jsx(i0,{id:w.slice(o0.length)});{const T=w?.match(o3);if(T){const[,C,j]=T;if(C==="workflow")return s.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:O=>{O.preventDefault(),O.stopPropagation(),at.navigate(me.WORK,{boardType:"workflows"})},title:`workflow: ${j}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:N})]});const _=t3(C);if(_)return s.jsx(i0,{id:j,type:_,label:N})}}return s.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:N})}}),[r,l]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(bV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(ZG,{resetKeys:[x],fallback:s.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:s.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${n}`,children:[u.length>0&&(()=>{const w=u.join(`
|
|
649
649
|
|
|
650
650
|
`),N=w.split(`
|
|
651
651
|
`)[0]??"",T=N.length>80?N.slice(0,80)+"…":N;return s.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[s.jsxs("summary",{className:"cursor-pointer select-none px-3 py-2 text-xs text-fg-secondary hover:text-fg-secondary transition-colors flex items-center gap-1.5 min-w-0",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),s.jsx("span",{className:"shrink-0",children:"Thinking"}),s.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:T})]}),s.jsx("div",{className:"px-3 pb-3 border-t border-border-default/50",children:s.jsx("div",{className:"mt-2 pl-3 border-l-2 border-brand-500/40 text-xs text-fg-secondary leading-relaxed",children:s.jsx(bp,{remarkPlugins:q2,rehypePlugins:G2,components:y,urlTransform:F2,children:g(w)})})})]})})(),s.jsx(bp,{remarkPlugins:q2,rehypePlugins:G2,components:y,urlTransform:F2,children:x})]})})}),h&&s.jsx(pV,{src:h,onClose:()=>p(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&xV(e.knownNames,t.knownNames));function xV(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 l3=Object.freeze(Object.defineProperty({__proto__:null,MarkdownMessage:Ar},Symbol.toStringTag,{value:"Module"})),zp={suppressAdjustUntil:0};function bc(e=2500){const t=typeof performance<"u"?performance.now():Date.now();zp.suppressAdjustUntil=Math.max(zp.suppressAdjustUntil,t+e)}function NW(){return(typeof performance<"u"?performance.now():Date.now())<zp.suppressAdjustUntil}const W2={shell_execute:{label:"Running command",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},apply_patch:{label:"Applying patch",icon:"🔀"},list_directory:{label:"Listing directory",icon:"📂"},glob_find:{label:"Finding files",icon:"🔍"},grep_search:{label:"Searching code",icon:"🔍"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},task_get:{label:"Getting task",icon:"📋"},task_note:{label:"Adding note",icon:"📝"},task_assign:{label:"Assigning task",icon:"👥"},task_submit_review:{label:"Submitting for review",icon:"✅"},task_comment:{label:"Commenting task",icon:"💬"},subtask_create:{label:"Adding subtask",icon:"📌"},subtask_complete:{label:"Completing subtask",icon:"✅"},subtask_cancel:{label:"Cancelling subtask",icon:"🚫"},subtask_list:{label:"Listing subtasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},requirement_get:{label:"Getting requirement",icon:"📋"},requirement_update:{label:"Updating requirement",icon:"📋"},requirement_update_status:{label:"Updating req status",icon:"✅"},requirement_resubmit:{label:"Resubmitting requirement",icon:"📋"},requirement_comment:{label:"Commenting requirement",icon:"💬"},list_projects:{label:"Listing projects",icon:"🗂"},get_project:{label:"Getting project",icon:"🗂"},create_project:{label:"Creating project",icon:"🗂"},update_project:{label:"Updating project",icon:"🗂"},deliverable_create:{label:"Creating deliverable",icon:"📦"},deliverable_search:{label:"Searching deliverables",icon:"🔍"},deliverable_list:{label:"Listing deliverables",icon:"📦"},deliverable_update:{label:"Updating deliverable",icon:"📦"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list_colleagues:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},memory_list:{label:"Listing memory",icon:"💾"},memory_update:{label:"Updating memory",icon:"💾"},recall_activity:{label:"Recalling activity",icon:"📜"},update_working_memory:{label:"Updating notes",icon:"📝"},notify_user:{label:"Notifying user",icon:"🔔"},request_user_input:{label:"Requesting input",icon:"❓"},request_user_approval:{label:"Requesting approval",icon:"❓"},schedule_wakeup:{label:"Scheduling wakeup",icon:"⏰"},cancel_wakeup:{label:"Cancelling wakeup",icon:"⏰"},set_heartbeat_interval:{label:"Setting heartbeat",icon:"⏱"},discover_tools:{label:"Discovering tools",icon:"🧰"},check_mailbox:{label:"Checking mailbox",icon:"📥"},goal_create:{label:"Creating goal",icon:"🎯"},goal_update:{label:"Updating goal",icon:"🎯"},goal_status:{label:"Goal status",icon:"🎯"},background_exec:{label:"Background command",icon:"⌨"},process:{label:"Managing process",icon:"⚙"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"},invoke_coding_tool:{label:"Invoke Coding Tool",icon:"🛠"},coding_tool_apply:{label:"Apply Coding Result",icon:"🔀"},generate_image:{label:"Generating image",icon:"🖼"},text_to_speech:{label:"Generating speech",icon:"🔊"},speech_to_text:{label:"Transcribing audio",icon:"🎙"},generate_video:{label:"Generating video",icon:"🎬"},llm_list_providers:{label:"Listing providers",icon:"⚙"},llm_switch_model:{label:"Switching model",icon:"⚙"},llm_switch_default_provider:{label:"Switching provider",icon:"⚙"},llm_add_provider:{label:"Adding provider",icon:"⚙"},llm_edit_provider:{label:"Editing provider",icon:"⚙"},llm_add_model:{label:"Adding model",icon:"⚙"},llm_get_capability_routing:{label:"Checking capability routing",icon:"⚙"},llm_set_capability_routing:{label:"Setting capability routing",icon:"⚙"},team_list:{label:"Listing teams",icon:"👥"},team_status:{label:"Team status",icon:"👥"},team_start:{label:"Starting team",icon:"👥"},team_stop:{label:"Stopping team",icon:"👥"},team_update:{label:"Updating team",icon:"👥"},agent_start:{label:"Starting agent",icon:"◎"},agent_stop:{label:"Stopping agent",icon:"◎"},agent_update:{label:"Updating agent",icon:"◎"},agent_delegate_task:{label:"Delegating task",icon:"📌"},agent_broadcast_status:{label:"Broadcasting status",icon:"📣"},agent_create_group_chat:{label:"Creating group chat",icon:"💬"},agent_list_group_chats:{label:"Listing group chats",icon:"💬"},agent_send_group_message:{label:"Sending group message",icon:"💬"},delete_project:{label:"Deleting project",icon:"🗂"},project_stats:{label:"Project stats",icon:"📊"},hub_search:{label:"Searching Hub",icon:"🔍"},hub_install:{label:"Installing from Hub",icon:"📦"},package_list:{label:"Listing packages",icon:"📦"},package_install:{label:"Installing package",icon:"📦"},memory_delete:{label:"Deleting memory",icon:"💾"},memory_update_longterm:{label:"Updating long-term memory",icon:"💾"},clear_working_memory:{label:"Clearing notes",icon:"📝"},clear_notebook:{label:"Clearing notebook",icon:"📝"},update_notebook:{label:"Updating notebook",icon:"📝"},recall_context:{label:"Recalling context",icon:"📜"},defer_mailbox_item:{label:"Deferring mailbox item",icon:"📥"},drop_mailbox_item:{label:"Dropping mailbox item",icon:"📥"},prioritize_mailbox_item:{label:"Prioritizing mailbox",icon:"📥"},delegate_message:{label:"Delegating message",icon:"💬"},task_board_health:{label:"Checking task board",icon:"📋"},task_check_duplicates:{label:"Checking duplicates",icon:"📋"},task_cleanup_duplicates:{label:"Cleaning duplicates",icon:"📋"},workflow_list:{label:"Listing workflows",icon:"🔄"},workflow_create:{label:"Creating workflow",icon:"🔄"},workflow_update:{label:"Updating workflow",icon:"🔄"},workflow_delete:{label:"Deleting workflow",icon:"🔄"},workflow_run:{label:"Running workflow",icon:"🔄"},workflow_status:{label:"Workflow status",icon:"🔄"},workflow_cancel:{label:"Cancelling workflow",icon:"🔄"},open_page:{label:"Opening page",icon:"🌐"},resize_page:{label:"Resizing page",icon:"🌐"},drag:{label:"Dragging element",icon:"👆"},upload_file:{label:"Uploading file",icon:"📎"},emulate:{label:"Emulating device",icon:"📱"},handle_dialog:{label:"Handling dialog",icon:"💬"},get_console_message:{label:"Console message",icon:"🔍"},get_network_request:{label:"Network request",icon:"🔍"}},Y2={shell_execute:"square-terminal",background_exec:"square-terminal",process:"settings",file_read:"file-text",file_write:"edit",file_edit:"edit",apply_patch:"git-branch",list_directory:"folder",glob_find:"search",grep_search:"search",web_fetch:"globe",web_search:"search",web_extract:"file-text",create_task:"clipboard",task_create:"clipboard",create_subtask:"clipboard",update_task:"check-circle",task_update:"check-circle",add_task_note:"edit",task_add_note:"edit",task_note:"edit",task_list:"clipboard",task_get:"clipboard",task_assign:"users",task_submit_review:"check-circle",task_comment:"message-square",subtask_create:"clipboard",subtask_complete:"check-circle",subtask_cancel:"alert-circle",subtask_list:"clipboard",requirement_propose:"clipboard",requirement_list:"clipboard",requirement_get:"clipboard",requirement_update:"clipboard",requirement_update_status:"check-circle",requirement_resubmit:"clipboard",requirement_comment:"message-square",list_projects:"layers",get_project:"layers",create_project:"layers",update_project:"layers",deliverable_create:"package",deliverable_search:"search",deliverable_list:"package",deliverable_update:"edit",git_status:"git-branch",git_diff:"git-branch",git_log:"book-open",git_branch:"git-branch",git_add:"git-branch",git_commit:"save",project_structure:"layers",code_stats:"bar-chart",navigate_page:"globe",new_page:"globe",close_page:"globe",select_page:"globe",list_pages:"globe",click:"target",hover:"target",fill:"terminal",fill_form:"terminal",type_text:"terminal",press_key:"terminal",take_screenshot:"camera",take_snapshot:"camera",evaluate_script:"code",wait_for:"clock",list_console_messages:"terminal",list_network_requests:"globe",lighthouse_audit:"bar-chart",agent_send_message:"message-square",agent_list_colleagues:"users",memory_save:"database",memory_search:"search",memory_list:"database",memory_update:"database",recall_activity:"book-open",update_working_memory:"edit",notify_user:"megaphone",request_user_input:"message-square",request_user_approval:"check-circle",schedule_wakeup:"clock",cancel_wakeup:"clock",set_heartbeat_interval:"clock",discover_tools:"wrench",check_mailbox:"message-square",goal_create:"target",goal_update:"target",goal_status:"target",feishu_send_message:"message-square",feishu_search_docs:"search",spawn_subagent:"bot",spawn_subagents:"bot",invoke_coding_tool:"wrench",coding_tool_apply:"git-branch",generate_image:"camera",text_to_speech:"headphones",speech_to_text:"headphones",generate_video:"camera",llm_list_providers:"settings",llm_switch_model:"settings",llm_switch_default_provider:"settings",llm_add_provider:"settings",llm_edit_provider:"settings",llm_add_model:"settings",llm_get_capability_routing:"settings",llm_set_capability_routing:"settings",team_list:"users",team_status:"users",team_start:"users",team_stop:"users",team_update:"users",agent_start:"bot",agent_stop:"bot",agent_update:"bot",agent_delegate_task:"clipboard",agent_broadcast_status:"megaphone",agent_create_group_chat:"message-square",agent_list_group_chats:"message-square",agent_send_group_message:"message-square",delete_project:"layers",project_stats:"bar-chart",hub_search:"search",hub_install:"package",package_list:"package",package_install:"package",memory_delete:"database",memory_update_longterm:"database",clear_working_memory:"edit",clear_notebook:"edit",update_notebook:"edit",recall_context:"book-open",defer_mailbox_item:"message-square",drop_mailbox_item:"message-square",prioritize_mailbox_item:"message-square",delegate_message:"message-square",task_board_health:"clipboard",task_check_duplicates:"clipboard",task_cleanup_duplicates:"clipboard",workflow_list:"git-branch",workflow_create:"git-branch",workflow_update:"git-branch",workflow_delete:"git-branch",workflow_run:"git-branch",workflow_status:"git-branch",workflow_cancel:"git-branch",open_page:"globe",resize_page:"globe",drag:"target",upload_file:"file-text",emulate:"settings",handle_dialog:"message-square",get_console_message:"terminal",get_network_request:"globe"};function Ci(e){const t=e.includes("__")?e.split("__").pop():e,n=W2[t]??W2[e],r=Y2[t]??Y2[e]??"settings";return n?{...n,iconName:r,key:t}:{label:t.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase()),icon:"⚙",iconName:r,key:t}}function Po(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function yV(e){const t=new Date(e);if(isNaN(t.getTime()))return e;const n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),u=String(t.getSeconds()).padStart(2,"0");return`${n}-${r} ${o}:${l}:${u}`}function Bp(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function X2(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function c3(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,n])=>n!=null).map(([n,r])=>({key:n,value:typeof r=="string"?r:JSON.stringify(r,null,2)}))}function vV(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const t=e.args.command;return typeof t=="string"?t:null}function CW(e,t){const n=new Map;let r=null;for(const o of e)if(o.type==="tool_start"&&(o.content==="spawn_subagent"||o.content==="spawn_subagents"))r=o.seq,n.set(o.seq,[]);else if(o.type==="tool_end"&&(o.content==="spawn_subagent"||o.content==="spawn_subagents")){if(r!==null){const l=n.get(r);l&&n.set(o.seq,l)}r=null}else if(r!==null&&o.type.startsWith("subagent_")){const l=o.type.replace("subagent_",""),u=o.metadata;n.get(r)?.push({eventType:l,content:o.content,metadata:u})}return t.map(o=>{if(o.type!=="tool")return o;const l=o.key;if(!l)return o;const u=l.replace(/^(?:t[se]_|e[se]_)/,""),d=parseInt(u,10);if(isNaN(d))return o;const m=n.get(d);return!m||m.length===0?o:{...o,info:{...o.info,subagentLogs:m}}})}function Q2(e){const t=new Set;for(let n=0;n<e.length;n++){const r=e[n];if(r.type==="tool"&&(r.info.status==="done"||r.info.status==="error"))for(let o=n-1;o>=0;o--){const l=e[o];if(l.type==="tool"&&l.info.status==="running"&&l.info.tool===r.info.tool&&!t.has(o)){t.add(o);break}}}return e.filter((n,r)=>!t.has(r))}function u3(e){const t=yV(e.createdAt),n=e.createdAt,r=e.metadata;switch(e.type){case"text":return r?.isThinking?{type:"thinking",content:e.content,time:t,timestamp:n}:{type:"text",content:e.content,time:t,timestamp:n};case"status":{const o=r?.action;return o&&["chat","chat_stream","task_execution","respond_in_session"].includes(o)?null:{type:"status",content:e.content,time:t,timestamp:n}}case"error":return{type:"error",content:e.content,time:t,timestamp:n};case"tool_start":return{type:"tool",time:t,timestamp:n,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:r?.arguments,subagentLogs:r?.subagentLogs}};case"tool_end":return{type:"tool",time:t,timestamp:n,key:`ee_${e.seq}`,info:{tool:e.content,status:r?.success===!1?"error":"done",args:r?.arguments,result:r?.result,error:r?.error,durationMs:r?.durationMs,subagentLogs:r?.subagentLogs}};default:return null}}function d3(e,t){if(e!=="task_create"&&e!=="create_task"||!t)return null;try{const n=JSON.parse(t);if(!n.task)return null;const r=n.task;return{taskId:r.id,title:r.title,description:r.description,assignedAgentId:r.assignedAgentId,priority:r.priority}}catch{return null}}function m3(e,t){if(e!=="requirement_propose"||!t)return null;try{const n=JSON.parse(t);if(n.status!=="success"||!n.requirement)return null;const r=n.requirement;return r.status!=="pending"?null:{requirementId:r.id,title:r.title,description:r.description,priority:r.priority}}catch{return null}}const f3={code:s.jsxs(s.Fragment,{children:[s.jsx("polyline",{points:"16 18 22 12 16 6"}),s.jsx("polyline",{points:"8 6 2 12 8 18"})]}),search:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]}),clipboard:s.jsxs(s.Fragment,{children:[s.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),s.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"})]}),"check-circle":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"m9 12 2 2 4-4"})]}),server:s.jsxs(s.Fragment,{children:[s.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),s.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),"file-text":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),s.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),s.jsx("path",{d:"M10 9H8"}),s.jsx("path",{d:"M16 13H8"}),s.jsx("path",{d:"M16 17H8"})]}),"book-open":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 7v14"}),s.jsx("path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"})]}),users:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"9",cy:"7",r:"4"}),s.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),s.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"dollar-sign":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"}),s.jsx("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]}),megaphone:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m3 11 18-5v12L3 14v-3z"}),s.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]}),edit:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),headphones:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5a9 9 0 0 1 18 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"})}),settings:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),target:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("circle",{cx:"12",cy:"12",r:"6"}),s.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),zap:s.jsx(s.Fragment,{children:s.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),terminal:s.jsxs(s.Fragment,{children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]}),sparkles:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .962 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.962 0z"}),s.jsx("path",{d:"M20 3v4"}),s.jsx("path",{d:"M22 5h-4"})]}),wrench:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),globe:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),s.jsx("path",{d:"M2 12h20"})]}),link:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),bot:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 8V4H8"}),s.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),s.jsx("path",{d:"M2 14h2"}),s.jsx("path",{d:"M20 14h2"}),s.jsx("path",{d:"M15 13v2"}),s.jsx("path",{d:"M9 13v2"})]}),"message-square":s.jsx(s.Fragment,{children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),newspaper:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"}),s.jsx("path",{d:"M18 14h-8"}),s.jsx("path",{d:"M15 18h-5"}),s.jsx("path",{d:"M10 6h8v4h-8V6Z"})]}),layers:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"}),s.jsx("path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}),s.jsx("path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"})]}),"bar-chart":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),s.jsx("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),s.jsx("line",{x1:"6",x2:"6",y1:"20",y2:"16"})]}),folder:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}),"git-branch":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"18",r:"3"}),s.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),save:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),s.jsx("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),s.jsx("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]}),camera:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"}),s.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),clock:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),database:s.jsxs(s.Fragment,{children:[s.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),s.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),s.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]}),lightbulb:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}),s.jsx("path",{d:"M9 18h6"}),s.jsx("path",{d:"M10 22h4"})]}),"alert-circle":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),s.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),"square-terminal":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m7 11 2-2-2-2"}),s.jsx("path",{d:"M11 13h4"}),s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]}),package:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m7.5 4.27 9 5.15"}),s.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),s.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),s.jsx("path",{d:"M12 22V12"})]})};function wV(e){return!!e&&e in f3}function Vo({name:e,size:t=24,className:n=""}){const r=f3[e];return r?s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":!0,children:r}):null}const Z2={"coding-tools":"terminal",markitdown:"file-text","markus-admin-cli":"terminal",codex:"code","self-evolution":"sparkles","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"},J2={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Dd(e,t){const n=(e||"").toLowerCase();return Z2[n]?Z2[n]:t&&J2[t]?J2[t]:"layers"}function kV(e){const t=[];for(const n of e)if(n.phase!=="output"){if(n.phase==="start"){const r=`${n.tool}_${n.ts}`;t.push({key:r,tool:n.tool,status:"running"})}else for(let r=t.length-1;r>=0;r--)if(t[r].tool===n.tool&&t[r].status==="running"){t[r]={...t[r],status:n.success===!1?"error":"done"};break}}return t}function h3(){return s.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function SV(){return s.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>s.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function e4({item:e}){const{t}=ft("common"),n=Ci(e.tool);return s.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[s.jsx(Vo,{name:n.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),s.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[t(`execution.tools.${n.key}`,{defaultValue:n.label}),e.status==="running"?"…":""]}),e.status==="running"&&s.jsx(h3,{})]})}function NV({activities:e,isActive:t,persistent:n}){const{t:r}=ft("common"),o=kV(e),[l,u]=k.useState(!1),d=o.length>0,m=d&&o.every(w=>w.status!=="running");if(n&&m){const w=o.filter(T=>T.status==="error").length,N=o.filter(T=>T.status==="done").length;return s.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[s.jsxs("button",{onClick:()=>u(T=>!T),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[s.jsx("span",{className:`transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),s.jsx("span",{className:"font-medium",children:r("activity.step",{count:N})}),w>0&&s.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",r("activity.failed",{count:w})]}),!l&&s.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[o.slice(0,5).map(T=>{const C=Ci(T.tool);return s.jsx(Vo,{name:C.iconName,size:13,className:`shrink-0 ${T.status==="error"?"text-red-500":"text-green-500"}`},T.key)}),o.length>5&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",o.length-5]})]})]}),l&&s.jsx("div",{className:"mt-2 space-y-0.5",children:o.map((T,C)=>s.jsx(e4,{item:T,idx:C,total:o.length},T.key))})]})}if(!d)return s.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[s.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:r("activity.thinking")}),s.jsx(SV,{})]});const h=o.filter(w=>w.status==="error").length;let p=null;for(let w=o.length-1;w>=0;w--)if(o[w].status==="running"){p=o[w];break}const g=o[o.length-1];let x;if(p){const w=Ci(p.tool);x=`${r(`execution.tools.${w.key}`,{defaultValue:w.label})}…`}else if(t&&m)x=r("activity.writingResponse");else{const w=Ci(g.tool);x=r(`execution.tools.${w.key}`,{defaultValue:w.label})}const y=!!p||t&&m;return s.jsxs("div",{className:"mb-1",children:[s.jsxs("button",{onClick:w=>{w.stopPropagation(),u(N=>!N)},className:"flex items-center gap-1.5 text-xs w-full min-w-0 select-none text-fg-tertiary hover:text-fg-secondary transition-colors",children:[s.jsx("span",{className:`shrink-0 transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),s.jsx("span",{className:`truncate font-medium ${y?"activity-text-shimmer":"text-fg-secondary"}`,children:x}),s.jsxs("span",{className:"shrink-0",children:["· ",r("activity.step",{count:o.length})]}),h>0&&s.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",r("activity.failed",{count:h})]}),y&&s.jsx(h3,{})]}),l&&s.jsx("div",{className:"mt-1 space-y-0.5",children:o.map((w,N)=>s.jsx(e4,{item:w,idx:N,total:o.length},w.key))})]})}const CV={"claude-code":{label:"Claude Code",icon:"🤖",badgeClass:"bg-orange-500/15 text-orange-500"},codex:{label:"Codex",icon:"⬡",badgeClass:"bg-emerald-500/15 text-emerald-500"},"cursor-agent":{label:"Cursor",icon:"▶",badgeClass:"bg-blue-500/15 text-blue-500"}},Mo=["created","context_injected","running"],TV=new Set(["completed","failed","cancelled","timeout"]),t4={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function EV(e){return CV[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function AV(e,t){if(e.cost?.durationMs!=null)return e.cost.durationMs;const n=e.startedAt??e.createdAt,r=new Date(n).getTime();if(!Number.isNaN(r)){if(e.completedAt){const o=new Date(e.completedAt).getTime();return Number.isNaN(o)?void 0:Math.max(0,o-r)}if(e.status==="running"||e.status==="context_injected")return Math.max(0,t-r)}}function _V(e){if(e==="completed"||TV.has(e))return Mo.length;const t=Mo.indexOf(e);return t>=0?t:0}function jV({session:e,className:t}){const n=EV(e.tool),[r,o]=k.useState(!1),[l,u]=k.useState(()=>Date.now()),d=e.status==="running"||e.status==="context_injected"||e.status==="created",m=e.status==="failed"||e.status==="timeout"||e.result?.success===!1,h=e.status==="completed"||e.result?.success===!0;k.useEffect(()=>{if(!d)return;const w=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(w)},[d]);const p=k.useMemo(()=>AV(e,l),[e,l]),g=_V(e.status),x=e.result?.rawOutput??(h||m?e.result?.summary:void 0),y=d?"border-brand-500/40 bg-brand-500/5":m?"border-red-500/30 bg-red-500/5":h?"border-green-500/30 bg-green-500/5":"border-border-default bg-surface-secondary/30";return s.jsxs("div",{className:`my-2 rounded-lg border ${y} p-3 max-w-2xl transition-colors ${t??""}`,children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-sm mt-0.5",children:n.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${n.badgeClass}`,children:n.label}),s.jsx("span",{className:`text-[10px] font-medium ${d?"text-brand-500":m?"text-red-500":h?"text-green-500":"text-fg-tertiary"}`,children:t4[e.status]??e.status}),p!=null&&s.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:Po(p)}),e.cost?.estimatedCostUsd!=null&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:["$",e.cost.estimatedCostUsd.toFixed(4)]})]}),s.jsx("div",{className:"text-xs text-fg-secondary mt-1 line-clamp-2",children:e.prompt})]}),d&&s.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0 mt-0.5",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),s.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-6",children:[Mo.map((w,N)=>{const T=g>N||g===N&&!d&&h,C=g===N&&d,j=m&&N===Mo.length-1&&e.status!=="completed";return s.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${j?"bg-red-500":T?"bg-green-500":C?"bg-brand-500 animate-pulse":"bg-gray-600"}`,title:t4[w]}),N<Mo.length-1&&s.jsx("div",{className:`h-px flex-1 ${T?"bg-green-500/50":"bg-border-default/60"}`})]},w)}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${m?"bg-red-500":h?"bg-green-500":"bg-gray-600"}`,title:m?"Failed":"Done"})]}),(e.progressMessage||e.progressPercent!=null)&&d&&s.jsxs("div",{className:"mt-2 ml-6 space-y-1",children:[e.progressPercent!=null&&s.jsx("div",{className:"h-1 bg-surface-elevated rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-brand-500 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progressPercent))}%`}})}),e.progressMessage&&s.jsx("div",{className:"text-[11px] text-fg-tertiary font-mono truncate",children:e.progressMessage})]}),e.result&&!d&&s.jsxs("div",{className:"mt-2 ml-6 space-y-1.5",children:[e.result.summary&&s.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[s.jsxs("span",{className:"text-fg-tertiary",children:[e.result.diffStats.filesChanged," files"]}),s.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["−",e.result.diffStats.deletions]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null)&&s.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[e.cost.inputTokens!=null&&s.jsxs("span",{children:[e.cost.inputTokens.toLocaleString()," in"]}),e.cost.inputTokens!=null&&e.cost.outputTokens!=null&&s.jsx("span",{className:"mx-1",children:"·"}),e.cost.outputTokens!=null&&s.jsxs("span",{children:[e.cost.outputTokens.toLocaleString()," out"]})]})]}),x&&s.jsxs("div",{className:"mt-2 ml-6 border-t border-border-default/30 pt-2",children:[s.jsxs("button",{type:"button",onClick:()=>o(!r),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[s.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),s.jsx("span",{className:"font-medium uppercase tracking-wider",children:"Raw output"})]}),r&&s.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-48 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:x})]})]})}function MV({label:e}){const{t}=ft("common");return s.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[s.jsx("span",{className:"activity-text-shimmer",children:e??t("execution.thinking")}),s.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(n=>s.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${n}ms`,animationDuration:"1s"}},n))})]})}const n4=150;function RV({content:e,className:t}){const[n,r]=k.useState(e),o=k.useRef(0),l=k.useRef(null);k.useEffect(()=>{const d=Date.now(),m=d-o.current;return m>=n4?(o.current=d,r(e)):l.current||(l.current=setTimeout(()=>{o.current=Date.now(),l.current=null,r(e)},n4-m)),()=>{l.current&&(clearTimeout(l.current),l.current=null)}},[e]);const u=k.useMemo(()=>n,[n]);return s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[s.jsx(Ar,{content:u,className:t??"text-sm text-fg-secondary break-words"}),s.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}const l0=8e3,pd=120;function Fh({text:e,className:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),l=e.length>l0,u=!l||r?e:`${e.slice(0,l0)}
|
|
@@ -654,7 +654,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=Pe,rn=wt),Ut===void
|
|
|
654
654
|
`)[0]]}),m&&s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 opacity-60",children:r("execution.toolSteps",{count:e.subagentLogs.filter(_=>_.eventType==="tool_end").length})})]}),e.liveOutput&&e.status==="running"&&s.jsx("pre",{ref:T,className:"mt-1 font-mono text-[11px] text-fg-tertiary bg-surface-secondary/60 rounded px-2 py-1.5 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-all",children:e.liveOutput.length>l0?e.liveOutput.slice(e.liveOutput.length-l0):e.liveOutput}),!h&&d&&e.status==="running"&&C&&s.jsx("div",{className:"mt-1 ml-[23px] font-mono text-[11px] text-fg-tertiary truncate",title:C,children:C}),h&&j&&s.jsx("div",{className:"mt-1 ml-[23px] border-l-2 border-border-default/60 pl-3 max-h-80 overflow-y-auto overflow-x-hidden",children:s.jsx(OV,{info:e,time:t})})]}),l&&!n&&(()=>{const _=d3(e.tool,e.result);if(_)return s.jsx(g3,{info:_});const O=m3(e.tool,e.result);return O?s.jsx(b3,{info:O}):null})()]})}function BV({content:e,time:t,defaultExpanded:n}){const{t:r}=ft("common"),[o,l]=k.useState(n??!1);return k.useEffect(()=>{n&&l(!0)},[n]),s.jsxs("div",{className:"min-w-0 py-0.5 overflow-hidden",children:[s.jsxs("button",{onClick:()=>{bc(),l(u=>!u)},className:"flex items-center gap-2 text-xs w-full min-w-0",children:[s.jsx(Vo,{name:"sparkles",size:15,className:"shrink-0 text-violet-400"}),s.jsx("span",{className:`shrink-0 ${n?"activity-text-shimmer":"text-fg-secondary"}`,children:r("execution.thinking")}),s.jsx("svg",{className:`w-3 h-3 shrink-0 text-fg-tertiary transition-transform ${o?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),o&&t&&s.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-fg-tertiary tabular-nums",children:t})]}),o&&s.jsx("div",{className:"mt-1.5 ml-[23px] border-l-2 border-border-default/60 pl-3 overflow-hidden",children:s.jsx(Ar,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})}const o4=k.memo(UV);function UV({entry:e,showTime:t,isLast:n,defaultThinkingExpanded:r,hideApprovalCards:o}){const{t:l}=ft("common");if(e.type==="tool")return s.jsx(zV,{info:e.info,showTime:t,time:e.time,isLast:n,hideApprovalCards:o},e.key);if(e.type==="thinking")return s.jsx(BV,{content:e.content,time:e.time,showTime:t,defaultExpanded:r});if(e.type==="text")return e.content.startsWith("⚠")?s.jsx("div",{className:"min-w-0 pl-[23px] pr-1 overflow-hidden",children:s.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap break-words",children:e.content.replace(/^⚠\s*/,"")})}):s.jsx("div",{className:"min-w-0 pl-[23px] pr-1 overflow-hidden",children:s.jsx(Ar,{content:e.content,className:"text-sm text-fg-secondary break-words"})});if(e.type==="status"){const u=e.content==="completed"||e.content==="execution_finished",d=e.content==="started",m=e.content==="resumed",h=u?"text-green-600":d?"text-blue-600":m?"text-amber-600":"text-fg-tertiary",p=u?"bg-green-400":d?"bg-blue-400":m?"bg-amber-400":"bg-gray-500";return s.jsxs("div",{className:"flex items-center gap-2 py-0.5 min-w-0",children:[s.jsx("span",{className:"w-[15px] flex justify-center shrink-0",children:s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${p}`})}),s.jsx("span",{className:`text-xs capitalize ${h}`,children:l(`execution.statusKnown.${e.content}`,{defaultValue:e.content})})]})}return e.type==="error"?s.jsxs("div",{className:"flex items-start gap-2 py-0.5 min-w-0",children:[s.jsx(Vo,{name:"alert-circle",size:15,className:"shrink-0 mt-0.5 text-fg-tertiary"}),s.jsxs("span",{className:"text-xs text-fg-tertiary leading-relaxed break-words min-w-0",children:[s.jsx("span",{className:"font-medium",children:l("execution.errorPrefix")})," ",e.content.replace(/^⚠\s*/,"")]})]}):null}function TW({entries:e,streamingText:t,isActive:n,onExpand:r,showRounds:o,embedded:l}){const{t:u}=ft("common"),d=e.length>0?e[e.length-1]:null,m=e.filter(O=>O.type==="tool_end").length,h=e.filter(O=>O.type==="error").length,p=e.length>0?new Date(e[0].createdAt).getTime():Date.now(),g=d?new Date(d.createdAt).getTime():Date.now(),x=n?Date.now()-p:g-p,y=new Set(e.filter(O=>O.executionRound!=null).map(O=>O.executionRound)),w=y.size>0?Math.max(...y):void 0,N=o&&y.size>1;let T,C,j=null;if(n)if(t)T="✍",C=u("execution.compact.writingResponse"),j=Bp(t.split(`
|
|
655
655
|
`).pop()??"",80);else if(d?.type==="tool_start"){const O=Ci(d.content);T=O.icon,C=`${u(`execution.tools.${O.key}`,{defaultValue:O.label})}...`;const z=d.metadata?.arguments&&typeof d.metadata.arguments=="object"?d.metadata.arguments.command:void 0;z&&(j=`$ ${Bp(z.split(`
|
|
656
656
|
`)[0]??"",80)}`)}else if(d?.type==="tool_end"){const O=Ci(d.content);T=O.icon,C=u(`execution.tools.${O.key}`,{defaultValue:O.label})}else T="💭",C=u("execution.compact.thinking");else if(h>0&&d?.type==="error")T="❌",C=u("execution.compact.failed");else{const z=[...e].reverse().find(D=>D.type==="status")?.content??"";z==="completed"||z==="execution_finished"?(T="✅",C=u("execution.compact.completed")):(T="●",C=u("execution.compact.toolsExecuted",{count:m}))}const _=Po(x);return s.jsx("div",{onClick:()=>{bc(),r()},className:`overflow-hidden transition-all cursor-pointer min-w-0 ${l?"hover:bg-surface-elevated/20":`rounded-lg border hover:brightness-110 ${n?"border-2 exec-card-active":"border border-border-default bg-surface-elevated/30 hover:border-brand-500/40"}`}`,children:s.jsxs("div",{className:l?"py-2":"px-3 py-2.5 bg-surface-primary/80",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n?s.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):s.jsx("span",{className:"text-sm shrink-0",children:T}),s.jsx("span",{className:`text-xs font-medium truncate ${n?"text-fg-primary":"text-fg-secondary"}`,children:C})]}),_&&s.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums shrink-0",children:_})]}),t?s.jsx("div",{className:`mt-1.5 ml-5.5 text-xs text-fg-secondary whitespace-pre-wrap break-words leading-relaxed ${l&&n?"":"max-h-32 overflow-y-auto"}`,children:s.jsx(Ar,{content:t,className:"text-xs"})}):j?s.jsx("div",{className:"mt-1 ml-5.5 text-[11px] font-mono text-fg-tertiary truncate",children:j}):null,s.jsxs("div",{className:"flex items-center justify-between mt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[m>0&&s.jsxs("span",{children:["🔧 ",u("execution.compact.toolsLine",{count:m})]}),e.some(O=>O.type==="text"&&!O.metadata?.isThinking)&&s.jsxs("span",{children:["💬 ",u("execution.compact.text")]}),e.some(O=>O.type==="text"&&O.metadata?.isThinking)&&s.jsxs("span",{className:"text-purple-400",children:["💭 ",u("execution.compact.thinkingTag")]}),N&&w!=null&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"opacity-30",children:"·"}),s.jsx("span",{children:u("execution.compact.round",{n:w})}),s.jsx("span",{className:"opacity-30",children:"·"}),s.jsx("span",{children:u("execution.compact.rounds",{count:y.size})})]})]}),s.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:[u("execution.compact.showFullLog"),s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]})]})})}function $V(e){const t=new Map;for(const n of e){const r=n.executionRound??1;t.has(r)||t.set(r,[]);const o=u3(n);o&&t.get(r).push(o)}return Array.from(t.entries()).sort(([n],[r])=>n-r).map(([n,r])=>({round:n,entries:r}))}function HV({entries:e,streamingText:t,isActive:n,onCollapse:r,showRounds:o,embedded:l,expandThinking:u,hideApprovalCards:d}){const{t:m}=ft("common"),h=k.useRef(null),[p,g]=k.useState(new Set),x=$V(e),y=o&&x.length>1;k.useEffect(()=>{x.length>0&&g(C=>{const j=new Set(C);return j.add(x[x.length-1].round),j})},[x.length]),k.useEffect(()=>{l||!h.current||!n||(h.current.scrollTop=h.current.scrollHeight)},[e.length,t,n,l]);const w=C=>{bc(),g(j=>{const _=new Set(j);return _.has(C)?_.delete(C):_.add(C),_})},N=y?null:e.map(u3).filter(C=>C!==null),T=N?Q2(N):null;return s.jsxs("div",{className:`min-w-0 overflow-hidden ${l?"":"rounded-lg border border-border-default bg-surface-primary/50"}`,children:[r&&s.jsxs("div",{onClick:()=>{bc(),r()},className:`flex items-center cursor-pointer hover:bg-surface-elevated/40 transition-colors ${l?"justify-end py-0.5":"justify-between px-3 py-1.5 border-b border-border-default"}`,children:[!l&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:m("execution.fullLog.title")}),s.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:[m("execution.fullLog.collapse"),s.jsx("svg",{className:"w-3 h-3 rotate-180",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),s.jsxs("div",{ref:l?void 0:h,className:`space-y-2.5 min-w-0 overflow-x-hidden ${l?"py-1":"px-3 py-2 max-h-[60vh] overflow-y-auto scrollbar-thin"}`,children:[y?x.map(C=>{const j=p.has(C.round),_=Q2(C.entries),O=C.entries.filter(z=>z.type==="tool"&&z.info?.status!=="running").length;return s.jsxs("div",{className:"border border-border-default/50 rounded-lg mb-2 overflow-hidden",children:[s.jsxs("button",{onClick:()=>w(C.round),className:"w-full flex items-center justify-between px-3 py-1.5 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-medium",children:m("execution.compact.round",{n:C.round})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:m("execution.compact.toolsLine",{count:O})}),s.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${j?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),j&&s.jsx("div",{className:"px-3 py-1.5 space-y-2.5",children:_.map((z,D)=>s.jsx(o4,{entry:z,showTime:!1,isLast:D===_.length-1,defaultThinkingExpanded:!!u,hideApprovalCards:d},D))})]},C.round)}):T&&T.map((C,j)=>s.jsx(o4,{entry:C,showTime:!1,isLast:j===T.length-1,defaultThinkingExpanded:!!u,hideApprovalCards:d},j)),n&&t&&s.jsx(RV,{content:t}),n&&!t&&s.jsx(MV,{})]})]})}function EW({priority:e}){const t=e==="high"||e==="critical";return s.jsxs("div",{className:`inline-flex items-center gap-1 mt-1.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${t?"bg-amber-500/10 text-amber-500 border border-amber-500/20":"bg-brand-500/10 text-brand-400 border border-brand-500/20"}`,children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),s.jsxs("span",{children:["Notification",e&&e!=="normal"?` · ${e}`:""]})]})}function AW({name:e,agentId:t,agents:n,onViewProfile:r}){const{t:o}=ft(["team","common"]),[l,u]=k.useState(!1),d=k.useRef(null),m=t?n.find(h=>h.id===t):n.find(h=>h.name===e);return k.useEffect(()=>{if(!l)return;const h=p=>{d.current&&!d.current.contains(p.target)&&u(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[l]),m?s.jsxs("span",{ref:d,className:"relative inline-block",children:[s.jsx("button",{onClick:()=>u(!l),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),l&&s.jsxs("div",{className:"absolute left-0 top-full mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-40 w-56 p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Us,{name:m.name,avatarUrl:m.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-600"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:m.name}),s.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[m.role," · ",m.agentRole??o("page.workerRole")]})]}),s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${m.status==="working"?"bg-blue-400 animate-pulse":m.status==="error"?"bg-red-400":"bg-green-400"}`})]}),s.jsx("button",{onClick:()=>{u(!1),r?.(m.id)},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:o("page.viewProfileArrow")})]})]}):s.jsx("span",{children:e})}function _W({agent:e,anchorRect:t,onClose:n,onViewProfile:r}){const{t:o}=ft(["common","team"]),l=k.useRef(null);k.useEffect(()=>{const h=p=>{l.current&&!l.current.contains(p.target)&&n()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n]);const u=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",d=e.status==="idle"?o("common:status.online"):e.status==="working"?o("common:status.working"):e.status==="error"?o("common:status.error"):o("common:status.offline"),m=k.useCallback(h=>{if(!h)return;l.current=h;const p=h.getBoundingClientRect(),g=window.innerWidth,x=window.innerHeight,y=8;p.right>g-y&&(h.style.left=`${Math.max(y,g-p.width-y)}px`),p.left<y&&(h.style.left=`${y}px`),p.bottom>x-y&&(h.style.top=`${Math.max(y,x-p.height-y)}px`)},[]);return s.jsxs("div",{ref:m,className:"fixed z-50 w-64 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:t.top+40,left:t.left},children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Us,{name:e.name,avatarUrl:e.avatarUrl,size:40,bgClass:"bg-brand-500/15 text-brand-600"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u}`}),s.jsx("span",{className:"text-[10px] text-fg-secondary",children:d}),e.agentRole&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),s.jsx("button",{onClick:()=>{n(),r(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:o("team:page.viewProfileArrow")})]})}function FV(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const x3="markus:credit-notif-muted";let l4=0;function jW(){try{if(localStorage.getItem(x3))return}catch{}const e=Date.now();e-l4<5*6e4||(l4=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function qV(){try{localStorage.setItem(x3,"1")}catch{}}function MW(e,t){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let r="";const o=n.match(/\{[\s\S]*\}/);if(o)try{const d=JSON.parse(o[0]);r=d.error?.message??d.message??""}catch{}if(!r){const d=n.lastIndexOf(": ");d>=0&&(r=n.slice(d+2).trim())}const l=(d,m)=>t(`team:errors.${d}`,m);if(n.includes("MARKUS_UPSTREAM_ERROR"))return l("aiUpstreamBillingMismatch",{detail:r||l("defaultUpstreamBillingMismatch")});if(FV(n)||n.includes("CU_EXCEEDED"))return l("markusCuExceeded");if(n.includes("CU_WINDOW_EXCEEDED"))return l("markusWindowExceeded");if(n.includes("MARKUS_RATE_LIMITED"))return l("markusRateLimited");if(/not available in your region/i.test(n))return l("aiRegionBlocked",{model:(n.match(/\[(?:markus|openrouter):([^\]]+)\]/i)?.[1]||"").trim()||"—"});if(n.includes("401")||/unauthorized|invalid.?api.?key/i.test(n))return l("ai401",{detail:r||l("defaultInvalidApiKey")});if(n.includes("429")||/rate.?limit/i.test(n))return l("ai429",{detail:r||l("defaultTooManyRequests")});if(/\b409\b/.test(n)||/conflict/i.test(n))return l("ai409",{detail:r||l("defaultConflict")});if(n.includes("502")||/bad.?gateway/i.test(n))return l("ai502",{detail:r||l("defaultUpstreamDown")});if(n.includes("503")||/service.?unavailable/i.test(n))return l("ai503",{detail:r||l("defaultServiceDown")});const u=(r||n).replace(/https?:\/\/[^\s]*openrouter\.ai[^\s]*/gi,"").trim();return l("aiGeneric",{detail:(u||n).slice(0,120)})}function RW({msg:e,onCopy:t,onRetry:n,onResume:r,onReply:o,isCopied:l,isLastAgentMsg:u}){const{t:d}=ft(["team","common"]),m=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),h=e.isStopped,p=u!==!1;return s.jsxs("div",{className:"flex items-center flex-wrap gap-0.5 mt-1",children:[s.jsxs("button",{onClick:()=>t(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:d("common:copy"),children:[l?s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}):s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),d(l?"common:copied":"common:copy")]}),p&&h&&r&&s.jsxs("button",{onClick:()=>r(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-green-500 hover:text-green-400 hover:bg-green-500/10 transition-colors",title:d("page.messageActions.resumeTitle"),children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),d("page.messageActions.resumeTitle")]}),p&&h&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-brand-500 hover:text-brand-500 hover:bg-brand-500/10 transition-colors",title:d("page.messageActions.reaskTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),d("page.messageActions.reaskTitle")]}),p&&m&&!h&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-amber-600 hover:text-amber-600 hover:bg-amber-500/10 transition-colors",title:d("page.messageActions.retryTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),d("page.messageActions.retryTitle")]}),p&&!m&&!h&&e.sender==="agent"&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:d("page.messageActions.retryTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),d("page.messageActions.retryTitle")]}),o&&s.jsxs("button",{onClick:()=>o(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:d("page.messageActions.replyTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"9 17 4 12 9 7"}),s.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),d("page.messageActions.replyTitle")]}),e.sender==="agent"&&s.jsx("span",{className:"ml-1 px-1 text-[10px] leading-none text-fg-tertiary/70 select-none whitespace-nowrap",children:d("page.messageActions.aiGeneratedDisclaimer")})]})}function c4(e,t,n){if(!e)return[];const r=[];let o=0;const l=t??"";let d=n?new Date(n).getTime():Date.now();const m=e.some(_=>_.createdAt),h=_=>{if(_.createdAt)return _.createdAt;if(m)return new Date(d).toISOString();const O=new Date(d).toISOString();return _.type==="tool"&&_.durationMs?d+=_.durationMs:d+=1e3,O};let p=!1,g="",x="",y="";const w=()=>{const _=g.trim();_&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:_,createdAt:y,metadata:{isThinking:!0}}),g=""},N=()=>{const _=x.trim();_&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:_,createdAt:y}),x=""},T="<think>",C="</think>",j=_=>{let O=0;for(;O<_.length;)if(p){const z=_.indexOf(C,O);z===-1?(g+=_.slice(O),O=_.length):(g+=_.slice(O,z),p=!1,w(),O=z+C.length)}else{const z=_.indexOf(T,O);z===-1?(x+=_.slice(O),O=_.length):(x+=_.slice(O,z),N(),p=!0,O=z+T.length)}};for(const _ of e)if(y=h(_),_.type==="tool"){p||N();const O=_.createdAt&&_.durationMs?new Date(new Date(_.createdAt).getTime()-_.durationMs).toISOString():y;r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_start",content:_.tool,metadata:{arguments:_.args,..._.status==="running"&&_.subagentLogs?.length?{subagentLogs:_.subagentLogs}:{}},createdAt:O}),_.status!=="running"&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_end",content:_.tool,metadata:{arguments:_.args,result:_.result,error:_.error,durationMs:_.durationMs,success:_.status!=="error",..._.subagentLogs?.length?{subagentLogs:_.subagentLogs}:{}},createdAt:y})}else _.thinking&&(p||N(),g+=_.thinking,w()),j(_.content);return p?w():N(),r}const OW=k.memo(function({msg:t,isStreaming:n,liveActivities:r,onMentionClick:o,knownNames:l}){const{t:u}=ft(["team","common"]),d=t.segments,m=t.isStopped,h=_=>_.type==="text"?_.content.length+(_.thinking?.length??0):(_.result?.length??0)+(_.subagentLogs?.length??0)*1e3+(_.liveOutput?.length??0),p=d?d.length+":"+(d.length>0?h(d[d.length-1]):0):"",g=d?d.reduce((_,O)=>_+(O.type==="tool"?O.subagentLogs?.length??0:0),0):0,x=k.useMemo(()=>d&&d.length>0?c4(d,t.agentId,t.rawCreatedAt):[],[p,g,t.agentId,t.rawCreatedAt]),y=t.committedSegments,w=y?y.length+":"+(y.length>0?h(y[y.length-1]):0):"",N=y?y.reduce((_,O)=>_+(O.type==="tool"?O.subagentLogs?.length??0:0),0):0,T=k.useMemo(()=>n?x:y&&y.length>0?c4(y,t.agentId,t.rawCreatedAt):x,[n,w,N,t.agentId,t.rawCreatedAt,x]);if(d!==void 0&&d.length>0){const _=d.some(U=>U.type==="tool"),O=d.filter(U=>U.type==="text"),z=n?null:O.map(U=>U.content).join(""),D=U=>U.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim()||null,W=(z?D(z):null)||(!n&&t.text?D(t.text):null),Z=[];for(const U of d){if(U.type!=="tool")continue;const Y=d3(U.tool,U.result);if(Y){Z.push({key:`task-${Y.taskId}`,kind:"task",info:Y});continue}const se=m3(U.tool,U.result);se&&Z.push({key:`req-${se.requirementId}`,kind:"req",info:se})}return s.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[_||n?s.jsx(HV,{entries:T,isActive:n,embedded:!0,hideApprovalCards:!0}):W&&s.jsx(Ar,{content:W,onMentionClick:o,knownNames:l}),Z.map(U=>U.kind==="task"?s.jsx(g3,{info:U.info},U.key):s.jsx(b3,{info:U.info},U.key)),!n&&!W&&!_&&Z.length===0&&!m&&!t.isError&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:u("page.emptyReply")})}),!n&&(t.isError||t.text.startsWith("⚠"))&&t.text&&!d?.some(U=>U.type==="text"&&U.content&&(U.content===t.text||U.content.startsWith("⚠")))&&s.jsx("p",{className:"mt-1.5 text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:t.text.replace(/^⚠\s*/,"")}),m&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),s.jsx("span",{children:u("page.stopped")})]})]})}const C=(t.activities?.length??0)>0,j=t.text?t.text.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim():"";return s.jsxs(s.Fragment,{children:[(n||C)&&s.jsx(NV,{activities:n?r:t.activities??[],isActive:n,persistent:!n&&C}),j?t.isError||j.startsWith("⚠")?s.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:j.replace(/^⚠\s*/,"")}):s.jsx(Ar,{content:j,onMentionClick:o,knownNames:l}):null,!n&&!j&&!C&&!m&&!t.isError&&t.sender==="agent"&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:u("page.emptyReply")})}),m&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),s.jsx("span",{children:u("page.stopped")})]})]})});function GV(e){return e.questions&&e.questions.length>0?e.questions:e.options&&e.options.length>0?[{id:"q1",prompt:e.description||e.title,inputType:"choice",options:e.options,allowMultiple:!1,allowFreeform:e.allowFreeform}]:[{id:"q1",prompt:e.description||e.title,inputType:"text",allowFreeform:!0}]}function VV({approval:e,submitting:t,readOnly:n,onClose:r,onSubmit:o}){const{t:l}=ft(["team","common"]);zo(!0);const u=k.useMemo(()=>GV(e),[e]),[d,m]=k.useState(0),[h,p]=k.useState(()=>{if(n&&e.answers&&e.answers.length>0){const z={};for(const D of e.answers)z[D.questionId]={selectedOptionIds:D.selectedOptionIds??[],text:D.text??""};return z}return{}}),g=u[d],x=d===u.length-1,y=u.length>1,w=z=>h[z]??{selectedOptionIds:[],text:""},N=(z,D)=>{p(H=>({...H,[z]:{...w(z),...D}}))},T=(z,D)=>{const H=w(z.id);if(z.allowMultiple){const W=H.selectedOptionIds.includes(D);N(z.id,{selectedOptionIds:W?H.selectedOptionIds.filter(Z=>Z!==D):[...H.selectedOptionIds,D],text:W?H.text:""})}else{const W=H.selectedOptionIds.includes(D);N(z.id,{selectedOptionIds:W?[]:[D],text:W?H.text:""})}},C=z=>{const D=w(z.id);return z.inputType==="choice"?D.selectedOptionIds.length>0?!0:!!(z.allowFreeform&&D.text.trim()):D.text.trim().length>0},j=u.every(C),_=()=>u.map(z=>{const D=w(z.id),H={questionId:z.id};return D.selectedOptionIds.length>0&&(H.selectedOptionIds=D.selectedOptionIds),D.text.trim()&&(H.text=D.text.trim()),H}),O=()=>{const z=_();let D=!0,H;if(!e.questions?.length&&e.options?.length){const Z=z[0];H=Z?.selectedOptionIds?.[0]??(Z?.text?"custom":void 0),D=H!=="reject"&&H!=="request_changes"}const W=z.map(Z=>Z.text).filter(Boolean).join(`
|
|
657
|
-
`)||void 0;o({approved:D,comment:W,selectedOption:H,answers:z})};return Ja.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:z=>{z.target===z.currentTarget&&r()},children:s.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[s.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),s.jsx("path",{d:"M12 8v4"}),s.jsx("path",{d:"M12 16h.01"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),s.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:l("common:close"),children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&s.jsx("div",{className:"flex items-center gap-2",children:u.map((z,D)=>s.jsx("button",{onClick:()=>m(D),className:`h-1.5 flex-1 rounded-full transition-colors ${D===d?"bg-brand-500":C(z)?"bg-green-500/60":"bg-border-default"}`,title:`${D+1}. ${z.prompt.slice(0,40)}`},z.id))}),y&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:u.length,defaultValue:`Question ${d+1} of ${u.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Ar,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((z,D)=>{const H=w(g.id).selectedOptionIds.includes(z.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,z.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${H?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!H?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${H?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:H?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+D)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Ar,{content:z.label}),z.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Ar,{content:z.description})})]})]},z.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&s.jsx("textarea",{rows:g.inputType==="text"?4:2,readOnly:n,placeholder:g.inputType==="text"?l("team:userInput.textPlaceholder",{defaultValue:"Type your answer…"}):l("team:userInput.freeformPlaceholder",{defaultValue:"Or write your own answer…"}),value:w(g.id).text,onChange:z=>{const D=z.target.value;N(g.id,{text:D,selectedOptionIds:D.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:y&&d>0&&s.jsx("button",{onClick:()=>m(z=>Math.max(0,z-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("team:userInput.previous",{defaultValue:"Previous"})})}),s.jsx("div",{className:"flex items-center gap-2",children:y&&!x?s.jsx("button",{disabled:!n&&!C(g),onClick:()=>m(z=>Math.min(u.length-1,z+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:l("team:userInput.next",{defaultValue:"Next"})}):n?s.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("common:close",{defaultValue:"Close"})}):s.jsxs("button",{disabled:t||!j,onClick:O,className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[t&&s.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l("team:userInput.submit",{defaultValue:"Submit"})]})})]})]})}),document.body)}function gd(e){return Array.isArray(e.questions)&&e.questions.length>0}const bd={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},So={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},u4={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function No(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}const d4="markus:template-updates-ack";let qh=!1,xd=null;function KV(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function m4(e,t){if(e.type!=="system"||!e.metadata?.templateUpdates)return!1;if(!t)return!0;const n=e.metadata.templateUpdatesFingerprint;return!n||n===t}function yd(e,t){const n=e.actionType;if(n==="open_chat")return t("team:notifications.actionHints.openChat");if(n==="navigate")return t("team:notifications.actionHints.viewDetails");const r=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return r.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return r.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return r.agentId?t("team:notifications.actionHints.viewAgent"):null;case"direct_message":return t("team:notifications.actionHints.openChat");case"group_message":return t("team:notifications.actionHints.openChat");case"approval_request":return t("team:notifications.actionHints.viewApproval");case"system":return r.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return r.taskId?t("team:notifications.actionHints.viewTask"):r.requirementId?t("team:notifications.actionHints.viewRequirement"):r.agentId?t("team:notifications.actionHints.viewAgent"):null}}function Gh(){try{const e=new AudioContext,t=e.currentTime,n=e.createGain();n.connect(e.destination),n.gain.setValueAtTime(.15,t),n.gain.exponentialRampToValueAtTime(.01,t+.6);const r=e.createOscillator();r.type="sine",r.frequency.setValueAtTime(880,t),r.frequency.setValueAtTime(1174.66,t+.15),r.connect(n),r.start(t),r.stop(t+.6),r.onended=()=>e.close()}catch{}}function WV({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:u,iconPath:d}){const{t:m}=ft(["team","common"]),[h,p]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[N,T]=k.useState([]),[C,j]=k.useState(null),[_,O]=k.useState(null),[z,D]=k.useState(null),[H,W]=k.useState({}),[Z,U]=k.useState(0),Y=k.useRef(null),se=k.useRef(null),[X,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),J=k.useRef(null),B=k.useRef(!1),[Q,re]=k.useState(!0),[ke,$]=k.useState(!1),G=k.useRef(null),le=k.useRef("approvals"),[I,Ee]=k.useState(!1),Ue=30,Oe=k.useCallback(async()=>{try{Wa("/approvals"),Wa("/notifications");const[R,oe]=await Promise.all([Ce.notifications.list(t,!1,{limit:Ue,offset:0}),Ce.approvals.list()]);w(R.notifications);const _e=R.unreadCount??R.notifications.filter(de=>!de.read).length;if(U(_e),re(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=Ue),T(oe.approvals),!B.current){const de=oe.approvals.filter($e=>$e.status==="pending").length;J.current=de,B.current=!0}}catch{}},[t]),We=k.useCallback(async()=>{if(!(ke||!Q)){$(!0);try{const R=await Ce.notifications.list(t,!1,{limit:Ue,offset:y.length});R.notifications.length>0&&w(oe=>[...oe,...R.notifications.filter(_e=>!oe.some(de=>de.id===_e.id))]),re(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=Ue)}catch{}$(!1)}},[t,y.length,ke,Q]),st=k.useCallback(R=>{const oe=R.detail;if(!oe)return;const{taskId:_e,requirementId:de}=oe;!_e&&!de||w($e=>{const qe=$e.filter(q=>!q.read&&(_e&&q.metadata?.taskId===_e||de&&q.metadata?.requirementId===de));if(qe.length===0)return $e;for(const q of qe)Ce.notifications.markRead(q.id).catch(()=>{});return U(q=>Math.max(0,q-qe.length)),$e.map(q=>qe.some(ie=>ie.id===q.id)?{...q,read:!0}:q)})},[]),dt=k.useRef(y);dt.current=y;const Et=k.useCallback(async()=>{if(!dt.current.some(oe=>!oe.read&&oe.type==="system"&&oe.metadata?.creditExhausted))try{await Ce.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),Oe(),Gh()}catch{}},[Oe,m]),gt=k.useCallback(async()=>{if(!qh){qh=!0;try{const{updates:R}=await Ce.skills.updates();if(!R.length)return;const oe=KV(R);try{if(localStorage.getItem(d4)===oe)return}catch{}if(xd===oe||dt.current.some(de=>!de.read&&m4(de,oe)))return;try{const $e=(await Ce.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(qe=>m4(qe,oe)).sort((qe,q)=>new Date(q.createdAt).getTime()-new Date(qe.createdAt).getTime());if($e.length>0){for(const qe of $e.slice(1))Ce.notifications.markRead(qe.id).catch(()=>{});$e.length>1&&Oe(),xd=oe;return}}catch{}xd=oe,await Ce.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:R.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:oe,count:R.length,skills:R.map(de=>de.name)}}),Oe(),Gh()}catch{xd=null}finally{qh=!1}}},[Oe,m,t]);k.useEffect(()=>{Oe();const R=setInterval(Oe,6e4);let oe=null;const _e=()=>{oe||(oe=setTimeout(()=>{oe=null,Oe()},400))},de=()=>_e(),$e=()=>{p(!0),Oe()};window.addEventListener("markus:notifications-changed",de),window.addEventListener("markus:mark-read-by-ref",st),window.addEventListener("markus:open-notifications",$e),window.addEventListener("markus:credit-exhausted",Et);const qe=va.on("notification",_e),q=va.on("approval:requested",_e);return()=>{clearInterval(R),oe&&clearTimeout(oe),window.removeEventListener("markus:notifications-changed",de),window.removeEventListener("markus:mark-read-by-ref",st),window.removeEventListener("markus:open-notifications",$e),window.removeEventListener("markus:credit-exhausted",Et),qe(),q()}},[Oe,st,Et]),k.useEffect(()=>{gt();const R=setInterval(()=>{gt()},5*6e4),oe=()=>{gt()};return window.addEventListener("markus:data-changed",oe),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",oe)}},[t]);const jt=k.useCallback(()=>{if(!Y.current)return;const R=Y.current.getBoundingClientRect(),oe=window.innerWidth,_e=window.innerHeight,de=Math.min(448,oe-16),$e=Math.min(576,_e-16);let qe=R.right+8,q=R.top;qe+de>oe-8&&(qe=Math.max(8,oe-de-8)),q+$e>_e-8&&(q=Math.max(8,_e-$e-8)),F({top:q,left:qe,width:de,maxHeight:$e})},[]);k.useLayoutEffect(()=>{h&&jt()},[h,jt]),k.useEffect(()=>{if(h)return window.addEventListener("resize",jt),()=>window.removeEventListener("resize",jt)},[h,jt]),k.useEffect(()=>{if(!h)return;const R=oe=>{Y.current?.contains(oe.target)||se.current?.contains(oe.target)||p(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[h]),k.useEffect(()=>{if(!h)return;const R=N.some(_e=>_e.status==="pending"),oe=y.some(_e=>!_e.read);x(R&&!oe?"approvals":!R&&oe?"notifications":le.current)},[h]);const Jt=new Set(N.filter(R=>R.status==="pending").map(R=>R.id)),Rt=new Set(N.map(R=>R.id)),be=y.filter(R=>!(R.type==="approval_request"&&R.metadata?.approvalId&&Rt.has(R.metadata.approvalId))),Me=y.filter(R=>R.type==="approval_request"&&!R.read&&R.metadata?.approvalId&&Jt.has(R.metadata.approvalId)).length,Ge=Math.max(0,Z-Me),ot=Jt.size,mt=Ge+ot;k.useEffect(()=>{J.current!==null&&ot>J.current&&Gh(),J.current=ot},[ot]);const ae=async R=>{await Ce.notifications.markRead(R),w(oe=>oe.map(_e=>_e.id===R?{..._e,read:!0}:_e)),U(oe=>Math.max(0,oe-1))},ze=R=>{const oe=R.metadata??{},_e=R.actionType,de=R.actionTarget;if(_e==="open_chat"&&de)try{const $e=typeof de=="string"?JSON.parse(de):de;if($e.agentId){const qe={agentId:$e.agentId};$e.sessionId&&(qe.sessionId=$e.sessionId),at.navigate(me.TEAM,qe);return}}catch{}if(_e==="navigate"&&de)try{const $e=typeof de=="string"?JSON.parse(de):de;if($e.path){if($e.path.startsWith("/team")){const qe={},q=new URLSearchParams($e.path.split("?")[1]||"");for(const[ie,Ne]of q.entries())qe[ie]=Ne;at.navigate(me.TEAM,qe);return}if($e.path.startsWith("/work")){const qe={},q=new URLSearchParams($e.path.split("?")[1]||"");for(const[ie,Ne]of q.entries())qe[ie]=Ne;at.navigate(me.WORK,qe);return}}}catch{}switch(R.type){case"approval_request":{const $e=oe.approvalId,qe=$e?N.find(Le=>Le.id===$e):void 0;if(qe&&gd(qe)){O(qe);break}const q=qe?.details?.taskId??oe.taskId,ie=qe?.details?.requirementId??oe.requirementId,Ne=qe?.details?.agentId??qe?.agentId;q?at.navigate(me.WORK,{openTask:q}):ie?at.navigate(me.WORK,{openRequirement:ie}):Ne?at.navigate(me.TEAM,{agentId:Ne}):at.navigate(me.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):at.navigate(me.WORK);break;case"requirement_created":case"requirement_decision":oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):at.navigate(me.WORK);break;case"agent_report":case"system":{if(oe.creditExhausted){Ee(!0);return}if(oe.templateUpdates){const $e=oe.templateUpdatesFingerprint;if($e)try{localStorage.setItem(d4,$e)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(me.STORE);return}if(oe.agentId){const $e={agentId:oe.agentId};oe.sessionId&&($e.sessionId=oe.sessionId),at.navigate(me.TEAM,$e)}else at.navigate(me.TEAM);break}case"direct_message":{const $e=oe.senderId;$e?at.navigate(me.TEAM,{dm:$e}):at.navigate(me.TEAM);break}case"group_message":{const $e=oe.channel;$e?at.navigate(me.TEAM,{channel:$e}):at.navigate(me.TEAM);break}default:oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):oe.projectId?at.navigate(me.WORK,{projectId:oe.projectId}):oe.agentId&&at.navigate(me.TEAM,{agentId:oe.agentId});break}},Xe=async R=>{R.read||ae(R.id);const oe=R.metadata??{},_e=oe.taskId,de=oe.requirementId;if(_e||de){const $e=y.filter(qe=>qe.id!==R.id&&!qe.read&&(_e&&qe.metadata?.taskId===_e||de&&qe.metadata?.requirementId===de));for(const qe of $e)ae(qe.id)}ze(R)},Ve=async(R,oe,_e,de,$e)=>{j(R);try{const{approval:qe}=await Ce.approvals.respond(R,oe,t,_e,de,$e);T(Le=>Le.map(Je=>Je.id===R?qe:Je)),O(null),D(null),W(Le=>{const Je={...Le};return delete Je[R],Je});const q=qe.details?.taskId,ie=qe.details?.requirementId,Ne=y.filter(Le=>!Le.read&&(Le.type==="approval_request"&&Le.metadata?.approvalId===R||q&&Le.metadata?.taskId===q||ie&&Le.metadata?.requirementId===ie));if(Ne.length>0){for(const Je of Ne)Ce.notifications.markRead(Je.id).catch(()=>{});const Le=new Set(Ne.map(Je=>Je.id));w(Je=>Je.map(vt=>Le.has(vt.id)?{...vt,read:!0}:vt)),U(Je=>Math.max(0,Je-Ne.length))}Wa("/approvals"),Wa("/notifications"),Wa("/tasks"),Wa("/taskboard"),Wa("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Oe(),800)}catch{}j(null)},et=async()=>{try{if(!t)return;await Ce.notifications.markAllRead(t),w(R=>R.map(oe=>({...oe,read:!0}))),U(0),Wa("/notifications")}catch{const R=be.filter(oe=>!oe.read);await Promise.all(R.map(oe=>Ce.notifications.markRead(oe.id))),w(oe=>oe.map(_e=>({..._e,read:!0}))),U(0),Wa("/notifications")}},yt=R=>{const oe=R.details?.subType;return oe==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):oe==="requirement"||R.details?.requirementId?m("team:notifications.approvalType.requirement"):oe==="task_review"?m("team:notifications.approvalType.taskReview"):oe==="task"||R.details?.taskId?m("team:notifications.approvalType.task"):R.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},pe=R=>{const oe=[];oe.push(R.agentName);const _e=R.details?.taskTitle,de=R.details?.taskId;_e?oe.push(_e):de&&oe.push(`Task ${de.slice(0,8)}`);const $e=R.details?.requirementId;return $e&&!de&&oe.push(`Req ${$e.slice(0,8)}`),oe.join(" · ")},V=[...N].sort((R,oe)=>new Date(oe.requestedAt).getTime()-new Date(R.requestedAt).getTime()),ye=V.filter(R=>R.status==="pending"),Qe=V.filter(R=>R.status!=="pending"),he=R=>{const oe=R.details?.taskId,_e=R.details?.requirementId,de=R.details?.agentId??R.agentId;oe?at.navigate(me.WORK,{openTask:oe}):_e?at.navigate(me.WORK,{openRequirement:_e}):de?at.navigate(me.TEAM,{agentId:de}):at.navigate(me.WORK)},ve=()=>{p(!1),r?.()},Ye=R=>s.jsxs("button",{disabled:C===R.id,onClick:()=>O(R),className:"w-full px-3 py-2 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center justify-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),m("team:userInput.respond",{defaultValue:"Respond"}),R.questions&&R.questions.length>1?` (${R.questions.length})`:""]}),nt=_?s.jsx(VV,{approval:_,submitting:C===_.id,readOnly:_.status!=="pending",onClose:()=>O(null),onSubmit:R=>Ve(_.id,R.approved,R.comment,R.selectedOption,R.answers)}):null,xt=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{x("approvals"),le.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.approvals"),ot>0?` (${ot})`:""]}),s.jsxs("button",{onClick:()=>{x("notifications"),le.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),Ge>0?` (${Ge})`:""]}),s.jsx("button",{onClick:ve,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&Z>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:et,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:G,className:"flex-1 overflow-y-auto",onScroll:R=>{if(g!=="notifications"||!Q||ke)return;const oe=R.currentTarget;oe.scrollTop+oe.clientHeight>=oe.scrollHeight-80&&We()},children:[g==="approvals"&&(N.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[ye.map(R=>{const oe=R.details?.command,_e=oe?R.description.replace(/\s*Command:.*$/,""):R.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>he(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[yt(R)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:yt(R)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Ar,{content:_e,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),oe&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:oe})]}),(()=>{if(gd(R))return Ye(R);const de=R.details?.subType,$e=de==="task"||de==="requirement"||de==="requirement_resubmit",qe=R.options&&R.options.length>0,q=(H[R.id]??"").trim();return qe?s.jsxs("div",{className:"space-y-1.5",children:[R.options.map((ie,Ne)=>s.jsxs("button",{disabled:C===R.id,onClick:()=>Ve(R.id,ie.id!=="reject",q||void 0,ie.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${ie.id==="reject"||ie.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:ie.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+Ne)}),ie.label]},ie.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&(H[R.id]??"").trim()&&Ve(R.id,!0,(H[R.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:C===R.id||!(H[R.id]??"").trim(),onClick:()=>Ve(R.id,!0,(H[R.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):$e?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:C===R.id,onClick:()=>Ve(R.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:C===R.id,onClick:()=>Ve(R.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),z!==R.id&&s.jsxs("button",{disabled:C===R.id,onClick:()=>D(R.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),z===R.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&(H[R.id]??"").trim()&&Ve(R.id,!1,(H[R.id]??"").trim(),"needs_adjustment"),ie.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===R.id||!(H[R.id]??"").trim(),onClick:()=>Ve(R.id,!1,(H[R.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&Ve(R.id,!0,q||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===R.id,onClick:()=>Ve(R.id,!0,q||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:C===R.id,onClick:()=>Ve(R.id,!1,q||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},R.id)}),Qe.length>0&&s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Qe.slice(0,50).map(R=>s.jsxs("button",{onClick:()=>gd(R)?O(R):he(R),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${R.status==="approved"?"bg-green-500":R.status==="cancelled"||R.status==="expired"?"bg-gray-400":"bg-red-500"}`}),yt(R)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:yt(R)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:R.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${R.status==="approved"?"text-green-500":R.status==="cancelled"||R.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${R.status}`,{defaultValue:R.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:pe(R)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(R.respondedAt??R.requestedAt,m)})]}),R.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",R.responseComment,"”"]})]},R.id))]})]})),g==="notifications"&&(be.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[be.map(R=>{const oe=u4[R.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Xe(R),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),Xe(R))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${R.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:oe,children:s.jsx("path",{d:So[R.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!R.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${bd[R.priority]??bd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Ar,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(R.createdAt,m)}),yd(R,m)&&s.jsx("span",{className:`text-[10px] font-medium ${oe}`,children:yd(R,m)})]})]})]},R.id)}),ke&&s.jsx("div",{className:"py-3 text-center",children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),Dt=k.useCallback(R=>{R?.mute&&qV()},[]),ct=k.useCallback(R=>{Dt(R),Ee(!1)},[Dt]),Xt=I?s.jsx(dr,{title:m("credits.dialogTitle",{ns:"common"}),message:m("credits.dialogDesc",{ns:"common"}),variant:"primary",cancelLabel:m("credits.configureModels",{ns:"common"}),confirmLabel:m("credits.topUp",{ns:"common"}),checkboxes:[{id:"mute",label:m("credits.dontRemind",{ns:"common"})}],onCancel:()=>Ee(!1),onCancelClick:R=>{ct(R),at.navigate(me.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:R=>{const oe=`${it.getUrl().replace(/\/$/,"")}/settings?tab=billing`;ct(R),Ro(oe)}}):null;if(n){const R=["approvals","notifications"],oe=R.indexOf(g),_e=(()=>{let de=0,$e=0;return{onTouchStart:qe=>{de=qe.touches[0].clientX,$e=qe.touches[0].clientY},onTouchEnd:qe=>{const q=qe.changedTouches[0].clientX-de,ie=qe.changedTouches[0].clientY-$e;Math.abs(q)>60&&Math.abs(q)>Math.abs(ie)*1.5&&(q<0&&oe<R.length-1&&x(R[oe+1]),q>0&&oe>0&&x(R[oe-1]))}}})();return s.jsxs(s.Fragment,{children:[Xt,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[nt,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:R.map(de=>s.jsx("button",{onClick:()=>x(de),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===de?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:de==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),ot>0?` (${ot})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),Ge>0?` (${Ge})`:""]})},de))}),g==="notifications"&&Z>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:et,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsx("div",{className:"flex-1 overflow-hidden relative",..._e,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${oe*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:N.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[ye.map(de=>{const $e=de.details?.command,qe=$e?de.description.replace(/\s*Command:.*$/,""):de.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>he(de),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[yt(de)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:yt(de)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(de.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:de.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Ar,{content:qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),$e&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:$e})]}),(()=>{if(gd(de))return Ye(de);const q=de.details?.subType,ie=q==="task"||q==="requirement"||q==="requirement_resubmit",Ne=de.options&&de.options.length>0,Le=(H[de.id]??"").trim();return Ne?s.jsxs("div",{className:"space-y-1.5",children:[de.options.map((Je,vt)=>s.jsxs("button",{disabled:C===de.id,onClick:()=>Ve(de.id,Je.id!=="reject",Le||void 0,Je.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${Je.id==="reject"||Je.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Je.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+vt)}),Je.label]},Je.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[de.id]??"",onChange:Je=>W(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&(H[de.id]??"").trim()&&Ve(de.id,!0,(H[de.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:C===de.id||!(H[de.id]??"").trim(),onClick:()=>Ve(de.id,!0,(H[de.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):ie?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:C===de.id,onClick:()=>Ve(de.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:C===de.id,onClick:()=>Ve(de.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),z!==de.id&&s.jsxs("button",{disabled:C===de.id,onClick:()=>D(de.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),z===de.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[de.id]??"",onChange:Je=>W(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&(H[de.id]??"").trim()&&Ve(de.id,!1,(H[de.id]??"").trim(),"needs_adjustment"),Je.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===de.id||!(H[de.id]??"").trim(),onClick:()=>Ve(de.id,!1,(H[de.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[de.id]??"",onChange:Je=>W(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&Ve(de.id,!0,Le||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===de.id,onClick:()=>Ve(de.id,!0,Le||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:C===de.id,onClick:()=>Ve(de.id,!1,Le||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},de.id)}),Qe.length>0&&s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Qe.slice(0,50).map(de=>s.jsxs("button",{onClick:()=>he(de),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${de.status==="approved"?"bg-green-500":de.status==="cancelled"||de.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:de.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${de.status==="approved"?"text-green-500":de.status==="cancelled"||de.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${de.status}`,{defaultValue:de.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:pe(de)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(de.respondedAt??de.requestedAt,m)})]})]},de.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:be.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsx("div",{className:"divide-y divide-border-default/50",children:be.slice(0,50).map(de=>{const $e=u4[de.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>Xe(de),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${de.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:$e,children:s.jsx("path",{d:So[de.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!de.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${bd[de.priority]??bd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Ar,{content:de.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(de.createdAt,m)}),yd(de,m)&&s.jsx("span",{className:`text-[10px] font-medium ${$e}`,children:yd(de,m)})]})]})]},de.id)})})})]})})]})]})}if(o){const R=d||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:Y,onClick:()=>{p(!h),h||Oe()},title:e?u||m("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors relative text-fg-primary ${h||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:R})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:u}):s.jsx("span",{className:"truncate",children:u}),mt>0&&s.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:mt>99?m("common:badgeOverLimit"):mt})]}),h&&Ja.createPortal(s.jsx("div",{ref:se,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:X.top,left:X.left,width:X.width,maxHeight:X.maxHeight},children:xt}),document.body),Xt]})}return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:Y,onClick:()=>{p(!h),h||Oe()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${h?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:m("team:notifications.bellTitle"),children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),mt>0&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:mt>99?m("common:badgeOverLimit"):mt})]}),h&&Ja.createPortal(s.jsx("div",{ref:se,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:X.top,left:X.left,width:X.width,maxHeight:X.maxHeight},children:xt}),document.body),Xt]})}function vd({d:e,size:t=14}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}const Vh=200;function YV({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:u}=ft(["nav","common"]),[d,m]=k.useState(!1),[h,p]=k.useState(!1),[g,x]=k.useState(()=>it.isAuthenticated()),[y,w]=k.useState(()=>ua()),[N,T]=k.useState({top:0,left:0}),C=k.useRef(null),j=k.useRef(null),_=k.useCallback(X=>{if(w(ua()),!it.isAuthenticated()){x(!1);return}if(!X?.validate){x(!0);return}t5().then(F=>{x(F),w(ua())})},[]);k.useEffect(()=>{_({validate:!0});const X=()=>_(),F=()=>_({validate:!0});return window.addEventListener("markus:hub-auth",X),window.addEventListener("focus",F),()=>{window.removeEventListener("markus:hub-auth",X),window.removeEventListener("focus",F)}},[_]);const O=k.useCallback(()=>{if(!C.current)return;const X=C.current.getBoundingClientRect(),F=window.innerWidth,J=window.innerHeight,B=j.current?.offsetHeight??220;let Q=X.right+8;Q+Vh>F-8&&(Q=Math.max(8,X.left-Vh-8));let re=X.top-B-8;re<8&&(re=Math.min(X.bottom+8,J-B-8)),T({top:Math.max(8,re),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const X=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(X)},[d,O,o]),k.useEffect(()=>{if(!d)return;const X=J=>{const B=J.target;C.current?.contains(B)||j.current?.contains(B)||m(!1)},F=()=>O();return document.addEventListener("mousedown",X),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",X),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[d,O]);const z=e?.name||y?.displayName||y?.username||u("common:userPlaceholder"),D=e?.email||y?.email||"",H=a5(e?.avatarUrl,y?.avatarUrl),W=g?"bg-emerald-500":"bg-fg-muted",Z=g?y?.username?u("sidebar.hubConnectedAs",{username:y.username}):u("sidebar.hubConnected"):u("sidebar.hubDisconnected"),U=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),Y=()=>{m(!1),_({validate:!0}),at.navigate(me.SETTINGS,{tab:"account"})},se=d&&Ja.createPortal(s.jsxs("div",{ref:j,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:N.top,left:N.left,width:Vh},children:[s.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:z}),D&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:D})]}),n&&s.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:u("common:profile.editProfile"),className:"shrink-0 mt-0.5 p-1.5 rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:s.jsx(vd,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),s.jsxs("button",{type:"button",onClick:Y,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${W}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:Z}),U&&y?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:u("sidebar.hubAccountMismatch",{username:y.username})})]}),s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-muted shrink-0",children:s.jsx("path",{d:"m9 18 6-6-6-6"})})]}),s.jsxs("div",{className:"py-1",children:[r&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),at.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:[s.jsx(vd,{d:cc[me.SETTINGS]}),u("settings")]}),window.markusDesktop&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),window.markusDesktop?.openInBrowser()},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{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"}),u("common:openInBrowser")]}),t&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),p(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),u("common:signOut")]})]})]}),document.body);return s.jsxs("div",{className:`relative ${o?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:C,type:"button",onClick:()=>m(X=>!X),title:z,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Us,{name:z,avatarUrl:H,size:o?28:32,fallback:"icon"}),s.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${W}`,title:Z})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.0-rc.4"]}),se,h&&t&&s.jsx(dr,{title:u("common:signOutConfirmTitle"),message:u("common:signOutConfirmMessage"),confirmLabel:u("common:signOut"),variant:"primary",onConfirm:()=>{p(!1),t()},onCancel:()=>p(!1)})]})}function XV({d:e,size:t=18}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}function QV({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l}){const{t:u}=ft(["nav","common"]);return s.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{className:`flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{onClick:o,title:u(r?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!r&&s.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),s.jsx("nav",{className:`${r?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:GO.map((d,m)=>{const h=VO.filter(g=>g.section===d.key);if(h.length===0)return null;const p=u(`sections.${d.key}`);return s.jsx("div",{children:s.jsxs("div",{className:m>0?"mt-3":"",children:[!r&&p&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:p}),r&&m>0&&s.jsx("div",{className:"my-3"}),h.map(g=>{if(g.id===me.NOTIFICATIONS)return s.jsx(WV,{sidebarMode:!0,collapsed:r,userId:n?.id,label:u(g.id),iconPath:cc[g.id],isActive:e===g.id},g.id);const x=e===g.id;return s.jsxs("button",{onClick:()=>t(g.id),title:r?u(g.id):void 0,className:`w-full flex items-center ${r?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${x?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(XV,{d:cc[g.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:u(g.id)}):s.jsx("span",{className:"truncate",children:u(g.id)})]},g.id)})]})},d.key)})}),s.jsx("div",{className:`shrink-0 border-t border-border-subtle ${r?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:s.jsx(YV,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const ZV=6e4;let Ps={},gi={};const Up=new Set,$p=new Set;let y3=0,ac=null,wd=0,Ld=null;function c0(){for(const e of Up)e()}async function Hp(){try{const e=await Ce.unread.getCounts();Ps=e.counts??{},gi=e.sessionAgentMap??{},c0()}catch{}}function JV(){ac||(Hp(),ac=setInterval(Hp,ZV),Ld=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!$p.has(t)&&Date.now()>y3&&(Ps[t]=(Ps[t]??0)+1,c0())}))}function eK(){ac&&(clearInterval(ac),ac=null),Ld&&(Ld(),Ld=null)}function tK(e){const t=e?.enabled??!0,[n,r]=k.useState(Ps),[o,l]=k.useState(gi),u=k.useCallback(async()=>{await Hp()},[]),d=k.useCallback(async w=>{const N=new Date().toISOString();delete Ps[w],c0();try{await Ce.unread.markRead(w,N)}catch{}},[]),m=k.useCallback(async()=>{Ps={},c0();try{await Ce.unread.markAllRead()}catch{}},[]),h=k.useCallback(w=>{$p.add(w)},[]),p=k.useCallback(w=>{$p.delete(w),y3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;wd++,JV();let w=gi;const N=()=>{r({...Ps}),w!==gi&&(w=gi,l({...gi}))};return Up.add(N),r({...Ps}),l({...gi}),()=>{Up.delete(N),wd--,wd<=0&&(wd=0,eK())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,N)=>w+N,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:u,setActiveKey:h,clearActiveKey:p}}function DW(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,o]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),u=e[l];u&&n.set(u,(n.get(u)??0)+o)}return n},[e,t])}function nK({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:u}=tK({enabled:!0}),d=k.useMemo(()=>{let h=0;for(const p of Object.values(u))h+=p;return h},[u]),m=k.useCallback(async()=>{try{const h=await Ce.notifications.list(n,!1);l(h.unreadCount??h.notifications.filter(p=>!p.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const h=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),p=()=>m();return window.addEventListener("markus:notifications-changed",p),()=>{clearInterval(h),window.removeEventListener("markus:notifications-changed",p)}},[m]),s.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:KO.map(h=>{const p=h.group.includes(e),g=h.id===me.NOTIFICATIONS,x=h.id===me.TEAM;return s.jsxs("button",{onClick:()=>t(h.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${p?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[s.jsxs("div",{className:"relative",children:[s.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:p?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:cc[h.id]})}),g&&o>0&&s.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:o>99?"99+":o}),x&&d>0&&s.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:d>99?"99+":d})]}),s.jsx("span",{className:`text-[10px] leading-tight ${p?"font-semibold":""}`,children:r(h.id)})]},h.id)})})}const u0=new Map;function pi(e,t){u0.has(e)||u0.set(e,t().catch(()=>{}))}function vi(e){const t=u0.get(e);return u0.delete(e),t}const Tr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Ti={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 Ko(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function v3(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 rK={agent:258,team:205,skill:32,connector:162};function Rg(e,t){const n=rK[e],r=v3(t),o=((n+(r%68-34))%360+360)%360,l=(o+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${o} 72% 56%), hsl(${l} 66% 43%))`}const f4=["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 w3(e){return f4[v3(e+"g")%f4.length]}function k3(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 aK(e){return!e||k3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function sK(e,t="user"){const n=t==="org"?"shapes":"thumbs",r=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${r}&radius=50&backgroundType=gradientLinear`}function Ao(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 h4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const p4={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"}},iK=["development","devops","management","productivity","browser","custom","general"],oK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],lK={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 Kh({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:u,readOnly:d}){if(d){const _=e||l,z=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:z,children:_}):n==="p"?s.jsx("p",{className:z,children:_}):s.jsx("span",{className:z,children:_})}const[m,h]=k.useState(!1),[p,g]=k.useState(e),x=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]);const y=()=>{h(!1),p!==e&&t(p)},w=()=>{g(e),h(!1)},N=_=>{_.key==="Escape"&&w(),_.key==="Enter"&&!u&&y()};if(m){const _=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return u?s.jsx("textarea",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:N,className:`${_} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:N,className:_,placeholder:l})}const T=e||l,C=!e,j="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T})}function cK({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,u]=k.useState(!1),[d,m]=k.useState(e),h=k.useRef(null),p=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>h.current?.focus(),0))},[l,e]);const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),u(!1)};return l?s.jsxs("div",{ref:p,className:"relative inline-block",children:[s.jsx("input",{ref:h,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&u(!1)},onBlur:y=>{p.current?.contains(y.relatedTarget)||x(d)},className:`${r??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:g.map(y=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):s.jsx("span",{onClick:()=>u(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function uK({tags:e,onChange:t,readOnly:n}){if(n)return s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(p=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:p},p))});const{t:r}=ft(["builder"]),[o,l]=k.useState(!1),[u,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const h=p=>{if((p.key==="Enter"||p.key===",")&&u.trim()){p.preventDefault();const g=u.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else p.key==="Backspace"&&!u&&e.length>0?t(e.slice(0,-1)):p.key==="Escape"&&(l(!1),d(""))};return o?s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ring-1 ring-brand-500/50 rounded px-2 py-1 -mx-1 min-h-[32px]",children:[e.map(p=>s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] bg-surface-elevated text-fg-secondary rounded-full px-2 py-0.5 border border-border-default",children:[p,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==p)),className:"text-fg-muted hover:text-red-500",children:"×"})]},p)),s.jsx("input",{ref:m,value:u,onChange:p=>d(p.target.value),onKeyDown:h,onBlur:()=>{u||l(!1)},className:"flex-1 min-w-[80px] bg-transparent text-xs text-fg-primary placeholder:text-fg-muted focus:outline-none",placeholder:r("detail.typeTagAndEnter")})]}):s.jsx("div",{onClick:()=>l(!0),className:"flex flex-wrap items-center gap-1.5 cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 py-0.5 transition-all min-h-[24px]",children:e.length>0?e.map(p=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:p},p)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function Fp({content:e}){return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
657
|
+
`)||void 0;o({approved:D,comment:W,selectedOption:H,answers:z})};return Ja.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:z=>{z.target===z.currentTarget&&r()},children:s.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[s.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),s.jsx("path",{d:"M12 8v4"}),s.jsx("path",{d:"M12 16h.01"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),s.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:l("common:close"),children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&s.jsx("div",{className:"flex items-center gap-2",children:u.map((z,D)=>s.jsx("button",{onClick:()=>m(D),className:`h-1.5 flex-1 rounded-full transition-colors ${D===d?"bg-brand-500":C(z)?"bg-green-500/60":"bg-border-default"}`,title:`${D+1}. ${z.prompt.slice(0,40)}`},z.id))}),y&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:u.length,defaultValue:`Question ${d+1} of ${u.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Ar,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((z,D)=>{const H=w(g.id).selectedOptionIds.includes(z.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,z.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${H?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!H?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${H?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:H?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+D)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Ar,{content:z.label}),z.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Ar,{content:z.description})})]})]},z.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&s.jsx("textarea",{rows:g.inputType==="text"?4:2,readOnly:n,placeholder:g.inputType==="text"?l("team:userInput.textPlaceholder",{defaultValue:"Type your answer…"}):l("team:userInput.freeformPlaceholder",{defaultValue:"Or write your own answer…"}),value:w(g.id).text,onChange:z=>{const D=z.target.value;N(g.id,{text:D,selectedOptionIds:D.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:y&&d>0&&s.jsx("button",{onClick:()=>m(z=>Math.max(0,z-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("team:userInput.previous",{defaultValue:"Previous"})})}),s.jsx("div",{className:"flex items-center gap-2",children:y&&!x?s.jsx("button",{disabled:!n&&!C(g),onClick:()=>m(z=>Math.min(u.length-1,z+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:l("team:userInput.next",{defaultValue:"Next"})}):n?s.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("common:close",{defaultValue:"Close"})}):s.jsxs("button",{disabled:t||!j,onClick:O,className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[t&&s.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l("team:userInput.submit",{defaultValue:"Submit"})]})})]})]})}),document.body)}function gd(e){return Array.isArray(e.questions)&&e.questions.length>0}const bd={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},So={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},u4={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function No(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}const d4="markus:template-updates-ack";let qh=!1,xd=null;function KV(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function m4(e,t){if(e.type!=="system"||!e.metadata?.templateUpdates)return!1;if(!t)return!0;const n=e.metadata.templateUpdatesFingerprint;return!n||n===t}function yd(e,t){const n=e.actionType;if(n==="open_chat")return t("team:notifications.actionHints.openChat");if(n==="navigate")return t("team:notifications.actionHints.viewDetails");const r=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return r.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return r.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return r.agentId?t("team:notifications.actionHints.viewAgent"):null;case"direct_message":return t("team:notifications.actionHints.openChat");case"group_message":return t("team:notifications.actionHints.openChat");case"approval_request":return t("team:notifications.actionHints.viewApproval");case"system":return r.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return r.taskId?t("team:notifications.actionHints.viewTask"):r.requirementId?t("team:notifications.actionHints.viewRequirement"):r.agentId?t("team:notifications.actionHints.viewAgent"):null}}function Gh(){try{const e=new AudioContext,t=e.currentTime,n=e.createGain();n.connect(e.destination),n.gain.setValueAtTime(.15,t),n.gain.exponentialRampToValueAtTime(.01,t+.6);const r=e.createOscillator();r.type="sine",r.frequency.setValueAtTime(880,t),r.frequency.setValueAtTime(1174.66,t+.15),r.connect(n),r.start(t),r.stop(t+.6),r.onended=()=>e.close()}catch{}}function WV({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:u,iconPath:d}){const{t:m}=ft(["team","common"]),[h,p]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[N,T]=k.useState([]),[C,j]=k.useState(null),[_,O]=k.useState(null),[z,D]=k.useState(null),[H,W]=k.useState({}),[Z,U]=k.useState(0),Y=k.useRef(null),se=k.useRef(null),[X,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),J=k.useRef(null),B=k.useRef(!1),[Q,re]=k.useState(!0),[ke,$]=k.useState(!1),G=k.useRef(null),le=k.useRef("approvals"),[I,Ee]=k.useState(!1),Ue=30,Oe=k.useCallback(async()=>{try{Wa("/approvals"),Wa("/notifications");const[R,oe]=await Promise.all([Ce.notifications.list(t,!1,{limit:Ue,offset:0}),Ce.approvals.list()]);w(R.notifications);const _e=R.unreadCount??R.notifications.filter(de=>!de.read).length;if(U(_e),re(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=Ue),T(oe.approvals),!B.current){const de=oe.approvals.filter($e=>$e.status==="pending").length;J.current=de,B.current=!0}}catch{}},[t]),We=k.useCallback(async()=>{if(!(ke||!Q)){$(!0);try{const R=await Ce.notifications.list(t,!1,{limit:Ue,offset:y.length});R.notifications.length>0&&w(oe=>[...oe,...R.notifications.filter(_e=>!oe.some(de=>de.id===_e.id))]),re(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=Ue)}catch{}$(!1)}},[t,y.length,ke,Q]),st=k.useCallback(R=>{const oe=R.detail;if(!oe)return;const{taskId:_e,requirementId:de}=oe;!_e&&!de||w($e=>{const qe=$e.filter(q=>!q.read&&(_e&&q.metadata?.taskId===_e||de&&q.metadata?.requirementId===de));if(qe.length===0)return $e;for(const q of qe)Ce.notifications.markRead(q.id).catch(()=>{});return U(q=>Math.max(0,q-qe.length)),$e.map(q=>qe.some(ie=>ie.id===q.id)?{...q,read:!0}:q)})},[]),dt=k.useRef(y);dt.current=y;const Et=k.useCallback(async()=>{if(!dt.current.some(oe=>!oe.read&&oe.type==="system"&&oe.metadata?.creditExhausted))try{await Ce.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),Oe(),Gh()}catch{}},[Oe,m]),gt=k.useCallback(async()=>{if(!qh){qh=!0;try{const{updates:R}=await Ce.skills.updates();if(!R.length)return;const oe=KV(R);try{if(localStorage.getItem(d4)===oe)return}catch{}if(xd===oe||dt.current.some(de=>!de.read&&m4(de,oe)))return;try{const $e=(await Ce.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(qe=>m4(qe,oe)).sort((qe,q)=>new Date(q.createdAt).getTime()-new Date(qe.createdAt).getTime());if($e.length>0){for(const qe of $e.slice(1))Ce.notifications.markRead(qe.id).catch(()=>{});$e.length>1&&Oe(),xd=oe;return}}catch{}xd=oe,await Ce.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:R.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:oe,count:R.length,skills:R.map(de=>de.name)}}),Oe(),Gh()}catch{xd=null}finally{qh=!1}}},[Oe,m,t]);k.useEffect(()=>{Oe();const R=setInterval(Oe,6e4);let oe=null;const _e=()=>{oe||(oe=setTimeout(()=>{oe=null,Oe()},400))},de=()=>_e(),$e=()=>{p(!0),Oe()};window.addEventListener("markus:notifications-changed",de),window.addEventListener("markus:mark-read-by-ref",st),window.addEventListener("markus:open-notifications",$e),window.addEventListener("markus:credit-exhausted",Et);const qe=va.on("notification",_e),q=va.on("approval:requested",_e);return()=>{clearInterval(R),oe&&clearTimeout(oe),window.removeEventListener("markus:notifications-changed",de),window.removeEventListener("markus:mark-read-by-ref",st),window.removeEventListener("markus:open-notifications",$e),window.removeEventListener("markus:credit-exhausted",Et),qe(),q()}},[Oe,st,Et]),k.useEffect(()=>{gt();const R=setInterval(()=>{gt()},5*6e4),oe=()=>{gt()};return window.addEventListener("markus:data-changed",oe),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",oe)}},[t]);const jt=k.useCallback(()=>{if(!Y.current)return;const R=Y.current.getBoundingClientRect(),oe=window.innerWidth,_e=window.innerHeight,de=Math.min(448,oe-16),$e=Math.min(576,_e-16);let qe=R.right+8,q=R.top;qe+de>oe-8&&(qe=Math.max(8,oe-de-8)),q+$e>_e-8&&(q=Math.max(8,_e-$e-8)),F({top:q,left:qe,width:de,maxHeight:$e})},[]);k.useLayoutEffect(()=>{h&&jt()},[h,jt]),k.useEffect(()=>{if(h)return window.addEventListener("resize",jt),()=>window.removeEventListener("resize",jt)},[h,jt]),k.useEffect(()=>{if(!h)return;const R=oe=>{Y.current?.contains(oe.target)||se.current?.contains(oe.target)||p(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[h]),k.useEffect(()=>{if(!h)return;const R=N.some(_e=>_e.status==="pending"),oe=y.some(_e=>!_e.read);x(R&&!oe?"approvals":!R&&oe?"notifications":le.current)},[h]);const Jt=new Set(N.filter(R=>R.status==="pending").map(R=>R.id)),Rt=new Set(N.map(R=>R.id)),be=y.filter(R=>!(R.type==="approval_request"&&R.metadata?.approvalId&&Rt.has(R.metadata.approvalId))),Me=y.filter(R=>R.type==="approval_request"&&!R.read&&R.metadata?.approvalId&&Jt.has(R.metadata.approvalId)).length,Ge=Math.max(0,Z-Me),ot=Jt.size,mt=Ge+ot;k.useEffect(()=>{J.current!==null&&ot>J.current&&Gh(),J.current=ot},[ot]);const ae=async R=>{await Ce.notifications.markRead(R),w(oe=>oe.map(_e=>_e.id===R?{..._e,read:!0}:_e)),U(oe=>Math.max(0,oe-1))},ze=R=>{const oe=R.metadata??{},_e=R.actionType,de=R.actionTarget;if(_e==="open_chat"&&de)try{const $e=typeof de=="string"?JSON.parse(de):de;if($e.agentId){const qe={agentId:$e.agentId};$e.sessionId&&(qe.sessionId=$e.sessionId),at.navigate(me.TEAM,qe);return}}catch{}if(_e==="navigate"&&de)try{const $e=typeof de=="string"?JSON.parse(de):de;if($e.path){if($e.path.startsWith("/team")){const qe={},q=new URLSearchParams($e.path.split("?")[1]||"");for(const[ie,Ne]of q.entries())qe[ie]=Ne;at.navigate(me.TEAM,qe);return}if($e.path.startsWith("/work")){const qe={},q=new URLSearchParams($e.path.split("?")[1]||"");for(const[ie,Ne]of q.entries())qe[ie]=Ne;at.navigate(me.WORK,qe);return}}}catch{}switch(R.type){case"approval_request":{const $e=oe.approvalId,qe=$e?N.find(Le=>Le.id===$e):void 0;if(qe&&gd(qe)){O(qe);break}const q=qe?.details?.taskId??oe.taskId,ie=qe?.details?.requirementId??oe.requirementId,Ne=qe?.details?.agentId??qe?.agentId;q?at.navigate(me.WORK,{openTask:q}):ie?at.navigate(me.WORK,{openRequirement:ie}):Ne?at.navigate(me.TEAM,{agentId:Ne}):at.navigate(me.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):at.navigate(me.WORK);break;case"requirement_created":case"requirement_decision":oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):at.navigate(me.WORK);break;case"agent_report":case"system":{if(oe.creditExhausted){Ee(!0);return}if(oe.templateUpdates){const $e=oe.templateUpdatesFingerprint;if($e)try{localStorage.setItem(d4,$e)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(me.STORE);return}if(oe.agentId){const $e={agentId:oe.agentId};oe.sessionId&&($e.sessionId=oe.sessionId),at.navigate(me.TEAM,$e)}else at.navigate(me.TEAM);break}case"direct_message":{const $e=oe.senderId;$e?at.navigate(me.TEAM,{dm:$e}):at.navigate(me.TEAM);break}case"group_message":{const $e=oe.channel;$e?at.navigate(me.TEAM,{channel:$e}):at.navigate(me.TEAM);break}default:oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):oe.projectId?at.navigate(me.WORK,{projectId:oe.projectId}):oe.agentId&&at.navigate(me.TEAM,{agentId:oe.agentId});break}},Xe=async R=>{R.read||ae(R.id);const oe=R.metadata??{},_e=oe.taskId,de=oe.requirementId;if(_e||de){const $e=y.filter(qe=>qe.id!==R.id&&!qe.read&&(_e&&qe.metadata?.taskId===_e||de&&qe.metadata?.requirementId===de));for(const qe of $e)ae(qe.id)}ze(R)},Ve=async(R,oe,_e,de,$e)=>{j(R);try{const{approval:qe}=await Ce.approvals.respond(R,oe,t,_e,de,$e);T(Le=>Le.map(Je=>Je.id===R?qe:Je)),O(null),D(null),W(Le=>{const Je={...Le};return delete Je[R],Je});const q=qe.details?.taskId,ie=qe.details?.requirementId,Ne=y.filter(Le=>!Le.read&&(Le.type==="approval_request"&&Le.metadata?.approvalId===R||q&&Le.metadata?.taskId===q||ie&&Le.metadata?.requirementId===ie));if(Ne.length>0){for(const Je of Ne)Ce.notifications.markRead(Je.id).catch(()=>{});const Le=new Set(Ne.map(Je=>Je.id));w(Je=>Je.map(vt=>Le.has(vt.id)?{...vt,read:!0}:vt)),U(Je=>Math.max(0,Je-Ne.length))}Wa("/approvals"),Wa("/notifications"),Wa("/tasks"),Wa("/taskboard"),Wa("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Oe(),800)}catch{}j(null)},et=async()=>{try{if(!t)return;await Ce.notifications.markAllRead(t),w(R=>R.map(oe=>({...oe,read:!0}))),U(0),Wa("/notifications")}catch{const R=be.filter(oe=>!oe.read);await Promise.all(R.map(oe=>Ce.notifications.markRead(oe.id))),w(oe=>oe.map(_e=>({..._e,read:!0}))),U(0),Wa("/notifications")}},yt=R=>{const oe=R.details?.subType;return oe==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):oe==="requirement"||R.details?.requirementId?m("team:notifications.approvalType.requirement"):oe==="task_review"?m("team:notifications.approvalType.taskReview"):oe==="task"||R.details?.taskId?m("team:notifications.approvalType.task"):R.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},pe=R=>{const oe=[];oe.push(R.agentName);const _e=R.details?.taskTitle,de=R.details?.taskId;_e?oe.push(_e):de&&oe.push(`Task ${de.slice(0,8)}`);const $e=R.details?.requirementId;return $e&&!de&&oe.push(`Req ${$e.slice(0,8)}`),oe.join(" · ")},V=[...N].sort((R,oe)=>new Date(oe.requestedAt).getTime()-new Date(R.requestedAt).getTime()),ye=V.filter(R=>R.status==="pending"),Qe=V.filter(R=>R.status!=="pending"),he=R=>{const oe=R.details?.taskId,_e=R.details?.requirementId,de=R.details?.agentId??R.agentId;oe?at.navigate(me.WORK,{openTask:oe}):_e?at.navigate(me.WORK,{openRequirement:_e}):de?at.navigate(me.TEAM,{agentId:de}):at.navigate(me.WORK)},ve=()=>{p(!1),r?.()},Ye=R=>s.jsxs("button",{disabled:C===R.id,onClick:()=>O(R),className:"w-full px-3 py-2 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center justify-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),m("team:userInput.respond",{defaultValue:"Respond"}),R.questions&&R.questions.length>1?` (${R.questions.length})`:""]}),nt=_?s.jsx(VV,{approval:_,submitting:C===_.id,readOnly:_.status!=="pending",onClose:()=>O(null),onSubmit:R=>Ve(_.id,R.approved,R.comment,R.selectedOption,R.answers)}):null,xt=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{x("approvals"),le.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.approvals"),ot>0?` (${ot})`:""]}),s.jsxs("button",{onClick:()=>{x("notifications"),le.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),Ge>0?` (${Ge})`:""]}),s.jsx("button",{onClick:ve,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&Z>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:et,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:G,className:"flex-1 overflow-y-auto",onScroll:R=>{if(g!=="notifications"||!Q||ke)return;const oe=R.currentTarget;oe.scrollTop+oe.clientHeight>=oe.scrollHeight-80&&We()},children:[g==="approvals"&&(N.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[ye.map(R=>{const oe=R.details?.command,_e=oe?R.description.replace(/\s*Command:.*$/,""):R.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>he(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[yt(R)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:yt(R)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Ar,{content:_e,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),oe&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:oe})]}),(()=>{if(gd(R))return Ye(R);const de=R.details?.subType,$e=de==="task"||de==="requirement"||de==="requirement_resubmit",qe=R.options&&R.options.length>0,q=(H[R.id]??"").trim();return qe?s.jsxs("div",{className:"space-y-1.5",children:[R.options.map((ie,Ne)=>s.jsxs("button",{disabled:C===R.id,onClick:()=>Ve(R.id,ie.id!=="reject",q||void 0,ie.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${ie.id==="reject"||ie.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:ie.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+Ne)}),ie.label]},ie.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&(H[R.id]??"").trim()&&Ve(R.id,!0,(H[R.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:C===R.id||!(H[R.id]??"").trim(),onClick:()=>Ve(R.id,!0,(H[R.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):$e?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:C===R.id,onClick:()=>Ve(R.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:C===R.id,onClick:()=>Ve(R.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),z!==R.id&&s.jsxs("button",{disabled:C===R.id,onClick:()=>D(R.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),z===R.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&(H[R.id]??"").trim()&&Ve(R.id,!1,(H[R.id]??"").trim(),"needs_adjustment"),ie.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===R.id||!(H[R.id]??"").trim(),onClick:()=>Ve(R.id,!1,(H[R.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Ne=>({...Ne,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&Ve(R.id,!0,q||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===R.id,onClick:()=>Ve(R.id,!0,q||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:C===R.id,onClick:()=>Ve(R.id,!1,q||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},R.id)}),Qe.length>0&&s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Qe.slice(0,50).map(R=>s.jsxs("button",{onClick:()=>gd(R)?O(R):he(R),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${R.status==="approved"?"bg-green-500":R.status==="cancelled"||R.status==="expired"?"bg-gray-400":"bg-red-500"}`}),yt(R)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:yt(R)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:R.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${R.status==="approved"?"text-green-500":R.status==="cancelled"||R.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${R.status}`,{defaultValue:R.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:pe(R)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(R.respondedAt??R.requestedAt,m)})]}),R.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",R.responseComment,"”"]})]},R.id))]})]})),g==="notifications"&&(be.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[be.map(R=>{const oe=u4[R.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Xe(R),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),Xe(R))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${R.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:oe,children:s.jsx("path",{d:So[R.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!R.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${bd[R.priority]??bd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Ar,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(R.createdAt,m)}),yd(R,m)&&s.jsx("span",{className:`text-[10px] font-medium ${oe}`,children:yd(R,m)})]})]})]},R.id)}),ke&&s.jsx("div",{className:"py-3 text-center",children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),Dt=k.useCallback(R=>{R?.mute&&qV()},[]),ct=k.useCallback(R=>{Dt(R),Ee(!1)},[Dt]),Xt=I?s.jsx(dr,{title:m("credits.dialogTitle",{ns:"common"}),message:m("credits.dialogDesc",{ns:"common"}),variant:"primary",cancelLabel:m("credits.configureModels",{ns:"common"}),confirmLabel:m("credits.topUp",{ns:"common"}),checkboxes:[{id:"mute",label:m("credits.dontRemind",{ns:"common"})}],onCancel:()=>Ee(!1),onCancelClick:R=>{ct(R),at.navigate(me.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:R=>{const oe=`${it.getUrl().replace(/\/$/,"")}/settings?tab=billing`;ct(R),Ro(oe)}}):null;if(n){const R=["approvals","notifications"],oe=R.indexOf(g),_e=(()=>{let de=0,$e=0;return{onTouchStart:qe=>{de=qe.touches[0].clientX,$e=qe.touches[0].clientY},onTouchEnd:qe=>{const q=qe.changedTouches[0].clientX-de,ie=qe.changedTouches[0].clientY-$e;Math.abs(q)>60&&Math.abs(q)>Math.abs(ie)*1.5&&(q<0&&oe<R.length-1&&x(R[oe+1]),q>0&&oe>0&&x(R[oe-1]))}}})();return s.jsxs(s.Fragment,{children:[Xt,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[nt,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:R.map(de=>s.jsx("button",{onClick:()=>x(de),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===de?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:de==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),ot>0?` (${ot})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),Ge>0?` (${Ge})`:""]})},de))}),g==="notifications"&&Z>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:et,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsx("div",{className:"flex-1 overflow-hidden relative",..._e,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${oe*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:N.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[ye.map(de=>{const $e=de.details?.command,qe=$e?de.description.replace(/\s*Command:.*$/,""):de.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>he(de),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[yt(de)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:yt(de)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(de.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:de.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Ar,{content:qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),$e&&s.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:$e})]}),(()=>{if(gd(de))return Ye(de);const q=de.details?.subType,ie=q==="task"||q==="requirement"||q==="requirement_resubmit",Ne=de.options&&de.options.length>0,Le=(H[de.id]??"").trim();return Ne?s.jsxs("div",{className:"space-y-1.5",children:[de.options.map((Je,vt)=>s.jsxs("button",{disabled:C===de.id,onClick:()=>Ve(de.id,Je.id!=="reject",Le||void 0,Je.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${Je.id==="reject"||Je.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Je.description,children:[s.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+vt)}),Je.label]},Je.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[de.id]??"",onChange:Je=>W(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&(H[de.id]??"").trim()&&Ve(de.id,!0,(H[de.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:C===de.id||!(H[de.id]??"").trim(),onClick:()=>Ve(de.id,!0,(H[de.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):ie?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:C===de.id,onClick:()=>Ve(de.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:C===de.id,onClick:()=>Ve(de.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),z!==de.id&&s.jsxs("button",{disabled:C===de.id,onClick:()=>D(de.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),z===de.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[de.id]??"",onChange:Je=>W(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&(H[de.id]??"").trim()&&Ve(de.id,!1,(H[de.id]??"").trim(),"needs_adjustment"),Je.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===de.id||!(H[de.id]??"").trim(),onClick:()=>Ve(de.id,!1,(H[de.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[de.id]??"",onChange:Je=>W(vt=>({...vt,[de.id]:Je.target.value})),onKeyDown:Je=>{Je.key==="Enter"&&Ve(de.id,!0,Le||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===de.id,onClick:()=>Ve(de.id,!0,Le||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:m("common:approve")}),s.jsx("button",{disabled:C===de.id,onClick:()=>Ve(de.id,!1,Le||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:m("common:reject")})]})]})})()]},de.id)}),Qe.length>0&&s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),Qe.slice(0,50).map(de=>s.jsxs("button",{onClick:()=>he(de),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${de.status==="approved"?"bg-green-500":de.status==="cancelled"||de.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:de.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${de.status==="approved"?"text-green-500":de.status==="cancelled"||de.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${de.status}`,{defaultValue:de.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:pe(de)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(de.respondedAt??de.requestedAt,m)})]})]},de.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:be.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsx("div",{className:"divide-y divide-border-default/50",children:be.slice(0,50).map(de=>{const $e=u4[de.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>Xe(de),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${de.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:$e,children:s.jsx("path",{d:So[de.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!de.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${bd[de.priority]??bd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Ar,{content:de.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(de.createdAt,m)}),yd(de,m)&&s.jsx("span",{className:`text-[10px] font-medium ${$e}`,children:yd(de,m)})]})]})]},de.id)})})})]})})]})]})}if(o){const R=d||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:Y,onClick:()=>{p(!h),h||Oe()},title:e?u||m("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors relative text-fg-primary ${h||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:R})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:u}):s.jsx("span",{className:"truncate",children:u}),mt>0&&s.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:mt>99?m("common:badgeOverLimit"):mt})]}),h&&Ja.createPortal(s.jsx("div",{ref:se,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:X.top,left:X.left,width:X.width,maxHeight:X.maxHeight},children:xt}),document.body),Xt]})}return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:Y,onClick:()=>{p(!h),h||Oe()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${h?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:m("team:notifications.bellTitle"),children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),mt>0&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:mt>99?m("common:badgeOverLimit"):mt})]}),h&&Ja.createPortal(s.jsx("div",{ref:se,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:X.top,left:X.left,width:X.width,maxHeight:X.maxHeight},children:xt}),document.body),Xt]})}function vd({d:e,size:t=14}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}const Vh=200;function YV({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:u}=ft(["nav","common"]),[d,m]=k.useState(!1),[h,p]=k.useState(!1),[g,x]=k.useState(()=>it.isAuthenticated()),[y,w]=k.useState(()=>ua()),[N,T]=k.useState({top:0,left:0}),C=k.useRef(null),j=k.useRef(null),_=k.useCallback(X=>{if(w(ua()),!it.isAuthenticated()){x(!1);return}if(!X?.validate){x(!0);return}t5().then(F=>{x(F),w(ua())})},[]);k.useEffect(()=>{_({validate:!0});const X=()=>_(),F=()=>_({validate:!0});return window.addEventListener("markus:hub-auth",X),window.addEventListener("focus",F),()=>{window.removeEventListener("markus:hub-auth",X),window.removeEventListener("focus",F)}},[_]);const O=k.useCallback(()=>{if(!C.current)return;const X=C.current.getBoundingClientRect(),F=window.innerWidth,J=window.innerHeight,B=j.current?.offsetHeight??220;let Q=X.right+8;Q+Vh>F-8&&(Q=Math.max(8,X.left-Vh-8));let re=X.top-B-8;re<8&&(re=Math.min(X.bottom+8,J-B-8)),T({top:Math.max(8,re),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const X=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(X)},[d,O,o]),k.useEffect(()=>{if(!d)return;const X=J=>{const B=J.target;C.current?.contains(B)||j.current?.contains(B)||m(!1)},F=()=>O();return document.addEventListener("mousedown",X),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",X),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[d,O]);const z=e?.name||y?.displayName||y?.username||u("common:userPlaceholder"),D=e?.email||y?.email||"",H=a5(e?.avatarUrl,y?.avatarUrl),W=g?"bg-emerald-500":"bg-fg-muted",Z=g?y?.username?u("sidebar.hubConnectedAs",{username:y.username}):u("sidebar.hubConnected"):u("sidebar.hubDisconnected"),U=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),Y=()=>{m(!1),_({validate:!0}),at.navigate(me.SETTINGS,{tab:"account"})},se=d&&Ja.createPortal(s.jsxs("div",{ref:j,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:N.top,left:N.left,width:Vh},children:[s.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:z}),D&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:D})]}),n&&s.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:u("common:profile.editProfile"),className:"shrink-0 mt-0.5 p-1.5 rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:s.jsx(vd,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),s.jsxs("button",{type:"button",onClick:Y,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${W}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:Z}),U&&y?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:u("sidebar.hubAccountMismatch",{username:y.username})})]}),s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-muted shrink-0",children:s.jsx("path",{d:"m9 18 6-6-6-6"})})]}),s.jsxs("div",{className:"py-1",children:[r&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),at.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:[s.jsx(vd,{d:cc[me.SETTINGS]}),u("settings")]}),window.markusDesktop&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),window.markusDesktop?.openInBrowser()},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{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"}),u("common:openInBrowser")]}),t&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),p(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),u("common:signOut")]})]})]}),document.body);return s.jsxs("div",{className:`relative ${o?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:C,type:"button",onClick:()=>m(X=>!X),title:z,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Us,{name:z,avatarUrl:H,size:o?28:32,fallback:"icon"}),s.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${W}`,title:Z})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.0-rc.5"]}),se,h&&t&&s.jsx(dr,{title:u("common:signOutConfirmTitle"),message:u("common:signOutConfirmMessage"),confirmLabel:u("common:signOut"),variant:"primary",onConfirm:()=>{p(!1),t()},onCancel:()=>p(!1)})]})}function XV({d:e,size:t=18}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}function QV({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l}){const{t:u}=ft(["nav","common"]);return s.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{className:`flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{onClick:o,title:u(r?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!r&&s.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),s.jsx("nav",{className:`${r?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:GO.map((d,m)=>{const h=VO.filter(g=>g.section===d.key);if(h.length===0)return null;const p=u(`sections.${d.key}`);return s.jsx("div",{children:s.jsxs("div",{className:m>0?"mt-3":"",children:[!r&&p&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:p}),r&&m>0&&s.jsx("div",{className:"my-3"}),h.map(g=>{if(g.id===me.NOTIFICATIONS)return s.jsx(WV,{sidebarMode:!0,collapsed:r,userId:n?.id,label:u(g.id),iconPath:cc[g.id],isActive:e===g.id},g.id);const x=e===g.id;return s.jsxs("button",{onClick:()=>t(g.id),title:r?u(g.id):void 0,className:`w-full flex items-center ${r?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${x?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(XV,{d:cc[g.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:u(g.id)}):s.jsx("span",{className:"truncate",children:u(g.id)})]},g.id)})]})},d.key)})}),s.jsx("div",{className:`shrink-0 border-t border-border-subtle ${r?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:s.jsx(YV,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const ZV=6e4;let Ps={},gi={};const Up=new Set,$p=new Set;let y3=0,ac=null,wd=0,Ld=null;function c0(){for(const e of Up)e()}async function Hp(){try{const e=await Ce.unread.getCounts();Ps=e.counts??{},gi=e.sessionAgentMap??{},c0()}catch{}}function JV(){ac||(Hp(),ac=setInterval(Hp,ZV),Ld=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!$p.has(t)&&Date.now()>y3&&(Ps[t]=(Ps[t]??0)+1,c0())}))}function eK(){ac&&(clearInterval(ac),ac=null),Ld&&(Ld(),Ld=null)}function tK(e){const t=e?.enabled??!0,[n,r]=k.useState(Ps),[o,l]=k.useState(gi),u=k.useCallback(async()=>{await Hp()},[]),d=k.useCallback(async w=>{const N=new Date().toISOString();delete Ps[w],c0();try{await Ce.unread.markRead(w,N)}catch{}},[]),m=k.useCallback(async()=>{Ps={},c0();try{await Ce.unread.markAllRead()}catch{}},[]),h=k.useCallback(w=>{$p.add(w)},[]),p=k.useCallback(w=>{$p.delete(w),y3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;wd++,JV();let w=gi;const N=()=>{r({...Ps}),w!==gi&&(w=gi,l({...gi}))};return Up.add(N),r({...Ps}),l({...gi}),()=>{Up.delete(N),wd--,wd<=0&&(wd=0,eK())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,N)=>w+N,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:u,setActiveKey:h,clearActiveKey:p}}function DW(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,o]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),u=e[l];u&&n.set(u,(n.get(u)??0)+o)}return n},[e,t])}function nK({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:u}=tK({enabled:!0}),d=k.useMemo(()=>{let h=0;for(const p of Object.values(u))h+=p;return h},[u]),m=k.useCallback(async()=>{try{const h=await Ce.notifications.list(n,!1);l(h.unreadCount??h.notifications.filter(p=>!p.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const h=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),p=()=>m();return window.addEventListener("markus:notifications-changed",p),()=>{clearInterval(h),window.removeEventListener("markus:notifications-changed",p)}},[m]),s.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:KO.map(h=>{const p=h.group.includes(e),g=h.id===me.NOTIFICATIONS,x=h.id===me.TEAM;return s.jsxs("button",{onClick:()=>t(h.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${p?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[s.jsxs("div",{className:"relative",children:[s.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:p?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:cc[h.id]})}),g&&o>0&&s.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:o>99?"99+":o}),x&&d>0&&s.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:d>99?"99+":d})]}),s.jsx("span",{className:`text-[10px] leading-tight ${p?"font-semibold":""}`,children:r(h.id)})]},h.id)})})}const u0=new Map;function pi(e,t){u0.has(e)||u0.set(e,t().catch(()=>{}))}function vi(e){const t=u0.get(e);return u0.delete(e),t}const Tr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Ti={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 Ko(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function v3(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 rK={agent:258,team:205,skill:32,connector:162};function Rg(e,t){const n=rK[e],r=v3(t),o=((n+(r%68-34))%360+360)%360,l=(o+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${o} 72% 56%), hsl(${l} 66% 43%))`}const f4=["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 w3(e){return f4[v3(e+"g")%f4.length]}function k3(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 aK(e){return!e||k3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function sK(e,t="user"){const n=t==="org"?"shapes":"thumbs",r=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${r}&radius=50&backgroundType=gradientLinear`}function Ao(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 h4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const p4={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"}},iK=["development","devops","management","productivity","browser","custom","general"],oK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],lK={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 Kh({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:u,readOnly:d}){if(d){const _=e||l,z=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:z,children:_}):n==="p"?s.jsx("p",{className:z,children:_}):s.jsx("span",{className:z,children:_})}const[m,h]=k.useState(!1),[p,g]=k.useState(e),x=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]);const y=()=>{h(!1),p!==e&&t(p)},w=()=>{g(e),h(!1)},N=_=>{_.key==="Escape"&&w(),_.key==="Enter"&&!u&&y()};if(m){const _=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return u?s.jsx("textarea",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:N,className:`${_} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:N,className:_,placeholder:l})}const T=e||l,C=!e,j="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T})}function cK({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,u]=k.useState(!1),[d,m]=k.useState(e),h=k.useRef(null),p=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>h.current?.focus(),0))},[l,e]);const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),u(!1)};return l?s.jsxs("div",{ref:p,className:"relative inline-block",children:[s.jsx("input",{ref:h,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&u(!1)},onBlur:y=>{p.current?.contains(y.relatedTarget)||x(d)},className:`${r??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:g.map(y=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):s.jsx("span",{onClick:()=>u(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function uK({tags:e,onChange:t,readOnly:n}){if(n)return s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(p=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:p},p))});const{t:r}=ft(["builder"]),[o,l]=k.useState(!1),[u,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const h=p=>{if((p.key==="Enter"||p.key===",")&&u.trim()){p.preventDefault();const g=u.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else p.key==="Backspace"&&!u&&e.length>0?t(e.slice(0,-1)):p.key==="Escape"&&(l(!1),d(""))};return o?s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ring-1 ring-brand-500/50 rounded px-2 py-1 -mx-1 min-h-[32px]",children:[e.map(p=>s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] bg-surface-elevated text-fg-secondary rounded-full px-2 py-0.5 border border-border-default",children:[p,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==p)),className:"text-fg-muted hover:text-red-500",children:"×"})]},p)),s.jsx("input",{ref:m,value:u,onChange:p=>d(p.target.value),onKeyDown:h,onBlur:()=>{u||l(!1)},className:"flex-1 min-w-[80px] bg-transparent text-xs text-fg-primary placeholder:text-fg-muted focus:outline-none",placeholder:r("detail.typeTagAndEnter")})]}):s.jsx("div",{onClick:()=>l(!0),className:"flex flex-wrap items-center gap-1.5 cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 py-0.5 transition-all min-h-[24px]",children:e.length>0?e.map(p=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:p},p)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function Fp({content:e}){return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
658
658
|
prose-headings:text-fg-primary prose-headings:font-semibold
|
|
659
659
|
prose-p:text-fg-secondary prose-p:leading-relaxed
|
|
660
660
|
prose-a:text-brand-400 prose-a:no-underline hover:prose-a:underline
|
|
@@ -663,4 +663,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=Pe,rn=wt),Ut===void
|
|
|
663
663
|
prose-strong:text-fg-primary
|
|
664
664
|
prose-li:text-fg-secondary
|
|
665
665
|
prose-hr:border-border-default
|
|
666
|
-
prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(bp,{remarkPlugins:[vw,kk],rehypePlugins:[[Wk,{detect:!0,ignoreMissing:!0}]],children:e})})}function Wh({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=ft(["builder","common"]),[u,d]=k.useState(!1),[m,h]=k.useState(t),[p,g]=k.useState(!1),x=/\.(md|mdx|markdown)$/i.test(e),y=k.useRef(null);k.useEffect(()=>{h(t)},[t]),k.useEffect(()=>{if(u&&y.current){const T=y.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[u,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},N=o?null:s.jsx("div",{className:"flex items-center gap-2",children:u?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{h(t),d(!1)},className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors",children:l("common:cancel")}),s.jsx("button",{onClick:w,disabled:p,className:"text-[10px] px-2.5 py-1 rounded-md bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:l(p?"common:saving":"common:save")})]}):s.jsxs("button",{onClick:()=>d(!0),className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),l("detail.edit")]})});return r?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-end px-4 py-2 border-b border-border-default bg-surface-elevated/20",children:N}),u?s.jsx("textarea",{ref:y,value:m,onChange:T=>h(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Fp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]}):s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border-default bg-surface-elevated/30",children:[s.jsx("span",{className:"text-xs font-medium text-fg-secondary font-mono",children:e}),N]}),u?s.jsx("textarea",{ref:y,value:m,onChange:T=>h(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Fp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const g4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function dK(e){return[...e].sort(([t],[n])=>{const r=g4[t]??99,o=g4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function d0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>dK(e),[e]),[l,u]=k.useState(0);if(o.length===1)return n?s.jsx(Wh,{filename:o[0][0],content:o[0][1],onSave:p=>t(o[0][0],p),readOnly:r}):s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),s.jsx(Wh,{filename:o[0][0],content:o[0][1],onSave:p=>t(o[0][0],p),readOnly:r})]});const[d,m]=o[l]??o[0],h=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30",children:o.map(([p],g)=>s.jsx("button",{onClick:()=>u(g),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors ${g===l?"border-brand-500 text-brand-400 bg-surface-secondary/50":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:p},p))}),s.jsx(Wh,{filename:d,content:m,onSave:p=>t(d,p),embedded:!0,readOnly:r},d)]});return n?h:s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),h]})}function mK({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l}){const{t:u}=ft(["builder"]),d=k.useRef(null);return e.length===0?l?null:s.jsxs("div",{className:"border-2 border-dashed border-border-default rounded-xl p-6 text-center text-fg-muted text-sm cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>d.current?.click(),onDragOver:m=>m.preventDefault(),onDrop:m=>{m.preventDefault();const h=m.dataTransfer.files[0];h?.type.startsWith("image/")&&r(h)},children:[s.jsxs("svg",{className:"w-8 h-8 mx-auto mb-2 text-fg-muted/50",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsx("span",{className:"block",children:u("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:u("images.hint")}),s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const h=m.target.files?.[0];h&&r(h),m.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(m=>{const h=m.split("/").pop()??m;return s.jsxs("div",{className:"relative group shrink-0 rounded-lg border border-border-default overflow-hidden bg-surface-elevated",children:[s.jsx("img",{src:`/api/builder/artifacts/${t}s/${encodeURIComponent(n)}/images/${encodeURIComponent(h)}`,alt:h,className:"h-32 w-auto object-cover"}),!l&&s.jsx("button",{onClick:()=>o(h),className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-red-600/80 text-white flex items-center justify-center text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},m)}),!l&&s.jsx("button",{onClick:()=>d.current?.click(),className:"shrink-0 h-32 w-24 rounded-lg border-2 border-dashed border-border-default flex items-center justify-center text-fg-muted hover:border-brand-500/30 hover:text-brand-400 transition-colors",children:s.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),!l&&s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const h=m.target.files?.[0];h&&r(h),m.target.value=""}})]})}function fK({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=ft(["builder"]),[u,d]=k.useState(0),m=k.useMemo(()=>{const N=new Set;for(const T of Object.keys(n)){const C=T.match(/^members\/([^/]+)\//);C&&N.add(C[1])}return[...N]},[n]),h=k.useMemo(()=>{const N=new Map,T=new Set;for(let _=0;_<e.length;_++){const O=qd(e[_].name);m.includes(O)&&!T.has(O)&&(N.set(_,O),T.add(O))}for(let _=0;_<e.length;_++){if(N.has(_))continue;const O=e[_].roleName;if(O){const z=qd(O);m.includes(z)&&!T.has(z)&&(N.set(_,z),T.add(z))}}for(let _=0;_<e.length;_++){if(N.has(_))continue;const O=e[_].name;for(const z of m){if(T.has(z))continue;const D=n[`members/${z}/ROLE.md`];if(!D)continue;const H=D.match(/^#\s+(.+)$/m)?.[1]?.trim();if(H&&(H.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes(H.toLowerCase()))){N.set(_,z),T.add(z);break}}}const C=m.filter(_=>!T.has(_));let j=0;for(let _=0;_<e.length;_++)N.has(_)||j<C.length&&(N.set(_,C[j]),j++);return N},[e,m,n]),p=k.useCallback((N,T)=>{const C=h.get(T);return C?Object.entries(n).filter(([j])=>j.startsWith(`members/${C}/`)):[]},[n,h]),g=k.useMemo(()=>{const N=[{label:l("detail.overview")}];for(const T of e)N.push({label:T.name,role:T.role});return N},[e,l]),x=u>0?e[u-1]:null,y=u-1;return s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30 border-b border-border-default",children:g.map((N,T)=>{const C=T===u,j=N.role==="manager",_=T===0?C?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":j?C?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":C?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>d(T),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${_} ${C?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[T===0&&s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),T>0&&s.jsx("span",{className:`w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center shrink-0 ${j?"bg-amber-500/20 text-amber-400":"bg-blue-500/20 text-blue-400"}`,children:(N.label[0]??"?").toUpperCase()}),N.label]},T)})}),s.jsx("div",{className:"p-5",children:u===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(d0,{noHeader:!0,files:t,onSave:w,readOnly:o}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:l("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((N,T)=>{const C=N.role==="manager";return s.jsxs("button",{onClick:()=>d(T+1),className:"text-left rounded-lg border border-border-default bg-surface-elevated/30 px-4 py-3 flex gap-3 items-center hover:border-gray-600 transition-colors cursor-pointer",children:[s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${C?"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:(N.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:N.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${C?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:N.role}),N.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",N.count]})]}),N.skills&&N.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[N.skills.slice(0,3).map(j=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:j},j)),N.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",N.skills.length-3]})]})]}),s.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},T)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${x.role==="manager"?"bg-amber-500/15 text-amber-400 ring-2 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-2 ring-blue-500/30"}`,children:(x.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:x.name}),s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${x.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:x.role}),x.count>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",x.count]})]}),x.roleName&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 italic",children:x.roleName})]})]}),x.skills&&x.skills.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.skills.map(N=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:N},N))}),(()=>{const N=p(x.name,y);return N.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(d0,{noHeader:!0,readOnly:o,files:N.map(([T,C])=>[T.replace(/^members\/[^/]+\//,""),C]),onSave:(T,C)=>{const j=N.find(([_])=>_.endsWith(`/${T}`));j&&r(j[0],C)}})})()]}):null})]});function w(N,T){r(N,T)}}function Ai({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:u,contentSlot:d}){const{t:m}=ft(["builder","common"]),h=Bo(),[p,g]=k.useState(!0),[x,y]=k.useState(t),[w,N]=k.useState({}),[T,C]=k.useState(null),[j,_]=k.useState(""),[O,z]=k.useState("idle"),[D,H]=k.useState({shared:!1}),[W,Z]=k.useState(!1),[U,Y]=k.useState(!1),[se,X]=k.useState(!1),[F,J]=k.useState(!1),[B,Q]=k.useState(!1),[re,ke]=k.useState(!1),[$,G]=k.useState(null),[le,I]=k.useState(""),[Ee,Ue]=k.useState(""),[Oe,We]=k.useState(""),[st,dt]=k.useState(""),[Et,gt]=k.useState([]),[jt,Jt]=k.useState(""),Rt=k.useRef(null),be=k.useRef(l);be.current=l,k.useEffect(()=>{y(t)},[t]);const Me=k.useCallback(async()=>{const he=be.current;if(he){C(he),I(he.displayName||he.name||t),Ue(he.description||""),We(he.version||"1.0.0"),dt(he.category||"general"),gt(he.tags||[]),Jt(he.icon||""),N(he.files??{}),g(!1);return}g(!0);try{let ve=t;try{const xt=await Ce.builder.artifacts.ensureSlugSafe(e,t);ve=xt.name,y(ve),xt.converted&&(history.replaceState(null,"",Si(me.BUILDER,`${e}/${encodeURIComponent(ve)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const Ye=await Ce.builder.artifacts.get(e,ve);N(Ye.files??{}),_(Ye.path??"");const nt=Ye.files[`${e}.json`]??Ye.files["agent.json"]??Ye.files["team.json"]??Ye.files["skill.json"];if(nt){const xt=JSON.parse(nt);C(xt),I(xt.displayName||xt.name||t),Ue(xt.description||""),We(xt.version||"1.0.0"),dt(xt.category||"general"),gt(xt.tags||[]),Jt(xt.icon||"")}}catch(ve){console.error("Failed to load artifact:",ve)}finally{g(!1)}},[e,t]);k.useEffect(()=>{Me()},[Me]),k.useEffect(()=>{l?.files&&N(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const he=localStorage.getItem("markus_builder_shared_map");if(he){const ve=JSON.parse(he),Ye=`${e}/${t}`;ve[Ye]&&H({shared:!0,id:ve[Ye].id,slug:ve[Ye].slug,version:ve[Ye].version,visibility:ve[Ye].visibility??"public"})}}catch{}it.myItems().then(he=>{const ve=he?.items??[],Ye=e==="agent"?"agent":e==="team"?"team":"skill";for(const nt of ve)if(nt.itemType===Ye&&(nt.slug===t||nt.name===t)){H({shared:!0,id:nt.id,slug:nt.slug,version:nt.version,visibility:nt.visibility??"public",moderationStatus:nt.moderationStatus,pendingReview:nt.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const Ge=k.useCallback(async he=>{if(!(!T||o)){z("saving");try{const ve={...T,...he};await Ce.builder.artifacts.save(e,ve),C(ve),z("saved"),setTimeout(()=>z(Ye=>Ye==="saved"?"idle":Ye),2e3)}catch{z("error"),setTimeout(()=>z("idle"),3e3)}}},[T,e]),ot=k.useCallback(he=>{Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(()=>Ge(he),800)},[Ge]),mt=k.useCallback((he,ve)=>{const Ye={};he==="displayName"?(I(ve),Ye.displayName=ve,Y(!0)):he==="description"?(Ue(ve),Ye.description=ve,Y(!0)):he==="version"?(We(ve),Ye.version=ve,Y(!1),X(!1)):he==="category"?(dt(ve),Ye.category=ve,Y(!0)):he==="tags"?(gt(ve),Ye.tags=ve,Y(!0)):he==="icon"&&(Jt(ve),Ye.icon=ve||void 0,Y(!0)),ot({...T,...Ye})},[T,ot]),ae=k.useCallback(async(he,ve)=>{try{const Ye={...w,[he]:ve};N(Ye);const nt={...T,files:Ye};await Ce.builder.artifacts.save(e,nt),z("saved"),Y(!0),setTimeout(()=>z(xt=>xt==="saved"?"idle":xt),2e3)}catch{z("error")}},[w,e,T]),ze=k.useCallback(async he=>{if(T){Z(!0);try{await it.ensureAuth();const ve=await Ce.builder.artifacts.ensureSlugSafe(e,x,T.displayName||T.name||x),Ye=ve.name,nt=ve.slug||dc(Ye);if(!nt)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 xt=ve.displayName||T.displayName||T.name||x;ve.converted&&(y(Ye),C(ie=>ie&&{...ie,name:nt,displayName:xt}),history.replaceState(null,"",Si(me.BUILDER,`${e}/${encodeURIComponent(Ye)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const Dt={...T,name:nt,displayName:xt},ct=Dt.description||"",Xt=Dt.category||"general",R=Dt.tags??[];let oe=Dt.icon||void 0;const _e=Dt.version||"1.0.0";if(oe&&!oe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(oe)){const ie=oe.split("/").pop()??oe;try{const Ne=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ye)}/images/${encodeURIComponent(ie)}`);if(Ne.ok){const Le=await Ne.blob(),Je=new File([Le],ie,{type:Le.type}),vt=await it.uploadImage(Je);vt?.url&&(oe=vt.url)}}catch{}}let de;const $e=[],qe=Dt.screenshots??[];for(let ie=0;ie<qe.length;ie++){const Ne=qe[ie],Le=Ne.split("/").pop()??Ne;try{const Je=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ye)}/images/${encodeURIComponent(Le)}`);if(Je.ok){const vt=await Je.blob(),Ie=new File([vt],Le,{type:vt.type}),tt=await it.uploadImage(Ie);tt?.url&&($e.push({url:tt.url,alt:Le,order:ie}),ie===0&&(de=tt.url))}}catch{}}const q=await it.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:xt,slug:nt,description:ct,category:Xt,tags:R,icon:oe,version:_e,config:Dt,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:de,images:$e.length>0?$e:void 0,priceCents:he?.priceCents,donationsEnabled:he?.donationsEnabled,visibility:he?.visibility,orgId:he?.orgId});q.id&&(H({shared:!0,id:q.id,slug:q.slug??nt,version:_e,visibility:q.visibility??he?.visibility??"public",moderationStatus:q.moderationStatus,pendingReview:q.pendingReview}),Y(!1),(q.visibility??he?.visibility??"public")!=="org"&&(q.moderationStatus==="pending"||q.pendingReview)?G({title:m("common:share"),message:ve.converted?m("share.convertedAndSubmitted",{previous:t,slug:nt}):q.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):ve.converted&&G({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:nt}),variant:"primary"}))}catch(ve){console.error("Share to Hub failed:",ve),G({title:m("common:share"),message:ve instanceof Error?ve.message:String(ve),variant:"danger"})}finally{Z(!1)}}},[T,w,e,t,x,m]),Xe=async he=>{const ve=new FormData;ve.append("image",he);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:ve,credentials:"include"}),await Me(),Y(!0)}catch(Ye){console.error("Image upload failed:",Ye)}},Ve=async he=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(he)}`,{method:"DELETE",credentials:"include"}),await Me(),Y(!0)}catch(ve){console.error("Image remove failed:",ve)}},et=p4[e]??p4.agent,yt=T?.screenshots??[],pe=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],V=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")),[w,e]),ye=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")),[w,e]),Qe=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const he=new Set;if(e==="skill"){const ve=T?.skill?.skillFile;ve&&w[ve]&&he.add(ve),!ve&&w["SKILL.md"]&&he.add("SKILL.md"),!ve&&!w["SKILL.md"]&&w["README.md"]&&he.add("README.md")}return Object.entries(w).filter(([ve])=>!ve.endsWith(".json")&&!ve.startsWith("images/")&&!ve.startsWith("members/")&&!he.has(ve))},[w,e,T?.skill?.skillFile]);return p?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse py-20 text-center",children:m("common:loading")})]})}):T?s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:`${h?"px-4 py-5":"px-6 py-8"}`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m(o?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!o&&O==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&O==="saved"&&s.jsxs("span",{className:"text-[10px] text-green-500 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),m("detail.saved")]}),!o&&O==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),u,!o&&D.shared&&(()=>{const he=it.getUser(),ve=he&&D.slug?`${it.getUrl()}/@${encodeURIComponent(he.username)}/${encodeURIComponent(D.slug)}`:null,Ye=Oe||T?.version||"1.0.0",nt=D.version!==Ye;return s.jsxs(s.Fragment,{children:[D.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):D.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):D.pendingReview?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,ve&&s.jsxs("a",{href:ve,target:"_blank",rel:"noopener noreferrer",onClick:xt=>{Gd()&&(xt.preventDefault(),Ro(ve))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${D.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":D.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:[D.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):D.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),D.visibility==="org"?m("visibility.sharedOrg"):D.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),nt&&s.jsx("button",{onClick:()=>{ze({visibility:D.visibility})},disabled:W,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:W?m("share.updating"):m("share.updateVersion",{version:Ye})})]})})(),!o&&!D.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:W,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:m(W?"share.sharing":"share.toHub")})]})]}),!o&&U&&!se&&s.jsxs("div",{className:"mb-4 px-4 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20 flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),s.jsx("button",{onClick:()=>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")})]}),!o&&se&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),s.jsx("input",{type:"text",defaultValue:(()=>{const he=(Oe||"1.0.0").split(".");return he[2]=String(Number(he[2]??0)+1),he.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:he=>{he.key==="Enter"&&mt("version",he.target.value)}}),s.jsx("button",{onClick:he=>{const ve=he.target.parentElement?.querySelector("input");ve&&mt("version",ve.value)},className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("common:confirm")}),s.jsx("button",{onClick:()=>X(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),D.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${h?"flex-col":""}`,children:[s.jsxs("div",{className:`${h?"w-full":"flex-1 min-w-0"}`,children:[s.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>!o&&ke(!re),className:`w-16 h-16 rounded-xl ${et.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${et.ring} transition-all overflow-hidden`,children:jt&&jt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(jt.replace("images/",""))}`,alt:"",className:"w-full h-full object-cover"}):jt&&(jt.startsWith("http")||jt.startsWith("/"))?s.jsx("img",{src:jt,alt:"",className:"w-full h-full object-cover"}):(()=>{const he=jt||"";if(he&&[...he].length<=2&&new RegExp("\\p{Emoji}","u").test(he))return he;const Ye=Ti[Ko(e)].accent;return s.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:w3(le||t||e),fill:Ye})})})()}),!o&&re&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ke(!1)}),s.jsxs("div",{className:"absolute top-full left-0 mt-2 z-50 bg-surface-secondary border border-border-default rounded-xl p-3 shadow-xl w-80",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("input",{type:"text",placeholder:m("detail.pasteEmojiOrUrl"),className:"flex-1 text-sm px-2 py-1.5 rounded-lg bg-surface-elevated border border-border-default text-fg-primary placeholder:text-fg-muted",defaultValue:jt,onKeyDown:he=>{he.key==="Enter"&&(mt("icon",he.target.value),ke(!1))}}),s.jsxs("label",{className:"text-[10px] text-brand-400 hover:text-brand-300 cursor-pointer px-1.5 py-1 border border-brand-500/30 rounded-lg",children:[m("detail.upload"),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async he=>{const ve=he.target.files?.[0];if(!ve)return;const Ye=new FormData;Ye.append("image",ve);try{const nt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:Ye,credentials:"include"});if(nt.ok){const Dt=(await nt.json()).path;if(Jt(Dt),ke(!1),T){const ct={...T,icon:Dt};C(ct),await Ce.builder.artifacts.save(e,ct)}Y(!0)}}catch{}}})]}),jt&&s.jsx("button",{onClick:()=>{mt("icon",""),ke(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto",children:oK.map(he=>s.jsxs("div",{className:"mb-2.5",children:[s.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:he.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:he.emojis.map(ve=>s.jsx("button",{onClick:()=>{mt("icon",ve),ke(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${jt===ve?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:ve},ve))})]},he.label))})]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Kh,{value:le,onChange:he=>mt("displayName",he),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:o}),s.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${et.bg} ${et.color}`,children:et.label}),s.jsx(Kh,{value:Oe,onChange:he=>mt("version",he),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:o})]}),s.jsx(Kh,{value:Ee,onChange:he=>mt("description",he),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:o}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(cK,{value:st,options:iK,onChange:he=>mt("category",he),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(uK,{tags:Et,onChange:he=>mt("tags",he),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(mK,{images:yt,artifactType:e,artifactName:t,onUpload:Xe,onRemove:Ve,readOnly:o})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(fK,{members:T.team.members,teamTopFiles:ye,files:w,onFileSave:ae,readOnly:o})}),e==="agent"&&V.length>0&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),s.jsx(d0,{noHeader:!0,files:V,onSave:ae,readOnly:o})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[T.skill?.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:T.skill.requiredPermissions.map(he=>{const ve=lK[he];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${ve?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:ve?.icon??"?"})," ",he]},he)})})]}),T.skill?.mcpServers&&Object.keys(T.skill.mcpServers).length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),s.jsx("div",{className:"grid gap-2",children:Object.entries(T.skill.mcpServers).map(([he,ve])=>s.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[s.jsx("span",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center text-purple-400 text-sm shrink-0",children:"◎"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary",children:he}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof ve=="object"?JSON.stringify(ve).slice(0,80):String(ve)})]})]},he))})]}),pe&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),s.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:s.jsx(Fp,{content:pe})})]})]}),Qe.length>0&&s.jsx(d0,{files:Qe,onSave:ae,readOnly:o})]}),s.jsx("div",{className:`${h?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${h?"":"sticky top-6"} space-y-4`,children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),s.jsx("span",{className:`font-medium ${et.color}`,children:et.label})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),s.jsx("span",{className:"text-fg-secondary",children:st})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:Oe})]}),T.author&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),s.jsx("span",{className:"text-fg-secondary",children:typeof T.author=="string"?T.author:T.author?.name??""})]})]})]}),e==="agent"&&T.agent&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.agent.roleName&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.roleName})]}),T.agent.llmProvider&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.llmProvider})]}),T.agent.llmModel&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:T.agent.llmModel})]}),T.agent.temperature!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.temperature})]})]})]}),e==="team"&&T.team&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),s.jsx("span",{className:"text-fg-secondary",children:T.team.members.reduce((he,ve)=>he+ve.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),s.jsx("span",{className:"text-amber-400",children:T.team.members.filter(he=>he.role==="manager").reduce((he,ve)=>he+ve.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),s.jsx("span",{className:"text-blue-400",children:T.team.members.filter(he=>he.role!=="manager").reduce((he,ve)=>he+ve.count,0)})]})]})]}),e==="skill"&&T.skill&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.skill.alwaysOn!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),s.jsx("span",{className:T.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:T.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),s.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:T.skill.skillFile})]}),T.skill.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:T.skill.requiredPermissions.map(he=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:he},he))})]})]})]}),T.dependencies&&(T.dependencies.skills?.length||T.dependencies.env?.length)?s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),T.dependencies.skills?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.skills.map(he=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:he},he))})]}):null,T.dependencies.env?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.env.map(he=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:he},he))})]}):null]}):null,!o&&j&&s.jsxs("button",{onClick:()=>Ce.system.openPath(j).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:j,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),j.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&F&&s.jsx(pK,{onClose:()=>J(!1),onConfirm:(he,ve)=>{J(!1),ze({donationsEnabled:!1,priceCents:he==="paid"?ve:void 0})},isUpdate:D.shared}),!o&&B&&s.jsx(hK,{onClose:()=>Q(!1),onConfirm:(he,ve,Ye,nt)=>{Q(!1),ze({visibility:he,orgId:ve,priceCents:Ye,donationsEnabled:nt})}}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function hK({onClose:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,u]=k.useState([]),[d,m]=k.useState(""),[h,p]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(p(!0),it.myOrgs().then(C=>{u(C.memberships),C.memberships.length>0&&m(C.memberships[0].id)}).catch(()=>{}).finally(()=>p(!1)))},[r,l.length]);const N=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:C=>C.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(C=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===C.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===C.value,onChange:()=>o(C.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:C.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:C.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:C.desc})]})]},C.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),h?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:C=>m(C.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(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),N&&s.jsxs("div",{className:"mb-5",children:[s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:S3.map(C=>s.jsx("button",{type:"button",onClick:()=>x(C.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===C.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:C.label},C.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:C=>w(C.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),N&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,N&&g>0?g:void 0,N?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const S3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function pK({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:u=>u.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(n?"shareMode.titleUpdate":"share.toHub")}),s.jsx("div",{className:"space-y-2 mb-5",children:S3.map(u=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===u.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===u.cents,onChange:()=>l(u.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:u.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:u.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},u.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>t(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(n?"shareMode.update":"shareMode.share")})]})]})})}function m0(e,t){return!e||!k3(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function gK({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:u="rounded-xl"}){const d=Ko(e),m=m0(n,r),h=k.useMemo(()=>Rg(d,t),[d,t]),p=k.useMemo(()=>w3(t),[t]),[g,x]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>x(!0),style:{width:o,height:o},className:`${u} object-cover shrink-0 ${l}`}):aK(n)?s.jsx("div",{style:{width:o,height:o,background:h,fontSize:o*.5},className:`${u} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&wV(n)?s.jsx("div",{style:{width:o,height:o,background:h},className:`${u} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Vo,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:h},className:`${u} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:o*.55,height:o*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:p,fill:"rgba(255,255,255,0.92)"})})})}function f0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:u}){const d=t||e||"markus",m=m0(n,r),[h,p]=k.useState(!1),g=m&&!h?m:sK(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:o,height:o},children:[s.jsx("img",{src:g,alt:e||t||"",onError:()=>p(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),u&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 ring-2 ring-surface-primary",style:{width:o*.42,height:o*.42},children:s.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"white","aria-hidden":!0,children:s.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function bK({type:e,className:t=""}){const n=Ko(e),r=Ti[n];return s.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white bg-gradient-to-r ${r.gradient} ${t}`,children:r.label})}function b4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",className:n<t?"text-amber-400":"text-fg-muted/40",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z"})},n))})}function sa(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:u,hubBase:d,author:m,authorLabel:h,version:p,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:N=0,priceCents:T,currency:C="usd",installed:j,glowing:_,selected:O,showTypeBadge:z=!0,hideStats:D=!1,cornerLabel:H,actions:W,footerLeft:Z,headerAction:U,onClick:Y,className:se=""}=e,X=Ko(t),F=Ti[X],J=o||n,B=(T??0)>0,Q=!!m0(u||void 0,d),re=Rg(X,J),ke=h??m?.displayName??m?.username??"",[$,G]=k.useState(null),le=j?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/12 text-emerald-400 border border-emerald-500/25 px-2 py-0.5 text-[10px] font-semibold",children:s.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):H?s.jsx("span",{className:"chip",children:H}):B?s.jsx("span",{className:"badge-paid",children:h4(T,C)}):null;if(Q){const I=m0(u||void 0,d);return s.jsxs("div",{onClick:Y,style:{aspectRatio:$??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${Y?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${se}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Ee=>{const Ue=Ee.currentTarget;Ue.naturalWidth&&Ue.naturalHeight&&G(Math.min(1.9,Math.max(1,Ue.naturalWidth/Ue.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),s.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),s.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[s.jsx("span",{children:z&&s.jsx(bK,{type:X})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ee=>Ee.stopPropagation(),children:[j?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/25 text-emerald-50 border border-emerald-300/40 px-2 py-0.5 text-[10px] font-semibold backdrop-blur-md",children:s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):H?s.jsx("span",{className:"inline-flex items-center rounded-full bg-white/15 text-white border border-white/25 px-2 py-0.5 text-[10px] font-medium backdrop-blur-md",children:H}):U?null:s.jsx("span",{className:B?"badge-paid":"badge-free",children:h4(T,C)}),U]})]}),s.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),p&&s.jsxs("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/25 px-1.5 py-0.5 text-[10px] font-medium backdrop-blur-md",children:["v",p]})]}),ke&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(f0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:ke})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[g&&s.jsx("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/20 text-white/95 px-2 py-0.5 text-[10px] font-semibold capitalize backdrop-blur-md",children:g}),x?.slice(0,3).map(Ee=>s.jsx("span",{className:"shrink-0 rounded-full bg-white/10 border border-white/15 text-white/85 px-2 py-0.5 text-[10px] backdrop-blur-md",children:Ee},Ee))]}),(!D||W)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[D?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(b4,{rating:y}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Ao(w),")"]})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ao(N)]})]}),W&&s.jsx("div",{className:"flex items-center gap-2",onClick:Ee=>Ee.stopPropagation(),children:W})]})]})]})}return s.jsxs("div",{onClick:Y,className:`group asset-card card-shine relative flex flex-col ${Y?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${se}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${F.accent}, transparent)`}}),s.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:re}}),U&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:U}),s.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(gK,{type:X,seed:J,icon:l,hubBase:d,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),s.jsxs("div",{className:`min-w-0 flex-1 ${U?"pr-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),p&&s.jsxs("span",{className:"chip shrink-0",children:["v",p]}),le&&s.jsx("span",{className:"ml-auto shrink-0",children:le})]}),(ke||z)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(f0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),ke&&s.jsx("span",{className:"truncate",children:ke}),z&&s.jsxs(s.Fragment,{children:[ke&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:F.accent},children:F.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),x?.slice(0,3).map(I=>s.jsx("span",{className:"chip",children:I},I)),(x?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(x?.length??0)-3]})]}),(()=>{const I=Z??(D?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(b4,{rating:y}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Ao(w)})`:""})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ao(N)]})]}));return!I&&!W?null:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Ee=>Ee.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),W&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:W})]})})()]})]})}function Er({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,u]=k.useState(0);k.useEffect(()=>{const p=o.current;if(!p)return;u(p.clientWidth);const g=new ResizeObserver(x=>{for(const y of x)u(y.contentRect.width)});return g.observe(p),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),h=Array.from({length:d},()=>[]);return m.forEach((p,g)=>{h[g%d].push(p)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:h.map((p,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:p},g))})}function xK(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const yK=[{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 vK(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return oc(r[0])===me.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const o=window.location.hash.slice(1).split("/");oc(o[0])===me.BUILDER&&o[1]&&o[2]?t({type:o[1],name:decodeURIComponent(o[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const N3="markus_builder_shared_map";function wK(){try{const e=localStorage.getItem(N3);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function kd(e){try{localStorage.setItem(N3,JSON.stringify(Object.fromEntries(e)))}catch{}}function C3({authUser:e}={}){const{t}=ft(["builder","common"]),n=Bo(),r=vK(),[o,l]=k.useState([]),[u,d]=k.useState([]),[m,h]=k.useState(!1),[p,g]=k.useState("all"),[x,y]=k.useState(null),[w,N]=k.useState(new Map),[T,C]=k.useState(null),[j,_]=k.useState(null),[O,z]=k.useState(null),[D,H]=k.useState(wK),[W,Z]=k.useState(null),[U,Y]=k.useState(null),[se,X]=k.useState(null),[F,J]=k.useState(null),[B,Q]=k.useState(null),[re,ke]=k.useState("creations"),[$,G]=k.useState([]),[le,I]=k.useState(""),[Ee,Ue]=k.useState([]),[Oe,We]=k.useState(!1),[st,dt]=k.useState("all"),Et=k.useCallback(()=>{h(!0),Promise.all([(vi(Tr.builderArtifacts)??Ce.builder.artifacts.list()).then(ae=>ae?.artifacts??[]).catch(()=>[]),(vi(Tr.builderAgents)??Ce.agents.list()).then(ae=>ae?.agents??[]).catch(()=>[]),(vi(Tr.builderHubMyItems)??it.myItems()).then(ae=>ae?.items??[]).catch(()=>[]),(vi(Tr.builderInstalled)??Ce.builder.artifacts.installed()).then(ae=>ae?.installed??{}).catch(()=>({}))]).then(([ae,ze,Xe,Ve])=>{if(d(ae),l(ze),Xe.length>0){const yt=new Map;for(const pe of Xe){const V=pe.itemType==="agent"?"agent":pe.itemType==="team"?"team":"skill";for(const ye of ae)ye.type===V&&(pe.slug===ye.name||pe.name===(ye.meta.displayName||ye.meta.name||ye.name))&&yt.set(`${ye.type}/${ye.name}`,{id:pe.id,name:pe.name,slug:pe.slug||ye.name,version:pe.version||"1.0.0",visibility:pe.visibility??"public",moderationStatus:pe.moderationStatus,pendingReview:pe.pendingReview})}yt.size>0&&H(pe=>{const V=new Map(pe);for(const[ye,Qe]of yt)V.set(ye,Qe);return kd(V),V})}const et=new Map;for(const yt of ae){const pe=`${yt.type}/${yt.name}`,V=Ve[pe];V&&et.set(pe,{agentId:V.agentId,agentIds:V.agentIds,teamId:V.teamId})}N(et)}).finally(()=>h(!1))},[]);k.useEffect(()=>{Et();const ae=ze=>{ze.detail?.page===me.BUILDER&&Et()};return window.addEventListener("markus:navigate",ae),()=>window.removeEventListener("markus:navigate",ae)},[Et]);const gt=ae=>{const ze=o.find(Xe=>Xe.role==="Secretary"||Xe.name==="Secretary");ze?at.navigate(me.TEAM,{agentId:ze.id,prefillMessage:ae}):at.navigate(me.TEAM,{prefillMessage:ae})},jt=async ae=>{const ze=`${ae.type}/${ae.name}`;if(!w.has(ze)){y({key:ze,action:"install"});try{const Xe=await Ce.builder.artifacts.install(ae.type,ae.name),Ve={};Xe.agent&&typeof Xe.agent=="object"&&(Ve.agentId=Xe.agent.id),Xe.team&&typeof Xe.team=="object"&&(Ve.teamId=Xe.team.id),Array.isArray(Xe.agents)&&(Ve.agentIds=Xe.agents.map(et=>et.id)),N(et=>new Map(et).set(ze,Ve)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Install failed:",Xe),Y({title:t("common:install"),message:t("installFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Jt=async ae=>{const ze=`${ae.type}/${ae.name}`;if(w.has(ze)){y({key:ze,action:"uninstall"});try{await Ce.builder.artifacts.uninstall(ae.type,ae.name),N(Xe=>{const Ve=new Map(Xe);return Ve.delete(ze),Ve}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Uninstall failed:",Xe),Y({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Rt=async(ae,ze)=>{const Xe=`${ae.type}/${ae.name}`;y({key:Xe,action:"share"});try{const Ve=await Ce.builder.artifacts.ensureSlugSafe(ae.type,ae.name,ae.meta.displayName||ae.meta.name||ae.name),et=Ve.name,yt=Ve.slug||dc(et);if(!yt)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 pe=`${ae.type}/${et}`;Ve.converted&&(d(oe=>oe.map(_e=>_e.type===ae.type&&_e.name===ae.name?{..._e,name:et,path:Ve.path,meta:{..._e.meta,name:et,displayName:Ve.displayName??_e.meta.displayName??ae.name}}:_e)),H(oe=>{const _e=new Map(oe),de=_e.get(Xe);return de&&(_e.delete(Xe),_e.set(pe,{...de,slug:yt,name:Ve.displayName??de.name})),kd(_e),_e}),N(oe=>{const _e=new Map(oe),de=_e.get(Xe);return de&&(_e.delete(Xe),_e.set(pe,de)),_e}));const V=await Ce.builder.artifacts.get(ae.type,et);let ye={...ae.meta,name:et,displayName:Ve.displayName??ae.meta.displayName??ae.name};try{const oe=V.files?.[`${ae.type}.json`]??V.files?.["agent.json"]??V.files?.["team.json"]??V.files?.["skill.json"];oe&&(ye={...JSON.parse(oe),...ye,name:et,displayName:ye.displayName})}catch{}const Qe=ye.displayName||ye.name||et,he=ye.description||"",ve=ye.category||"general",Ye=Array.isArray(ye.tags)?ye.tags:[];let nt=ye.icon||void 0;const xt=ye.version||"1.0.0";if(nt&&!nt.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)){const oe=nt.split("/").pop()??nt;try{const _e=await fetch(`/api/builder/artifacts/${ae.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(oe)}`);if(_e.ok){const de=await _e.blob(),$e=new File([de],oe,{type:de.type}),qe=await it.uploadImage($e);qe?.url&&(nt=qe.url)}}catch{}}let Dt;const ct=[],Xt=Array.isArray(ye.screenshots)?ye.screenshots:[];for(let oe=0;oe<Xt.length;oe++){const _e=Xt[oe],de=_e.split("/").pop()??_e;try{const $e=await fetch(`/api/builder/artifacts/${ae.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(de)}`);if($e.ok){const qe=await $e.blob(),q=new File([qe],de,{type:qe.type}),ie=await it.uploadImage(q);ie?.url&&(ct.push({url:ie.url,alt:de,order:oe}),(oe===0||ye.thumbnail===_e)&&(Dt=ie.url))}}catch{}}const R=await it.publishViaProxy({itemType:ae.type==="team"?"team":ae.type==="skill"?"skill":"agent",name:Qe,slug:yt,description:he,category:ve,tags:Ye,icon:nt,version:xt,config:{...ye,name:et,displayName:Qe},files:V.files&&Object.keys(V.files).length>0?V.files:void 0,thumbnailUrl:Dt,images:ct.length>0?ct:void 0,priceCents:ze?.priceCents,donationsEnabled:ze?.donationsEnabled,visibility:ze?.visibility,orgId:ze?.orgId});R.id&&(H(_e=>{const de=new Map(_e);return de.set(pe,{id:R.id,name:Qe,slug:R.slug??yt,version:xt,visibility:R.visibility??ze?.visibility??"public",moderationStatus:R.moderationStatus,pendingReview:R.pendingReview}),kd(de),de}),(R.visibility??ze?.visibility??"public")!=="org"&&(R.moderationStatus==="pending"||R.pendingReview)?Y({title:t("common:share"),message:Ve.converted?t("share.convertedAndSubmitted",{previous:ae.name,slug:yt}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):Ve.converted&&Y({title:t("common:share"),message:t("share.convertedSlug",{previous:ae.name,slug:yt}),variant:"primary"}))}catch(Ve){console.error("Share failed:",Ve),Y({title:t("common:share"),message:t("shareFailed",{error:Ve instanceof Error?Ve.message:String(Ve)}),variant:"danger"})}finally{y(null)}},be=async()=>{if(!W)return;const{key:ae}=W,ze=D.get(ae);if(Z(null),!ze)return;const Xe=ze.id;y({key:ae,action:"hubDelete"});try{await it.deleteItem(Xe),H(Ve=>{const et=new Map(Ve);return et.delete(ae),kd(et),et})}catch(Ve){console.error("Hub delete failed:",Ve),Y({title:t("unshare"),message:t("hubDeleteFailed",{error:String(Ve)}),variant:"danger"})}finally{y(null)}},Me=async()=>{if(!T)return;const ae=T,ze=`${ae.type}/${ae.name}`;C(null),y({key:ze,action:"delete"});try{await Ce.builder.artifacts.delete(ae.type,ae.name),d(Xe=>Xe.filter(Ve=>!(Ve.type===ae.type&&Ve.name===ae.name))),N(Xe=>{const Ve=new Map(Xe);return Ve.delete(ze),Ve}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Delete failed:",Xe)}finally{y(null)}},Ge=p==="all"?u:u.filter(ae=>ae.type===p);k.useEffect(()=>{re!=="orgAssets"||$.length>0||it.myOrgs().then(ae=>{G(ae.memberships),ae.memberships.length>0&&!le&&I(ae.memberships[0].id)}).catch(()=>{})},[re,$.length,le]),k.useEffect(()=>{re!=="orgAssets"||!le||(We(!0),it.browseItems({orgId:le,limit:100}).then(ae=>Ue(ae.items??[])).catch(()=>Ue([])).finally(()=>We(!1)))},[re,le]);const ot=st==="all"?Ee:Ee.filter(ae=>ae.itemType===st),mt=ae=>{history.pushState(null,"",Si(me.BUILDER,`${ae.type}/${encodeURIComponent(ae.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Ai,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Si(me.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),s.jsx("button",{onClick:Et,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:t("common:refresh")})]}),s.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:yK.map(ae=>{const ze=t(`prompts.${ae.id}Prompt`),Xe=t(`prompts.${ae.id}Examples`,{returnObjects:!0}),Ve=Array.isArray(Xe)?Xe:[];return s.jsx("button",{onClick:()=>gt(ze),className:`group text-left w-full rounded-xl border ${ae.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${ae.bgColor} flex items-center justify-center shrink-0`,children:ae.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ae.color} bg-clip-text text-transparent`,children:t(`prompts.${ae.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ae.id}Desc`)}),Ve.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Ve.slice(0,2).map((et,yt)=>s.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:pe=>{pe.stopPropagation(),gt(ze+et)},children:["“",et,"”"]},yt))})]})]})},ae.id)})})]}),s.jsx("div",{className:"mb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>ke("creations"),className:`text-sm font-semibold transition-colors ${re==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>ke("orgAssets"),className:`text-sm font-semibold transition-colors ${re==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),re==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ae=>s.jsx("button",{onClick:()=>g(ae),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${p===ae?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ae==="all"?"myCreations.filterAll":ae==="agent"?"myCreations.filterAgents":ae==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ae))}),re==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ae=>s.jsx("button",{onClick:()=>dt(ae),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${st===ae?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ae==="all"?"myCreations.filterAll":ae==="agent"?"myCreations.filterAgents":ae==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ae))})]})}),re==="orgAssets"&&$.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:$.map(ae=>s.jsx("button",{onClick:()=>I(ae.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${le===ae.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:ae.name},ae.id))}),re==="orgAssets"&&($.length===0&&!Oe?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):Oe?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):ot.length===0?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):s.jsx(Er,{children:ot.map(ae=>{const ze=ae.author?.username&&ae.slug?`${it.getUrl()}/@${encodeURIComponent(ae.author.username)}/${encodeURIComponent(ae.slug)}`:null;return s.jsx(sa,{type:ae.itemType,name:ae.name,description:ae.description,seed:ae.slug||ae.id||ae.name,icon:ae.icon,cover:ae.thumbnailUrl,hubBase:it.getUrl(),author:ae.author,version:ae.version,rating:parseFloat(ae.avgRating)||0,ratingCount:ae.ratingCount,downloadCount:ae.downloadCount,actions:ze?s.jsxs("a",{href:ze,target:"_blank",rel:"noopener noreferrer",onClick:Xe=>{Xe.stopPropagation(),Gd()&&(Xe.preventDefault(),Ro(ze))},className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},ae.id)})})),re==="creations"&&(m&&u.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):Ge.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),s.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):s.jsx(Er,{children:Ge.map(ae=>{const ze=ae.meta.displayName||ae.meta.name||ae.name,Xe=ae.meta.description||"",Ve=`${ae.type}/${ae.name}`,et=x?.key===Ve?x.action:null,yt=D.get(Ve),pe=ae.meta.version||"1.0.0",V=!!yt,ye=V&&yt.version!==pe,Qe=()=>{const ct=it.getUser();return!yt||!ct?null:`${it.getUrl()}/@${encodeURIComponent(ct.username)}/${encodeURIComponent(yt.slug)}`},he=V&&(yt?.moderationStatus==="pending"||yt?.moderationStatus==="rejected"||!!yt?.pendingReview),ve=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:ct=>ct.stopPropagation(),children:[w.has(Ve)?s.jsxs("button",{onClick:()=>z(ae),disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:bg-red-500/10 hover:text-red-500 hover:border-red-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"17 8 12 3 7 8"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(et==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>_(ae),disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(et==="install"?"common:installing":"common:install")]}),V&&he?yt?.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.underReview")]}):yt?.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}):s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.updateUnderReview")]}):V?s.jsxs(s.Fragment,{children:[ye&&s.jsxs("button",{onClick:()=>{const ct=yt?.visibility??"public";Rt(ae,{visibility:ct})},disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("polyline",{points:"1 20 1 14 7 14"}),s.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),et==="share"?t("common:sharing"):t("share.updateVersion",{version:pe})]}),s.jsxs("a",{href:Qe()??"#",target:"_blank",rel:"noopener noreferrer",onClick:ct=>{const Xt=Qe();Gd()&&Xt&&(ct.preventDefault(),Ro(Xt))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${yt?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":yt?.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:[yt?.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):yt?.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),yt?.visibility==="org"?t("visibility.sharedOrg"):yt?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>Z({key:Ve,name:ze}),disabled:!!et,className:"text-xs px-2.5 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-amber-500 hover:border-amber-500/40 hover:bg-amber-500/10 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("removeFromHubTooltip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):s.jsxs("button",{onClick:async()=>{await it.ensureAuth(),Array.isArray(ae.meta.screenshots)&&ae.meta.screenshots.length>0?Q(ae):X(ae)},disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-green-600 hover:border-green-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"18",cy:"5",r:"3"}),s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"19",r:"3"}),s.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),s.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(et==="share"?"common:sharing":"common:share")]})]}),Ye=s.jsx("button",{onClick:()=>C(ae),disabled:!!et,className:"w-7 h-7 rounded-lg text-fg-muted hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 inline-flex items-center justify-center",title:t("deleteLocalTooltip"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"3 6 5 6 21 6"}),s.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),nt=ae.meta.icon,Dt=!!nt&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)?nt.startsWith("http")||nt.startsWith("/")?nt:`/api/builder/artifacts/${ae.type}s/${encodeURIComponent(ae.name)}/images/${encodeURIComponent(nt.split("/").pop()??"")}`:nt;return s.jsx(sa,{type:ae.type,name:ze,description:Xe,seed:Ve,icon:Dt,version:pe,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:ct=>{ct.stopPropagation(),Ce.system.openPath(ae.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ae.path,children:xK(ae.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(ae.updatedAt).toLocaleDateString()})]}),headerAction:Ye,actions:ve,onClick:()=>mt(ae)},Ve)})})),j&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:j.meta.displayName||j.meta.name||j.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ae=j;_(null),jt(ae)},onCancel:()=>_(null)}),O&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:O.meta.displayName||O.meta.name||O.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ae=O;z(null),Jt(ae)},onCancel:()=>z(null)}),T&&s.jsx(dr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:Me,onCancel:()=>C(null)}),W&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:W.name}),confirmLabel:t("unshare"),onConfirm:()=>{be()},onCancel:()=>Z(null)}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)}),se&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>X(null),children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ae=>ae.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),s.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>{const ae=se;X(null),Q(ae)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),s.jsx("button",{onClick:()=>{const ae=se;X(null),mt(ae)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>J(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ae=>ae.stopPropagation(),children:s.jsx(SK,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>J(null),onConfirm:(ae,ze)=>{const Xe=F;J(null),Rt(Xe,{priceCents:ze>0?ze:void 0})}})})}),B&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Q(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ae=>ae.stopPropagation(),children:s.jsx(kK,{onCancel:()=>Q(null),onConfirm:(ae,ze,Xe,Ve)=>{const et=B;Q(null),Rt(et,{visibility:ae,orgId:ze,priceCents:Xe,donationsEnabled:Ve})}})})})]})})}function kK({onCancel:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,u]=k.useState([]),[d,m]=k.useState(""),[h,p]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(p(!0),it.myOrgs().then(C=>{u(C.memberships),C.memberships.length>0&&m(C.memberships[0].id)}).catch(()=>{}).finally(()=>p(!1)))},[r,l.length]);const N=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(C=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===C.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===C.value,onChange:()=>o(C.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:C.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:C.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:C.desc})]})]},C.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),h?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:C=>m(C.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(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),N&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:T3.map(C=>s.jsx("button",{type:"button",onClick:()=>x(C.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===C.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:C.label},C.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:C=>w(C.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),N&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,N&&g>0?g:void 0,N?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const T3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function SK({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(e?"shareMode.titleUpdate":"shareMode.title")}),s.jsx("div",{className:"space-y-2 mb-5",children:T3.map(u=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===u.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===u.cents,onChange:()=>l(u.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:u.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:u.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},u.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>n(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(e?"shareMode.update":"shareMode.share")})]})]})}const NK=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:C3},Symbol.toStringTag,{value:"Module"}));async function E3(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(r=>r.id===t);if(n)return{items:[n,...e.filter(r=>r.id!==t)],highlighted:n,missing:!1};try{const{item:r}=await it.getItem(t);return r?{items:[r,...e],highlighted:r,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function CK(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}function h0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function x4(e,t){return e.i18n?.[t]?.description||e.description}const TK={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function EK({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=ft(["store","common"]),l=o.language,[u,d]=k.useState(""),[m,h]=k.useState([]),[p,g]=k.useState([]),[x,y]=k.useState(null),[w,N]=k.useState({}),[T,C]=k.useState(!1),[j,_]=k.useState(!0),[O,z]=k.useState(new Map),[D,H]=k.useState(new Set),[W,Z]=k.useState(null),[U,Y]=k.useState(null),se=k.useCallback(async()=>{try{const[J,B]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const re of J.artifacts){if(re.type!=="agent")continue;const ke=!!B.installed[`agent/${re.name}`];Q.set(re.name,{installed:ke,localVersion:re.meta.version||void 0,localUpdatedAt:re.updatedAt})}z(Q)}catch{}},[]),X=k.useCallback(async()=>{_(!0);try{const J=u?it.search({type:"agent",q:u,limit:50}):vi(Tr.hubAgents)??it.search({type:"agent",limit:50}),B=new URLSearchParams;u&&B.set("q",u);const Q=fetch("/api/templates?"+B.toString()).then(G=>G.json()).catch(()=>({templates:[]})),[re,ke]=await Promise.all([J.catch(()=>({items:[],total:0})),Q,se(),it.isAuthenticated()?it.purchases.mine().then(G=>H(new Set(G.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),$=await E3(re?.items??[],t);g($.items),h(Array.isArray(ke.templates)?ke.templates:[]),$.missing&&n?.()}catch{h([]),g([])}finally{_(!1)}},[u,se,t,n]);k.useEffect(()=>{X()},[X]),k.useEffect(()=>{if(!x){N({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(J=>J.json()).then(J=>N(J.files??{})).catch(()=>N({}))},[x]);const F=async(J,B,Q)=>{try{const re=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:J,name:B,orgId:"default",teamId:Q})});if(!re.ok)throw new Error(`Failed: ${re.status}`);C(!1),y(null)}catch(re){Y({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${re}`,variant:"danger"})}};if(W)return s.jsx(Ai,{type:W.type,name:W.name,onBack:()=>Z(null)});if(x){const J={type:"agent",name:x.id,displayName:h0(x,l),version:x.version,description:x4(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},B=s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.roleConfig")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.role")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.position")}),s.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${TK[x.agentRole]??""}`,children:x.agentRole})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.skills")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(Q=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:Q},Q)),x.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.starterTasks")}),s.jsx("div",{className:"space-y-2",children:x.starterTasks.map((Q,re)=>s.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${Q.priority==="high"?"bg-red-400":Q.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:Q.title}),Q.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:Q.description})]})]},re))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ai,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:J,actionSlot:s.jsx("button",{onClick:()=>C(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium",children:r("agentStore.hireAgent")}),contentSlot:B}),T&&s.jsx(y4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:r("agentStore.title")}),s.jsx("input",{type:"text",placeholder:r("agentStore.searchPlaceholder"),value:u,onChange:J=>d(J.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:j?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((J,B)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},B))}):m.length===0&&p.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:u?r("agentStore.noResults",{search:u}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(u?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):s.jsxs(s.Fragment,{children:[m.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:r("agentStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:r("agentStore.available",{count:m.length})})]}),s.jsx(Er,{columns:3,children:m.map(J=>s.jsx(sa,{type:"agent",name:h0(J,l),description:x4(J,l),seed:J.id,icon:J.icon,version:J.version,category:J.category,tags:J.tags,authorLabel:J.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>y(J)},J.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Er,{columns:3,children:p.map(J=>s.jsx(AK,{item:J,localInfo:O.get(Cc(J)),purchased:Hd(J,D),onStatusChange:se,highlight:J.id===t,onHighlightDone:n,onViewDetail:B=>Z({type:"agent",name:B})},J.id))})]})]})}),T&&x&&s.jsx(y4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Cc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return qd(n||e.name,"hub-pkg")}function wi(e){return(async()=>{const t=await it.download(e.id),n=t.name||e.name,r=t.config??{},o=Cc(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",u={type:"hub",hubItemId:e.id};if(t.files&&Object.keys(t.files).length>0)await Ce.builder.artifacts.import(l,o,t.files,u);else{const d={...r,name:o,displayName:r.displayName||n,description:e.description,source:u};await Ce.builder.artifacts.save(l,d)}return await Ce.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Og(e,t){t("checking"),await it.ensureAuth();const n=await it.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await wi(e),"installed";try{if((await it.creator.getBalance()).availableBalance>=(e.priceCents??0)){const l=await it.purchases.payWithEarnings(e.id);if(l.ok||l.alreadyOwned)return t("installing"),await wi(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=window.open(n.checkoutUrl,"_blank","noopener");return new Promise((o,l)=>{const u=setInterval(async()=>{const d=r?r.closed:!1;try{if((await it.purchases.checkout(e.id)).alreadyOwned){clearInterval(u),t("installing");try{await wi(e),o("installed")}catch(h){l(h)}return}}catch{}if(d){clearInterval(u);try{if((await it.purchases.checkout(e.id)).alreadyOwned){t("installing"),await wi(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function AK({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:u}){const{t:d}=ft(["store"]),[m,h]=k.useState(!1),[p,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const W=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(W)}},[o,l]);const N=t?.installed??!1,T=N&&e.version&&t?.localVersion&&CK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await wi(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Z){const U=Z instanceof Error?Z.message:"";U.includes("402")||U.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},_=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await Og(e,U=>{U==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):U==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Z){g(Z instanceof Error?Z.message:d("card.failed"))}finally{h(!1)}}},O=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,z=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{N&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):N?s.jsxs("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):C&&!n?s.jsx("button",{onClick:W=>{_(W)},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?p||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",O]})}):s.jsx("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),p&&!(C&&!n)&&s.jsx("span",{className:`text-[10px] ${p===d("card.failed")||p===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:p})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(sa,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:it.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:N,glowing:y,onClick:D,actions:H})})}function y4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,u]=k.useState(`${h0(e,t)} Agent`),[d,m]=k.useState(""),[h,p]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>p(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await r(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsx("div",{className:"flex items-center gap-3 mb-5",children:s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold",children:o("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:o("hireModal.creating",{name:h0(e,t)})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.agentName")}),s.jsx("input",{type:"text",value:l,onChange:w=>u(w.target.value),className:"input-field",autoFocus:!0})]}),h.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:o("hireModal.noTeam")}),h.map(w=>s.jsx("option",{value:w.id,children:w.name},w.id))]})]}),s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:o("hireModal.agentConfig")}),s.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||o("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:o("hireModal.cancel")}),s.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function Yh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function v4(e,t){return e.i18n?.[t]?.description||e.description}function w4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function _K(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}function jK({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,[l,u]=k.useState(""),[d,m]=k.useState([]),[h,p]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[N,T]=k.useState(!0),[C,j]=k.useState(!1),[_,O]=k.useState(null),[z,D]=k.useState(new Map),[H,W]=k.useState(new Set),[Z,U]=k.useState(null),Y=k.useCallback(async()=>{try{const[F,J]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),B=new Map;for(const Q of F.artifacts){if(Q.type!=="team")continue;const re=!!J.installed[`team/${Q.name}`];B.set(Q.name,{installed:re,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(B)}catch{}},[]),se=k.useCallback(async()=>{T(!0);try{const F=l?it.search({type:"team",q:l,limit:50}):vi(Tr.hubTeams)??it.search({type:"team",limit:50}),[J,B]=await Promise.all([F.catch(()=>({items:[],total:0})),Ce.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),Y(),it.isAuthenticated()?it.purchases.mine().then(re=>W(new Set(re.purchases.map(ke=>ke.itemId)))).catch(()=>{}):Promise.resolve()]),Q=await E3(J?.items??[],e);p(Q.items),m(B?.templates??[]),Q.missing&&t?.()}catch{m([]),p([])}finally{T(!1)}},[l,Y,e,t]);k.useEffect(()=>{se()},[se]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>w(F.files??{})).catch(()=>w({}))},[g]);const X=async F=>{j(!0),O(null);try{const B=(await Ce.teams.create(F.name,F.description)).team.id;let Q,re=0;const ke=[];for(const G of F.members){const le=G.count??1;for(let I=0;I<le;I++){const Ee=G.name??`${F.name} Agent ${I+1}`,Ue=le>1?`${Ee} ${I+1}`:Ee,Oe=G.roleName??G.templateId;try{const We=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Ue,...Oe?{roleName:Oe}:{},orgId:"default",teamId:B,agentRole:G.role??"worker",skills:G.skills??[]})});if(We.ok){re++;const st=await We.json();G.role==="manager"&&!Q&&(Q=st.agent?.id)}else{const st=await We.json().catch(()=>({error:`HTTP ${We.status}`}));ke.push(`${Ue}: ${st.error??We.statusText}`)}}catch(We){ke.push(`${Ue}: ${String(We)}`)}}}Q&&await Ce.teams.update(B,{managerId:Q,managerType:"agent"}).catch(()=>{});const $=ke.length>0?` (${ke.length} failed: ${ke[0]})`:"";O({ok:re>0,message:`Team "${Yh(F,o)}" deployed with ${re} agent(s)${$}`})}catch(J){O({ok:!1,message:`Failed: ${J}`})}finally{j(!1)}};if(Z)return s.jsx(Ai,{type:Z.type,name:Z.name,onBack:()=>U(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const J={type:"team",name:g.id,displayName:Yh(g,o),version:g.version,description:v4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(Q=>({name:w4(g,Q.name??Q.roleName??Q.templateId??"Agent",o),role:Q.role??"worker",roleName:Q.roleName??Q.templateId,count:Q.count??1,skills:Q.skills??[]}))}},B=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),s.jsx("div",{className:"p-5 space-y-2",children:g.members.map((Q,re)=>{const ke=w4(g,Q.name??Q.roleName??Q.templateId??"Agent",o);return s.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${Q.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(ke[0]??"?").toUpperCase()}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-fg-primary font-medium",children:ke}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${Q.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:Q.role??"worker"}),(Q.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",Q.count]})]}),(Q.roleName||Q.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:Q.roleName??Q.templateId})]}),Q.skills&&Q.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[Q.skills.slice(0,3).map($=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:$},$)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},re)})})]});return s.jsx(s.Fragment,{children:s.jsx(Ai,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:J,contentSlot:B,actionSlot:s.jsxs(s.Fragment,{children:[_&&s.jsx("span",{className:`text-xs ${_.ok?"text-green-500":"text-red-500"}`,children:_.message}),s.jsx("button",{onClick:()=>{X(g)},disabled:C,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(C?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),s.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:F=>u(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:N?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,J)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},J))}):d.length===0&&h.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):s.jsxs(s.Fragment,{children:[d.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),s.jsx(Er,{columns:2,children:d.map(F=>s.jsx(sa,{type:"team",name:Yh(F,o),description:v4(F,o),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(F)},F.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Er,{columns:2,children:h.map(F=>s.jsx(MK,{item:F,localInfo:z.get(Cc(F)),purchased:Hd(F,H),onStatusChange:Y,highlight:F.id===e,onHighlightDone:t,onViewDetail:J=>U({type:"team",name:J})},F.id))})]})]})})]})}function MK({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:u}){const{t:d}=ft(["store"]),[m,h]=k.useState(!1),[p,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const W=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(W)}},[o,l]);const N=t?.installed??!1,T=N&&e.version&&t?.localVersion&&_K(e.version,t.localVersion),C=(e.priceCents??0)>0,j=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await wi(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Z){const U=Z instanceof Error?Z.message:"";U.includes("402")||U.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},O=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await Og(e,U=>{U==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):U==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Z){g(Z instanceof Error?Z.message:d("card.failed"))}finally{h(!1)}}},z=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{N&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):N?s.jsxs("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):C&&!n?s.jsx("button",{onClick:W=>{O(W)},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?p||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",j]})}):s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),p&&s.jsx("span",{className:`text-[10px] ${p===d("card.failed")||p===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:p})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(sa,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:it.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:N,glowing:y,onClick:D,actions:H})})}function Xh(e,t){return e.i18n?.[t]?.displayName||e.name}function Qh(e,t){return e.i18n?.[t]?.description||e.description||""}function A3(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}const RK={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 OK({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=ft(["store"]),[u,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",h=t.find(C=>C.name===e.name||C.name===m||!!e.slug&&C.name===e.slug),p=!!h,g=p&&e.version&&h?.version&&A3(e.version,h.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),N=async()=>{if(!u){d(!0),w("");try{await wi(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(C){const j=C instanceof Error?C.message:"";j.includes("402")||j.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!u){d(!0),w("");try{await Og(e,j=>{j==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):j==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(C){r(C instanceof Error?C.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.jsx("button",{onClick:()=>{N()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:u?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(p)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),h?.version?` (v${h.version})`:""]});if(x&&!n){const C=`$${((e.priceCents??0)/100).toFixed(2)}`;return s.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.jsx("button",{onClick:()=>{T()},disabled:u,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:u?y||l("card.installing"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",C]})})})}return s.jsx("button",{onClick:()=>{N()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(u?"card.installing":"card.install")})}function k4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:u,type:d="skill"}){const m=k.useRef(null),[h,p]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),p(!0);const y=setTimeout(()=>{p(!1)},4e3);return()=>clearTimeout(y)}},[l,u]);const g=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:h?"animate-pulse":"",children:s.jsx(sa,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Dd(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:it.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:x,actions:s.jsx(OK,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function DK({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,l=Bo(),[u,d]=k.useState("skills"),[m,h]=k.useState(null),[p,g]=k.useState(new Set),[x,y]=k.useState([]),[w,N]=k.useState(null),[T,C]=k.useState([]),[j,_]=k.useState(0),[O,z]=k.useState(1),[D,H]=k.useState([]),[W,Z]=k.useState(""),[U,Y]=k.useState("score"),[se,X]=k.useState(""),[F,J]=k.useState(!1),[B,Q]=k.useState([]),[re,ke]=k.useState(!1),[$,G]=k.useState([]),[le,I]=k.useState(""),[Ee,Ue]=k.useState(!1),[Oe,We]=k.useState([]),[st,dt]=k.useState([]),[Et,gt]=k.useState(new Set),[jt,Jt]=k.useState(!1),[Rt,be]=k.useState(""),Me=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],Ge=(V,ye="success")=>{h({text:V,type:ye}),setTimeout(()=>h(null),ye==="error"?1e4:4e3)},ot=k.useCallback(async()=>{try{const V=await Ce.skills.list();y(V.skills)}catch{}},[]),mt=k.useCallback(async()=>{ke(!0);try{const V=await Ce.skills.builtin();Q(V.skills)}catch{}ke(!1)},[]),ae=k.useCallback(async V=>{J(!0);try{const ye=await Ce.skills.registrySkillhub({q:V?.q,category:V?.category,page:V?.page??1,limit:24,sort:V?.sort??U});C(ye.skills),_(ye.total),ye.categories?.length&&H(ye.categories)}catch{}J(!1)},[U]),ze=k.useCallback(async V=>{Ue(!0);try{const ye=await Ce.skills.registrySkillssh(V);G(ye.skills)}catch{}Ue(!1)},[]),Xe=k.useCallback(async V=>{Jt(!0);try{const ye=V?it.search({type:"skill",q:V,limit:50}):vi(Tr.hubSkills)??it.search({type:"skill",limit:50}),Qe=it.search({subtype:"connector",q:V||void 0,limit:50}).catch(()=>({items:[]})),[he,ve]=await Promise.all([ye,Qe,it.isAuthenticated()?it.purchases.mine().then(xt=>gt(new Set(xt.purchases.map(Dt=>Dt.itemId)))).catch(()=>{}):Promise.resolve()]);let Ye=he?.items??[],nt=ve?.items??[];if(e){const xt=Ye.some(ct=>ct.id===e),Dt=nt.some(ct=>ct.id===e);if(!xt&&!Dt)try{const{item:ct}=await it.getItem(e);ct?.subtype==="connector"?nt=[ct,...nt]:ct?Ye=[ct,...Ye]:t?.()}catch{t?.()}else xt&&(Ye=[Ye.find(Xt=>Xt.id===e),...Ye.filter(Xt=>Xt.id!==e)]),Dt&&(nt=[nt.find(Xt=>Xt.id===e),...nt.filter(Xt=>Xt.id!==e)])}We(Ye),dt(nt)}catch{}Jt(!1)},[e,t]);k.useEffect(()=>{ot(),mt(),ae(),ze()},[]),k.useEffect(()=>{u==="skills"&&Xe(Rt)},[u,Rt,Xe]);const Ve=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"skillhub",slug:V.slug,sourceUrl:V.homepage,description:V.description_zh??V.description,category:"custom",version:V.version});await ot(),Ge(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Ge(`Download failed for "${V.name}". You can try manually from: ${V.homepage}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},et=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"skillssh",sourceUrl:V.url,githubRepo:`${V.author}/${V.repo}`,githubSkillPath:V.name});await ot(),Ge(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Ge(`Download failed for "${V.name}". You can try manually from: ${V.url}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},yt=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"builtin"});await ot(),await mt(),Ge(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ye){Ge(`Install failed for "${V.name}": ${ye}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},pe=$.filter(V=>{if(!le)return!0;const ye=le.toLowerCase();return V.name.toLowerCase().includes(ye)||V.repo.toLowerCase().includes(ye)});if(w){const V=w,ye={};V.instructions&&(ye["SKILL.md"]=V.instructions);const Qe={type:"skill",name:V.name,displayName:Xh(V,o),version:V.version,description:Qh(V,o),author:V.author??"",category:V.category??"general",tags:V.tags,files:ye,skill:{skillFile:V.instructions?"SKILL.md":"",requiredPermissions:V.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},he=V.installed&&V.installedVersion&&A3(V.version,V.installedVersion)?s.jsx("button",{onClick:()=>{yt(V)},disabled:p.has(V.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:p.has(V.name)?n("card.upgrading"):n("card.upgrade",{version:V.version})}):V.installed?s.jsxs("span",{className:"px-4 py-1.5 text-xs bg-green-500/10 text-green-500 rounded-lg border border-green-500/20 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),V.installedVersion?` v${V.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{yt(V)},disabled:p.has(V.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:p.has(V.name)?n("card.installing"):n("card.install")}),ve=s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[V.category&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),s.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${RK[V.category]??"bg-gray-500/15 text-fg-secondary"}`,children:V.category})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:V.version})]}),V.hasMcpServers&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),V.hasInstructions&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),s.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(V.requiredPermissions.length>0||V.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[V.requiredPermissions.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.requiredPermissions.map(Ye=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:Ye},Ye))})]}),V.tags.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.tags.map(Ye=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:Ye},Ye))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ai,{type:"skill",name:V.name,onBack:()=>N(null),readOnly:!0,initialManifest:Qe,actionSlot:he,contentSlot:ve}),m&&s.jsx("div",{className:`mx-7 mb-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[s.jsx("div",{className:"flex items-center h-14",children:s.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),s.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:Me.map(V=>s.jsx("button",{onClick:()=>d(V.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${u===V.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(V.labelKey)},V.id))})]}),m&&s.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text}),u==="skills"&&(()=>{const V=Rt.trim().toLowerCase(),ye=V?B.filter(ve=>Xh(ve,o).toLowerCase().includes(V)||Qh(ve,o).toLowerCase().includes(V)):B,Qe=re&&jt,he=ye.length===0&&Oe.length===0&&st.length===0;return s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{value:Rt,onChange:ve=>be(ve.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"}`})}),Qe&&he?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((ve,Ye)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Ye))}):he?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),s.jsx("div",{children:n("skillStore.noBuiltin")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:ye.length})})]}),s.jsx(Er,{columns:3,children:ye.map(ve=>s.jsx(sa,{type:"skill",name:Xh(ve,o),description:Qh(ve,o),seed:ve.name,icon:Dd(ve.name,ve.category),version:ve.version,category:ve.category,tags:ve.tags,authorLabel:ve.author||void 0,installed:ve.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:ve.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>N(ve)},ve.name))})]}),Oe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Er,{columns:3,children:Oe.map(ve=>s.jsx(k4,{item:ve,installedSkills:x,purchased:Hd(ve,Et),onMsg:Ge,onRefresh:()=>{ot(),Xe(Rt)},highlight:ve.id===e,onHighlightDone:t},ve.id))})]}),st.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"mb-3",children:[s.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),s.jsx(Er,{columns:3,children:st.map(ve=>s.jsx(k4,{item:ve,type:"connector",installedSkills:x,purchased:Hd(ve,Et),onMsg:Ge,onRefresh:()=>{ot(),Xe(Rt)},highlight:ve.id===e,onHighlightDone:t},ve.id))})]})]})]})})(),u==="skillhub"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsxs("select",{value:W,onChange:V=>{Z(V.target.value),z(1),ae({q:se||void 0,category:V.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),D.map(V=>s.jsx("option",{value:V,children:V},V))]}),s.jsxs("select",{value:U,onChange:V=>{Y(V.target.value),z(1),ae({q:se||void 0,category:W||void 0,page:1,sort:V.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"score",children:n("skillStore.sortScore")}),s.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),s.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),s.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),s.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[s.jsx("input",{value:se,onChange:V=>X(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(z(1),ae({q:se||void 0,category:W||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),s.jsx("button",{onClick:()=>{z(1),ae({q:se||void 0,category:W||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),s.jsx("div",{children:n("skillStore.noSkillhub")})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:j.toLocaleString()})}),s.jsx(Er,{columns:3,children:T.map(V=>{const ye=x.some(Qe=>Qe.name===V.name||Qe.name===V.slug);return s.jsx(sa,{type:"skill",name:V.name,description:V.description_zh??V.description??"",seed:V.slug,icon:Dd(V.slug||V.name,V.tags?.[0]),version:V.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:V.tags,installed:ye,hideStats:!0,onClick:()=>window.open(V.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[V.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",V.stars.toLocaleString()]}),V.downloads>0&&s.jsxs("span",{children:[V.downloads>=1e4?`${(V.downloads/1e4).toFixed(1)}万`:V.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ye?void 0:s.jsx("button",{onClick:()=>{Ve(V)},disabled:p.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:p.has(V.name)?"...":n("card.install")})},V.slug)})}),j>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:O<=1,onClick:()=>{const V=O-1;z(V),ae({q:se||void 0,category:W||void 0,page:V})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.prevPage")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:O,total:Math.ceil(j/24)})}),s.jsx("button",{disabled:O>=Math.ceil(j/24),onClick:()=>{const V=O+1;z(V),ae({q:se||void 0,category:W||void 0,page:V})},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")})]})]})]}),u==="skillssh"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[s.jsx("input",{value:le,onChange:V=>I(V.target.value),onKeyDown:V=>{V.key==="Enter"&&le.trim()&&ze(le)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),s.jsx("button",{onClick:()=>{le.trim()&&ze(le)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ee?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):pe.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),s.jsx("div",{children:n("skillStore.browseSkillssh")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):s.jsx(Er,{columns:3,children:pe.map(V=>{const ye=x.some(Qe=>Qe.name===V.name);return s.jsx(sa,{type:"skill",name:V.name,description:V.description||"",seed:`${V.author}-${V.name}`,icon:Dd(V.name),authorLabel:`${V.author}/${V.repo}`,showTypeBadge:!1,installed:ye,hideStats:!0,cornerLabel:ye?void 0:"skills.sh",onClick:()=>window.open(V.url,"_blank","noopener,noreferrer"),footerLeft:V.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[V.installs," installs"]}):void 0,actions:ye?void 0:s.jsx("button",{onClick:()=>{et(V)},disabled:p.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:p.has(V.name)?"...":n("card.install")})},`${V.author}-${V.name}`)})})]})]})}const LK=["agent","team","skill","connector"];function Zh({title:e,subtitle:t,onMore:n,moreLabel:r}){return s.jsxs("div",{className:"flex items-end justify-between mb-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"section-title",children:e}),t&&s.jsx("p",{className:"section-subtitle",children:t})]}),n&&s.jsxs("button",{className:"section-link",onClick:n,children:[r??"View all"," →"]})]})}function IK({item:e,onOpen:t}){const n=Ko(e.subtype==="connector"?"connector":e.itemType),r=Rg(n,e.slug||e.name),o=Ti[n];return s.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:r},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),s.jsx("svg",{className:"absolute -right-8 -bottom-10 opacity-20",width:"220",height:"220",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",fill:"white"})}),s.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[s.jsxs("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:["★ Featured · ",o.label]}),s.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),s.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(f0,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:it.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),s.jsxs("span",{children:["↓ ",Ao(e.downloadCount)]}),(e.priceCents??0)>0?s.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):s.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function S4({items:e,onOpen:t}){return s.jsx(Er,{columns:3,children:e.map(n=>s.jsx(sa,{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:it.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 N4(){return s.jsx(Er,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function PK({onOpenType:e}){const{t}=ft(["store","common"]),[n,r]=k.useState([]),[o,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await it.search({limit:60,sort:"popular"});g||r(x.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const u=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),h=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),p=g=>e(Ko(g.subtype==="connector"?"connector":g.itemType),g.id);return s.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[s.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),s.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:LK.map(g=>s.jsxs("button",{onClick:()=>e(g),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Ti[g].gradient} hover:opacity-90 transition-opacity`,children:[Ti[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ti[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):u.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:u.map(g=>s.jsx(IK,{item:g,onOpen:()=>p(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(N4,{}):d.length>0?s.jsx(S4,{items:d,onOpen:p}):s.jsx(zK,{})]}),s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(N4,{}):m.length>0?s.jsx(S4,{items:m,onOpen:p}):null]}),h.length>0&&s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:h.map((g,x)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(f0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:it.getUrl(),size:48,verified:x<3}),x<3&&s.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:x+1})]}),s.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),s.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",Ao(g.downloads)]})]},g.author?.username||x))})]})]})}function zK(){const{t:e}=ft(["store"]);return s.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[s.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),s.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),s.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Sd(e,t,n){return e.i18n?.[n]?.[t]}function BK(){const{t:e,i18n:t}=ft(["store","common"]),n=Bo(),r=t.language,[o,l]=k.useState([]),[u,d]=k.useState({}),[m,h]=k.useState(new Set),[p,g]=k.useState(null),[x,y]=k.useState(!0),[w,N]=k.useState(""),[T,C]=k.useState("all"),[j,_]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[H,W,Z,U]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}})),Ce.skills.updates().catch(()=>({updates:[],count:0})),Ce.skills.builtin().catch(()=>({skills:[]}))]),Y={};for(const F of Z.updates)Y[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(Y);const se=H.artifacts.filter(F=>{const J=`${F.type}/${F.name}`;return!!W.installed[J]}),X=new Set(se.filter(F=>F.type==="skill").map(F=>F.name));for(const F of U.skills)!F.installed||X.has(F.name)||!(W.installed[`skill/${F.name}`]||Y[F.name])&&!F.updateAvailable||!W.installed[`skill/${F.name}`]&&!Y[F.name]||(se.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[r]?.displayName||F.name,description:F.i18n?.[r]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),X.add(F.name));for(const[F,J]of Object.entries(Y))X.has(F)||(se.push({type:"skill",name:F,meta:{displayName:J.displayName||F,description:J.description||"",version:J.installedVersion},path:"",updatedAt:""}),X.add(F));l(se)}catch{}y(!1)},[r]);k.useEffect(()=>{O()},[O]),k.useEffect(()=>{const H=()=>{O()};return window.addEventListener("markus:data-changed",H),()=>window.removeEventListener("markus:data-changed",H)},[O]),k.useEffect(()=>{if(!p)return;const H=setTimeout(()=>g(null),3e3);return()=>clearTimeout(H)},[p]);const z=async(H,W)=>{if(!m.has(H)){h(Z=>new Set(Z).add(H));try{await Ce.skills.install({name:H,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:H,version:W}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:H}),type:"error"})}h(Z=>{const U=new Set(Z);return U.delete(H),U})}},D=o.filter(H=>{if(T!=="all"&&H.type!==T)return!1;if(!w)return!0;const W=w.toLowerCase(),Z=(Sd(H.meta,"displayName",r)||H.meta.displayName||H.name).toLowerCase(),U=(Sd(H.meta,"description",r)||H.meta.description||"").toLowerCase();return Z.includes(W)||U.includes(W)}).sort((H,W)=>{const Z=H.type==="skill"&&u[H.name]?1:0;return(W.type==="skill"&&u[W.name]?1:0)-Z});return j?s.jsx(Ai,{type:j.type,name:j.name,onBack:()=>_(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(u).length>0&&s.jsxs("span",{className:"px-2 py-0.5 text-[11px] font-medium rounded-md bg-amber-500/15 text-amber-600 border border-amber-500/25",children:[e("installedTab.updateAvailable")," · ",Object.keys(u).length]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[s.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(H=>s.jsx("button",{onClick:()=>C(H),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===H?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${H==="all"?"All":H==="agent"?"Agents":H==="team"?"Teams":"Skills"}`)},H))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:H=>N(H.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):D.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Er,{columns:3,children:D.map(H=>{const W=Sd(H.meta,"displayName",r)||H.meta.displayName||H.name,Z=Sd(H.meta,"description",r)||H.meta.description||"",U=H.meta.version||"",Y=H.meta.author||"",se=H.meta.tags??[],X=H.meta.category||"",F=H.meta.icon,J=H.type==="skill"?u[H.name]:void 0;return s.jsx(sa,{type:H.type,name:W,description:Z,seed:H.name,icon:F,author:null,authorLabel:Y||void 0,version:J?J.installedVersion:U,category:X,tags:se,installed:!J,hideStats:!0,cornerLabel:J?e("installedTab.updateAvailable"):void 0,onClick:()=>{H.path&&_({type:H.type,name:H.name})},actions:J?s.jsx("button",{type:"button",disabled:m.has(H.name),onClick:()=>{z(H.name,J.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(H.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:J.availableVersion})}):void 0},`${H.type}/${H.name}`)})})}),p&&s.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-sm shadow-lg ${p.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:p.text})]})}const UK=50,$K=30;function HK(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),u=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const h=m.changedTouches[0].clientX-o.current,p=m.changedTouches[0].clientY-l.current,g=Math.abs(h),x=Math.abs(p);if(g<UK||Math.atan2(x,g)*(180/Math.PI)>$K)return;if(r?.scrollContainerRef?.current){const N=r.scrollContainerRef.current,T=N.scrollLeft<=1,C=N.scrollLeft+N.clientWidth>=N.scrollWidth-1;if(h>0&&!T||h<0&&!C)return}const w=e.findIndex(N=>N.id===t);h<0&&w<e.length-1?n(e[w+1].id):h>0&&w>0?n(e[w-1].id):h>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():h<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:u,onTouchEnd:d}}const FK=["builder","discover","agents","teams","skills","installed"],qK={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function qp(e){return!!e&&FK.includes(e)}function C4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:qp(t)?t:"builder",installId:e}}function GK({authUser:e}){const{t}=ft(["nav","store","common"]),n=k.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[r]=k.useState(C4),[o,l]=k.useState(r.tab),[u,d]=k.useState(r.installId),m=HK(n,o,l);k.useEffect(()=>{const p=C4();p.installId&&(d(p.installId),qp(p.tab)&&l(p.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const p=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");qp(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",p),()=>window.removeEventListener("markus:navigate",p)},[]);const h=(p,g)=>{g&&d(g),l(qK[p]??"agents")};return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[s.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[s.jsx(o5,{className:"ml-2"}),n.map(p=>s.jsx("button",{onClick:()=>l(p.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${o===p.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:p.label},p.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(C3,{authUser:e}),o==="discover"&&s.jsx(PK,{onOpenType:h}),o==="agents"&&s.jsx(EK,{authUser:e,highlightItemId:u,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(jK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(DK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(BK,{})]})]})}const T4="usageType",Jh="profile";function VK({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=ft(["onboarding","common"]),[u,d]=k.useState(0),[m,h]=k.useState(""),[p,g]=k.useState(""),[x,y]=k.useState(""),[w,N]=k.useState(""),[T,C]=k.useState(!1),[j,_]=k.useState(""),[O,z]=k.useState(!1),[D,H]=k.useState(null);k.useEffect(()=>{Ce.auth.me().then(({user:be})=>{be.name&&h(be.name),be.email&&g(be.email),be.avatarUrl&&H(be.avatarUrl);const Me=be.name||be.email?.split("@")[0]||"";Me&&Y(Ge=>Ge||l("usageType.defaultOrgName",{name:Me}))}).catch(()=>{}),Ce.settings.getOrg().then(({org:be})=>{be?.name&&be.name!=="My Organization"&&Y(be.name)}).catch(()=>{}),yn()&&Ce.hubOrgs.invitations().then(be=>{be.invitations?.length>0&&ke(be.invitations)}).catch(()=>{})},[]);const[W,Z]=k.useState(null),[U,Y]=k.useState(""),[se,X]=k.useState(!1),[F,J]=k.useState(!1),[B,Q]=k.useState(""),[re,ke]=k.useState([]),[$,G]=k.useState(null),[le,I]=k.useState(null),Ee=async()=>{const be=U.trim();if(be){X(!0),Q("");try{if(await Ce.settings.updateOrg(be),yn()){const Me=await Ce.hubOrgs.mine(),Ge=Me.orgs?.find(ot=>ot.role==="owner")??Me.orgs?.[0];Ge?.id?await Ce.hubOrgs.update(Ge.id,{name:be}):await Ce.hubOrgs.create(be)}J(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{X(!1)}}},[Ue,Oe]=k.useState(!0),We=async()=>{if(_(""),!m.trim()){_(l("profile.errors.nameRequired"));return}if(!p.trim()){_(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p.trim())){_(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){_(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){_(l("profile.errors.passwordMismatch"));return}C(!0);try{const{user:be}=await Ce.auth.updateProfile(m.trim(),p.trim());x&&await Ce.auth.changePassword("",x),o?.(be),z(!0)}catch{_(l("profile.errors.saveFailed"))}finally{C(!1)}},st=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],dt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:s.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:s.jsx(R7,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:T4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>{Z("personal"),J(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${W==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"👤"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),s.jsxs("button",{onClick:()=>{Z("organization"),J(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${W==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"🏢"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),W==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[re.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),re.map(be=>s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:be.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:be.invitedBy})})]}),s.jsx("button",{onClick:async()=>{G(be.orgId);try{await Ce.hubOrgs.acceptInvitation(be.orgId),I(be.orgId),J(!0)}catch{}finally{G(null)}},disabled:$===be.orgId||le===be.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:le===be.orgId?l("usageType.accepted"):$===be.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},be.orgId)),s.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),s.jsx("input",{type:"text",value:U,onChange:be=>{Y(be.target.value),J(!1),Q("")},placeholder:l("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),B&&s.jsx("p",{className:"text-xs text-red-500",children:B}),s.jsx("button",{onClick:()=>{Ee()},disabled:se||!U.trim()||F,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(se?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:Jh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:O?s.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[s.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",p]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(i5,{currentUrl:D,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange:be=>h(be.target.value),placeholder:l("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",value:p,onChange:be=>g(be.target.value),placeholder:l("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),s.jsx("input",{type:"password",value:x,onChange:be=>y(be.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),x&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),s.jsx("input",{type:"password",value:w,onChange:be=>N(be.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"})]}),j&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:j}),s.jsx("button",{onClick:()=>{We()},disabled:T||!m.trim()||!p.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(T?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"grid grid-cols-3 gap-3",children:st.map(be=>s.jsxs("button",{onClick:()=>n(be.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===be.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:be.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:be.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:be.desc})]},be.value))}),s.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[s.jsx("input",{type:"checkbox",checked:Ue,onChange:be=>Oe(be.target.checked),className:"accent-brand-500 shrink-0"}),s.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],Et=r?dt.filter(be=>be.id!==Jh):dt,gt=Et.findIndex(be=>be.id===T4),jt=Et.findIndex(be=>be.id===Jh),Jt=()=>{u===gt&>>=0&&!W||u===gt&&W==="organization"&&!F||u===jt&&jt>=0&&!O||(u<Et.length-1?d(u+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})}).catch(()=>{}),e()))},Rt=Et[u];return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:s.jsx("div",{className:"w-full max-w-lg",children:s.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[s.jsx("div",{className:"flex gap-1.5 mb-8",children:Et.map((be,Me)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Me<=u?"bg-brand-500":"bg-surface-elevated"}`},Me))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:Rt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:Rt.subtitle}),Rt.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[u>0?s.jsx("button",{onClick:()=>d(u-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):s.jsx("span",{}),s.jsx("button",{onClick:Jt,disabled:jt>=0&&u===jt&&!O||gt>=0&&u===gt&&(!W||W==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${jt>=0&&u===jt&&!O||gt>=0&&u===gt&&(!W||W==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:u===Et.length-1?l("getStarted"):l("common:next")})]})]})})})}const KK="markus:legal-consent",WK="https://markus.global";function YK({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=ft("auth"),[o,l]=k.useState(null),[u,d]=k.useState(""),[m,h]=k.useState(!1),[p,g]=k.useState(""),[x,y]=k.useState(""),[w,N]=k.useState(!1),[T,C]=k.useState(!1),j=Z=>{const U=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${WK}${Z}${U}`},_=()=>{try{localStorage.setItem(KK,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(_(),!0):(N(!1),requestAnimationFrame(()=>N(!0)),!1),z=async(Z,U=!1)=>{if(!(!U&&!O())){d(""),l(Z??"hub");try{await na(Z);const Y=yn(),se=ua();if(!Y||!se){d(n("login.hubUnavailable"));return}const{user:X,needsOnboarding:F}=await Ce.auth.hubLogin(Y,se);e(X,F??!1,{fromHub:!0})}catch(Y){const se=Y instanceof Error?Y.message:"";if(!se.includes("cancelled")){if(!U&&yn())return Ni(),z(Z,!0);d(se||n("login.hubUnavailable"))}}finally{l(null)}}};k.useEffect(()=>{const Z=window.markusDesktop;if(!Z?.consumePendingDeepLinkAuth)return;let U=!1;return Z.consumePendingDeepLinkAuth().then(async Y=>{if(!(U||!Y)&&T){d(""),l("hub");try{const se=await eD(Y),X=yn(),F=ua();if(!se||!X||!F){d(n("login.hubUnavailable"));return}const{user:J,needsOnboarding:B}=await Ce.auth.hubLogin(X,F);e(J,B??!1,{fromHub:!0})}catch{d(n("login.hubUnavailable"))}finally{U||l(null)}}}).catch(()=>{}),()=>{U=!0}},[]);const D=async Z=>{if(Z.preventDefault(),!(!p.trim()||!x)&&O()){d(""),l("local");try{const{user:U,needsOnboarding:Y}=await Ce.auth.login(p.trim(),x);e(U,Y??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},H=n(t?"login.welcomeBack":"login.getStarted"),W="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[s.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute -top-48 left-1/2 -translate-x-1/2 h-[42rem] w-[42rem] rounded-full bg-brand-500/20 blur-[120px]"}),s.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),s.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),s.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-16 h-16 mx-auto mb-4 rounded-2xl shadow-xl shadow-brand-900/20 ring-1 ring-border-default/40"}),s.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:H})]}),s.jsx("div",{className:"bg-surface-secondary/70 backdrop-blur-xl border border-border-default/80 rounded-3xl p-7 sm:p-8 shadow-2xl shadow-black/10",children:m?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),s.jsxs("form",{onSubmit:D,className:"space-y-3",children:[s.jsx("input",{type:"email",value:p,onChange:Z=>g(Z.target.value),autoComplete:"email",autoFocus:!0,placeholder:n("login.email"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),s.jsx("input",{type:"password",value:x,onChange:Z=>y(Z.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}),u&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:u}),!t&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!p||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(o==="local"?"login.signingIn":"login.signIn")})]}),s.jsx("div",{className:"text-center",children:s.jsx("button",{onClick:()=>{h(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("button",{onClick:()=>z("google"),disabled:!!o,className:W,children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),s.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),s.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),s.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),n(o==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>z("github"),disabled:!!o,className:W,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),n(o==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>z("email"),disabled:!!o,className:W,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(o==="email"?"login.connectingHub":"login.withEmail")]}),u&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:u}),s.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[s.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),s.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),s.jsx("button",{onClick:()=>{h(!0),d("")},disabled:!!o,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),s.jsxs("label",{onAnimationEnd:()=>N(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[s.jsx("input",{type:"checkbox",checked:T,onChange:Z=>{C(Z.target.checked),Z.target.checked&&N(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),s.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",s.jsx("a",{href:j("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",s.jsx("a",{href:j("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),s.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[s.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),s.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function XK({token:e,onComplete:t}){const{t:n}=ft("auth"),[r,o]=k.useState(null),[l,u]=k.useState(""),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[N,T]=k.useState(!1);k.useEffect(()=>{Ce.auth.inviteInfo(e).then(j=>o(j)).catch(()=>T(!0))},[e]);const C=async j=>{if(j.preventDefault(),p(""),l.length<6){p(n("invite.passwordMinLength"));return}if(l!==d){p(n("invite.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{p(n("invite.error"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),s.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:N?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),s.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):r?s.jsxs("form",{onSubmit:C,className:"space-y-5",children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:r.name})}),s.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:r.email}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),s.jsx("input",{type:"password",value:l,onChange:j=>u(j.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),s.jsx("input",{type:"password",value:d,onChange:j=>m(j.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})]}),h&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:h}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(g?"invite.settingUp":"invite.setupAccount")})]}):s.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function QK({onComplete:e,isFirstTime:t}){const{t:n}=ft("auth"),[r,o]=k.useState(""),[l,u]=k.useState(""),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),p(""),l.length<6){p(n("changePassword.passwordMinLength"));return}if(l!==d){p(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.changePassword(r,l),e()}catch{p(n("changePassword.failedToChange"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),s.jsxs("form",{onSubmit:y,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&s.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:r,onChange:w=>o(w.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),s.jsx("input",{type:"password",value:l,onChange:w=>u(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),s.jsx("input",{type:"password",value:d,onChange:w=>m(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),h&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:h}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:n(g?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}function ZK({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[u,d]=k.useState(()=>{try{const N=localStorage.getItem(`${l}_w`);if(N)return Math.max(n,Math.min(r,parseInt(N,10)))}catch{}return t}),[m,h]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),p=k.useRef(!1),g=k.useRef(n),x=k.useRef(r);g.current=n,x.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(u))}catch{}},[u,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(N=>Math.max(n,Math.min(r,N)))},[n,r]);const y=k.useCallback(N=>{N.preventDefault(),p.current=!0;const T=N.clientX,C=u,j=O=>{if(!p.current)return;const z=e==="left"?O.clientX-T:T-O.clientX;d(Math.max(g.current,Math.min(x.current,C+z)))},_=()=>{p.current=!1,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",_),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",j),document.addEventListener("mouseup",_),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[u,e]),w=k.useCallback(()=>h(N=>!N),[]);return{width:m?o:u,rawWidth:u,collapsed:m,toggle:w,setCollapsed:h,setWidth:d,onResizeStart:y}}const LW=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Gp="markus-theme";function E4(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 JK(){try{const e=localStorage.getItem(Gp);if(e==="midnight")return localStorage.setItem(Gp,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function eW(){const[e,t]=k.useState(JK),n=k.useCallback(r=>{t(r);try{localStorage.setItem(Gp,r)}catch{}E4(r)},[]);return k.useEffect(()=>{E4(e)},[e]),{mode:e,setMode:n}}const Id={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},tW={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},nW=["agents","tasks","requirements","projects","deliverables","workflows"];let A4="",_4="all",j4=Id,M4=!1;function rW({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);zo(!0);const[r,o]=k.useState(A4),[l,u]=k.useState(_4),[d,m]=k.useState(j4),[h,p]=k.useState(!1),[g,x]=k.useState(M4),[y,w]=k.useState(-1);k.useEffect(()=>{A4=r},[r]),k.useEffect(()=>{_4=l},[l]),k.useEffect(()=>{j4=d},[d]),k.useEffect(()=>{M4=g},[g]);const N=k.useRef(null),T=k.useRef(void 0),C=k.useRef(null),j=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{N.current?.focus(),N.current?.select()},100)},[]);const _=k.useCallback(async X=>{if(!X.trim()){m(Id),x(!1),w(-1);return}p(!0),x(!0),w(-1);const F=X.toLowerCase();try{const[J,B,Q,re,ke,$]=await Promise.allSettled([Ce.agents.list(),Ce.tasks.list({search:X,pageSize:20}),Ce.requirements.list(),Ce.projects.list(),Ce.deliverables.search({q:X,limit:20}),Ce.teams.list()]),G=J.status==="fulfilled"?J.value.agents.filter(We=>We.name?.toLowerCase().includes(F)||We.role?.toLowerCase().includes(F)):[],le=B.status==="fulfilled"?B.value.tasks:[],I=Q.status==="fulfilled"?Q.value.requirements.filter(We=>We.title?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],Ee=re.status==="fulfilled"?re.value.projects.filter(We=>We.name?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],Ue=ke.status==="fulfilled"?ke.value.results:[],Oe=[];if($.status==="fulfilled"){const We=await Promise.allSettled($.value.teams.map(st=>Ce.workflows.list(st.id)));for(const st of We)if(st.status==="fulfilled")for(const dt of st.value.workflows)(dt.name.toLowerCase().includes(F)||(dt.displayName||"").toLowerCase().includes(F)||dt.description?.toLowerCase().includes(F))&&Oe.push(dt)}m({agents:G,tasks:le,requirements:I,projects:Ee,deliverables:Ue,workflows:Oe})}catch{m(Id)}finally{p(!1)}},[]),O=X=>{o(X),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>_(X),400)},z=k.useCallback((X,F)=>{e(),at.navigate(X,F)},[e]),D=[{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:"工作流"})}],H=k.useMemo(()=>tW[t||""]||nW,[t]),W=k.useMemo(()=>{const X=[],F=l==="all"?8:void 0,J=B=>{if(l!=="all"&&l!==B)return;const Q=d[B].length;if(B==="workflows"){const re=F?d.workflows.slice(0,F):d.workflows;for(const ke of re)X.push({id:ke.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const re=d[B],ke=F?re.slice(0,F):re;for(const $ of ke)switch(B){case"agents":X.push({id:$.id,type:"agent",page:me.TEAM,params:{agentId:$.id}});break;case"tasks":X.push({id:$.id,type:"task",page:me.WORK,params:{openTask:$.id}});break;case"requirements":X.push({id:$.id,type:"requirement",page:me.WORK,params:{openRequirement:$.id}});break;case"projects":X.push({id:$.id,type:"project",page:me.WORK,params:{projectId:$.id}});break;case"deliverables":X.push({id:$.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:$.id}});break}}F&&Q>F&&X.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:Q})};for(const B of H)J(B);return X},[d,l,H]),Z=k.useCallback(X=>{if(X.type==="showMore"&&X.expandCategory){u(X.expandCategory),w(-1);return}z(X.page,X.params)},[z]);k.useEffect(()=>{const X=j.current;if(!X||y<0)return;const F=X.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const U=k.useCallback(X=>{if(X.key==="Escape"){e();return}if(X.key==="Tab"){X.preventDefault();const B=D.map(ke=>ke.id),Q=B.indexOf(l),re=X.shiftKey?Q<=0?B.length-1:Q-1:Q>=B.length-1?0:Q+1;u(B[re]),w(-1);return}const F=X.ctrlKey&&X.key==="n"||X.key==="ArrowDown",J=X.ctrlKey&&X.key==="p"||X.key==="ArrowUp";if(F||J){X.preventDefault(),w(B=>{const Q=W.length-1;return Q<0?-1:F?B>=Q?0:B+1:B<=0?Q:B-1});return}X.key==="Enter"&&(X.preventDefault(),y>=0&&y<W.length&&Z(W[y]))},[e,W,y,Z,D,l]);k.useEffect(()=>(document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)),[U]);const Y=W.length>0;let se=0;return s.jsx("div",{ref:C,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:X=>{X.target===C.current&&e()},children:s.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[s.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("input",{ref:N,value:r,onChange:X=>O(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"}),r&&s.jsx("button",{onClick:()=>{o(""),m(Id),x(!1),w(-1),N.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(X=>s.jsx("button",{onClick:()=>{u(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-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:X.label},X.id))})]}),s.jsxs("div",{ref:j,className:"flex-1 overflow-y-auto px-5 py-3",children:[h&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!h&&g&&!Y&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&Y&&s.jsx("div",{className:"space-y-4",children:H.map(X=>{if(l!=="all"&&l!==X)return null;const F=l==="all"?8:void 0,J=B=>{const Q=se++,re=B==="agents"?d.agents.length:B==="tasks"?d.tasks.length:B==="requirements"?d.requirements.length:B==="projects"?d.projects.length:B==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{u(B),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",re,")"]})};return X==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.agents.slice(0,F):d.agents).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.TEAM,{agentId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Us,{name:B.name||"Agent",avatarUrl:B.avatarUrl,size:28}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:B.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.role||B.status})]}),s.jsx(aW,{status:B.status})]},B.id)})}),F&&d.agents.length>F&&J("agents")]},"agents"):X==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.tasks.slice(0,F):d.tasks).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{openTask:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(sW,{status:B.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.id)})}),F&&d.tasks.length>F&&J("tasks")]},"tasks"):X==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.requirements.slice(0,F):d.requirements).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{openRequirement:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${B.status==="approved"?"text-green-500 bg-green-500/15":B.status==="pending"?"text-amber-500 bg-amber-500/15":B.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),s.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.id)})}),F&&d.requirements.length>F&&J("requirements")]},"requirements"):X==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.projects.slice(0,F):d.projects).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{projectId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:s.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.name}),B.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.description})]})]},B.id)})}),F&&d.projects.length>F&&J("projects")]},"projects"):X==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.deliverables.slice(0,F):d.deliverables).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.DELIVERABLES,{openDeliverable:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.type," · ",B.status]})]})]},B.id)})}),F&&d.deliverables.length>F&&J("deliverables")]},"deliverables"):X==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.workflows.slice(0,F):d.workflows).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.displayName||B.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.stepCount," steps · v",B.version]})]})]},B.name)})}),F&&d.workflows.length>F&&J("workflows")]},"workflows"):null})}),!h&&!g&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),s.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",n("common:toggle",{defaultValue:"唤起/关闭"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",n("common:switchTab",{defaultValue:"切换分类"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",n("common:navigate",{defaultValue:"导航"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",n("common:open",{defaultValue:"打开"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",n("common:close",{defaultValue:"关闭"})]})]})]})})}function aW({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function sW({status:e}){const t=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M9 11l3 3L22 4"}),s.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function iW({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=ft("common");zo(!0);const[l,u]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[h,p]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>a5(e.avatarUrl,ua()?.avatarUrl)),N=async T=>{if(T.preventDefault(),!l.trim()){x(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(o("profile.invalidEmail"));return}p(!0),x("");try{const{user:C}=await Ce.auth.updateProfile(l.trim(),d.trim());n({...C,avatarUrl:y??C.avatarUrl})}catch{x(o("profile.failedToSave"))}finally{p(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:s.jsxs("form",{onSubmit:N,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold mb-5",children:o("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(i5,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{w(T),r?.({...e,avatarUrl:T})}})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.name")}),s.jsx("input",{value:l,onChange:T=>u(T.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.email")}),s.jsx("input",{value:d,onChange:T=>m(T.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),g&&s.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:g})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:o("cancel")}),s.jsx("button",{type:"submit",disabled:h,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(h?"saving":"save")})]})]})})}const R4=k.lazy(()=>qr(()=>import("./Team-DqWZbYHu.js"),__vite__mapDeps([2,3,4,5])).then(e=>({default:e.TeamPage}))),O4=k.lazy(()=>qr(()=>import("./Settings-Dj0A3wpa.js"),[]).then(e=>({default:e.Settings}))),oW=k.lazy(()=>qr(()=>import("./Store-CVUJt0ed.js"),[]).then(e=>({default:e.StorePage}))),lW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>NK),void 0).then(e=>({default:e.AgentBuilder}))),D4=k.lazy(()=>qr(()=>import("./Work-DzPfAazv.js"),__vite__mapDeps([6,4,1,7,3,8])).then(e=>({default:e.WorkPage}))),L4=k.lazy(()=>qr(()=>import("./Deliverables-Bsyrqm3g.js"),__vite__mapDeps([9,4,5])).then(e=>({default:e.DeliverablesPage}))),cW=k.lazy(()=>qr(()=>import("./Notifications-BtdaN4ll.js"),[]).then(e=>({default:e.NotificationsPage}))),uW=k.lazy(()=>qr(()=>import("./Search-D-RYozg1.js"),[]).then(e=>({default:e.SearchPage}))),dW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function mW(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Ce.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function fW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const hW=k.memo(function({id:t,activePage:n,children:r}){const o=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:o?void 0:dW,children:s.jsx(k.Suspense,{fallback:s.jsx(fW,{}),children:r})})},(e,t)=>{const n=e.id===e.activePage,r=t.id===t.activePage;return n!==r?!1:r?e.children===t.children:!0}),Nd={};function _3(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?Q4[e]??e:e}function I4(){return _3(lc())}function pW(){const{t:e}=ft("common"),[t,n]=k.useState(I4),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,u]=k.useState(!0),d=Bo(),m=eW(),h=ZK({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[p,g]=k.useState(()=>new Set([I4()])),[x,y]=k.useState("loading"),[w,N]=k.useState(!1),[T,C]=k.useState(null),[j,_]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[O,z]=k.useState(!1),[D,H]=k.useState(!1),[W,Z]=k.useState(null),[U,Y]=k.useState(!1),[se,X]=k.useState(null),[F,J]=k.useState(()=>{const be=localStorage.getItem("markus_update_dismissed");return be||null}),[B,Q]=k.useState(!1),re=z0(),ke=re?.leftCollapsed??!1,$=re?.toggleLeftCollapsed,G=re?.toggleRightPanel,le=re?.openRightPanel,I=re?.closeRightPanelTab,Ee=re?.updateRightPanelBrowserTab,Ue=k.useRef(re?.rightPanelTabs);Ue.current=re?.rightPanelTabs,k.useEffect(()=>{const be=window.markusDesktop?.browser?.onPageEvent;if(!(!be||!le))return be(Me=>{if(Me.type==="closed"){const Ge=Ue.current?.find(ot=>ot.payload.kind==="url"&&ot.payload.browserId===Me.browserId);Ge&&I&&I(Ge.id);return}if(Me.type==="navigated"){Me.browserId&&Ee&&Ee(Me.browserId,{url:Me.url,title:Me.title||Me.url});return}if(Me.type==="opened"||Me.type==="selected"){if(!Me.url&&!Me.browserId||Me.browserId.startsWith("eb_")&&Me.type==="opened")return;le({kind:"url",url:Me.url||"about:blank",title:Me.title||Me.url||"Browser",browserId:Me.browserId,pageId:Me.pageId})}})},[le,I,Ee]);const Oe=re?.rightPanelOpen??!1;k.useLayoutEffect(()=>{const be=t===me.TEAM&&Oe;Jf(be)},[t,Oe]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const We=k.useRef(!1);k.useEffect(()=>{if(!We.current){We.current=!0;return}h.setCollapsed(ke)},[ke,h.setCollapsed]),k.useEffect(()=>{if(d)return;const be=navigator.platform.toUpperCase().includes("MAC"),Me=ot=>{be&&ot.metaKey&&!ot.ctrlKey&&ot.key==="p"?(ot.preventDefault(),Q(mt=>!mt)):!be&&ot.ctrlKey&&!ot.metaKey&&ot.key==="p"&&(ot.preventDefault(),Q(mt=>!mt))},Ge=()=>Q(!0);return document.addEventListener("keydown",Me),window.addEventListener("markus:open-search",Ge),()=>{document.removeEventListener("keydown",Me),window.removeEventListener("markus:open-search",Ge)}},[d]),k.useEffect(()=>{if(d||!$||!G)return;const be=navigator.platform.toUpperCase().includes("MAC"),Me=Ge=>{if(!(be?Ge.metaKey&&!Ge.ctrlKey:Ge.ctrlKey&&!Ge.metaKey)||Ge.altKey||Ge.shiftKey)return;const mt=Ge.key.toLowerCase();mt==="b"?(Ge.preventDefault(),$()):mt==="l"&&(Ge.preventDefault(),G())};return document.addEventListener("keydown",Me),()=>document.removeEventListener("keydown",Me)},[d,$,G]);const st=k.useCallback((be,Me)=>{let Ge=oc(be);d?Ge=Q4[Ge]??Ge:Ge===me.NOTIFICATIONS&&(Ge=me.HOME),Ge!==me.TEAM&&Jf(!1);const ot=lc(),mt=window.location.hash.slice(1);if(mt!==ap(ot)?Nd[ot]=mt:delete Nd[ot],Ge===me.SETTINGS&&Me?.tab){const ze=`settings/${Me.tab}`;Nd[Ge]=ze,history.pushState(null,"","#"+ze),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Ge),g(Xe=>Xe.has(Ge)?Xe:new Set([...Xe,Ge]));return}const ae=Ge!==me.WORK?Nd[Ge]:void 0;ae&&ae!==ap(Ge)?(history.pushState(null,"",Si(Ge)),history.pushState(null,"","#"+ae)):history.pushState(null,"",Si(Ge)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Ge),g(ze=>ze.has(Ge)?ze:new Set([...ze,Ge]))},[d]);k.useEffect(()=>{at.setHandler((be,Me)=>st(be,Me))},[st]),k.useEffect(()=>{const be=()=>N(!0);return window.addEventListener("markus:open-edit-profile",be),()=>window.removeEventListener("markus:open-edit-profile",be)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==me.SETTINGS&&!h.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[h.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(be=>{if(be.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),be.page){const Me=oc(be.page);be.params&&Object.entries(be.params).forEach(([Ge,ot])=>localStorage.setItem(`markus_nav_${Ge}`,ot)),st(Me),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Me,params:be.params}}))}})},[st]);const dt=k.useCallback(()=>{fetch("/api/settings/llm").then(be=>be.ok?be.json():null).then(be=>{if(be?.providers){const Me=Object.values(be.providers).some(Ge=>Ge.configured);Z(Me)}}).catch(()=>{})},[]),Et=k.useCallback((be,Me)=>{if(!be)return;const ot=Me&&{agent:"agents",team:"teams",skill:"skills"}[Me]||"agents";localStorage.setItem("markus_nav_installItem",be),localStorage.setItem("markus_nav_storeTab",ot);const mt=new URLSearchParams(window.location.search);mt.get("install")||(mt.set("install",be),Me&&mt.set("type",Me));const ae=mt.toString();window.history.replaceState(null,"",`${window.location.pathname}?${ae}${Si(me.STORE)}`);const ze=()=>at.navigate(me.STORE,{storeTab:ot,installItem:be});ze(),setTimeout(ze,500),setTimeout(ze,1500)},[]);k.useEffect(()=>{const be=new URLSearchParams(window.location.search),Me=be.get("install");Me&&Et(Me,be.get("type"));const Ge=window.markusDesktop;Ge?.onDeepLinkInstall?.(({id:ae,type:ze})=>Et(ae,ze)),Ge?.consumePendingDeepLinkInstall?.().then(ae=>{ae?.id&&Et(ae.id,ae.type)}),Ce.auth.me().then(({user:ae})=>{y(ae),C(!0),mW(ae),va.connect(ae.id),dt(),Ce.health().then(Xe=>{Xe.updateAvailable&&Xe.latestVersion&&X({latestVersion:Xe.latestVersion,currentVersion:Xe.version})}).catch(()=>{});const ze=()=>{pi(Tr.builderArtifacts,()=>Ce.builder.artifacts.list()),pi(Tr.builderAgents,()=>Ce.agents.list()),pi(Tr.builderHubMyItems,()=>it.myItems()),pi(Tr.builderInstalled,()=>Ce.builder.artifacts.installed()),pi(Tr.hubAgents,()=>it.search({type:"agent",limit:50})),pi(Tr.hubTeams,()=>it.search({type:"team",limit:50})),pi(Tr.hubSkills,()=>it.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(ze,{timeout:5e3}):setTimeout(ze,3e3)}).catch(()=>{y(null),Ce.auth.status().then(({initialized:ae,hasOwner:ze,hasMultipleUsers:Xe})=>{C(ae),_({hasOwner:ze,hasMultipleUsers:Xe})}).catch(()=>C(!0))}),va.connect();const ot=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),mt=()=>{const ae=_3(lc());ae!==me.TEAM&&Jf(!1),n(ae),g(ze=>ze.has(ae)?ze:new Set([...ze,ae]))};return window.addEventListener("hashchange",mt),window.addEventListener("popstate",mt),()=>{ot(),va.disconnect(),window.removeEventListener("hashchange",mt),window.removeEventListener("popstate",mt)}},[]);const gt=x!=="loading"&&x!==null?x:void 0,jt=k.useMemo(()=>d?{[me.HOME]:s.jsx(Ky,{authUser:gt}),[me.TEAM]:s.jsx(R4,{authUser:gt}),[me.BUILDER]:s.jsx(GK,{authUser:gt}),[me.SETTINGS]:s.jsx(O4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)},onUserUpdated:be=>y(be)}),[me.WORK]:s.jsx(D4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(L4,{authUser:gt}),[me.NOTIFICATIONS]:s.jsx(cW,{authUser:gt}),[me.SEARCH]:s.jsx(uW,{})}:{[me.HOME]:s.jsx(Ky,{authUser:gt}),[me.TEAM]:s.jsx(R4,{authUser:gt}),[me.SETTINGS]:s.jsx(O4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)},onUserUpdated:be=>y(be)}),[me.STORE]:s.jsx(oW,{authUser:gt}),[me.BUILDER]:s.jsx(lW,{authUser:gt}),[me.WORK]:s.jsx(D4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(L4,{authUser:gt})},[gt?.id,gt?.role,m.mode,d]);if(x==="loading"||x===null&&T===null)return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Rt=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Rt?s.jsx(XK,{token:Rt[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),z(!0),y("loading"),Ce.auth.me().then(be=>y(be.user)).catch(()=>y(null))}}):x===null?s.jsx(YK,{hasOwner:j.hasOwner,hasMultipleUsers:j.hasMultipleUsers,onLogin:(be,Me,Ge)=>{y(be),va.connect(be.id),Me?(localStorage.removeItem("markus_onboarded"),o(!0),Ge?.fromHub&&z(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):D?s.jsx(QK,{onComplete:()=>H(!1),isFirstTime:!0}):r?s.jsx(VK,{theme:m.mode,onThemeChange:m.setMode,skipProfile:O,onProfileUpdated:be=>{const Me={id:be.id,name:be.name,email:be.email,role:be.role,orgId:be.orgId??"default",avatarUrl:be.avatarUrl};y(Me)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),z(!1),Ce.auth.me().then(be=>y(be.user)).catch(()=>{}),dt(),st(me.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==me.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:h.width},children:s.jsx(QV,{currentPage:t,onNavigate:be=>{st(be),u(!1)},authUser:x,collapsed:h.collapsed,onToggleCollapse:h.toggle,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)}})}),s.jsx("div",{className:`${h.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:h.collapsed?void 0:h.onResizeStart,children:!h.collapsed&&s.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),s.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==me.SETTINGS&&t!==me.SEARCH?"pb-14":""}`,children:[W===!1&&!U&&t!==me.SETTINGS&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[s.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),s.jsx("button",{onClick:()=>Y(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),se&&F!==se.latestVersion&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[s.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:se.latestVersion,current:se.currentVersion})}),s.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[s.jsx("a",{href:"https://markus.global/download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),s.jsx("button",{onClick:()=>{J(se.latestVersion),localStorage.setItem("markus_update_dismissed",se.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),s.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(jt).map(be=>p.has(be)?s.jsx(hW,{id:be,activePage:t,children:jt[be]},be):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(nK,{currentPage:t,onNavigate:st,userId:gt?.id}),d&&s.jsx(iD,{authUser:gt,onNavigate:st}),!d&&B&&s.jsx(rW,{onClose:()=>Q(!1),currentPage:t}),w&>&&s.jsx(iW,{authUser:gt,onClose:()=>N(!1),onUserUpdated:be=>y(be),onSaved:be=>{N(!1),y(be)}})]})}US.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(Jq,{children:s.jsx(pW,{})})}));export{_W as $,Us as A,VG as B,dr as C,GG as D,UV as E,wW as F,TW as G,HV as H,BK as I,vW as J,Ci as K,Vo as L,o5 as M,WV as N,z0 as O,me as P,tK as Q,DW as R,PK as S,EK as T,NW as U,Wa as V,AW as W,ZG as X,EW as Y,RW as Z,qr as _,Bo as a,VV as a0,FV as a1,jW as a2,p0 as a3,D7 as a4,gW as a5,zo as a6,Si as a7,YO as a8,u3 as a9,CW as aa,Q2 as ab,o4 as ac,RV as ad,MV as ae,Gd as af,LW as ag,bW as ah,ua as ai,yn as aj,na as ak,SW as al,l3 as am,HK as b,jK as c,DK as d,Ja as e,Ce as f,MW as g,it as h,wi as i,s as j,OW as k,Ar as l,sD as m,at as n,ZK as o,oc as p,Mg as q,k as r,xc as s,R7 as t,ft as u,xW as v,va as w,yW as x,qd as y,H2 as z};
|
|
666
|
+
prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(bp,{remarkPlugins:[vw,kk],rehypePlugins:[[Wk,{detect:!0,ignoreMissing:!0}]],children:e})})}function Wh({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=ft(["builder","common"]),[u,d]=k.useState(!1),[m,h]=k.useState(t),[p,g]=k.useState(!1),x=/\.(md|mdx|markdown)$/i.test(e),y=k.useRef(null);k.useEffect(()=>{h(t)},[t]),k.useEffect(()=>{if(u&&y.current){const T=y.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[u,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},N=o?null:s.jsx("div",{className:"flex items-center gap-2",children:u?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{h(t),d(!1)},className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors",children:l("common:cancel")}),s.jsx("button",{onClick:w,disabled:p,className:"text-[10px] px-2.5 py-1 rounded-md bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:l(p?"common:saving":"common:save")})]}):s.jsxs("button",{onClick:()=>d(!0),className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),l("detail.edit")]})});return r?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-end px-4 py-2 border-b border-border-default bg-surface-elevated/20",children:N}),u?s.jsx("textarea",{ref:y,value:m,onChange:T=>h(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Fp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]}):s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border-default bg-surface-elevated/30",children:[s.jsx("span",{className:"text-xs font-medium text-fg-secondary font-mono",children:e}),N]}),u?s.jsx("textarea",{ref:y,value:m,onChange:T=>h(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Fp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const g4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function dK(e){return[...e].sort(([t],[n])=>{const r=g4[t]??99,o=g4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function d0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>dK(e),[e]),[l,u]=k.useState(0);if(o.length===1)return n?s.jsx(Wh,{filename:o[0][0],content:o[0][1],onSave:p=>t(o[0][0],p),readOnly:r}):s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),s.jsx(Wh,{filename:o[0][0],content:o[0][1],onSave:p=>t(o[0][0],p),readOnly:r})]});const[d,m]=o[l]??o[0],h=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30",children:o.map(([p],g)=>s.jsx("button",{onClick:()=>u(g),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors ${g===l?"border-brand-500 text-brand-400 bg-surface-secondary/50":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:p},p))}),s.jsx(Wh,{filename:d,content:m,onSave:p=>t(d,p),embedded:!0,readOnly:r},d)]});return n?h:s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),h]})}function mK({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l}){const{t:u}=ft(["builder"]),d=k.useRef(null);return e.length===0?l?null:s.jsxs("div",{className:"border-2 border-dashed border-border-default rounded-xl p-6 text-center text-fg-muted text-sm cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>d.current?.click(),onDragOver:m=>m.preventDefault(),onDrop:m=>{m.preventDefault();const h=m.dataTransfer.files[0];h?.type.startsWith("image/")&&r(h)},children:[s.jsxs("svg",{className:"w-8 h-8 mx-auto mb-2 text-fg-muted/50",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsx("span",{className:"block",children:u("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:u("images.hint")}),s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const h=m.target.files?.[0];h&&r(h),m.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(m=>{const h=m.split("/").pop()??m;return s.jsxs("div",{className:"relative group shrink-0 rounded-lg border border-border-default overflow-hidden bg-surface-elevated",children:[s.jsx("img",{src:`/api/builder/artifacts/${t}s/${encodeURIComponent(n)}/images/${encodeURIComponent(h)}`,alt:h,className:"h-32 w-auto object-cover"}),!l&&s.jsx("button",{onClick:()=>o(h),className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-red-600/80 text-white flex items-center justify-center text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},m)}),!l&&s.jsx("button",{onClick:()=>d.current?.click(),className:"shrink-0 h-32 w-24 rounded-lg border-2 border-dashed border-border-default flex items-center justify-center text-fg-muted hover:border-brand-500/30 hover:text-brand-400 transition-colors",children:s.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),!l&&s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const h=m.target.files?.[0];h&&r(h),m.target.value=""}})]})}function fK({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=ft(["builder"]),[u,d]=k.useState(0),m=k.useMemo(()=>{const N=new Set;for(const T of Object.keys(n)){const C=T.match(/^members\/([^/]+)\//);C&&N.add(C[1])}return[...N]},[n]),h=k.useMemo(()=>{const N=new Map,T=new Set;for(let _=0;_<e.length;_++){const O=qd(e[_].name);m.includes(O)&&!T.has(O)&&(N.set(_,O),T.add(O))}for(let _=0;_<e.length;_++){if(N.has(_))continue;const O=e[_].roleName;if(O){const z=qd(O);m.includes(z)&&!T.has(z)&&(N.set(_,z),T.add(z))}}for(let _=0;_<e.length;_++){if(N.has(_))continue;const O=e[_].name;for(const z of m){if(T.has(z))continue;const D=n[`members/${z}/ROLE.md`];if(!D)continue;const H=D.match(/^#\s+(.+)$/m)?.[1]?.trim();if(H&&(H.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes(H.toLowerCase()))){N.set(_,z),T.add(z);break}}}const C=m.filter(_=>!T.has(_));let j=0;for(let _=0;_<e.length;_++)N.has(_)||j<C.length&&(N.set(_,C[j]),j++);return N},[e,m,n]),p=k.useCallback((N,T)=>{const C=h.get(T);return C?Object.entries(n).filter(([j])=>j.startsWith(`members/${C}/`)):[]},[n,h]),g=k.useMemo(()=>{const N=[{label:l("detail.overview")}];for(const T of e)N.push({label:T.name,role:T.role});return N},[e,l]),x=u>0?e[u-1]:null,y=u-1;return s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30 border-b border-border-default",children:g.map((N,T)=>{const C=T===u,j=N.role==="manager",_=T===0?C?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":j?C?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":C?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>d(T),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${_} ${C?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[T===0&&s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),T>0&&s.jsx("span",{className:`w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center shrink-0 ${j?"bg-amber-500/20 text-amber-400":"bg-blue-500/20 text-blue-400"}`,children:(N.label[0]??"?").toUpperCase()}),N.label]},T)})}),s.jsx("div",{className:"p-5",children:u===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(d0,{noHeader:!0,files:t,onSave:w,readOnly:o}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:l("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((N,T)=>{const C=N.role==="manager";return s.jsxs("button",{onClick:()=>d(T+1),className:"text-left rounded-lg border border-border-default bg-surface-elevated/30 px-4 py-3 flex gap-3 items-center hover:border-gray-600 transition-colors cursor-pointer",children:[s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${C?"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:(N.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:N.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${C?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:N.role}),N.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",N.count]})]}),N.skills&&N.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[N.skills.slice(0,3).map(j=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:j},j)),N.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",N.skills.length-3]})]})]}),s.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},T)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${x.role==="manager"?"bg-amber-500/15 text-amber-400 ring-2 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-2 ring-blue-500/30"}`,children:(x.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:x.name}),s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${x.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:x.role}),x.count>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",x.count]})]}),x.roleName&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 italic",children:x.roleName})]})]}),x.skills&&x.skills.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.skills.map(N=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:N},N))}),(()=>{const N=p(x.name,y);return N.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(d0,{noHeader:!0,readOnly:o,files:N.map(([T,C])=>[T.replace(/^members\/[^/]+\//,""),C]),onSave:(T,C)=>{const j=N.find(([_])=>_.endsWith(`/${T}`));j&&r(j[0],C)}})})()]}):null})]});function w(N,T){r(N,T)}}function Ai({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:u,contentSlot:d}){const{t:m}=ft(["builder","common"]),h=Bo(),[p,g]=k.useState(!0),[x,y]=k.useState(t),[w,N]=k.useState({}),[T,C]=k.useState(null),[j,_]=k.useState(""),[O,z]=k.useState("idle"),[D,H]=k.useState({shared:!1}),[W,Z]=k.useState(!1),[U,Y]=k.useState(!1),[se,X]=k.useState(!1),[F,J]=k.useState(!1),[B,Q]=k.useState(!1),[re,ke]=k.useState(!1),[$,G]=k.useState(null),[le,I]=k.useState(""),[Ee,Ue]=k.useState(""),[Oe,We]=k.useState(""),[st,dt]=k.useState(""),[Et,gt]=k.useState([]),[jt,Jt]=k.useState(""),Rt=k.useRef(null),be=k.useRef(l);be.current=l,k.useEffect(()=>{y(t)},[t]);const Me=k.useCallback(async()=>{const he=be.current;if(he){C(he),I(he.displayName||he.name||t),Ue(he.description||""),We(he.version||"1.0.0"),dt(he.category||"general"),gt(he.tags||[]),Jt(he.icon||""),N(he.files??{}),g(!1);return}g(!0);try{let ve=t;try{const xt=await Ce.builder.artifacts.ensureSlugSafe(e,t);ve=xt.name,y(ve),xt.converted&&(history.replaceState(null,"",Si(me.BUILDER,`${e}/${encodeURIComponent(ve)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const Ye=await Ce.builder.artifacts.get(e,ve);N(Ye.files??{}),_(Ye.path??"");const nt=Ye.files[`${e}.json`]??Ye.files["agent.json"]??Ye.files["team.json"]??Ye.files["skill.json"];if(nt){const xt=JSON.parse(nt);C(xt),I(xt.displayName||xt.name||t),Ue(xt.description||""),We(xt.version||"1.0.0"),dt(xt.category||"general"),gt(xt.tags||[]),Jt(xt.icon||"")}}catch(ve){console.error("Failed to load artifact:",ve)}finally{g(!1)}},[e,t]);k.useEffect(()=>{Me()},[Me]),k.useEffect(()=>{l?.files&&N(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const he=localStorage.getItem("markus_builder_shared_map");if(he){const ve=JSON.parse(he),Ye=`${e}/${t}`;ve[Ye]&&H({shared:!0,id:ve[Ye].id,slug:ve[Ye].slug,version:ve[Ye].version,visibility:ve[Ye].visibility??"public"})}}catch{}it.myItems().then(he=>{const ve=he?.items??[],Ye=e==="agent"?"agent":e==="team"?"team":"skill";for(const nt of ve)if(nt.itemType===Ye&&(nt.slug===t||nt.name===t)){H({shared:!0,id:nt.id,slug:nt.slug,version:nt.version,visibility:nt.visibility??"public",moderationStatus:nt.moderationStatus,pendingReview:nt.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const Ge=k.useCallback(async he=>{if(!(!T||o)){z("saving");try{const ve={...T,...he};await Ce.builder.artifacts.save(e,ve),C(ve),z("saved"),setTimeout(()=>z(Ye=>Ye==="saved"?"idle":Ye),2e3)}catch{z("error"),setTimeout(()=>z("idle"),3e3)}}},[T,e]),ot=k.useCallback(he=>{Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(()=>Ge(he),800)},[Ge]),mt=k.useCallback((he,ve)=>{const Ye={};he==="displayName"?(I(ve),Ye.displayName=ve,Y(!0)):he==="description"?(Ue(ve),Ye.description=ve,Y(!0)):he==="version"?(We(ve),Ye.version=ve,Y(!1),X(!1)):he==="category"?(dt(ve),Ye.category=ve,Y(!0)):he==="tags"?(gt(ve),Ye.tags=ve,Y(!0)):he==="icon"&&(Jt(ve),Ye.icon=ve||void 0,Y(!0)),ot({...T,...Ye})},[T,ot]),ae=k.useCallback(async(he,ve)=>{try{const Ye={...w,[he]:ve};N(Ye);const nt={...T,files:Ye};await Ce.builder.artifacts.save(e,nt),z("saved"),Y(!0),setTimeout(()=>z(xt=>xt==="saved"?"idle":xt),2e3)}catch{z("error")}},[w,e,T]),ze=k.useCallback(async he=>{if(T){Z(!0);try{await it.ensureAuth();const ve=await Ce.builder.artifacts.ensureSlugSafe(e,x,T.displayName||T.name||x),Ye=ve.name,nt=ve.slug||dc(Ye);if(!nt)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 xt=ve.displayName||T.displayName||T.name||x;ve.converted&&(y(Ye),C(ie=>ie&&{...ie,name:nt,displayName:xt}),history.replaceState(null,"",Si(me.BUILDER,`${e}/${encodeURIComponent(Ye)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const Dt={...T,name:nt,displayName:xt},ct=Dt.description||"",Xt=Dt.category||"general",R=Dt.tags??[];let oe=Dt.icon||void 0;const _e=Dt.version||"1.0.0";if(oe&&!oe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(oe)){const ie=oe.split("/").pop()??oe;try{const Ne=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ye)}/images/${encodeURIComponent(ie)}`);if(Ne.ok){const Le=await Ne.blob(),Je=new File([Le],ie,{type:Le.type}),vt=await it.uploadImage(Je);vt?.url&&(oe=vt.url)}}catch{}}let de;const $e=[],qe=Dt.screenshots??[];for(let ie=0;ie<qe.length;ie++){const Ne=qe[ie],Le=Ne.split("/").pop()??Ne;try{const Je=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ye)}/images/${encodeURIComponent(Le)}`);if(Je.ok){const vt=await Je.blob(),Ie=new File([vt],Le,{type:vt.type}),tt=await it.uploadImage(Ie);tt?.url&&($e.push({url:tt.url,alt:Le,order:ie}),ie===0&&(de=tt.url))}}catch{}}const q=await it.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:xt,slug:nt,description:ct,category:Xt,tags:R,icon:oe,version:_e,config:Dt,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:de,images:$e.length>0?$e:void 0,priceCents:he?.priceCents,donationsEnabled:he?.donationsEnabled,visibility:he?.visibility,orgId:he?.orgId});q.id&&(H({shared:!0,id:q.id,slug:q.slug??nt,version:_e,visibility:q.visibility??he?.visibility??"public",moderationStatus:q.moderationStatus,pendingReview:q.pendingReview}),Y(!1),(q.visibility??he?.visibility??"public")!=="org"&&(q.moderationStatus==="pending"||q.pendingReview)?G({title:m("common:share"),message:ve.converted?m("share.convertedAndSubmitted",{previous:t,slug:nt}):q.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):ve.converted&&G({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:nt}),variant:"primary"}))}catch(ve){console.error("Share to Hub failed:",ve),G({title:m("common:share"),message:ve instanceof Error?ve.message:String(ve),variant:"danger"})}finally{Z(!1)}}},[T,w,e,t,x,m]),Xe=async he=>{const ve=new FormData;ve.append("image",he);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:ve,credentials:"include"}),await Me(),Y(!0)}catch(Ye){console.error("Image upload failed:",Ye)}},Ve=async he=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(he)}`,{method:"DELETE",credentials:"include"}),await Me(),Y(!0)}catch(ve){console.error("Image remove failed:",ve)}},et=p4[e]??p4.agent,yt=T?.screenshots??[],pe=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],V=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")),[w,e]),ye=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")),[w,e]),Qe=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const he=new Set;if(e==="skill"){const ve=T?.skill?.skillFile;ve&&w[ve]&&he.add(ve),!ve&&w["SKILL.md"]&&he.add("SKILL.md"),!ve&&!w["SKILL.md"]&&w["README.md"]&&he.add("README.md")}return Object.entries(w).filter(([ve])=>!ve.endsWith(".json")&&!ve.startsWith("images/")&&!ve.startsWith("members/")&&!he.has(ve))},[w,e,T?.skill?.skillFile]);return p?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse py-20 text-center",children:m("common:loading")})]})}):T?s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:`${h?"px-4 py-5":"px-6 py-8"}`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m(o?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!o&&O==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&O==="saved"&&s.jsxs("span",{className:"text-[10px] text-green-500 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),m("detail.saved")]}),!o&&O==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),u,!o&&D.shared&&(()=>{const he=it.getUser(),ve=he&&D.slug?`${it.getUrl()}/@${encodeURIComponent(he.username)}/${encodeURIComponent(D.slug)}`:null,Ye=Oe||T?.version||"1.0.0",nt=D.version!==Ye;return s.jsxs(s.Fragment,{children:[D.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):D.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):D.pendingReview?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,ve&&s.jsxs("a",{href:ve,target:"_blank",rel:"noopener noreferrer",onClick:xt=>{Gd()&&(xt.preventDefault(),Ro(ve))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${D.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":D.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:[D.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):D.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),D.visibility==="org"?m("visibility.sharedOrg"):D.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),nt&&s.jsx("button",{onClick:()=>{ze({visibility:D.visibility})},disabled:W,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:W?m("share.updating"):m("share.updateVersion",{version:Ye})})]})})(),!o&&!D.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:W,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:m(W?"share.sharing":"share.toHub")})]})]}),!o&&U&&!se&&s.jsxs("div",{className:"mb-4 px-4 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20 flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),s.jsx("button",{onClick:()=>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")})]}),!o&&se&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),s.jsx("input",{type:"text",defaultValue:(()=>{const he=(Oe||"1.0.0").split(".");return he[2]=String(Number(he[2]??0)+1),he.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:he=>{he.key==="Enter"&&mt("version",he.target.value)}}),s.jsx("button",{onClick:he=>{const ve=he.target.parentElement?.querySelector("input");ve&&mt("version",ve.value)},className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("common:confirm")}),s.jsx("button",{onClick:()=>X(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),D.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${h?"flex-col":""}`,children:[s.jsxs("div",{className:`${h?"w-full":"flex-1 min-w-0"}`,children:[s.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>!o&&ke(!re),className:`w-16 h-16 rounded-xl ${et.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${et.ring} transition-all overflow-hidden`,children:jt&&jt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(jt.replace("images/",""))}`,alt:"",className:"w-full h-full object-cover"}):jt&&(jt.startsWith("http")||jt.startsWith("/"))?s.jsx("img",{src:jt,alt:"",className:"w-full h-full object-cover"}):(()=>{const he=jt||"";if(he&&[...he].length<=2&&new RegExp("\\p{Emoji}","u").test(he))return he;const Ye=Ti[Ko(e)].accent;return s.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:w3(le||t||e),fill:Ye})})})()}),!o&&re&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ke(!1)}),s.jsxs("div",{className:"absolute top-full left-0 mt-2 z-50 bg-surface-secondary border border-border-default rounded-xl p-3 shadow-xl w-80",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("input",{type:"text",placeholder:m("detail.pasteEmojiOrUrl"),className:"flex-1 text-sm px-2 py-1.5 rounded-lg bg-surface-elevated border border-border-default text-fg-primary placeholder:text-fg-muted",defaultValue:jt,onKeyDown:he=>{he.key==="Enter"&&(mt("icon",he.target.value),ke(!1))}}),s.jsxs("label",{className:"text-[10px] text-brand-400 hover:text-brand-300 cursor-pointer px-1.5 py-1 border border-brand-500/30 rounded-lg",children:[m("detail.upload"),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async he=>{const ve=he.target.files?.[0];if(!ve)return;const Ye=new FormData;Ye.append("image",ve);try{const nt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:Ye,credentials:"include"});if(nt.ok){const Dt=(await nt.json()).path;if(Jt(Dt),ke(!1),T){const ct={...T,icon:Dt};C(ct),await Ce.builder.artifacts.save(e,ct)}Y(!0)}}catch{}}})]}),jt&&s.jsx("button",{onClick:()=>{mt("icon",""),ke(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto",children:oK.map(he=>s.jsxs("div",{className:"mb-2.5",children:[s.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:he.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:he.emojis.map(ve=>s.jsx("button",{onClick:()=>{mt("icon",ve),ke(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${jt===ve?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:ve},ve))})]},he.label))})]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Kh,{value:le,onChange:he=>mt("displayName",he),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:o}),s.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${et.bg} ${et.color}`,children:et.label}),s.jsx(Kh,{value:Oe,onChange:he=>mt("version",he),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:o})]}),s.jsx(Kh,{value:Ee,onChange:he=>mt("description",he),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:o}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(cK,{value:st,options:iK,onChange:he=>mt("category",he),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(uK,{tags:Et,onChange:he=>mt("tags",he),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(mK,{images:yt,artifactType:e,artifactName:t,onUpload:Xe,onRemove:Ve,readOnly:o})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(fK,{members:T.team.members,teamTopFiles:ye,files:w,onFileSave:ae,readOnly:o})}),e==="agent"&&V.length>0&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),s.jsx(d0,{noHeader:!0,files:V,onSave:ae,readOnly:o})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[T.skill?.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:T.skill.requiredPermissions.map(he=>{const ve=lK[he];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${ve?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:ve?.icon??"?"})," ",he]},he)})})]}),T.skill?.mcpServers&&Object.keys(T.skill.mcpServers).length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),s.jsx("div",{className:"grid gap-2",children:Object.entries(T.skill.mcpServers).map(([he,ve])=>s.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[s.jsx("span",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center text-purple-400 text-sm shrink-0",children:"◎"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary",children:he}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof ve=="object"?JSON.stringify(ve).slice(0,80):String(ve)})]})]},he))})]}),pe&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),s.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:s.jsx(Fp,{content:pe})})]})]}),Qe.length>0&&s.jsx(d0,{files:Qe,onSave:ae,readOnly:o})]}),s.jsx("div",{className:`${h?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${h?"":"sticky top-6"} space-y-4`,children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),s.jsx("span",{className:`font-medium ${et.color}`,children:et.label})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),s.jsx("span",{className:"text-fg-secondary",children:st})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:Oe})]}),T.author&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),s.jsx("span",{className:"text-fg-secondary",children:typeof T.author=="string"?T.author:T.author?.name??""})]})]})]}),e==="agent"&&T.agent&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.agent.roleName&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.roleName})]}),T.agent.llmProvider&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.llmProvider})]}),T.agent.llmModel&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:T.agent.llmModel})]}),T.agent.temperature!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.temperature})]})]})]}),e==="team"&&T.team&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),s.jsx("span",{className:"text-fg-secondary",children:T.team.members.reduce((he,ve)=>he+ve.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),s.jsx("span",{className:"text-amber-400",children:T.team.members.filter(he=>he.role==="manager").reduce((he,ve)=>he+ve.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),s.jsx("span",{className:"text-blue-400",children:T.team.members.filter(he=>he.role!=="manager").reduce((he,ve)=>he+ve.count,0)})]})]})]}),e==="skill"&&T.skill&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.skill.alwaysOn!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),s.jsx("span",{className:T.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:T.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),s.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:T.skill.skillFile})]}),T.skill.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:T.skill.requiredPermissions.map(he=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:he},he))})]})]})]}),T.dependencies&&(T.dependencies.skills?.length||T.dependencies.env?.length)?s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),T.dependencies.skills?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.skills.map(he=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:he},he))})]}):null,T.dependencies.env?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.env.map(he=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:he},he))})]}):null]}):null,!o&&j&&s.jsxs("button",{onClick:()=>Ce.system.openPath(j).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:j,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),j.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&F&&s.jsx(pK,{onClose:()=>J(!1),onConfirm:(he,ve)=>{J(!1),ze({donationsEnabled:!1,priceCents:he==="paid"?ve:void 0})},isUpdate:D.shared}),!o&&B&&s.jsx(hK,{onClose:()=>Q(!1),onConfirm:(he,ve,Ye,nt)=>{Q(!1),ze({visibility:he,orgId:ve,priceCents:Ye,donationsEnabled:nt})}}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function hK({onClose:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,u]=k.useState([]),[d,m]=k.useState(""),[h,p]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(p(!0),it.myOrgs().then(C=>{u(C.memberships),C.memberships.length>0&&m(C.memberships[0].id)}).catch(()=>{}).finally(()=>p(!1)))},[r,l.length]);const N=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:C=>C.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(C=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===C.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===C.value,onChange:()=>o(C.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:C.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:C.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:C.desc})]})]},C.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),h?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:C=>m(C.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(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),N&&s.jsxs("div",{className:"mb-5",children:[s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:S3.map(C=>s.jsx("button",{type:"button",onClick:()=>x(C.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===C.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:C.label},C.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:C=>w(C.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),N&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,N&&g>0?g:void 0,N?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const S3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function pK({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:u=>u.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(n?"shareMode.titleUpdate":"share.toHub")}),s.jsx("div",{className:"space-y-2 mb-5",children:S3.map(u=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===u.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===u.cents,onChange:()=>l(u.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:u.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:u.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},u.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>t(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(n?"shareMode.update":"shareMode.share")})]})]})})}function m0(e,t){return!e||!k3(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function gK({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:u="rounded-xl"}){const d=Ko(e),m=m0(n,r),h=k.useMemo(()=>Rg(d,t),[d,t]),p=k.useMemo(()=>w3(t),[t]),[g,x]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>x(!0),style:{width:o,height:o},className:`${u} object-cover shrink-0 ${l}`}):aK(n)?s.jsx("div",{style:{width:o,height:o,background:h,fontSize:o*.5},className:`${u} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&wV(n)?s.jsx("div",{style:{width:o,height:o,background:h},className:`${u} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Vo,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:h},className:`${u} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:o*.55,height:o*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:p,fill:"rgba(255,255,255,0.92)"})})})}function f0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:u}){const d=t||e||"markus",m=m0(n,r),[h,p]=k.useState(!1),g=m&&!h?m:sK(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:o,height:o},children:[s.jsx("img",{src:g,alt:e||t||"",onError:()=>p(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),u&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 ring-2 ring-surface-primary",style:{width:o*.42,height:o*.42},children:s.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"white","aria-hidden":!0,children:s.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function bK({type:e,className:t=""}){const n=Ko(e),r=Ti[n];return s.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white bg-gradient-to-r ${r.gradient} ${t}`,children:r.label})}function b4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",className:n<t?"text-amber-400":"text-fg-muted/40",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z"})},n))})}function sa(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:u,hubBase:d,author:m,authorLabel:h,version:p,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:N=0,priceCents:T,currency:C="usd",installed:j,glowing:_,selected:O,showTypeBadge:z=!0,hideStats:D=!1,cornerLabel:H,actions:W,footerLeft:Z,headerAction:U,onClick:Y,className:se=""}=e,X=Ko(t),F=Ti[X],J=o||n,B=(T??0)>0,Q=!!m0(u||void 0,d),re=Rg(X,J),ke=h??m?.displayName??m?.username??"",[$,G]=k.useState(null),le=j?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/12 text-emerald-400 border border-emerald-500/25 px-2 py-0.5 text-[10px] font-semibold",children:s.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):H?s.jsx("span",{className:"chip",children:H}):B?s.jsx("span",{className:"badge-paid",children:h4(T,C)}):null;if(Q){const I=m0(u||void 0,d);return s.jsxs("div",{onClick:Y,style:{aspectRatio:$??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${Y?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${se}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Ee=>{const Ue=Ee.currentTarget;Ue.naturalWidth&&Ue.naturalHeight&&G(Math.min(1.9,Math.max(1,Ue.naturalWidth/Ue.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),s.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),s.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[s.jsx("span",{children:z&&s.jsx(bK,{type:X})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ee=>Ee.stopPropagation(),children:[j?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/25 text-emerald-50 border border-emerald-300/40 px-2 py-0.5 text-[10px] font-semibold backdrop-blur-md",children:s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):H?s.jsx("span",{className:"inline-flex items-center rounded-full bg-white/15 text-white border border-white/25 px-2 py-0.5 text-[10px] font-medium backdrop-blur-md",children:H}):U?null:s.jsx("span",{className:B?"badge-paid":"badge-free",children:h4(T,C)}),U]})]}),s.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),p&&s.jsxs("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/25 px-1.5 py-0.5 text-[10px] font-medium backdrop-blur-md",children:["v",p]})]}),ke&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(f0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:ke})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[g&&s.jsx("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/20 text-white/95 px-2 py-0.5 text-[10px] font-semibold capitalize backdrop-blur-md",children:g}),x?.slice(0,3).map(Ee=>s.jsx("span",{className:"shrink-0 rounded-full bg-white/10 border border-white/15 text-white/85 px-2 py-0.5 text-[10px] backdrop-blur-md",children:Ee},Ee))]}),(!D||W)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[D?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(b4,{rating:y}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Ao(w),")"]})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ao(N)]})]}),W&&s.jsx("div",{className:"flex items-center gap-2",onClick:Ee=>Ee.stopPropagation(),children:W})]})]})]})}return s.jsxs("div",{onClick:Y,className:`group asset-card card-shine relative flex flex-col ${Y?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${se}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${F.accent}, transparent)`}}),s.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:re}}),U&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:U}),s.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(gK,{type:X,seed:J,icon:l,hubBase:d,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),s.jsxs("div",{className:`min-w-0 flex-1 ${U?"pr-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),p&&s.jsxs("span",{className:"chip shrink-0",children:["v",p]}),le&&s.jsx("span",{className:"ml-auto shrink-0",children:le})]}),(ke||z)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(f0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),ke&&s.jsx("span",{className:"truncate",children:ke}),z&&s.jsxs(s.Fragment,{children:[ke&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:F.accent},children:F.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),x?.slice(0,3).map(I=>s.jsx("span",{className:"chip",children:I},I)),(x?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(x?.length??0)-3]})]}),(()=>{const I=Z??(D?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(b4,{rating:y}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Ao(w)})`:""})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ao(N)]})]}));return!I&&!W?null:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Ee=>Ee.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),W&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:W})]})})()]})]})}function Er({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,u]=k.useState(0);k.useEffect(()=>{const p=o.current;if(!p)return;u(p.clientWidth);const g=new ResizeObserver(x=>{for(const y of x)u(y.contentRect.width)});return g.observe(p),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),h=Array.from({length:d},()=>[]);return m.forEach((p,g)=>{h[g%d].push(p)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:h.map((p,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:p},g))})}function xK(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const yK=[{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 vK(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return oc(r[0])===me.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const o=window.location.hash.slice(1).split("/");oc(o[0])===me.BUILDER&&o[1]&&o[2]?t({type:o[1],name:decodeURIComponent(o[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const N3="markus_builder_shared_map";function wK(){try{const e=localStorage.getItem(N3);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function kd(e){try{localStorage.setItem(N3,JSON.stringify(Object.fromEntries(e)))}catch{}}function C3({authUser:e}={}){const{t}=ft(["builder","common"]),n=Bo(),r=vK(),[o,l]=k.useState([]),[u,d]=k.useState([]),[m,h]=k.useState(!1),[p,g]=k.useState("all"),[x,y]=k.useState(null),[w,N]=k.useState(new Map),[T,C]=k.useState(null),[j,_]=k.useState(null),[O,z]=k.useState(null),[D,H]=k.useState(wK),[W,Z]=k.useState(null),[U,Y]=k.useState(null),[se,X]=k.useState(null),[F,J]=k.useState(null),[B,Q]=k.useState(null),[re,ke]=k.useState("creations"),[$,G]=k.useState([]),[le,I]=k.useState(""),[Ee,Ue]=k.useState([]),[Oe,We]=k.useState(!1),[st,dt]=k.useState("all"),Et=k.useCallback(()=>{h(!0),Promise.all([(vi(Tr.builderArtifacts)??Ce.builder.artifacts.list()).then(ae=>ae?.artifacts??[]).catch(()=>[]),(vi(Tr.builderAgents)??Ce.agents.list()).then(ae=>ae?.agents??[]).catch(()=>[]),(vi(Tr.builderHubMyItems)??it.myItems()).then(ae=>ae?.items??[]).catch(()=>[]),(vi(Tr.builderInstalled)??Ce.builder.artifacts.installed()).then(ae=>ae?.installed??{}).catch(()=>({}))]).then(([ae,ze,Xe,Ve])=>{if(d(ae),l(ze),Xe.length>0){const yt=new Map;for(const pe of Xe){const V=pe.itemType==="agent"?"agent":pe.itemType==="team"?"team":"skill";for(const ye of ae)ye.type===V&&(pe.slug===ye.name||pe.name===(ye.meta.displayName||ye.meta.name||ye.name))&&yt.set(`${ye.type}/${ye.name}`,{id:pe.id,name:pe.name,slug:pe.slug||ye.name,version:pe.version||"1.0.0",visibility:pe.visibility??"public",moderationStatus:pe.moderationStatus,pendingReview:pe.pendingReview})}yt.size>0&&H(pe=>{const V=new Map(pe);for(const[ye,Qe]of yt)V.set(ye,Qe);return kd(V),V})}const et=new Map;for(const yt of ae){const pe=`${yt.type}/${yt.name}`,V=Ve[pe];V&&et.set(pe,{agentId:V.agentId,agentIds:V.agentIds,teamId:V.teamId})}N(et)}).finally(()=>h(!1))},[]);k.useEffect(()=>{Et();const ae=ze=>{ze.detail?.page===me.BUILDER&&Et()};return window.addEventListener("markus:navigate",ae),()=>window.removeEventListener("markus:navigate",ae)},[Et]);const gt=ae=>{const ze=o.find(Xe=>Xe.role==="Secretary"||Xe.name==="Secretary");ze?at.navigate(me.TEAM,{agentId:ze.id,prefillMessage:ae}):at.navigate(me.TEAM,{prefillMessage:ae})},jt=async ae=>{const ze=`${ae.type}/${ae.name}`;if(!w.has(ze)){y({key:ze,action:"install"});try{const Xe=await Ce.builder.artifacts.install(ae.type,ae.name),Ve={};Xe.agent&&typeof Xe.agent=="object"&&(Ve.agentId=Xe.agent.id),Xe.team&&typeof Xe.team=="object"&&(Ve.teamId=Xe.team.id),Array.isArray(Xe.agents)&&(Ve.agentIds=Xe.agents.map(et=>et.id)),N(et=>new Map(et).set(ze,Ve)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Install failed:",Xe),Y({title:t("common:install"),message:t("installFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Jt=async ae=>{const ze=`${ae.type}/${ae.name}`;if(w.has(ze)){y({key:ze,action:"uninstall"});try{await Ce.builder.artifacts.uninstall(ae.type,ae.name),N(Xe=>{const Ve=new Map(Xe);return Ve.delete(ze),Ve}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Uninstall failed:",Xe),Y({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Rt=async(ae,ze)=>{const Xe=`${ae.type}/${ae.name}`;y({key:Xe,action:"share"});try{const Ve=await Ce.builder.artifacts.ensureSlugSafe(ae.type,ae.name,ae.meta.displayName||ae.meta.name||ae.name),et=Ve.name,yt=Ve.slug||dc(et);if(!yt)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 pe=`${ae.type}/${et}`;Ve.converted&&(d(oe=>oe.map(_e=>_e.type===ae.type&&_e.name===ae.name?{..._e,name:et,path:Ve.path,meta:{..._e.meta,name:et,displayName:Ve.displayName??_e.meta.displayName??ae.name}}:_e)),H(oe=>{const _e=new Map(oe),de=_e.get(Xe);return de&&(_e.delete(Xe),_e.set(pe,{...de,slug:yt,name:Ve.displayName??de.name})),kd(_e),_e}),N(oe=>{const _e=new Map(oe),de=_e.get(Xe);return de&&(_e.delete(Xe),_e.set(pe,de)),_e}));const V=await Ce.builder.artifacts.get(ae.type,et);let ye={...ae.meta,name:et,displayName:Ve.displayName??ae.meta.displayName??ae.name};try{const oe=V.files?.[`${ae.type}.json`]??V.files?.["agent.json"]??V.files?.["team.json"]??V.files?.["skill.json"];oe&&(ye={...JSON.parse(oe),...ye,name:et,displayName:ye.displayName})}catch{}const Qe=ye.displayName||ye.name||et,he=ye.description||"",ve=ye.category||"general",Ye=Array.isArray(ye.tags)?ye.tags:[];let nt=ye.icon||void 0;const xt=ye.version||"1.0.0";if(nt&&!nt.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)){const oe=nt.split("/").pop()??nt;try{const _e=await fetch(`/api/builder/artifacts/${ae.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(oe)}`);if(_e.ok){const de=await _e.blob(),$e=new File([de],oe,{type:de.type}),qe=await it.uploadImage($e);qe?.url&&(nt=qe.url)}}catch{}}let Dt;const ct=[],Xt=Array.isArray(ye.screenshots)?ye.screenshots:[];for(let oe=0;oe<Xt.length;oe++){const _e=Xt[oe],de=_e.split("/").pop()??_e;try{const $e=await fetch(`/api/builder/artifacts/${ae.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(de)}`);if($e.ok){const qe=await $e.blob(),q=new File([qe],de,{type:qe.type}),ie=await it.uploadImage(q);ie?.url&&(ct.push({url:ie.url,alt:de,order:oe}),(oe===0||ye.thumbnail===_e)&&(Dt=ie.url))}}catch{}}const R=await it.publishViaProxy({itemType:ae.type==="team"?"team":ae.type==="skill"?"skill":"agent",name:Qe,slug:yt,description:he,category:ve,tags:Ye,icon:nt,version:xt,config:{...ye,name:et,displayName:Qe},files:V.files&&Object.keys(V.files).length>0?V.files:void 0,thumbnailUrl:Dt,images:ct.length>0?ct:void 0,priceCents:ze?.priceCents,donationsEnabled:ze?.donationsEnabled,visibility:ze?.visibility,orgId:ze?.orgId});R.id&&(H(_e=>{const de=new Map(_e);return de.set(pe,{id:R.id,name:Qe,slug:R.slug??yt,version:xt,visibility:R.visibility??ze?.visibility??"public",moderationStatus:R.moderationStatus,pendingReview:R.pendingReview}),kd(de),de}),(R.visibility??ze?.visibility??"public")!=="org"&&(R.moderationStatus==="pending"||R.pendingReview)?Y({title:t("common:share"),message:Ve.converted?t("share.convertedAndSubmitted",{previous:ae.name,slug:yt}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):Ve.converted&&Y({title:t("common:share"),message:t("share.convertedSlug",{previous:ae.name,slug:yt}),variant:"primary"}))}catch(Ve){console.error("Share failed:",Ve),Y({title:t("common:share"),message:t("shareFailed",{error:Ve instanceof Error?Ve.message:String(Ve)}),variant:"danger"})}finally{y(null)}},be=async()=>{if(!W)return;const{key:ae}=W,ze=D.get(ae);if(Z(null),!ze)return;const Xe=ze.id;y({key:ae,action:"hubDelete"});try{await it.deleteItem(Xe),H(Ve=>{const et=new Map(Ve);return et.delete(ae),kd(et),et})}catch(Ve){console.error("Hub delete failed:",Ve),Y({title:t("unshare"),message:t("hubDeleteFailed",{error:String(Ve)}),variant:"danger"})}finally{y(null)}},Me=async()=>{if(!T)return;const ae=T,ze=`${ae.type}/${ae.name}`;C(null),y({key:ze,action:"delete"});try{await Ce.builder.artifacts.delete(ae.type,ae.name),d(Xe=>Xe.filter(Ve=>!(Ve.type===ae.type&&Ve.name===ae.name))),N(Xe=>{const Ve=new Map(Xe);return Ve.delete(ze),Ve}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Delete failed:",Xe)}finally{y(null)}},Ge=p==="all"?u:u.filter(ae=>ae.type===p);k.useEffect(()=>{re!=="orgAssets"||$.length>0||it.myOrgs().then(ae=>{G(ae.memberships),ae.memberships.length>0&&!le&&I(ae.memberships[0].id)}).catch(()=>{})},[re,$.length,le]),k.useEffect(()=>{re!=="orgAssets"||!le||(We(!0),it.browseItems({orgId:le,limit:100}).then(ae=>Ue(ae.items??[])).catch(()=>Ue([])).finally(()=>We(!1)))},[re,le]);const ot=st==="all"?Ee:Ee.filter(ae=>ae.itemType===st),mt=ae=>{history.pushState(null,"",Si(me.BUILDER,`${ae.type}/${encodeURIComponent(ae.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Ai,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Si(me.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),s.jsx("button",{onClick:Et,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:t("common:refresh")})]}),s.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:yK.map(ae=>{const ze=t(`prompts.${ae.id}Prompt`),Xe=t(`prompts.${ae.id}Examples`,{returnObjects:!0}),Ve=Array.isArray(Xe)?Xe:[];return s.jsx("button",{onClick:()=>gt(ze),className:`group text-left w-full rounded-xl border ${ae.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${ae.bgColor} flex items-center justify-center shrink-0`,children:ae.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ae.color} bg-clip-text text-transparent`,children:t(`prompts.${ae.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ae.id}Desc`)}),Ve.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Ve.slice(0,2).map((et,yt)=>s.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:pe=>{pe.stopPropagation(),gt(ze+et)},children:["“",et,"”"]},yt))})]})]})},ae.id)})})]}),s.jsx("div",{className:"mb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>ke("creations"),className:`text-sm font-semibold transition-colors ${re==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>ke("orgAssets"),className:`text-sm font-semibold transition-colors ${re==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),re==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ae=>s.jsx("button",{onClick:()=>g(ae),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${p===ae?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ae==="all"?"myCreations.filterAll":ae==="agent"?"myCreations.filterAgents":ae==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ae))}),re==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ae=>s.jsx("button",{onClick:()=>dt(ae),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${st===ae?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ae==="all"?"myCreations.filterAll":ae==="agent"?"myCreations.filterAgents":ae==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ae))})]})}),re==="orgAssets"&&$.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:$.map(ae=>s.jsx("button",{onClick:()=>I(ae.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${le===ae.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:ae.name},ae.id))}),re==="orgAssets"&&($.length===0&&!Oe?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):Oe?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):ot.length===0?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):s.jsx(Er,{children:ot.map(ae=>{const ze=ae.author?.username&&ae.slug?`${it.getUrl()}/@${encodeURIComponent(ae.author.username)}/${encodeURIComponent(ae.slug)}`:null;return s.jsx(sa,{type:ae.itemType,name:ae.name,description:ae.description,seed:ae.slug||ae.id||ae.name,icon:ae.icon,cover:ae.thumbnailUrl,hubBase:it.getUrl(),author:ae.author,version:ae.version,rating:parseFloat(ae.avgRating)||0,ratingCount:ae.ratingCount,downloadCount:ae.downloadCount,actions:ze?s.jsxs("a",{href:ze,target:"_blank",rel:"noopener noreferrer",onClick:Xe=>{Xe.stopPropagation(),Gd()&&(Xe.preventDefault(),Ro(ze))},className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},ae.id)})})),re==="creations"&&(m&&u.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):Ge.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),s.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):s.jsx(Er,{children:Ge.map(ae=>{const ze=ae.meta.displayName||ae.meta.name||ae.name,Xe=ae.meta.description||"",Ve=`${ae.type}/${ae.name}`,et=x?.key===Ve?x.action:null,yt=D.get(Ve),pe=ae.meta.version||"1.0.0",V=!!yt,ye=V&&yt.version!==pe,Qe=()=>{const ct=it.getUser();return!yt||!ct?null:`${it.getUrl()}/@${encodeURIComponent(ct.username)}/${encodeURIComponent(yt.slug)}`},he=V&&(yt?.moderationStatus==="pending"||yt?.moderationStatus==="rejected"||!!yt?.pendingReview),ve=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:ct=>ct.stopPropagation(),children:[w.has(Ve)?s.jsxs("button",{onClick:()=>z(ae),disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:bg-red-500/10 hover:text-red-500 hover:border-red-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"17 8 12 3 7 8"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(et==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>_(ae),disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(et==="install"?"common:installing":"common:install")]}),V&&he?yt?.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.underReview")]}):yt?.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}):s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.updateUnderReview")]}):V?s.jsxs(s.Fragment,{children:[ye&&s.jsxs("button",{onClick:()=>{const ct=yt?.visibility??"public";Rt(ae,{visibility:ct})},disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("polyline",{points:"1 20 1 14 7 14"}),s.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),et==="share"?t("common:sharing"):t("share.updateVersion",{version:pe})]}),s.jsxs("a",{href:Qe()??"#",target:"_blank",rel:"noopener noreferrer",onClick:ct=>{const Xt=Qe();Gd()&&Xt&&(ct.preventDefault(),Ro(Xt))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${yt?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":yt?.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:[yt?.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):yt?.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),yt?.visibility==="org"?t("visibility.sharedOrg"):yt?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>Z({key:Ve,name:ze}),disabled:!!et,className:"text-xs px-2.5 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-amber-500 hover:border-amber-500/40 hover:bg-amber-500/10 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("removeFromHubTooltip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):s.jsxs("button",{onClick:async()=>{await it.ensureAuth(),Array.isArray(ae.meta.screenshots)&&ae.meta.screenshots.length>0?Q(ae):X(ae)},disabled:!!et,className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-green-600 hover:border-green-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"18",cy:"5",r:"3"}),s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"19",r:"3"}),s.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),s.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(et==="share"?"common:sharing":"common:share")]})]}),Ye=s.jsx("button",{onClick:()=>C(ae),disabled:!!et,className:"w-7 h-7 rounded-lg text-fg-muted hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 inline-flex items-center justify-center",title:t("deleteLocalTooltip"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"3 6 5 6 21 6"}),s.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),nt=ae.meta.icon,Dt=!!nt&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)?nt.startsWith("http")||nt.startsWith("/")?nt:`/api/builder/artifacts/${ae.type}s/${encodeURIComponent(ae.name)}/images/${encodeURIComponent(nt.split("/").pop()??"")}`:nt;return s.jsx(sa,{type:ae.type,name:ze,description:Xe,seed:Ve,icon:Dt,version:pe,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:ct=>{ct.stopPropagation(),Ce.system.openPath(ae.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ae.path,children:xK(ae.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(ae.updatedAt).toLocaleDateString()})]}),headerAction:Ye,actions:ve,onClick:()=>mt(ae)},Ve)})})),j&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:j.meta.displayName||j.meta.name||j.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ae=j;_(null),jt(ae)},onCancel:()=>_(null)}),O&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:O.meta.displayName||O.meta.name||O.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ae=O;z(null),Jt(ae)},onCancel:()=>z(null)}),T&&s.jsx(dr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:Me,onCancel:()=>C(null)}),W&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:W.name}),confirmLabel:t("unshare"),onConfirm:()=>{be()},onCancel:()=>Z(null)}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)}),se&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>X(null),children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ae=>ae.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),s.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>{const ae=se;X(null),Q(ae)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),s.jsx("button",{onClick:()=>{const ae=se;X(null),mt(ae)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>J(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ae=>ae.stopPropagation(),children:s.jsx(SK,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>J(null),onConfirm:(ae,ze)=>{const Xe=F;J(null),Rt(Xe,{priceCents:ze>0?ze:void 0})}})})}),B&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Q(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ae=>ae.stopPropagation(),children:s.jsx(kK,{onCancel:()=>Q(null),onConfirm:(ae,ze,Xe,Ve)=>{const et=B;Q(null),Rt(et,{visibility:ae,orgId:ze,priceCents:Xe,donationsEnabled:Ve})}})})})]})})}function kK({onCancel:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,u]=k.useState([]),[d,m]=k.useState(""),[h,p]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(p(!0),it.myOrgs().then(C=>{u(C.memberships),C.memberships.length>0&&m(C.memberships[0].id)}).catch(()=>{}).finally(()=>p(!1)))},[r,l.length]);const N=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(C=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===C.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===C.value,onChange:()=>o(C.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:C.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:C.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:C.desc})]})]},C.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),h?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:C=>m(C.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(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),N&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:T3.map(C=>s.jsx("button",{type:"button",onClick:()=>x(C.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===C.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:C.label},C.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:C=>w(C.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),N&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,N&&g>0?g:void 0,N?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const T3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function SK({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(e?"shareMode.titleUpdate":"shareMode.title")}),s.jsx("div",{className:"space-y-2 mb-5",children:T3.map(u=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===u.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===u.cents,onChange:()=>l(u.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:u.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:u.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},u.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>n(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(e?"shareMode.update":"shareMode.share")})]})]})}const NK=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:C3},Symbol.toStringTag,{value:"Module"}));async function E3(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(r=>r.id===t);if(n)return{items:[n,...e.filter(r=>r.id!==t)],highlighted:n,missing:!1};try{const{item:r}=await it.getItem(t);return r?{items:[r,...e],highlighted:r,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function CK(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}function h0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function x4(e,t){return e.i18n?.[t]?.description||e.description}const TK={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function EK({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=ft(["store","common"]),l=o.language,[u,d]=k.useState(""),[m,h]=k.useState([]),[p,g]=k.useState([]),[x,y]=k.useState(null),[w,N]=k.useState({}),[T,C]=k.useState(!1),[j,_]=k.useState(!0),[O,z]=k.useState(new Map),[D,H]=k.useState(new Set),[W,Z]=k.useState(null),[U,Y]=k.useState(null),se=k.useCallback(async()=>{try{const[J,B]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const re of J.artifacts){if(re.type!=="agent")continue;const ke=!!B.installed[`agent/${re.name}`];Q.set(re.name,{installed:ke,localVersion:re.meta.version||void 0,localUpdatedAt:re.updatedAt})}z(Q)}catch{}},[]),X=k.useCallback(async()=>{_(!0);try{const J=u?it.search({type:"agent",q:u,limit:50}):vi(Tr.hubAgents)??it.search({type:"agent",limit:50}),B=new URLSearchParams;u&&B.set("q",u);const Q=fetch("/api/templates?"+B.toString()).then(G=>G.json()).catch(()=>({templates:[]})),[re,ke]=await Promise.all([J.catch(()=>({items:[],total:0})),Q,se(),it.isAuthenticated()?it.purchases.mine().then(G=>H(new Set(G.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),$=await E3(re?.items??[],t);g($.items),h(Array.isArray(ke.templates)?ke.templates:[]),$.missing&&n?.()}catch{h([]),g([])}finally{_(!1)}},[u,se,t,n]);k.useEffect(()=>{X()},[X]),k.useEffect(()=>{if(!x){N({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(J=>J.json()).then(J=>N(J.files??{})).catch(()=>N({}))},[x]);const F=async(J,B,Q)=>{try{const re=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:J,name:B,orgId:"default",teamId:Q})});if(!re.ok)throw new Error(`Failed: ${re.status}`);C(!1),y(null)}catch(re){Y({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${re}`,variant:"danger"})}};if(W)return s.jsx(Ai,{type:W.type,name:W.name,onBack:()=>Z(null)});if(x){const J={type:"agent",name:x.id,displayName:h0(x,l),version:x.version,description:x4(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},B=s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.roleConfig")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.role")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.position")}),s.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${TK[x.agentRole]??""}`,children:x.agentRole})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.skills")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(Q=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:Q},Q)),x.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.starterTasks")}),s.jsx("div",{className:"space-y-2",children:x.starterTasks.map((Q,re)=>s.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${Q.priority==="high"?"bg-red-400":Q.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:Q.title}),Q.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:Q.description})]})]},re))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ai,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:J,actionSlot:s.jsx("button",{onClick:()=>C(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium",children:r("agentStore.hireAgent")}),contentSlot:B}),T&&s.jsx(y4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:r("agentStore.title")}),s.jsx("input",{type:"text",placeholder:r("agentStore.searchPlaceholder"),value:u,onChange:J=>d(J.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:j?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((J,B)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},B))}):m.length===0&&p.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:u?r("agentStore.noResults",{search:u}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(u?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):s.jsxs(s.Fragment,{children:[m.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:r("agentStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:r("agentStore.available",{count:m.length})})]}),s.jsx(Er,{columns:3,children:m.map(J=>s.jsx(sa,{type:"agent",name:h0(J,l),description:x4(J,l),seed:J.id,icon:J.icon,version:J.version,category:J.category,tags:J.tags,authorLabel:J.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>y(J)},J.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Er,{columns:3,children:p.map(J=>s.jsx(AK,{item:J,localInfo:O.get(Cc(J)),purchased:Hd(J,D),onStatusChange:se,highlight:J.id===t,onHighlightDone:n,onViewDetail:B=>Z({type:"agent",name:B})},J.id))})]})]})}),T&&x&&s.jsx(y4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Cc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return qd(n||e.name,"hub-pkg")}function wi(e){return(async()=>{const t=await it.download(e.id),n=t.name||e.name,r=t.config??{},o=Cc(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",u={type:"hub",hubItemId:e.id},d=(t.version||e.version||(typeof r.version=="string"?r.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Ce.builder.artifacts.import(l,o,t.files,u,d);else{const m={...r,...d?{version:d}:{},name:o,displayName:r.displayName||n,description:e.description,source:u};await Ce.builder.artifacts.save(l,m)}return await Ce.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Og(e,t){t("checking"),await it.ensureAuth();const n=await it.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await wi(e),"installed";try{if((await it.creator.getBalance()).availableBalance>=(e.priceCents??0)){const l=await it.purchases.payWithEarnings(e.id);if(l.ok||l.alreadyOwned)return t("installing"),await wi(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=window.open(n.checkoutUrl,"_blank","noopener");return new Promise((o,l)=>{const u=setInterval(async()=>{const d=r?r.closed:!1;try{if((await it.purchases.checkout(e.id)).alreadyOwned){clearInterval(u),t("installing");try{await wi(e),o("installed")}catch(h){l(h)}return}}catch{}if(d){clearInterval(u);try{if((await it.purchases.checkout(e.id)).alreadyOwned){t("installing"),await wi(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function AK({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:u}){const{t:d}=ft(["store"]),[m,h]=k.useState(!1),[p,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const W=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(W)}},[o,l]);const N=t?.installed??!1,T=N&&e.version&&t?.localVersion&&CK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await wi(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Z){const U=Z instanceof Error?Z.message:"";U.includes("402")||U.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},_=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await Og(e,U=>{U==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):U==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Z){g(Z instanceof Error?Z.message:d("card.failed"))}finally{h(!1)}}},O=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,z=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{N&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):N?s.jsxs("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):C&&!n?s.jsx("button",{onClick:W=>{_(W)},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?p||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",O]})}):s.jsx("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),p&&!(C&&!n)&&s.jsx("span",{className:`text-[10px] ${p===d("card.failed")||p===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:p})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(sa,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:it.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:N,glowing:y,onClick:D,actions:H})})}function y4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,u]=k.useState(`${h0(e,t)} Agent`),[d,m]=k.useState(""),[h,p]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>p(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await r(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsx("div",{className:"flex items-center gap-3 mb-5",children:s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold",children:o("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:o("hireModal.creating",{name:h0(e,t)})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.agentName")}),s.jsx("input",{type:"text",value:l,onChange:w=>u(w.target.value),className:"input-field",autoFocus:!0})]}),h.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:o("hireModal.noTeam")}),h.map(w=>s.jsx("option",{value:w.id,children:w.name},w.id))]})]}),s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:o("hireModal.agentConfig")}),s.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||o("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:o("hireModal.cancel")}),s.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function Yh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function v4(e,t){return e.i18n?.[t]?.description||e.description}function w4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function _K(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}function jK({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,[l,u]=k.useState(""),[d,m]=k.useState([]),[h,p]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[N,T]=k.useState(!0),[C,j]=k.useState(!1),[_,O]=k.useState(null),[z,D]=k.useState(new Map),[H,W]=k.useState(new Set),[Z,U]=k.useState(null),Y=k.useCallback(async()=>{try{const[F,J]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),B=new Map;for(const Q of F.artifacts){if(Q.type!=="team")continue;const re=!!J.installed[`team/${Q.name}`];B.set(Q.name,{installed:re,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(B)}catch{}},[]),se=k.useCallback(async()=>{T(!0);try{const F=l?it.search({type:"team",q:l,limit:50}):vi(Tr.hubTeams)??it.search({type:"team",limit:50}),[J,B]=await Promise.all([F.catch(()=>({items:[],total:0})),Ce.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),Y(),it.isAuthenticated()?it.purchases.mine().then(re=>W(new Set(re.purchases.map(ke=>ke.itemId)))).catch(()=>{}):Promise.resolve()]),Q=await E3(J?.items??[],e);p(Q.items),m(B?.templates??[]),Q.missing&&t?.()}catch{m([]),p([])}finally{T(!1)}},[l,Y,e,t]);k.useEffect(()=>{se()},[se]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>w(F.files??{})).catch(()=>w({}))},[g]);const X=async F=>{j(!0),O(null);try{const B=(await Ce.teams.create(F.name,F.description)).team.id;let Q,re=0;const ke=[];for(const G of F.members){const le=G.count??1;for(let I=0;I<le;I++){const Ee=G.name??`${F.name} Agent ${I+1}`,Ue=le>1?`${Ee} ${I+1}`:Ee,Oe=G.roleName??G.templateId;try{const We=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Ue,...Oe?{roleName:Oe}:{},orgId:"default",teamId:B,agentRole:G.role??"worker",skills:G.skills??[]})});if(We.ok){re++;const st=await We.json();G.role==="manager"&&!Q&&(Q=st.agent?.id)}else{const st=await We.json().catch(()=>({error:`HTTP ${We.status}`}));ke.push(`${Ue}: ${st.error??We.statusText}`)}}catch(We){ke.push(`${Ue}: ${String(We)}`)}}}Q&&await Ce.teams.update(B,{managerId:Q,managerType:"agent"}).catch(()=>{});const $=ke.length>0?` (${ke.length} failed: ${ke[0]})`:"";O({ok:re>0,message:`Team "${Yh(F,o)}" deployed with ${re} agent(s)${$}`})}catch(J){O({ok:!1,message:`Failed: ${J}`})}finally{j(!1)}};if(Z)return s.jsx(Ai,{type:Z.type,name:Z.name,onBack:()=>U(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const J={type:"team",name:g.id,displayName:Yh(g,o),version:g.version,description:v4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(Q=>({name:w4(g,Q.name??Q.roleName??Q.templateId??"Agent",o),role:Q.role??"worker",roleName:Q.roleName??Q.templateId,count:Q.count??1,skills:Q.skills??[]}))}},B=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),s.jsx("div",{className:"p-5 space-y-2",children:g.members.map((Q,re)=>{const ke=w4(g,Q.name??Q.roleName??Q.templateId??"Agent",o);return s.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${Q.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(ke[0]??"?").toUpperCase()}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-fg-primary font-medium",children:ke}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${Q.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:Q.role??"worker"}),(Q.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",Q.count]})]}),(Q.roleName||Q.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:Q.roleName??Q.templateId})]}),Q.skills&&Q.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[Q.skills.slice(0,3).map($=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:$},$)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},re)})})]});return s.jsx(s.Fragment,{children:s.jsx(Ai,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:J,contentSlot:B,actionSlot:s.jsxs(s.Fragment,{children:[_&&s.jsx("span",{className:`text-xs ${_.ok?"text-green-500":"text-red-500"}`,children:_.message}),s.jsx("button",{onClick:()=>{X(g)},disabled:C,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(C?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),s.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:F=>u(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:N?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,J)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},J))}):d.length===0&&h.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):s.jsxs(s.Fragment,{children:[d.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),s.jsx(Er,{columns:2,children:d.map(F=>s.jsx(sa,{type:"team",name:Yh(F,o),description:v4(F,o),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(F)},F.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Er,{columns:2,children:h.map(F=>s.jsx(MK,{item:F,localInfo:z.get(Cc(F)),purchased:Hd(F,H),onStatusChange:Y,highlight:F.id===e,onHighlightDone:t,onViewDetail:J=>U({type:"team",name:J})},F.id))})]})]})})]})}function MK({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:u}){const{t:d}=ft(["store"]),[m,h]=k.useState(!1),[p,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const W=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(W)}},[o,l]);const N=t?.installed??!1,T=N&&e.version&&t?.localVersion&&_K(e.version,t.localVersion),C=(e.priceCents??0)>0,j=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await wi(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Z){const U=Z instanceof Error?Z.message:"";U.includes("402")||U.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},O=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await Og(e,U=>{U==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):U==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Z){g(Z instanceof Error?Z.message:d("card.failed"))}finally{h(!1)}}},z=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{N&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):N?s.jsxs("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):C&&!n?s.jsx("button",{onClick:W=>{O(W)},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?p||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",j]})}):s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),p&&s.jsx("span",{className:`text-[10px] ${p===d("card.failed")||p===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:p})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(sa,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:it.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:N,glowing:y,onClick:D,actions:H})})}function Xh(e,t){return e.i18n?.[t]?.displayName||e.name}function Qh(e,t){return e.i18n?.[t]?.description||e.description||""}function A3(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}const RK={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 OK({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=ft(["store"]),[u,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",h=t.find(C=>C.name===e.name||C.name===m||!!e.slug&&C.name===e.slug),p=!!h,g=p&&e.version&&h?.version&&A3(e.version,h.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),N=async()=>{if(!u){d(!0),w("");try{await wi(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(C){const j=C instanceof Error?C.message:"";j.includes("402")||j.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!u){d(!0),w("");try{await Og(e,j=>{j==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):j==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(C){r(C instanceof Error?C.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.jsx("button",{onClick:()=>{N()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:u?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(p)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),h?.version?` (v${h.version})`:""]});if(x&&!n){const C=`$${((e.priceCents??0)/100).toFixed(2)}`;return s.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.jsx("button",{onClick:()=>{T()},disabled:u,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:u?y||l("card.installing"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",C]})})})}return s.jsx("button",{onClick:()=>{N()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(u?"card.installing":"card.install")})}function k4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:u,type:d="skill"}){const m=k.useRef(null),[h,p]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),p(!0);const y=setTimeout(()=>{p(!1)},4e3);return()=>clearTimeout(y)}},[l,u]);const g=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:h?"animate-pulse":"",children:s.jsx(sa,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Dd(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:it.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:x,actions:s.jsx(OK,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function DK({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,l=Bo(),[u,d]=k.useState("skills"),[m,h]=k.useState(null),[p,g]=k.useState(new Set),[x,y]=k.useState([]),[w,N]=k.useState(null),[T,C]=k.useState([]),[j,_]=k.useState(0),[O,z]=k.useState(1),[D,H]=k.useState([]),[W,Z]=k.useState(""),[U,Y]=k.useState("score"),[se,X]=k.useState(""),[F,J]=k.useState(!1),[B,Q]=k.useState([]),[re,ke]=k.useState(!1),[$,G]=k.useState([]),[le,I]=k.useState(""),[Ee,Ue]=k.useState(!1),[Oe,We]=k.useState([]),[st,dt]=k.useState([]),[Et,gt]=k.useState(new Set),[jt,Jt]=k.useState(!1),[Rt,be]=k.useState(""),Me=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],Ge=(V,ye="success")=>{h({text:V,type:ye}),setTimeout(()=>h(null),ye==="error"?1e4:4e3)},ot=k.useCallback(async()=>{try{const V=await Ce.skills.list();y(V.skills)}catch{}},[]),mt=k.useCallback(async()=>{ke(!0);try{const V=await Ce.skills.builtin();Q(V.skills)}catch{}ke(!1)},[]),ae=k.useCallback(async V=>{J(!0);try{const ye=await Ce.skills.registrySkillhub({q:V?.q,category:V?.category,page:V?.page??1,limit:24,sort:V?.sort??U});C(ye.skills),_(ye.total),ye.categories?.length&&H(ye.categories)}catch{}J(!1)},[U]),ze=k.useCallback(async V=>{Ue(!0);try{const ye=await Ce.skills.registrySkillssh(V);G(ye.skills)}catch{}Ue(!1)},[]),Xe=k.useCallback(async V=>{Jt(!0);try{const ye=V?it.search({type:"skill",q:V,limit:50}):vi(Tr.hubSkills)??it.search({type:"skill",limit:50}),Qe=it.search({subtype:"connector",q:V||void 0,limit:50}).catch(()=>({items:[]})),[he,ve]=await Promise.all([ye,Qe,it.isAuthenticated()?it.purchases.mine().then(xt=>gt(new Set(xt.purchases.map(Dt=>Dt.itemId)))).catch(()=>{}):Promise.resolve()]);let Ye=he?.items??[],nt=ve?.items??[];if(e){const xt=Ye.some(ct=>ct.id===e),Dt=nt.some(ct=>ct.id===e);if(!xt&&!Dt)try{const{item:ct}=await it.getItem(e);ct?.subtype==="connector"?nt=[ct,...nt]:ct?Ye=[ct,...Ye]:t?.()}catch{t?.()}else xt&&(Ye=[Ye.find(Xt=>Xt.id===e),...Ye.filter(Xt=>Xt.id!==e)]),Dt&&(nt=[nt.find(Xt=>Xt.id===e),...nt.filter(Xt=>Xt.id!==e)])}We(Ye),dt(nt)}catch{}Jt(!1)},[e,t]);k.useEffect(()=>{ot(),mt(),ae(),ze()},[]),k.useEffect(()=>{u==="skills"&&Xe(Rt)},[u,Rt,Xe]);const Ve=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"skillhub",slug:V.slug,sourceUrl:V.homepage,description:V.description_zh??V.description,category:"custom",version:V.version});await ot(),Ge(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Ge(`Download failed for "${V.name}". You can try manually from: ${V.homepage}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},et=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"skillssh",sourceUrl:V.url,githubRepo:`${V.author}/${V.repo}`,githubSkillPath:V.name});await ot(),Ge(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Ge(`Download failed for "${V.name}". You can try manually from: ${V.url}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},yt=async V=>{g(ye=>new Set(ye).add(V.name));try{const ye=await Ce.skills.install({name:V.name,source:"builtin"});await ot(),await mt(),Ge(`"${V.name}" installed (${ye.method}) → ${ye.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ye){Ge(`Install failed for "${V.name}": ${ye}`,"error")}g(ye=>{const Qe=new Set(ye);return Qe.delete(V.name),Qe})},pe=$.filter(V=>{if(!le)return!0;const ye=le.toLowerCase();return V.name.toLowerCase().includes(ye)||V.repo.toLowerCase().includes(ye)});if(w){const V=w,ye={};V.instructions&&(ye["SKILL.md"]=V.instructions);const Qe={type:"skill",name:V.name,displayName:Xh(V,o),version:V.version,description:Qh(V,o),author:V.author??"",category:V.category??"general",tags:V.tags,files:ye,skill:{skillFile:V.instructions?"SKILL.md":"",requiredPermissions:V.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},he=V.installed&&V.installedVersion&&A3(V.version,V.installedVersion)?s.jsx("button",{onClick:()=>{yt(V)},disabled:p.has(V.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:p.has(V.name)?n("card.upgrading"):n("card.upgrade",{version:V.version})}):V.installed?s.jsxs("span",{className:"px-4 py-1.5 text-xs bg-green-500/10 text-green-500 rounded-lg border border-green-500/20 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),V.installedVersion?` v${V.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{yt(V)},disabled:p.has(V.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:p.has(V.name)?n("card.installing"):n("card.install")}),ve=s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[V.category&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),s.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${RK[V.category]??"bg-gray-500/15 text-fg-secondary"}`,children:V.category})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:V.version})]}),V.hasMcpServers&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),V.hasInstructions&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),s.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(V.requiredPermissions.length>0||V.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[V.requiredPermissions.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.requiredPermissions.map(Ye=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:Ye},Ye))})]}),V.tags.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.tags.map(Ye=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:Ye},Ye))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ai,{type:"skill",name:V.name,onBack:()=>N(null),readOnly:!0,initialManifest:Qe,actionSlot:he,contentSlot:ve}),m&&s.jsx("div",{className:`mx-7 mb-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[s.jsx("div",{className:"flex items-center h-14",children:s.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),s.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:Me.map(V=>s.jsx("button",{onClick:()=>d(V.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${u===V.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(V.labelKey)},V.id))})]}),m&&s.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text}),u==="skills"&&(()=>{const V=Rt.trim().toLowerCase(),ye=V?B.filter(ve=>Xh(ve,o).toLowerCase().includes(V)||Qh(ve,o).toLowerCase().includes(V)):B,Qe=re&&jt,he=ye.length===0&&Oe.length===0&&st.length===0;return s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{value:Rt,onChange:ve=>be(ve.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"}`})}),Qe&&he?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((ve,Ye)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Ye))}):he?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),s.jsx("div",{children:n("skillStore.noBuiltin")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):s.jsxs(s.Fragment,{children:[ye.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:ye.length})})]}),s.jsx(Er,{columns:3,children:ye.map(ve=>s.jsx(sa,{type:"skill",name:Xh(ve,o),description:Qh(ve,o),seed:ve.name,icon:Dd(ve.name,ve.category),version:ve.version,category:ve.category,tags:ve.tags,authorLabel:ve.author||void 0,installed:ve.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:ve.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>N(ve)},ve.name))})]}),Oe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Er,{columns:3,children:Oe.map(ve=>s.jsx(k4,{item:ve,installedSkills:x,purchased:Hd(ve,Et),onMsg:Ge,onRefresh:()=>{ot(),Xe(Rt)},highlight:ve.id===e,onHighlightDone:t},ve.id))})]}),st.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"mb-3",children:[s.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),s.jsx(Er,{columns:3,children:st.map(ve=>s.jsx(k4,{item:ve,type:"connector",installedSkills:x,purchased:Hd(ve,Et),onMsg:Ge,onRefresh:()=>{ot(),Xe(Rt)},highlight:ve.id===e,onHighlightDone:t},ve.id))})]})]})]})})(),u==="skillhub"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsxs("select",{value:W,onChange:V=>{Z(V.target.value),z(1),ae({q:se||void 0,category:V.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),D.map(V=>s.jsx("option",{value:V,children:V},V))]}),s.jsxs("select",{value:U,onChange:V=>{Y(V.target.value),z(1),ae({q:se||void 0,category:W||void 0,page:1,sort:V.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"score",children:n("skillStore.sortScore")}),s.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),s.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),s.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),s.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[s.jsx("input",{value:se,onChange:V=>X(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(z(1),ae({q:se||void 0,category:W||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),s.jsx("button",{onClick:()=>{z(1),ae({q:se||void 0,category:W||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),s.jsx("div",{children:n("skillStore.noSkillhub")})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:j.toLocaleString()})}),s.jsx(Er,{columns:3,children:T.map(V=>{const ye=x.some(Qe=>Qe.name===V.name||Qe.name===V.slug);return s.jsx(sa,{type:"skill",name:V.name,description:V.description_zh??V.description??"",seed:V.slug,icon:Dd(V.slug||V.name,V.tags?.[0]),version:V.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:V.tags,installed:ye,hideStats:!0,onClick:()=>window.open(V.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[V.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",V.stars.toLocaleString()]}),V.downloads>0&&s.jsxs("span",{children:[V.downloads>=1e4?`${(V.downloads/1e4).toFixed(1)}万`:V.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ye?void 0:s.jsx("button",{onClick:()=>{Ve(V)},disabled:p.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:p.has(V.name)?"...":n("card.install")})},V.slug)})}),j>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:O<=1,onClick:()=>{const V=O-1;z(V),ae({q:se||void 0,category:W||void 0,page:V})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.prevPage")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:O,total:Math.ceil(j/24)})}),s.jsx("button",{disabled:O>=Math.ceil(j/24),onClick:()=>{const V=O+1;z(V),ae({q:se||void 0,category:W||void 0,page:V})},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")})]})]})]}),u==="skillssh"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[s.jsx("input",{value:le,onChange:V=>I(V.target.value),onKeyDown:V=>{V.key==="Enter"&&le.trim()&&ze(le)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),s.jsx("button",{onClick:()=>{le.trim()&&ze(le)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ee?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):pe.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),s.jsx("div",{children:n("skillStore.browseSkillssh")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):s.jsx(Er,{columns:3,children:pe.map(V=>{const ye=x.some(Qe=>Qe.name===V.name);return s.jsx(sa,{type:"skill",name:V.name,description:V.description||"",seed:`${V.author}-${V.name}`,icon:Dd(V.name),authorLabel:`${V.author}/${V.repo}`,showTypeBadge:!1,installed:ye,hideStats:!0,cornerLabel:ye?void 0:"skills.sh",onClick:()=>window.open(V.url,"_blank","noopener,noreferrer"),footerLeft:V.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[V.installs," installs"]}):void 0,actions:ye?void 0:s.jsx("button",{onClick:()=>{et(V)},disabled:p.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:p.has(V.name)?"...":n("card.install")})},`${V.author}-${V.name}`)})})]})]})}const LK=["agent","team","skill","connector"];function Zh({title:e,subtitle:t,onMore:n,moreLabel:r}){return s.jsxs("div",{className:"flex items-end justify-between mb-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"section-title",children:e}),t&&s.jsx("p",{className:"section-subtitle",children:t})]}),n&&s.jsxs("button",{className:"section-link",onClick:n,children:[r??"View all"," →"]})]})}function IK({item:e,onOpen:t}){const n=Ko(e.subtype==="connector"?"connector":e.itemType),r=Rg(n,e.slug||e.name),o=Ti[n];return s.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:r},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),s.jsx("svg",{className:"absolute -right-8 -bottom-10 opacity-20",width:"220",height:"220",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",fill:"white"})}),s.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[s.jsxs("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:["★ Featured · ",o.label]}),s.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),s.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(f0,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:it.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),s.jsxs("span",{children:["↓ ",Ao(e.downloadCount)]}),(e.priceCents??0)>0?s.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):s.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function S4({items:e,onOpen:t}){return s.jsx(Er,{columns:3,children:e.map(n=>s.jsx(sa,{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:it.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 N4(){return s.jsx(Er,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function PK({onOpenType:e}){const{t}=ft(["store","common"]),[n,r]=k.useState([]),[o,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await it.search({limit:60,sort:"popular"});g||r(x.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const u=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),h=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),p=g=>e(Ko(g.subtype==="connector"?"connector":g.itemType),g.id);return s.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[s.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),s.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:LK.map(g=>s.jsxs("button",{onClick:()=>e(g),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Ti[g].gradient} hover:opacity-90 transition-opacity`,children:[Ti[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ti[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):u.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:u.map(g=>s.jsx(IK,{item:g,onOpen:()=>p(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(N4,{}):d.length>0?s.jsx(S4,{items:d,onOpen:p}):s.jsx(zK,{})]}),s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(N4,{}):m.length>0?s.jsx(S4,{items:m,onOpen:p}):null]}),h.length>0&&s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:h.map((g,x)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(f0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:it.getUrl(),size:48,verified:x<3}),x<3&&s.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:x+1})]}),s.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),s.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",Ao(g.downloads)]})]},g.author?.username||x))})]})]})}function zK(){const{t:e}=ft(["store"]);return s.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[s.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),s.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),s.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Sd(e,t,n){return e.i18n?.[n]?.[t]}function BK(){const{t:e,i18n:t}=ft(["store","common"]),n=Bo(),r=t.language,[o,l]=k.useState([]),[u,d]=k.useState({}),[m,h]=k.useState(new Set),[p,g]=k.useState(null),[x,y]=k.useState(!0),[w,N]=k.useState(""),[T,C]=k.useState("all"),[j,_]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[H,W,Z,U]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}})),Ce.skills.updates().catch(()=>({updates:[],count:0})),Ce.skills.builtin().catch(()=>({skills:[]}))]),Y={};for(const F of Z.updates)Y[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(Y);const se=H.artifacts.filter(F=>{const J=`${F.type}/${F.name}`;return!!W.installed[J]}),X=new Set(se.filter(F=>F.type==="skill").map(F=>F.name));for(const F of U.skills)!F.installed||X.has(F.name)||!(W.installed[`skill/${F.name}`]||Y[F.name])&&!F.updateAvailable||!W.installed[`skill/${F.name}`]&&!Y[F.name]||(se.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[r]?.displayName||F.name,description:F.i18n?.[r]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),X.add(F.name));for(const[F,J]of Object.entries(Y))X.has(F)||(se.push({type:"skill",name:F,meta:{displayName:J.displayName||F,description:J.description||"",version:J.installedVersion},path:"",updatedAt:""}),X.add(F));l(se)}catch{}y(!1)},[r]);k.useEffect(()=>{O()},[O]),k.useEffect(()=>{const H=()=>{O()};return window.addEventListener("markus:data-changed",H),()=>window.removeEventListener("markus:data-changed",H)},[O]),k.useEffect(()=>{if(!p)return;const H=setTimeout(()=>g(null),3e3);return()=>clearTimeout(H)},[p]);const z=async(H,W)=>{if(!m.has(H)){h(Z=>new Set(Z).add(H));try{await Ce.skills.install({name:H,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:H,version:W}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:H}),type:"error"})}h(Z=>{const U=new Set(Z);return U.delete(H),U})}},D=o.filter(H=>{if(T!=="all"&&H.type!==T)return!1;if(!w)return!0;const W=w.toLowerCase(),Z=(Sd(H.meta,"displayName",r)||H.meta.displayName||H.name).toLowerCase(),U=(Sd(H.meta,"description",r)||H.meta.description||"").toLowerCase();return Z.includes(W)||U.includes(W)}).sort((H,W)=>{const Z=H.type==="skill"&&u[H.name]?1:0;return(W.type==="skill"&&u[W.name]?1:0)-Z});return j?s.jsx(Ai,{type:j.type,name:j.name,onBack:()=>_(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(u).length>0&&s.jsxs("span",{className:"px-2 py-0.5 text-[11px] font-medium rounded-md bg-amber-500/15 text-amber-600 border border-amber-500/25",children:[e("installedTab.updateAvailable")," · ",Object.keys(u).length]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[s.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(H=>s.jsx("button",{onClick:()=>C(H),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===H?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${H==="all"?"All":H==="agent"?"Agents":H==="team"?"Teams":"Skills"}`)},H))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:H=>N(H.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):D.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Er,{columns:3,children:D.map(H=>{const W=Sd(H.meta,"displayName",r)||H.meta.displayName||H.name,Z=Sd(H.meta,"description",r)||H.meta.description||"",U=H.meta.version||"",Y=H.meta.author||"",se=H.meta.tags??[],X=H.meta.category||"",F=H.meta.icon,J=H.type==="skill"?u[H.name]:void 0;return s.jsx(sa,{type:H.type,name:W,description:Z,seed:H.name,icon:F,author:null,authorLabel:Y||void 0,version:J?J.installedVersion:U,category:X,tags:se,installed:!J,hideStats:!0,cornerLabel:J?e("installedTab.updateAvailable"):void 0,onClick:()=>{H.path&&_({type:H.type,name:H.name})},actions:J?s.jsx("button",{type:"button",disabled:m.has(H.name),onClick:()=>{z(H.name,J.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(H.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:J.availableVersion})}):void 0},`${H.type}/${H.name}`)})})}),p&&s.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-sm shadow-lg ${p.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:p.text})]})}const UK=50,$K=30;function HK(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),u=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const h=m.changedTouches[0].clientX-o.current,p=m.changedTouches[0].clientY-l.current,g=Math.abs(h),x=Math.abs(p);if(g<UK||Math.atan2(x,g)*(180/Math.PI)>$K)return;if(r?.scrollContainerRef?.current){const N=r.scrollContainerRef.current,T=N.scrollLeft<=1,C=N.scrollLeft+N.clientWidth>=N.scrollWidth-1;if(h>0&&!T||h<0&&!C)return}const w=e.findIndex(N=>N.id===t);h<0&&w<e.length-1?n(e[w+1].id):h>0&&w>0?n(e[w-1].id):h>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():h<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:u,onTouchEnd:d}}const FK=["builder","discover","agents","teams","skills","installed"],qK={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function qp(e){return!!e&&FK.includes(e)}function C4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:qp(t)?t:"builder",installId:e}}function GK({authUser:e}){const{t}=ft(["nav","store","common"]),n=k.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[r]=k.useState(C4),[o,l]=k.useState(r.tab),[u,d]=k.useState(r.installId),m=HK(n,o,l);k.useEffect(()=>{const p=C4();p.installId&&(d(p.installId),qp(p.tab)&&l(p.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const p=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");qp(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",p),()=>window.removeEventListener("markus:navigate",p)},[]);const h=(p,g)=>{g&&d(g),l(qK[p]??"agents")};return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[s.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[s.jsx(o5,{className:"ml-2"}),n.map(p=>s.jsx("button",{onClick:()=>l(p.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${o===p.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:p.label},p.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(C3,{authUser:e}),o==="discover"&&s.jsx(PK,{onOpenType:h}),o==="agents"&&s.jsx(EK,{authUser:e,highlightItemId:u,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(jK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(DK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(BK,{})]})]})}const T4="usageType",Jh="profile";function VK({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=ft(["onboarding","common"]),[u,d]=k.useState(0),[m,h]=k.useState(""),[p,g]=k.useState(""),[x,y]=k.useState(""),[w,N]=k.useState(""),[T,C]=k.useState(!1),[j,_]=k.useState(""),[O,z]=k.useState(!1),[D,H]=k.useState(null);k.useEffect(()=>{Ce.auth.me().then(({user:be})=>{be.name&&h(be.name),be.email&&g(be.email),be.avatarUrl&&H(be.avatarUrl);const Me=be.name||be.email?.split("@")[0]||"";Me&&Y(Ge=>Ge||l("usageType.defaultOrgName",{name:Me}))}).catch(()=>{}),Ce.settings.getOrg().then(({org:be})=>{be?.name&&be.name!=="My Organization"&&Y(be.name)}).catch(()=>{}),yn()&&Ce.hubOrgs.invitations().then(be=>{be.invitations?.length>0&&ke(be.invitations)}).catch(()=>{})},[]);const[W,Z]=k.useState(null),[U,Y]=k.useState(""),[se,X]=k.useState(!1),[F,J]=k.useState(!1),[B,Q]=k.useState(""),[re,ke]=k.useState([]),[$,G]=k.useState(null),[le,I]=k.useState(null),Ee=async()=>{const be=U.trim();if(be){X(!0),Q("");try{if(await Ce.settings.updateOrg(be),yn()){const Me=await Ce.hubOrgs.mine(),Ge=Me.orgs?.find(ot=>ot.role==="owner")??Me.orgs?.[0];Ge?.id?await Ce.hubOrgs.update(Ge.id,{name:be}):await Ce.hubOrgs.create(be)}J(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{X(!1)}}},[Ue,Oe]=k.useState(!0),We=async()=>{if(_(""),!m.trim()){_(l("profile.errors.nameRequired"));return}if(!p.trim()){_(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p.trim())){_(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){_(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){_(l("profile.errors.passwordMismatch"));return}C(!0);try{const{user:be}=await Ce.auth.updateProfile(m.trim(),p.trim());x&&await Ce.auth.changePassword("",x),o?.(be),z(!0)}catch{_(l("profile.errors.saveFailed"))}finally{C(!1)}},st=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],dt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:s.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:s.jsx(R7,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:T4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>{Z("personal"),J(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${W==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"👤"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),s.jsxs("button",{onClick:()=>{Z("organization"),J(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${W==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"🏢"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),W==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[re.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),re.map(be=>s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:be.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:be.invitedBy})})]}),s.jsx("button",{onClick:async()=>{G(be.orgId);try{await Ce.hubOrgs.acceptInvitation(be.orgId),I(be.orgId),J(!0)}catch{}finally{G(null)}},disabled:$===be.orgId||le===be.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:le===be.orgId?l("usageType.accepted"):$===be.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},be.orgId)),s.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),s.jsx("input",{type:"text",value:U,onChange:be=>{Y(be.target.value),J(!1),Q("")},placeholder:l("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),B&&s.jsx("p",{className:"text-xs text-red-500",children:B}),s.jsx("button",{onClick:()=>{Ee()},disabled:se||!U.trim()||F,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(se?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:Jh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:O?s.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[s.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",p]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(i5,{currentUrl:D,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange:be=>h(be.target.value),placeholder:l("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",value:p,onChange:be=>g(be.target.value),placeholder:l("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),s.jsx("input",{type:"password",value:x,onChange:be=>y(be.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),x&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),s.jsx("input",{type:"password",value:w,onChange:be=>N(be.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"})]}),j&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:j}),s.jsx("button",{onClick:()=>{We()},disabled:T||!m.trim()||!p.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(T?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"grid grid-cols-3 gap-3",children:st.map(be=>s.jsxs("button",{onClick:()=>n(be.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===be.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:be.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:be.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:be.desc})]},be.value))}),s.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[s.jsx("input",{type:"checkbox",checked:Ue,onChange:be=>Oe(be.target.checked),className:"accent-brand-500 shrink-0"}),s.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],Et=r?dt.filter(be=>be.id!==Jh):dt,gt=Et.findIndex(be=>be.id===T4),jt=Et.findIndex(be=>be.id===Jh),Jt=()=>{u===gt&>>=0&&!W||u===gt&&W==="organization"&&!F||u===jt&&jt>=0&&!O||(u<Et.length-1?d(u+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})}).catch(()=>{}),e()))},Rt=Et[u];return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:s.jsx("div",{className:"w-full max-w-lg",children:s.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[s.jsx("div",{className:"flex gap-1.5 mb-8",children:Et.map((be,Me)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Me<=u?"bg-brand-500":"bg-surface-elevated"}`},Me))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:Rt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:Rt.subtitle}),Rt.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[u>0?s.jsx("button",{onClick:()=>d(u-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):s.jsx("span",{}),s.jsx("button",{onClick:Jt,disabled:jt>=0&&u===jt&&!O||gt>=0&&u===gt&&(!W||W==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${jt>=0&&u===jt&&!O||gt>=0&&u===gt&&(!W||W==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:u===Et.length-1?l("getStarted"):l("common:next")})]})]})})})}const KK="markus:legal-consent",WK="https://markus.global";function YK({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=ft("auth"),[o,l]=k.useState(null),[u,d]=k.useState(""),[m,h]=k.useState(!1),[p,g]=k.useState(""),[x,y]=k.useState(""),[w,N]=k.useState(!1),[T,C]=k.useState(!1),j=Z=>{const U=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${WK}${Z}${U}`},_=()=>{try{localStorage.setItem(KK,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(_(),!0):(N(!1),requestAnimationFrame(()=>N(!0)),!1),z=async(Z,U=!1)=>{if(!(!U&&!O())){d(""),l(Z??"hub");try{await na(Z);const Y=yn(),se=ua();if(!Y||!se){d(n("login.hubUnavailable"));return}const{user:X,needsOnboarding:F}=await Ce.auth.hubLogin(Y,se);e(X,F??!1,{fromHub:!0})}catch(Y){const se=Y instanceof Error?Y.message:"";if(!se.includes("cancelled")){if(!U&&yn())return Ni(),z(Z,!0);d(se||n("login.hubUnavailable"))}}finally{l(null)}}};k.useEffect(()=>{const Z=window.markusDesktop;if(!Z?.consumePendingDeepLinkAuth)return;let U=!1;return Z.consumePendingDeepLinkAuth().then(async Y=>{if(!(U||!Y)&&T){d(""),l("hub");try{const se=await eD(Y),X=yn(),F=ua();if(!se||!X||!F){d(n("login.hubUnavailable"));return}const{user:J,needsOnboarding:B}=await Ce.auth.hubLogin(X,F);e(J,B??!1,{fromHub:!0})}catch{d(n("login.hubUnavailable"))}finally{U||l(null)}}}).catch(()=>{}),()=>{U=!0}},[]);const D=async Z=>{if(Z.preventDefault(),!(!p.trim()||!x)&&O()){d(""),l("local");try{const{user:U,needsOnboarding:Y}=await Ce.auth.login(p.trim(),x);e(U,Y??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},H=n(t?"login.welcomeBack":"login.getStarted"),W="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[s.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute -top-48 left-1/2 -translate-x-1/2 h-[42rem] w-[42rem] rounded-full bg-brand-500/20 blur-[120px]"}),s.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),s.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),s.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-16 h-16 mx-auto mb-4 rounded-2xl shadow-xl shadow-brand-900/20 ring-1 ring-border-default/40"}),s.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:H})]}),s.jsx("div",{className:"bg-surface-secondary/70 backdrop-blur-xl border border-border-default/80 rounded-3xl p-7 sm:p-8 shadow-2xl shadow-black/10",children:m?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),s.jsxs("form",{onSubmit:D,className:"space-y-3",children:[s.jsx("input",{type:"email",value:p,onChange:Z=>g(Z.target.value),autoComplete:"email",autoFocus:!0,placeholder:n("login.email"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),s.jsx("input",{type:"password",value:x,onChange:Z=>y(Z.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}),u&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:u}),!t&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!p||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(o==="local"?"login.signingIn":"login.signIn")})]}),s.jsx("div",{className:"text-center",children:s.jsx("button",{onClick:()=>{h(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("button",{onClick:()=>z("google"),disabled:!!o,className:W,children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),s.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),s.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),s.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),n(o==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>z("github"),disabled:!!o,className:W,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),n(o==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>z("email"),disabled:!!o,className:W,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(o==="email"?"login.connectingHub":"login.withEmail")]}),u&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:u}),s.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[s.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),s.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),s.jsx("button",{onClick:()=>{h(!0),d("")},disabled:!!o,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),s.jsxs("label",{onAnimationEnd:()=>N(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[s.jsx("input",{type:"checkbox",checked:T,onChange:Z=>{C(Z.target.checked),Z.target.checked&&N(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),s.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",s.jsx("a",{href:j("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",s.jsx("a",{href:j("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),s.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[s.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),s.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function XK({token:e,onComplete:t}){const{t:n}=ft("auth"),[r,o]=k.useState(null),[l,u]=k.useState(""),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[N,T]=k.useState(!1);k.useEffect(()=>{Ce.auth.inviteInfo(e).then(j=>o(j)).catch(()=>T(!0))},[e]);const C=async j=>{if(j.preventDefault(),p(""),l.length<6){p(n("invite.passwordMinLength"));return}if(l!==d){p(n("invite.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{p(n("invite.error"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),s.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:N?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),s.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):r?s.jsxs("form",{onSubmit:C,className:"space-y-5",children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:r.name})}),s.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:r.email}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),s.jsx("input",{type:"password",value:l,onChange:j=>u(j.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),s.jsx("input",{type:"password",value:d,onChange:j=>m(j.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})]}),h&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:h}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:n(g?"invite.settingUp":"invite.setupAccount")})]}):s.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function QK({onComplete:e,isFirstTime:t}){const{t:n}=ft("auth"),[r,o]=k.useState(""),[l,u]=k.useState(""),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),p(""),l.length<6){p(n("changePassword.passwordMinLength"));return}if(l!==d){p(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.changePassword(r,l),e()}catch{p(n("changePassword.failedToChange"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),s.jsxs("form",{onSubmit:y,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&s.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:r,onChange:w=>o(w.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),s.jsx("input",{type:"password",value:l,onChange:w=>u(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),s.jsx("input",{type:"password",value:d,onChange:w=>m(w.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),h&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:h}),s.jsx("button",{type:"submit",disabled:g||!l||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:n(g?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}function ZK({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[u,d]=k.useState(()=>{try{const N=localStorage.getItem(`${l}_w`);if(N)return Math.max(n,Math.min(r,parseInt(N,10)))}catch{}return t}),[m,h]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),p=k.useRef(!1),g=k.useRef(n),x=k.useRef(r);g.current=n,x.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(u))}catch{}},[u,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(N=>Math.max(n,Math.min(r,N)))},[n,r]);const y=k.useCallback(N=>{N.preventDefault(),p.current=!0;const T=N.clientX,C=u,j=O=>{if(!p.current)return;const z=e==="left"?O.clientX-T:T-O.clientX;d(Math.max(g.current,Math.min(x.current,C+z)))},_=()=>{p.current=!1,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",_),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",j),document.addEventListener("mouseup",_),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[u,e]),w=k.useCallback(()=>h(N=>!N),[]);return{width:m?o:u,rawWidth:u,collapsed:m,toggle:w,setCollapsed:h,setWidth:d,onResizeStart:y}}const LW=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Gp="markus-theme";function E4(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 JK(){try{const e=localStorage.getItem(Gp);if(e==="midnight")return localStorage.setItem(Gp,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function eW(){const[e,t]=k.useState(JK),n=k.useCallback(r=>{t(r);try{localStorage.setItem(Gp,r)}catch{}E4(r)},[]);return k.useEffect(()=>{E4(e)},[e]),{mode:e,setMode:n}}const Id={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},tW={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},nW=["agents","tasks","requirements","projects","deliverables","workflows"];let A4="",_4="all",j4=Id,M4=!1;function rW({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);zo(!0);const[r,o]=k.useState(A4),[l,u]=k.useState(_4),[d,m]=k.useState(j4),[h,p]=k.useState(!1),[g,x]=k.useState(M4),[y,w]=k.useState(-1);k.useEffect(()=>{A4=r},[r]),k.useEffect(()=>{_4=l},[l]),k.useEffect(()=>{j4=d},[d]),k.useEffect(()=>{M4=g},[g]);const N=k.useRef(null),T=k.useRef(void 0),C=k.useRef(null),j=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{N.current?.focus(),N.current?.select()},100)},[]);const _=k.useCallback(async X=>{if(!X.trim()){m(Id),x(!1),w(-1);return}p(!0),x(!0),w(-1);const F=X.toLowerCase();try{const[J,B,Q,re,ke,$]=await Promise.allSettled([Ce.agents.list(),Ce.tasks.list({search:X,pageSize:20}),Ce.requirements.list(),Ce.projects.list(),Ce.deliverables.search({q:X,limit:20}),Ce.teams.list()]),G=J.status==="fulfilled"?J.value.agents.filter(We=>We.name?.toLowerCase().includes(F)||We.role?.toLowerCase().includes(F)):[],le=B.status==="fulfilled"?B.value.tasks:[],I=Q.status==="fulfilled"?Q.value.requirements.filter(We=>We.title?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],Ee=re.status==="fulfilled"?re.value.projects.filter(We=>We.name?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],Ue=ke.status==="fulfilled"?ke.value.results:[],Oe=[];if($.status==="fulfilled"){const We=await Promise.allSettled($.value.teams.map(st=>Ce.workflows.list(st.id)));for(const st of We)if(st.status==="fulfilled")for(const dt of st.value.workflows)(dt.name.toLowerCase().includes(F)||(dt.displayName||"").toLowerCase().includes(F)||dt.description?.toLowerCase().includes(F))&&Oe.push(dt)}m({agents:G,tasks:le,requirements:I,projects:Ee,deliverables:Ue,workflows:Oe})}catch{m(Id)}finally{p(!1)}},[]),O=X=>{o(X),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>_(X),400)},z=k.useCallback((X,F)=>{e(),at.navigate(X,F)},[e]),D=[{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:"工作流"})}],H=k.useMemo(()=>tW[t||""]||nW,[t]),W=k.useMemo(()=>{const X=[],F=l==="all"?8:void 0,J=B=>{if(l!=="all"&&l!==B)return;const Q=d[B].length;if(B==="workflows"){const re=F?d.workflows.slice(0,F):d.workflows;for(const ke of re)X.push({id:ke.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const re=d[B],ke=F?re.slice(0,F):re;for(const $ of ke)switch(B){case"agents":X.push({id:$.id,type:"agent",page:me.TEAM,params:{agentId:$.id}});break;case"tasks":X.push({id:$.id,type:"task",page:me.WORK,params:{openTask:$.id}});break;case"requirements":X.push({id:$.id,type:"requirement",page:me.WORK,params:{openRequirement:$.id}});break;case"projects":X.push({id:$.id,type:"project",page:me.WORK,params:{projectId:$.id}});break;case"deliverables":X.push({id:$.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:$.id}});break}}F&&Q>F&&X.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:Q})};for(const B of H)J(B);return X},[d,l,H]),Z=k.useCallback(X=>{if(X.type==="showMore"&&X.expandCategory){u(X.expandCategory),w(-1);return}z(X.page,X.params)},[z]);k.useEffect(()=>{const X=j.current;if(!X||y<0)return;const F=X.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const U=k.useCallback(X=>{if(X.key==="Escape"){e();return}if(X.key==="Tab"){X.preventDefault();const B=D.map(ke=>ke.id),Q=B.indexOf(l),re=X.shiftKey?Q<=0?B.length-1:Q-1:Q>=B.length-1?0:Q+1;u(B[re]),w(-1);return}const F=X.ctrlKey&&X.key==="n"||X.key==="ArrowDown",J=X.ctrlKey&&X.key==="p"||X.key==="ArrowUp";if(F||J){X.preventDefault(),w(B=>{const Q=W.length-1;return Q<0?-1:F?B>=Q?0:B+1:B<=0?Q:B-1});return}X.key==="Enter"&&(X.preventDefault(),y>=0&&y<W.length&&Z(W[y]))},[e,W,y,Z,D,l]);k.useEffect(()=>(document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)),[U]);const Y=W.length>0;let se=0;return s.jsx("div",{ref:C,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:X=>{X.target===C.current&&e()},children:s.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[s.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("input",{ref:N,value:r,onChange:X=>O(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"}),r&&s.jsx("button",{onClick:()=>{o(""),m(Id),x(!1),w(-1),N.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(X=>s.jsx("button",{onClick:()=>{u(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-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:X.label},X.id))})]}),s.jsxs("div",{ref:j,className:"flex-1 overflow-y-auto px-5 py-3",children:[h&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!h&&g&&!Y&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&Y&&s.jsx("div",{className:"space-y-4",children:H.map(X=>{if(l!=="all"&&l!==X)return null;const F=l==="all"?8:void 0,J=B=>{const Q=se++,re=B==="agents"?d.agents.length:B==="tasks"?d.tasks.length:B==="requirements"?d.requirements.length:B==="projects"?d.projects.length:B==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{u(B),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",re,")"]})};return X==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.agents.slice(0,F):d.agents).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.TEAM,{agentId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Us,{name:B.name||"Agent",avatarUrl:B.avatarUrl,size:28}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:B.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.role||B.status})]}),s.jsx(aW,{status:B.status})]},B.id)})}),F&&d.agents.length>F&&J("agents")]},"agents"):X==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.tasks.slice(0,F):d.tasks).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{openTask:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(sW,{status:B.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.id)})}),F&&d.tasks.length>F&&J("tasks")]},"tasks"):X==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.requirements.slice(0,F):d.requirements).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{openRequirement:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${B.status==="approved"?"text-green-500 bg-green-500/15":B.status==="pending"?"text-amber-500 bg-amber-500/15":B.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),s.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.id)})}),F&&d.requirements.length>F&&J("requirements")]},"requirements"):X==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.projects.slice(0,F):d.projects).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{projectId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:s.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.name}),B.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.description})]})]},B.id)})}),F&&d.projects.length>F&&J("projects")]},"projects"):X==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.deliverables.slice(0,F):d.deliverables).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.DELIVERABLES,{openDeliverable:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.type," · ",B.status]})]})]},B.id)})}),F&&d.deliverables.length>F&&J("deliverables")]},"deliverables"):X==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.workflows.slice(0,F):d.workflows).map(B=>{const Q=se++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.displayName||B.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.stepCount," steps · v",B.version]})]})]},B.name)})}),F&&d.workflows.length>F&&J("workflows")]},"workflows"):null})}),!h&&!g&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),s.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",n("common:toggle",{defaultValue:"唤起/关闭"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",n("common:switchTab",{defaultValue:"切换分类"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",n("common:navigate",{defaultValue:"导航"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",n("common:open",{defaultValue:"打开"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",n("common:close",{defaultValue:"关闭"})]})]})]})})}function aW({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function sW({status:e}){const t=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M9 11l3 3L22 4"}),s.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function iW({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=ft("common");zo(!0);const[l,u]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[h,p]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>a5(e.avatarUrl,ua()?.avatarUrl)),N=async T=>{if(T.preventDefault(),!l.trim()){x(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(o("profile.invalidEmail"));return}p(!0),x("");try{const{user:C}=await Ce.auth.updateProfile(l.trim(),d.trim());n({...C,avatarUrl:y??C.avatarUrl})}catch{x(o("profile.failedToSave"))}finally{p(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:s.jsxs("form",{onSubmit:N,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold mb-5",children:o("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(i5,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{w(T),r?.({...e,avatarUrl:T})}})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.name")}),s.jsx("input",{value:l,onChange:T=>u(T.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.email")}),s.jsx("input",{value:d,onChange:T=>m(T.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),g&&s.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:g})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:o("cancel")}),s.jsx("button",{type:"submit",disabled:h,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(h?"saving":"save")})]})]})})}const R4=k.lazy(()=>qr(()=>import("./Team-Dyhls1uE.js"),__vite__mapDeps([2,3,4,5])).then(e=>({default:e.TeamPage}))),O4=k.lazy(()=>qr(()=>import("./Settings-C0L0uTkp.js"),[]).then(e=>({default:e.Settings}))),oW=k.lazy(()=>qr(()=>import("./Store-DgIScz2q.js"),[]).then(e=>({default:e.StorePage}))),lW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>NK),void 0).then(e=>({default:e.AgentBuilder}))),D4=k.lazy(()=>qr(()=>import("./Work-CEcYUxLY.js"),__vite__mapDeps([6,4,1,7,3,8])).then(e=>({default:e.WorkPage}))),L4=k.lazy(()=>qr(()=>import("./Deliverables-DIvdy1w0.js"),__vite__mapDeps([9,4,5])).then(e=>({default:e.DeliverablesPage}))),cW=k.lazy(()=>qr(()=>import("./Notifications-CBB92VJG.js"),[]).then(e=>({default:e.NotificationsPage}))),uW=k.lazy(()=>qr(()=>import("./Search-CQM1v92W.js"),[]).then(e=>({default:e.SearchPage}))),dW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function mW(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Ce.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function fW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const hW=k.memo(function({id:t,activePage:n,children:r}){const o=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:o?void 0:dW,children:s.jsx(k.Suspense,{fallback:s.jsx(fW,{}),children:r})})},(e,t)=>{const n=e.id===e.activePage,r=t.id===t.activePage;return n!==r?!1:r?e.children===t.children:!0}),Nd={};function _3(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?Q4[e]??e:e}function I4(){return _3(lc())}function pW(){const{t:e}=ft("common"),[t,n]=k.useState(I4),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,u]=k.useState(!0),d=Bo(),m=eW(),h=ZK({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[p,g]=k.useState(()=>new Set([I4()])),[x,y]=k.useState("loading"),[w,N]=k.useState(!1),[T,C]=k.useState(null),[j,_]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[O,z]=k.useState(!1),[D,H]=k.useState(!1),[W,Z]=k.useState(null),[U,Y]=k.useState(!1),[se,X]=k.useState(null),[F,J]=k.useState(()=>{const be=localStorage.getItem("markus_update_dismissed");return be||null}),[B,Q]=k.useState(!1),re=z0(),ke=re?.leftCollapsed??!1,$=re?.toggleLeftCollapsed,G=re?.toggleRightPanel,le=re?.openRightPanel,I=re?.closeRightPanelTab,Ee=re?.updateRightPanelBrowserTab,Ue=k.useRef(re?.rightPanelTabs);Ue.current=re?.rightPanelTabs,k.useEffect(()=>{const be=window.markusDesktop?.browser?.onPageEvent;if(!(!be||!le))return be(Me=>{if(Me.type==="closed"){const Ge=Ue.current?.find(ot=>ot.payload.kind==="url"&&ot.payload.browserId===Me.browserId);Ge&&I&&I(Ge.id);return}if(Me.type==="navigated"){Me.browserId&&Ee&&Ee(Me.browserId,{url:Me.url,title:Me.title||Me.url});return}if(Me.type==="opened"||Me.type==="selected"){if(!Me.url&&!Me.browserId||Me.browserId.startsWith("eb_")&&Me.type==="opened")return;le({kind:"url",url:Me.url||"about:blank",title:Me.title||Me.url||"Browser",browserId:Me.browserId,pageId:Me.pageId})}})},[le,I,Ee]);const Oe=re?.rightPanelOpen??!1;k.useLayoutEffect(()=>{const be=t===me.TEAM&&Oe;Jf(be)},[t,Oe]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const We=k.useRef(!1);k.useEffect(()=>{if(!We.current){We.current=!0;return}h.setCollapsed(ke)},[ke,h.setCollapsed]),k.useEffect(()=>{if(d)return;const be=navigator.platform.toUpperCase().includes("MAC"),Me=ot=>{be&&ot.metaKey&&!ot.ctrlKey&&ot.key==="p"?(ot.preventDefault(),Q(mt=>!mt)):!be&&ot.ctrlKey&&!ot.metaKey&&ot.key==="p"&&(ot.preventDefault(),Q(mt=>!mt))},Ge=()=>Q(!0);return document.addEventListener("keydown",Me),window.addEventListener("markus:open-search",Ge),()=>{document.removeEventListener("keydown",Me),window.removeEventListener("markus:open-search",Ge)}},[d]),k.useEffect(()=>{if(d||!$||!G)return;const be=navigator.platform.toUpperCase().includes("MAC"),Me=Ge=>{if(!(be?Ge.metaKey&&!Ge.ctrlKey:Ge.ctrlKey&&!Ge.metaKey)||Ge.altKey||Ge.shiftKey)return;const mt=Ge.key.toLowerCase();mt==="b"?(Ge.preventDefault(),$()):mt==="l"&&(Ge.preventDefault(),G())};return document.addEventListener("keydown",Me),()=>document.removeEventListener("keydown",Me)},[d,$,G]);const st=k.useCallback((be,Me)=>{let Ge=oc(be);d?Ge=Q4[Ge]??Ge:Ge===me.NOTIFICATIONS&&(Ge=me.HOME),Ge!==me.TEAM&&Jf(!1);const ot=lc(),mt=window.location.hash.slice(1);if(mt!==ap(ot)?Nd[ot]=mt:delete Nd[ot],Ge===me.SETTINGS&&Me?.tab){const ze=`settings/${Me.tab}`;Nd[Ge]=ze,history.pushState(null,"","#"+ze),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Ge),g(Xe=>Xe.has(Ge)?Xe:new Set([...Xe,Ge]));return}const ae=Ge!==me.WORK?Nd[Ge]:void 0;ae&&ae!==ap(Ge)?(history.pushState(null,"",Si(Ge)),history.pushState(null,"","#"+ae)):history.pushState(null,"",Si(Ge)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Ge),g(ze=>ze.has(Ge)?ze:new Set([...ze,Ge]))},[d]);k.useEffect(()=>{at.setHandler((be,Me)=>st(be,Me))},[st]),k.useEffect(()=>{const be=()=>N(!0);return window.addEventListener("markus:open-edit-profile",be),()=>window.removeEventListener("markus:open-edit-profile",be)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==me.SETTINGS&&!h.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[h.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(be=>{if(be.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),be.page){const Me=oc(be.page);be.params&&Object.entries(be.params).forEach(([Ge,ot])=>localStorage.setItem(`markus_nav_${Ge}`,ot)),st(Me),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Me,params:be.params}}))}})},[st]);const dt=k.useCallback(()=>{fetch("/api/settings/llm").then(be=>be.ok?be.json():null).then(be=>{if(be?.providers){const Me=Object.values(be.providers).some(Ge=>Ge.configured);Z(Me)}}).catch(()=>{})},[]),Et=k.useCallback((be,Me)=>{if(!be)return;const ot=Me&&{agent:"agents",team:"teams",skill:"skills"}[Me]||"agents";localStorage.setItem("markus_nav_installItem",be),localStorage.setItem("markus_nav_storeTab",ot);const mt=new URLSearchParams(window.location.search);mt.get("install")||(mt.set("install",be),Me&&mt.set("type",Me));const ae=mt.toString();window.history.replaceState(null,"",`${window.location.pathname}?${ae}${Si(me.STORE)}`);const ze=()=>at.navigate(me.STORE,{storeTab:ot,installItem:be});ze(),setTimeout(ze,500),setTimeout(ze,1500)},[]);k.useEffect(()=>{const be=new URLSearchParams(window.location.search),Me=be.get("install");Me&&Et(Me,be.get("type"));const Ge=window.markusDesktop;Ge?.onDeepLinkInstall?.(({id:ae,type:ze})=>Et(ae,ze)),Ge?.consumePendingDeepLinkInstall?.().then(ae=>{ae?.id&&Et(ae.id,ae.type)}),Ce.auth.me().then(({user:ae})=>{y(ae),C(!0),mW(ae),va.connect(ae.id),dt(),Ce.health().then(Xe=>{Xe.updateAvailable&&Xe.latestVersion&&X({latestVersion:Xe.latestVersion,currentVersion:Xe.version})}).catch(()=>{});const ze=()=>{pi(Tr.builderArtifacts,()=>Ce.builder.artifacts.list()),pi(Tr.builderAgents,()=>Ce.agents.list()),pi(Tr.builderHubMyItems,()=>it.myItems()),pi(Tr.builderInstalled,()=>Ce.builder.artifacts.installed()),pi(Tr.hubAgents,()=>it.search({type:"agent",limit:50})),pi(Tr.hubTeams,()=>it.search({type:"team",limit:50})),pi(Tr.hubSkills,()=>it.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(ze,{timeout:5e3}):setTimeout(ze,3e3)}).catch(()=>{y(null),Ce.auth.status().then(({initialized:ae,hasOwner:ze,hasMultipleUsers:Xe})=>{C(ae),_({hasOwner:ze,hasMultipleUsers:Xe})}).catch(()=>C(!0))}),va.connect();const ot=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),mt=()=>{const ae=_3(lc());ae!==me.TEAM&&Jf(!1),n(ae),g(ze=>ze.has(ae)?ze:new Set([...ze,ae]))};return window.addEventListener("hashchange",mt),window.addEventListener("popstate",mt),()=>{ot(),va.disconnect(),window.removeEventListener("hashchange",mt),window.removeEventListener("popstate",mt)}},[]);const gt=x!=="loading"&&x!==null?x:void 0,jt=k.useMemo(()=>d?{[me.HOME]:s.jsx(Ky,{authUser:gt}),[me.TEAM]:s.jsx(R4,{authUser:gt}),[me.BUILDER]:s.jsx(GK,{authUser:gt}),[me.SETTINGS]:s.jsx(O4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)},onUserUpdated:be=>y(be)}),[me.WORK]:s.jsx(D4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(L4,{authUser:gt}),[me.NOTIFICATIONS]:s.jsx(cW,{authUser:gt}),[me.SEARCH]:s.jsx(uW,{})}:{[me.HOME]:s.jsx(Ky,{authUser:gt}),[me.TEAM]:s.jsx(R4,{authUser:gt}),[me.SETTINGS]:s.jsx(O4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)},onUserUpdated:be=>y(be)}),[me.STORE]:s.jsx(oW,{authUser:gt}),[me.BUILDER]:s.jsx(lW,{authUser:gt}),[me.WORK]:s.jsx(D4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(L4,{authUser:gt})},[gt?.id,gt?.role,m.mode,d]);if(x==="loading"||x===null&&T===null)return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Rt=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Rt?s.jsx(XK,{token:Rt[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),z(!0),y("loading"),Ce.auth.me().then(be=>y(be.user)).catch(()=>y(null))}}):x===null?s.jsx(YK,{hasOwner:j.hasOwner,hasMultipleUsers:j.hasMultipleUsers,onLogin:(be,Me,Ge)=>{y(be),va.connect(be.id),Me?(localStorage.removeItem("markus_onboarded"),o(!0),Ge?.fromHub&&z(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):D?s.jsx(QK,{onComplete:()=>H(!1),isFirstTime:!0}):r?s.jsx(VK,{theme:m.mode,onThemeChange:m.setMode,skipProfile:O,onProfileUpdated:be=>{const Me={id:be.id,name:be.name,email:be.email,role:be.role,orgId:be.orgId??"default",avatarUrl:be.avatarUrl};y(Me)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),z(!1),Ce.auth.me().then(be=>y(be.user)).catch(()=>{}),dt(),st(me.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==me.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:h.width},children:s.jsx(QV,{currentPage:t,onNavigate:be=>{st(be),u(!1)},authUser:x,collapsed:h.collapsed,onToggleCollapse:h.toggle,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)}})}),s.jsx("div",{className:`${h.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:h.collapsed?void 0:h.onResizeStart,children:!h.collapsed&&s.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),s.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==me.SETTINGS&&t!==me.SEARCH?"pb-14":""}`,children:[W===!1&&!U&&t!==me.SETTINGS&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[s.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),s.jsx("button",{onClick:()=>Y(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),se&&F!==se.latestVersion&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[s.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:se.latestVersion,current:se.currentVersion})}),s.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[s.jsx("a",{href:"https://markus.global/download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),s.jsx("button",{onClick:()=>{J(se.latestVersion),localStorage.setItem("markus_update_dismissed",se.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),s.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(jt).map(be=>p.has(be)?s.jsx(hW,{id:be,activePage:t,children:jt[be]},be):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(nK,{currentPage:t,onNavigate:st,userId:gt?.id}),d&&s.jsx(iD,{authUser:gt,onNavigate:st}),!d&&B&&s.jsx(rW,{onClose:()=>Q(!1),currentPage:t}),w&>&&s.jsx(iW,{authUser:gt,onClose:()=>N(!1),onUserUpdated:be=>y(be),onSaved:be=>{N(!1),y(be)}})]})}US.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(Jq,{children:s.jsx(pW,{})})}));export{_W as $,Us as A,VG as B,dr as C,GG as D,UV as E,wW as F,TW as G,HV as H,BK as I,vW as J,Ci as K,Vo as L,o5 as M,WV as N,z0 as O,me as P,tK as Q,DW as R,PK as S,EK as T,NW as U,Wa as V,AW as W,ZG as X,EW as Y,RW as Z,qr as _,Bo as a,VV as a0,FV as a1,jW as a2,p0 as a3,D7 as a4,gW as a5,zo as a6,Si as a7,YO as a8,u3 as a9,CW as aa,Q2 as ab,o4 as ac,RV as ad,MV as ae,Gd as af,LW as ag,bW as ah,ua as ai,yn as aj,na as ak,SW as al,l3 as am,HK as b,jK as c,DK as d,Ja as e,Ce as f,MW as g,it as h,wi as i,s as j,OW as k,Ar as l,sD as m,at as n,ZK as o,oc as p,Mg as q,k as r,xc as s,R7 as t,ft as u,xW as v,va as w,yW as x,qd as y,H2 as z};
|