@markus-global/cli 0.9.0-rc.7 → 0.9.0-rc.8
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 +55 -20
- package/dist/web-ui/assets/{CommentInput-TaVC_Fip.js → CommentInput-BJmv0Rha.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-DtcL0FZI.js → ContentRenderer-DJQo68Rq.js} +2 -2
- package/dist/web-ui/assets/{Deliverables-C8pzzt4r.js → Deliverables-DCXoaQpj.js} +1 -1
- package/dist/web-ui/assets/{Notifications-BqOlKcov.js → Notifications-BTkCe_FT.js} +1 -1
- package/dist/web-ui/assets/{Search-MQIbxh2k.js → Search-DJMnvmW4.js} +1 -1
- package/dist/web-ui/assets/{Settings-DXRyCb9R.js → Settings-Bo7g6_tg.js} +1 -1
- package/dist/web-ui/assets/{Store-Csz6HWC-.js → Store-B_9bFi_v.js} +1 -1
- package/dist/web-ui/assets/{Team-Jgmy2XLK.js → Team-Bp5j4tGQ.js} +4 -4
- package/dist/web-ui/assets/{Work-D1xxd9Cj.js → Work-CBpfr_rN.js} +1 -1
- package/dist/web-ui/assets/{arc-CvlRbL1f.js → arc-FGZKJEo5.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-tI_qyItI.js → architectureDiagram-3BPJPVTR-DrHriKKt.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-DPlp1wAS.js → blockDiagram-GPEHLZMM-B1KrBMG4.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-B4HY_088.js → c4Diagram-AAUBKEIU-CB3d18fE.js} +1 -1
- package/dist/web-ui/assets/channel-Dn6ohvAA.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-CLfRhfYo.js → chunk-2J33WTMH-yhAAZF8B.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-CDx25iZK.js → chunk-4BX2VUAB-DhGfeR_u.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-BENXIwET.js → chunk-55IACEB6-B4ZyaFdf.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-CwIpvaPE.js → chunk-727SXJPM-DiEJq1Wh.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-D-YRf-Fg.js → chunk-AQP2D5EJ-DJgXMRvd.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-Dp_h4d6j.js → chunk-FMBD7UC4-DLzapSRw.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-CUBDxwHR.js → chunk-ND2GUHAM-KaWi6H4E.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-CVAgDt5p.js → chunk-QZHKN3VN-CedM3HE_.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BNcvQTsC.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BNcvQTsC.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-DDrJZ_Lt.js → cose-bilkent-S5V4N54A-DGOMWPFW.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-LX7QV3G0.js → dagre-BM42HDAG-CsB6PNx2.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-CK0Esb13.js → diagram-2AECGRRQ-dsKr5CnT.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-Ba2o4U6S.js → diagram-5GNKFQAL-CfKFUiA0.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-DhYIvmyJ.js → diagram-KO2AKTUF-C-iYqWwv.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-Cy62pgA6.js → diagram-LMA3HP47-VrnDGieS.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-YVinWnza.js → diagram-OG6HWLK6-2CPw94I0.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DZ72-TSc.js → erDiagram-TEJ5UH35-B2CXjopz.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-CMllMvlP.js → flowDiagram-I6XJVG4X-uYZBII8i.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-DsjTLEpK.js → ganttDiagram-6RSMTGT7-DX__je4a.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-Xl_METoZ.js → gitGraphDiagram-PVQCEYII-ClWVZgy5.js} +1 -1
- package/dist/web-ui/assets/{index-DO8_O8Vw.js → index-Dgg0L65t.js} +4 -4
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-BxKfEOlz.js → infoDiagram-5YYISTIA-0bE4Z9ff.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-ZpSC4-IS.js → ishikawaDiagram-YF4QCWOH-nCIQcUlM.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-DlHtkZv8.js → journeyDiagram-JHISSGLW-Bc1umCm3.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-BreNG-31.js → kanban-definition-UN3LZRKU-BqkpB1pF.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-DvatjXnq.js → mermaid.core-CSfwY1-0.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-qveAmQec.js → mindmap-definition-RKZ34NQL-nQyDFxhc.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-DX62E3l6.js → pieDiagram-4H26LBE5-5HVdrqjx.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-C5dKRXCq.js → quadrantDiagram-W4KKPZXB-NuRh23Sl.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-a084_Ugq.js → requirementDiagram-4Y6WPE33-BGztYPcI.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-DthKmaYC.js → sankeyDiagram-5OEKKPKP-bjpwDt_z.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-DdyLG-Lx.js → sequenceDiagram-3UESZ5HK-DyTeuxtF.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-9M6azc5R.js → stateDiagram-AJRCARHV-BHPWZwpF.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-56cdLVMt.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-CAZ1B9ki.js → timeline-definition-PNZ67QCA-LPx8DOxK.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-C1q-T-PV.js → vennDiagram-CIIHVFJN-Dy6cnqv-.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-BUHmrj16.js → wardley-L42UT6IY-BtpmXexA.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-C0Y_McWW.js → wardleyDiagram-YWT4CUSO-BsyOd3d4.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-Bh5mmFGf.js → xychartDiagram-2RQKCTM6-BcIF0Smp.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-CTTzbind.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BOpo-nB5.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BOpo-nB5.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DmZSwAmU.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-CSfwY1-0.js","assets/transform-CpIVI4vC.js","assets/Team-Bp5j4tGQ.js","assets/CommentInput-BJmv0Rha.js","assets/ContentRenderer-DJQo68Rq.js","assets/ChatHelpers-DDWzuvqW.js","assets/Work-CBpfr_rN.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-DCXoaQpj.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 Ff={exports:{}},Hl={};var my;function IS(){if(my)return Hl;my=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 Hl.Fragment=t,Hl.jsx=n,Hl.jsxs=n,Hl}var fy;function PS(){return fy||(fy=1,Ff.exports=IS()),Ff.exports}var s=PS(),qf={exports:{}},Ot={};var hy;function zS(){if(hy)return Ot;hy=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(){}},S=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=_,S(O,C.prototype),O.isPureReactComponent=!0;var z=Array.isArray;function D(){}var H={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function ee(G,le,I){var Ae=I.ref;return{$$typeof:e,type:G,key:le,ref:Ae!==void 0?Ae:null,props:I}}function $(G,le){return ee(G.type,le,G.props)}function K(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function re(G){var le={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(I){return le[I]})}var W=/\/+/g;function F(G,le){return typeof G=="object"&&G!==null&&G.key!=null?re(""+G.key):le.toString(36)}function Z(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,Ae,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,Ae,Ue)}}if(We)return Ue=Ue(G),We=Ae===""?"."+F(G,0):Ae,z(Ue)?(I="",We!=null&&(I=We.replace(W,"$&/")+"/"),B(Ue,le,I,"",function(At){return At})):Ue!=null&&(K(Ue)&&(Ue=$(Ue,I+(Ue.key==null||G&&G.key===Ue.key?"":(""+Ue.key).replace(W,"$&/")+"/")+We)),le.push(Ue)),1;We=0;var st=Ae===""?".":Ae+":";if(z(G))for(var dt=0;dt<G.length;dt++)Ae=G[dt],Oe=st+F(Ae,dt),We+=B(Ae,le,I,Oe,Ue);else if(dt=y(G),typeof dt=="function")for(G=dt.call(G),dt=0;!(Ae=G.next()).done;)Ae=Ae.value,Oe=st+F(Ae,dt++),We+=B(Ae,le,I,Oe,Ue);else if(Oe==="object"){if(typeof G.then=="function")return B(Z(G),le,I,Ae,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 Ae=[],Ue=0;return B(G,Ae,"","",function(Oe){return le.call(I,Oe,Ue++)}),Ae}function ae(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)},U={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(!K(G))throw Error("React.Children.only expected to receive a single React element child.");return G}};return Ot.Activity=g,Ot.Children=U,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 Ae=S({},G.props),Ue=G.key;if(le!=null)for(Oe in le.key!==void 0&&(Ue=""+le.key),le)!X.call(le,Oe)||Oe==="key"||Oe==="__self"||Oe==="__source"||Oe==="ref"&&le.ref===void 0||(Ae[Oe]=le[Oe]);var Oe=arguments.length-2;if(Oe===1)Ae.children=I;else if(1<Oe){for(var We=Array(Oe),st=0;st<Oe;st++)We[st]=arguments[st+2];Ae.children=We}return ee(G.type,Ue,Ae)},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 Ae,Ue={},Oe=null;if(le!=null)for(Ae in le.key!==void 0&&(Oe=""+le.key),le)X.call(le,Ae)&&Ae!=="key"&&Ae!=="__self"&&Ae!=="__source"&&(Ue[Ae]=le[Ae]);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(Ae in We=G.defaultProps,We)Ue[Ae]===void 0&&(Ue[Ae]=We[Ae]);return ee(G,Oe,Ue)},Ot.createRef=function(){return{current:null}},Ot.forwardRef=function(G){return{$$typeof:d,render:G}},Ot.isValidElement=K,Ot.lazy=function(G){return{$$typeof:p,_payload:{_status:-1,_result:G},_init:ae}},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 Ae=G(),Ue=H.S;Ue!==null&&Ue(I,Ae),typeof Ae=="object"&&Ae!==null&&typeof Ae.then=="function"&&Ae.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 py;function b0(){return py||(py=1,qf.exports=zS()),qf.exports}var k=b0();const wW=xc(k);var Gf={exports:{}},$l={},Vf={exports:{}},Kf={};var gy;function BS(){return gy||(gy=1,(function(e){function t(B,Q){var ae=B.length;B.push(Q);e:for(;0<ae;){var ke=ae-1>>>1,U=B[ke];if(0<o(U,Q))B[ke]=Q,B[ae]=U,ae=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],ae=B.pop();if(ae!==Q){B[0]=ae;e:for(var ke=0,U=B.length,G=U>>>1;ke<G;){var le=2*(ke+1)-1,I=B[le],Ae=le+1,Ue=B[Ae];if(0>o(I,ae))Ae<U&&0>o(Ue,I)?(B[ke]=Ue,B[Ae]=ae,ke=Ae):(B[ke]=I,B[le]=ae,ke=le);else if(Ae<U&&0>o(Ue,ae))B[ke]=Ue,B[Ae]=ae,ke=Ae;else break e}}return Q}function o(B,Q){var ae=B.sortIndex-Q.sortIndex;return ae!==0?ae: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,S=!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(S=!1,O(B),!w)if(n(m)!==null)w=!0,D||(D=!0,re());else{var Q=n(h);Q!==null&&Z(z,Q.startTime-B)}}var D=!1,H=-1,X=5,ee=-1;function $(){return T?!0:!(e.unstable_now()-ee<X)}function K(){if(T=!1,D){var B=e.unstable_now();ee=B;var Q=!0;try{e:{w=!1,S&&(S=!1,j(H),H=-1),y=!0;var ae=x;try{t:{for(O(B),g=n(m);g!==null&&!(g.expirationTime>B&&$());){var ke=g.callback;if(typeof ke=="function"){g.callback=null,x=g.priorityLevel;var U=ke(g.expirationTime<=B);if(B=e.unstable_now(),typeof U=="function"){g.callback=U,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&&Z(z,G.startTime-B),Q=!1}}break e}finally{g=null,x=ae,y=!1}Q=void 0}}finally{Q?re():D=!1}}}var re;if(typeof _=="function")re=function(){_(K)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,F=W.port2;W.port1.onmessage=K,re=function(){F.postMessage(null)}}else re=function(){C(K,0)};function Z(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"):X=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 ae=x;x=Q;try{return B()}finally{x=ae}},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 ae=x;x=B;try{return Q()}finally{x=ae}},e.unstable_scheduleCallback=function(B,Q,ae){var ke=e.unstable_now();switch(typeof ae=="object"&&ae!==null?(ae=ae.delay,ae=typeof ae=="number"&&0<ae?ke+ae:ke):ae=ke,B){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=ae+U,B={id:p++,callback:Q,priorityLevel:B,startTime:ae,expirationTime:U,sortIndex:-1},ae>ke?(B.sortIndex=ae,t(h,B),n(m)===null&&B===n(h)&&(S?(j(H),H=-1):S=!0,Z(z,ae-ke))):(B.sortIndex=U,t(m,B),w||y||(w=!0,D||(D=!0,re()))),B},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(B){var Q=x;return function(){var ae=x;x=Q;try{return B.apply(this,arguments)}finally{x=ae}}}})(Kf)),Kf}var by;function US(){return by||(by=1,Vf.exports=BS()),Vf.exports}var Wf={exports:{}},nr={};var xy;function HS(){if(xy)return nr;xy=1;var e=b0();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 yy;function U4(){if(yy)return Wf.exports;yy=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wf.exports=HS(),Wf.exports}var vy;function $S(){if(vy)return $l;vy=1;var e=US(),t=b0(),n=U4();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 E=!1,L=b.child;L;){if(L===c){E=!0,c=b,f=v;break}if(L===f){E=!0,f=b,c=v;break}L=L.sibling}if(!E){for(L=v.child;L;){if(L===c){E=!0,c=v,f=b;break}if(L===f){E=!0,f=v,c=b;break}L=L.sibling}if(!E)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"),S=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"),X=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function re(a){return a===null||typeof a!="object"?null:(a=K&&a[K]||a["@@iterator"],typeof a=="function"?a:null)}var W=Symbol.for("react.client.reference");function F(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===W?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case S:return"Fragment";case C:return"Profiler";case T:return"StrictMode";case z:return"Suspense";case D:return"SuspenseList";case ee: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 X:i=a._payload,a=a._init;try{return F(a(i))}catch{}}return null}var Z=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,ae={pending:!1,data:null,method:null,action:null},ke=[],U=-1;function G(a){return{current:a}}function le(a){0>U||(a.current=ke[U],ke[U]=null,U--)}function I(a,i){U++,ke[U]=a.current,a.current=i}var Ae=G(null),Ue=G(null),Oe=G(null),We=G(null);function st(a,i){switch(I(Oe,i),I(Ue,a),I(Ae,null),i.nodeType){case 9:case 11:a=(a=i.documentElement)&&(a=a.namespaceURI)?Lx(a):0;break;default:if(a=i.tagName,i=i.namespaceURI)i=Lx(i),a=Ix(i,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}le(Ae),I(Ae,a)}function dt(){le(Ae),le(Ue),le(Oe)}function At(a){a.memoizedState!==null&&I(We,a);var i=Ae.current,c=Ix(i,a.type);i!==c&&(I(Ue,a),I(Ae,c))}function gt(a){Ue.current===a&&(le(Ae),le(Ue)),We.current===a&&(le(We),Pl._currentValue=ae)}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(),E=v[0],L=v[1];if(E&&L){var ne=E.split(`
|
|
@@ -645,7 +645,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
645
645
|
`},h]}}const nq=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_-]*/}}),rq=["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"],aq=["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"],sq=[...rq,...aq],iq=["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(),Bk=["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(),Uk=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),oq=["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(),lq=Bk.concat(Uk).sort().reverse();function cq(e){const t=nq(e),n=lq,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:iq.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("+oq.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:d}}]},S={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("+sq.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:":("+Bk.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+Uk.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,S,T,j,w,C,y,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:u}}function uq(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 dq(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 mq(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 fq(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 hq(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=(S,T,C="\\1")=>{const j=C==="\\1"?C:t.concat(C,T);return t.concat(t.concat("(?:",S,")"),T,/(?:\\.|[^\\\/])*?/,j,/(?:\\.|[^\\\/])*?/,C,r)},y=(S,T,C)=>t.concat(t.concat("(?:",S,")"),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 pq(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,Z)=>{Z.data._beginMatch=F[1]||F[2]},"on:end":(F,Z)=>{Z.data._beginMatch!==F[1]&&Z.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]},S={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 Z=[];return F.forEach(B=>{Z.push(B),B.toLowerCase()===B?Z.push(B.toUpperCase()):Z.push(B.toLowerCase())}),Z})(T),built_in:j},z=F=>F.map(Z=>Z.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(?!\\()"),X={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"}}]},ee={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},$={relevance:0,begin:/\(/,end:/\)/,keywords:O,contains:[ee,u,X,e.C_BLOCK_COMMENT_MODE,w,S,D]},K={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:[$]};$.contains.push(K);const re=[ee,X,e.C_BLOCK_COMMENT_MODE,w,S,D],W={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",...re]},...re,{scope:"meta",variants:[{match:o},{match:l}]}]};return{case_insensitive:!1,keywords:O,contains:[W,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,K,X,{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",W,u,X,e.C_BLOCK_COMMENT_MODE,w,S]}]},{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,S]}}function gq(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 bq(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function xq(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("|")}`,S={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,S,g,e.HASH_COMMENT_MODE]}]};return h.contains=[g,S,m],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:d,illegal:/(<\/|\?)|=>/,contains:[m,S,{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:[S,C,g]}]}}function yq(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function vq(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 wq(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"}]},S={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:[S]},{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,S.contains=D;const $=[{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($).concat(h).concat(D)}}function kq(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 Sq=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_-]*/}}),Nq=["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"],Cq=["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"],Tq=[...Nq,...Cq],Aq=["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(),Eq=["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(),_q=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),jq=["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 Mq(e){const t=Sq(e),n=_q,r=Eq,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("+Tq.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("+jq.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:Aq.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 Rq(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Oq(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)),S={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 X=H;return D=D||[],z.map(ee=>ee.match(/\|\d+$/)||D.includes(ee)?ee:X(ee)?`${ee}|0`:ee)}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,S,r,o,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,T]}}function Hk(e){return e?typeof e=="string"?e:e.source:null}function Wl(e){return dn("(?=",e,")")}function dn(...e){return e.map(n=>Hk(n)).join("")}function Dq(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"("+(Dq(e).capture?"":"?:")+e.map(r=>Hk(r)).join("|")+")"}const Rg=e=>dn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),Lq=["Protocol","Type"].map(Rg),R2=["init","self"].map(Rg),Iq=["Any","Self"],Bh=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],O2=["false","nil","true"],Pq=["assignment","associativity","higherThan","left","lowerThan","none","right"],zq=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],D2=["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"],$k=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]/),Fk=cr($k,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Uh=dn($k,Fk,"*"),qk=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]/),s0=cr(qk,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),ba=dn(qk,s0,"*"),ud=dn(/[A-Z]/,s0,"*"),Bq=["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"],Uq=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function Hq(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],o={match:[/\./,cr(...Lq,...R2)],className:{2:"keyword"}},l={match:dn(/\./,cr(...Bh)),relevance:0},u=Bh.filter(Me=>typeof Me=="string").concat(["_|0"]),d=Bh.filter(Me=>typeof Me!="string").concat(Iq).map(Rg),m={variants:[{className:"keyword",match:cr(...d,...R2)}]},h={$pattern:cr(/\b\w+/,/#\w+/),keyword:u.concat(zq),literal:O2},p=[o,l,m],g={match:dn(/\./,cr(...D2)),relevance:0},x={className:"built_in",match:dn(/\b/,cr(...D2),/(?=\()/)},y=[g,x],w={match:/->/,relevance:0},S={className:"operator",relevance:0,variants:[{match:Uh},{match:`\\.(\\.|${Fk})+`}]},T=[w,S],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)]}),X=(Me="")=>({begin:dn(Me,/"/),end:dn(/"/,Me),contains:[O(Me),D(Me)]}),ee={className:"string",variants:[H(),H("#"),H("##"),H("###"),X(),X("#"),X("##"),X("###")]},$=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],K={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:$},re=Me=>{const Ge=dn(Me,/\//),ot=dn(/\//,Me);return{begin:Ge,end:ot,contains:[...$,{scope:"comment",begin:`#(?!.*${ot})`,end:/$/}]}},W={scope:"regexp",variants:[re("###"),re("##"),re("#"),K]},F={match:dn(/`/,ba,/`/)},Z={className:"variable",match:/\$\d+/},B={className:"variable",match:`\\$${s0}+`},Q=[F,Z,B],ae={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:Uq,contains:[...T,_,ee]}]}},ke={scope:"keyword",match:dn(/@/,cr(...Bq),Wl(cr(/\(/,/\s+/)))},U={scope:"meta",match:dn(/@/,ba)},G=[ae,ke,U],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)/,s0,"+")},{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 Ae={match:dn(ba,/\s*:/),keywords:"_|0",relevance:0},Ue={begin:/\(/,end:/\)/,relevance:0,keywords:h,contains:["self",Ae,...r,W,...p,...y,...T,_,ee,...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,_,ee,...G,le,Ue],endsParent:!0,illegal:/["']/},dt={match:[/(func|macro)/,/\s+/,cr(F.match,ba,Uh)],className:{1:"keyword",3:"title.function"},contains:[Oe,st,t],illegal:[/\[/,/%/]},At={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Oe,st,t],illegal:/\[|%/},gt={match:[/operator/,/\s+/,Uh],className:{1:"keyword",3:"title"}},jt={begin:[/precedencegroup/,/\s+/,ud],className:{1:"keyword",3:"title"},contains:[le],keywords:[...Pq,...O2],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 ee.variants){const Ge=Me.contains.find(mt=>mt.label==="interpol");Ge.keywords=h;const ot=[...p,...y,...T,_,ee,...Q];Ge.contains=[...ot,{begin:/\(/,end:/\)/,contains:["self",...ot]}]}return{name:"Swift",keywords:h,contains:[...r,dt,At,Jt,Rt,be,gt,jt,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},W,...p,...y,...T,_,ee,...Q,...G,le,Ue]}}const i0="[A-Za-z$_][0-9A-Za-z$_]*",Gk=["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"],Vk=["true","false","null","undefined","NaN","Infinity"],Kk=["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"],Wk=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Yk=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Xk=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Qk=[].concat(Yk,Kk,Wk);function $q(e){const t=e.regex,n=(ae,{after:ke})=>{const U="</"+ae[0].slice(1);return ae.input.indexOf(U,ke)!==-1},r=i0,o={begin:"<>",end:"</>"},l=/<[A-Za-z0-9\\._:-]+\s*\/>/,u={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(ae,ke)=>{const U=ae[0].length+ae.index,G=ae.input[U];if(G==="<"||G===","){ke.ignoreMatch();return}G===">"&&(n(ae,{after:U})||ke.ignoreMatch());let le;const I=ae.input.substring(U);if(le=I.match(/^\s*=/)){ke.ignoreMatch();return}if((le=I.match(/^\s+extends\s+/))&&le.index===0){ke.ignoreMatch();return}}},d={$pattern:i0,keyword:Gk,literal:Vk,built_in:Qk,"variable.language":Xk},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"}},S={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,S,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"}}]},X={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:{_:[...Kk,...Wk]}},ee={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},$={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[D],illegal:/%/},K={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function re(ae){return t.concat("(?!",ae.join("|"),")")}const W={match:t.concat(/\b/,re([...Yk,"super","import"].map(ae=>`${ae}\\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},Z={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:X},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),ee,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,S,T,j,{match:/\$\d+/},g,X,{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"]}]}]},$,{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]},W,K,H,Z,{match:/\$[(.]/}]}}function Fq(e){const t=e.regex,n=$q(e),r=i0,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:i0,keyword:Gk.concat(m),literal:Vk,built_in:Qk.concat(o),"variable.language":Xk},p={className:"meta",begin:"@"+r},g=(S,T,C)=>{const j=S.contains.findIndex(_=>_.label===T);if(j===-1)throw new Error("can not find mode to replace");S.contains.splice(j,1,C)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(p);const x=n.contains.find(S=>S.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(S=>S.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function qq(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 Gq(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 Vq(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 Kq(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},S={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,S,l,u],C=[...T];return C.pop(),C.push(d),y.contains=C,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:T}}const Wq={arduino:_F,bash:jF,c:MF,cpp:RF,csharp:OF,css:$F,diff:FF,go:qF,graphql:GF,ini:VF,java:KF,javascript:ZF,json:JF,kotlin:tq,less:cq,lua:uq,makefile:dq,markdown:mq,objectivec:fq,perl:hq,php:pq,"php-template":gq,plaintext:bq,python:xq,"python-repl":yq,r:vq,ruby:wq,rust:kq,scss:Mq,shell:Rq,sql:Oq,swift:Hq,typescript:Fq,vbnet:qq,wasm:Gq,xml:Vq,yaml:Kq};var Hh,L2;function Yq(){if(L2)return Hh;L2=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 S("(?=",q,")")}function y(q){return S("(?:",q,")*")}function w(q){return S("(?:",q,")?")}function S(...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*",X="[a-zA-Z_]\\w*",ee="\\b\\d+(\\.\\d+)?",$="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",K="\\b(0b[01]+)",re="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",W=(q={})=>{const ie=/^#![ ]*\//;return q.binary&&(q.begin=S(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},Z={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/},ae=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:S(/[ ]+/,"(",Je,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Le},ke=ae("//","$"),U=ae("/\\*","\\*/"),G=ae("#","$"),le={scope:"number",begin:ee,relevance:0},I={scope:"number",begin:$,relevance:0},Ae={scope:"number",begin:K,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:X,relevance:0},st={begin:"\\.\\s*"+X,relevance:0};var At=Object.freeze({__proto__:null,APOS_STRING_MODE:Z,BACKSLASH_ESCAPE:F,BINARY_NUMBER_MODE:Ae,BINARY_NUMBER_RE:K,COMMENT:ae,C_BLOCK_COMMENT_MODE:U,C_LINE_COMMENT_MODE:ke,C_NUMBER_MODE:I,C_NUMBER_RE:$,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:ee,PHRASAL_WORDS_MODE:Q,QUOTE_STRING_MODE:B,REGEXP_MODE:Ue,RE_STARTERS_RE:re,SHEBANG:W,TITLE_MODE:Oe,UNDERSCORE_IDENT_RE:X,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=S(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 se(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,se(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((Aa,Ri)=>Ri>0&&Aa!==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=se(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,He=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:Aa(tr.language,tr.code,Ut);return Mr.code=tr.code,Ws("after:highlight",Mr),Mr}function Aa(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=Aa(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 H0(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 H0(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=>Aa(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 Ac(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&&Ea(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 Ea(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 Ec(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:Ac,unregisterLanguage:Ks,listLanguages:Yo,getLanguage:ir,registerAliases:Ea,autoDetection:is,inherit:oe,addPlugin:Ln,removePlugin:Ec}),q.debugMode=function(){Je=!1},q.safeMode=function(){Je=!0},q.versionString=ct,q.regex={concat:S,lookahead:x,either:C,optional:w,anyNumberOfTimes:y};for(const Pe in At)typeof At[Pe]=="object"&&e(At[Pe]);return Object.assign(q,At),q},qe=He({});return qe.newInstance=()=>He({}),Hh=qe,qe.HighlightJS=qe,qe.default=qe,Hh}var Xq=Yq();const Qq=xc(Xq),I2={},Zq="hljs-";function Jq(e){const t=Qq.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||I2,x=typeof g.prefix=="string"?g.prefix:Zq;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:eG,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,S=w.data;return S.language=y.language,S.relevance=y.relevance,w}function r(m,h){const g=(h||I2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const S=g[x];if(!t.getLanguage(S))continue;const T=n(S,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 eG{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 tG={};function Zk(e){const t=e||tG,n=t.aliases,r=t.detect||!1,o=t.languages||Wq,l=t.plainText,u=t.prefix,d=t.subset;let m="hljs";const h=Jq(o);if(n&&h.registerAlias(n),u){const p=u.indexOf("-");m=p===-1?u:u.slice(0,p)}return function(p,g){C0(p,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const S=nG(x);if(S===!1||!S&&!r||S&&l&&l.includes(S))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=Mk(x,{whitespace:"pre"});let C;try{C=S?h.highlight(S,T,{prefix:u}):h.highlightAuto(T,{prefix:u,subset:d})}catch(j){const _=j;if(S&&/Unknown language/.test(_.message)){g.message("Cannot highlight as `"+S+"`, it’s not registered",{ancestors:[w,x],cause:_,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw _}!S&&C.data&&C.data.language&&x.properties.className.push("language-"+C.data.language),C.children.length>0&&(x.children=C.children)})}}function nG(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 rG=10;function P2(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 aG(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 Jk=k.createContext(null);function sG({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(W=>n(W),[]),S=k.useCallback(()=>n(W=>!W),[]),T=k.useCallback(W=>{const F=P2(W),Z=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let B=null;o(Q=>{const ae=Q.find(G=>P2(G.payload)===F);if(ae)return B=ae.id,g.current=Q,Q;let U=[{id:Z,title:aG(W),payload:W},...Q];for(;U.length>rG;){let G=-1;for(let le=U.length-1;le>=0;le--)if(!U[le].pinned){G=le;break}if(G<0)break;U=U.filter((le,I)=>I!==G)}return B=Z,g.current=U,U}),B&&(u(B),x.current=B),n(!0)},[]),C=W=>{W?.kind==="url"&&W.browserId&&window.markusDesktop?.browser?.destroy(W.browserId)},j=k.useCallback(W=>{let F,Z,B=!1;o(Q=>{const ae=Q.findIndex(U=>U.id===W);if(ae<0)return Q;F=Q[ae]?.payload;const ke=Q.filter(U=>U.id!==W);return g.current=ke,B=ke.length===0,Z=void 0,(x.current===W||ke.length===0)&&(Z=ke[Math.min(ae,ke.length-1)]?.id??null),ke}),B&&m(!1),Z!==void 0&&(u(Z),x.current=Z),C(F)},[]),_=k.useCallback(()=>{let W=[];o(F=>(W=F.map(Z=>Z.payload),[])),u(null),m(!1),g.current=[],x.current=null;for(const F of W)C(F)},[]),O=k.useCallback(W=>{u(W),x.current=W},[]),z=k.useCallback((W,F)=>{o(Z=>{let B=!1;const Q=Z.map(ae=>{if(ae.payload.kind!=="url"||ae.payload.browserId!==W)return ae;B=!0;const ke=F.url??ae.payload.url,U=F.title||ae.payload.title||ke;return{...ae,title:U,payload:{...ae.payload,url:ke,title:U}}});return B&&(g.current=Q),B?Q:Z})},[]),D=k.useCallback(()=>{o(W=>W.length===0?W:(g.current=W,y.current&&(x.current=y.current),[])),u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()},[]),H=k.useCallback(()=>{const W=`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 Z,B=!1,Q=!1;o(ae=>{if(ae.length>0)return g.current=ae,y.current&&(x.current=y.current),Q=!0,Z=null,[];if(g.current.length>0){B=!0;const U=g.current;return Z=x.current&&U.some(le=>le.id===x.current)?x.current:U[0].id,U}B=!0;const ke={id:W,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:F}};return g.current=[ke],Z=ke.id,[ke]}),B&&n(!0),Q?(u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()):Z!=null&&(u(Z),x.current=Z)},[]),X=k.useCallback(W=>m(W),[]),ee=k.useCallback(()=>m(W=>!W),[]),$=r.find(W=>W.id===l)??r[0]??null,K=$?.payload??null,re=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:w,toggleLeftCollapsed:S,rightPanel:K,rightPanelOpen:r.length>0,rightPanelTabs:r,activeRightPanelTabId:$?.id??null,openRightPanel:T,closeRightPanel:_,closeRightPanelTab:j,setActiveRightPanelTab:O,updateRightPanelBrowserTab:z,toggleRightPanel:H,collapseRightPanelOnly:D,rightPanelFullscreen:d,setRightPanelFullscreen:X,toggleRightPanelFullscreen:ee,hostAvailable:h,setHostAvailable:p}),[t,w,S,K,r,$,T,_,j,O,z,H,D,d,X,ee,h]);return s.jsx(Jk.Provider,{value:re,children:e})}function U0(){return k.useContext(Jk)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>m3),void 0).then(e=>({default:e.MarkdownMessage})));const iG=k.lazy(()=>qr(()=>import("./ContentRenderer-DtcL0FZI.js"),[]).then(e=>({default:e.ContentRenderer})));let vo=[],z2=60;function oG(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++z2);return k.useEffect(()=>{const r=()=>t.current();vo.push(r);const o=l=>{l.key==="Escape"&&vo[vo.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),vo=vo.filter(l=>l!==r),vo.length===0&&(z2=60)}},[]),n}const B2=500,Bs=new Map,o0=new Set,Od=new Map;let Dd=null;function lG(){if(Bs.size<=B2)return;const e=Bs.size-B2,t=Bs.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;Bs.delete(r)}}function U2(e,t){Bs.delete(e),Bs.set(e,t),lG()}function H2(e){const t=Od.get(e);if(t)for(const n of t)n()}function cG(){Dd=null;const e=[...o0];o0.clear(),e.length!==0&&Ce.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))U2(n,r),H2(n)}).catch(()=>{for(const t of e)U2(t,{exists:!1,isFile:!1,type:"unknown"}),H2(t)})}function uG(e){Bs.has(e)||o0.has(e)||(o0.add(e),Dd&&clearTimeout(Dd),Dd=setTimeout(cG,30))}function dG(e,t){let n=Od.get(e);return n||(n=new Set,Od.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Od.delete(e)}}function mG(e){const t=k.useCallback(o=>dG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{uG(e)},[e]),r}const fG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function hG(e){return e.length<2||e.length>500?!1:fG.test(e)}function pG({filePath:e,onClose:t}){const n=oG(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(""),[S,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"&&S&&s.jsx("audio",{controls:!0,preload:"metadata",src:S,className:"w-full"}),!r&&!l&&h==="video"&&S&&s.jsx("video",{controls:!0,preload:"metadata",src:S,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(iG,{content:d,format:h==="text"?"text":h,className:"text-sm"})})]})]})}),document.body)}function gG({path:e}){const t=mG(e),[n,r]=k.useState(null),o=U0(),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(pG,{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 $h=null;function bG(){return $h||($h=qr(()=>import("./mermaid.core-DvatjXnq.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),$h}function xG(){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 yG(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 vG(){return xG()}function wG(){return k.useSyncExternalStore(yG,vG)}function e3({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=wG();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 bG();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 kG="/assets/viz-global-C_AyN6D9.js";let dd=!1,Fh=null;function SG(){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=kG,r.onload=()=>{dd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function NG(){return Fh||(Fh=SG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),Fh}let $2=Promise.resolve();function CG(e,t){const n=$2.then(()=>new Promise((r,o)=>{NG().then(({renderToString:l})=>{const u=e.split(/\r\n|\r|\n/);l(u,r,o,{dark:t})}).catch(o)}));return $2=n.then(()=>{},()=>{}),n}function TG(){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 AG(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 EG(){return k.useSyncExternalStore(AG,()=>TG())}function t3({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,u]=k.useState(!0),d=k.useRef(null),m=EG();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),CG(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 _G(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 Og(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 jG(e,t,n,r){const o=_G(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 Og(n),method:"text"}}}function Pp({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 Og(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 MG(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const fd="#mention:";function RG(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 n3="#entity:",OG=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),DG=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function LG(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function IG(e){return e.replace(DG,(t,n,r)=>`[${n}](${n3}${r})`)}function PG(e){return e.replace(OG,(t,n,r)=>LG(e,r)?t:`[${t}](${n3}${t})`)}function zG(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const BG=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function UG(e){return BG.test(e.trim())}const HG={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 $G(e){return HG[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function FG(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const qG=[e3,t3];function GG(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return FG(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 VG({children:e}){const{t}=ft("common"),n=GG(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)&&qG.includes(p.type))){const p=rc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Pp,{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:$G(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 r3="markus-copy-typography",F2={fontFamily:"default",fontSize:15,headingScale:"standard"};function a3(){try{const e=localStorage.getItem(r3);if(e)return{...F2,...JSON.parse(e)}}catch{}return F2}function KG(e){localStorage.setItem(r3,JSON.stringify(e))}function WG(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 YG({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(a3);k.useEffect(()=>{KG(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 XG=k.lazy(()=>qr(()=>Promise.resolve().then(()=>m3),void 0).then(e=>({default:e.MarkdownMessage}))),QG={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},q2={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 ZG({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=QG[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=q2[e.status]??q2.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(XG,{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 JG={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function s3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const i3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},o3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},eV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function zp(e){return eV.test(e.trim())}function tV(e){const t=e.split("_")[0]?.toLowerCase();return t?JG[t]:void 0}function l3(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 qh=new Map,hd=new Map;async function nV(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 c3(e,t){const n=t??tV(e),[r,o]=k.useState(()=>qh.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=qh.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let u=!0,d=hd.get(e);return d||(d=nV(e,n),hd.set(e,d)),d.then(m=>{qh.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 u3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function l0({id:e,type:t,label:n}){const r=c3(e,t),o=U0(),l=i3[r.type]??"🔗",u=n??(r.loading||r.notFound?u3(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}l3(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:`${o3[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 rV({id:e,type:t,label:n}){const r=c3(e,t),[o,l]=k.useState(!1),u=U0(),d=i3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}l3(e)},h=r.loading?u3(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:o3[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(ZG,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:p=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:p})}})]})}class aV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!sV(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 sV(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 iV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function G2(e){return iV.test(e)?e:Z5(e)}const V2=[Nw,W$,Tk],K2=[[AF,{strict:"ignore"}],[Zk,{detect:!0,ignoreMissing:!0}]],oV=/<think>([\s\S]*?)(<\/think>|$)/g;function lV(e){const t=[];let n=e.replace(oV,(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 W2="#mention:",c0="#entity:",cV=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,d3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Bp(e){return e.type==="text"?e.value??"":(e.children??[]).map(Bp).join("")}function uV(e){return e.type==="text"&&(e.value??"").trim()===""}function dV(e){if(!e?.children)return null;const t=e.children.filter(r=>!uV(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=Bp(n);if(r.startsWith(c0))return{id:r.slice(c0.length)};const l=r.match(d3);return l&&l[1]!=="workflow"?{id:l[2],type:s3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Bp(n).trim();if(zp(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(zp(r))return{id:r}}return null}const mV={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")||zG(r))return s.jsx(Pp,{code:r,language:"plantuml",children:s.jsx(t3,{code:r})});if(t?.includes("language-mermaid")||!t&&UG(r))return s.jsx(Pp,{code:r,language:"mermaid",children:s.jsx(e3,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(zp(n))return s.jsx(l0,{id:n.trim()});const o=n.match(cV);return o?s.jsx(l0,{id:o[2],label:o[1]}):hG(n)?s.jsx(gG,{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(VG,{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})},fV=/^(?:\/[\w.\-@+ ]|~\/|\.\.?\/|[A-Z]:\\)/,hV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function pV(e){return fV.test(e)&&hV.test(e)}function gV(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 bV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const wo=new Map;function xV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>pV(e)?bV(gV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),u=wo.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),[S,T]=k.useState(0),C=k.useRef(0),j=k.useCallback(()=>{wo.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 _=wo.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 X=`HTTP ${z.status}`;try{const ee=await z.json();ee.error&&(X=ee.error)}catch{}throw new Error(X)}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);wo.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,S]),k.useEffect(()=>{l||(m(o),p(!!wo.get(o)),x(!1),w(null))},[o,l,S]),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||wo.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 Y2(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function yV(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 vV(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 wV({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 Y2(e),y=await yV(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 Y2(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=vV(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 kV(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 SV({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=kV();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 Og(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},S=async T=>{const C=t.current?.firstElementChild;if(!C)return;const j=a3(),_=WG(j),O=await jG(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(YG,{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:()=>S("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:()=>S("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Er=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:u,rest:d}=lV(t),m=k.useRef(null),[h,p]=k.useState(null),g=k.useCallback(w=>{let S=md(w,MG);return S=md(S,IG),S=md(S,PG),S=md(S,T=>RG(T,o)),S},[o]),x=k.useMemo(()=>g(d),[d,g]),y=k.useMemo(()=>({...mV,img:({src:w,alt:S})=>s.jsx(xV,{src:w??"",alt:S,onPreview:p,basePath:l},w??""),p:({children:w,node:S})=>{const T=dV(S);return T?s.jsx(rV,{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:S})=>{if(w?.startsWith(W2)){const T=decodeURIComponent(w.slice(W2.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:S})}if(w?.startsWith(c0))return s.jsx(l0,{id:w.slice(c0.length)});{const T=w?.match(d3);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:S})]});const _=s3(C);if(_)return s.jsx(l0,{id:j,type:_,label:S})}}return s.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:S})}}),[r,l]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(SV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(aV,{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=>Aa(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 Ac(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&&Ea(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 Ea(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 Ec(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:Ac,unregisterLanguage:Ks,listLanguages:Yo,getLanguage:ir,registerAliases:Ea,autoDetection:is,inherit:oe,addPlugin:Ln,removePlugin:Ec}),q.debugMode=function(){Je=!1},q.safeMode=function(){Je=!0},q.versionString=ct,q.regex={concat:S,lookahead:x,either:C,optional:w,anyNumberOfTimes:y};for(const Pe in At)typeof At[Pe]=="object"&&e(At[Pe]);return Object.assign(q,At),q},qe=He({});return qe.newInstance=()=>He({}),Hh=qe,qe.HighlightJS=qe,qe.default=qe,Hh}var Xq=Yq();const Qq=xc(Xq),I2={},Zq="hljs-";function Jq(e){const t=Qq.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||I2,x=typeof g.prefix=="string"?g.prefix:Zq;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:eG,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,S=w.data;return S.language=y.language,S.relevance=y.relevance,w}function r(m,h){const g=(h||I2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const S=g[x];if(!t.getLanguage(S))continue;const T=n(S,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 eG{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 tG={};function Zk(e){const t=e||tG,n=t.aliases,r=t.detect||!1,o=t.languages||Wq,l=t.plainText,u=t.prefix,d=t.subset;let m="hljs";const h=Jq(o);if(n&&h.registerAlias(n),u){const p=u.indexOf("-");m=p===-1?u:u.slice(0,p)}return function(p,g){C0(p,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const S=nG(x);if(S===!1||!S&&!r||S&&l&&l.includes(S))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=Mk(x,{whitespace:"pre"});let C;try{C=S?h.highlight(S,T,{prefix:u}):h.highlightAuto(T,{prefix:u,subset:d})}catch(j){const _=j;if(S&&/Unknown language/.test(_.message)){g.message("Cannot highlight as `"+S+"`, it’s not registered",{ancestors:[w,x],cause:_,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw _}!S&&C.data&&C.data.language&&x.properties.className.push("language-"+C.data.language),C.children.length>0&&(x.children=C.children)})}}function nG(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 rG=10;function P2(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 aG(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 Jk=k.createContext(null);function sG({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(W=>n(W),[]),S=k.useCallback(()=>n(W=>!W),[]),T=k.useCallback(W=>{const F=P2(W),Z=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let B=null;o(Q=>{const ae=Q.find(G=>P2(G.payload)===F);if(ae)return B=ae.id,g.current=Q,Q;let U=[{id:Z,title:aG(W),payload:W},...Q];for(;U.length>rG;){let G=-1;for(let le=U.length-1;le>=0;le--)if(!U[le].pinned){G=le;break}if(G<0)break;U=U.filter((le,I)=>I!==G)}return B=Z,g.current=U,U}),B&&(u(B),x.current=B),n(!0)},[]),C=W=>{W?.kind==="url"&&W.browserId&&window.markusDesktop?.browser?.destroy(W.browserId)},j=k.useCallback(W=>{let F,Z,B=!1;o(Q=>{const ae=Q.findIndex(U=>U.id===W);if(ae<0)return Q;F=Q[ae]?.payload;const ke=Q.filter(U=>U.id!==W);return g.current=ke,B=ke.length===0,Z=void 0,(x.current===W||ke.length===0)&&(Z=ke[Math.min(ae,ke.length-1)]?.id??null),ke}),B&&m(!1),Z!==void 0&&(u(Z),x.current=Z),C(F)},[]),_=k.useCallback(()=>{let W=[];o(F=>(W=F.map(Z=>Z.payload),[])),u(null),m(!1),g.current=[],x.current=null;for(const F of W)C(F)},[]),O=k.useCallback(W=>{u(W),x.current=W},[]),z=k.useCallback((W,F)=>{o(Z=>{let B=!1;const Q=Z.map(ae=>{if(ae.payload.kind!=="url"||ae.payload.browserId!==W)return ae;B=!0;const ke=F.url??ae.payload.url,U=F.title||ae.payload.title||ke;return{...ae,title:U,payload:{...ae.payload,url:ke,title:U}}});return B&&(g.current=Q),B?Q:Z})},[]),D=k.useCallback(()=>{o(W=>W.length===0?W:(g.current=W,y.current&&(x.current=y.current),[])),u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()},[]),H=k.useCallback(()=>{const W=`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 Z,B=!1,Q=!1;o(ae=>{if(ae.length>0)return g.current=ae,y.current&&(x.current=y.current),Q=!0,Z=null,[];if(g.current.length>0){B=!0;const U=g.current;return Z=x.current&&U.some(le=>le.id===x.current)?x.current:U[0].id,U}B=!0;const ke={id:W,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:F}};return g.current=[ke],Z=ke.id,[ke]}),B&&n(!0),Q?(u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()):Z!=null&&(u(Z),x.current=Z)},[]),X=k.useCallback(W=>m(W),[]),ee=k.useCallback(()=>m(W=>!W),[]),$=r.find(W=>W.id===l)??r[0]??null,K=$?.payload??null,re=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:w,toggleLeftCollapsed:S,rightPanel:K,rightPanelOpen:r.length>0,rightPanelTabs:r,activeRightPanelTabId:$?.id??null,openRightPanel:T,closeRightPanel:_,closeRightPanelTab:j,setActiveRightPanelTab:O,updateRightPanelBrowserTab:z,toggleRightPanel:H,collapseRightPanelOnly:D,rightPanelFullscreen:d,setRightPanelFullscreen:X,toggleRightPanelFullscreen:ee,hostAvailable:h,setHostAvailable:p}),[t,w,S,K,r,$,T,_,j,O,z,H,D,d,X,ee,h]);return s.jsx(Jk.Provider,{value:re,children:e})}function U0(){return k.useContext(Jk)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>m3),void 0).then(e=>({default:e.MarkdownMessage})));const iG=k.lazy(()=>qr(()=>import("./ContentRenderer-DJQo68Rq.js"),[]).then(e=>({default:e.ContentRenderer})));let vo=[],z2=60;function oG(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++z2);return k.useEffect(()=>{const r=()=>t.current();vo.push(r);const o=l=>{l.key==="Escape"&&vo[vo.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),vo=vo.filter(l=>l!==r),vo.length===0&&(z2=60)}},[]),n}const B2=500,Bs=new Map,o0=new Set,Od=new Map;let Dd=null;function lG(){if(Bs.size<=B2)return;const e=Bs.size-B2,t=Bs.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;Bs.delete(r)}}function U2(e,t){Bs.delete(e),Bs.set(e,t),lG()}function H2(e){const t=Od.get(e);if(t)for(const n of t)n()}function cG(){Dd=null;const e=[...o0];o0.clear(),e.length!==0&&Ce.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))U2(n,r),H2(n)}).catch(()=>{for(const t of e)U2(t,{exists:!1,isFile:!1,type:"unknown"}),H2(t)})}function uG(e){Bs.has(e)||o0.has(e)||(o0.add(e),Dd&&clearTimeout(Dd),Dd=setTimeout(cG,30))}function dG(e,t){let n=Od.get(e);return n||(n=new Set,Od.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Od.delete(e)}}function mG(e){const t=k.useCallback(o=>dG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{uG(e)},[e]),r}const fG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function hG(e){return e.length<2||e.length>500?!1:fG.test(e)}function pG({filePath:e,onClose:t}){const n=oG(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(""),[S,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"&&S&&s.jsx("audio",{controls:!0,preload:"metadata",src:S,className:"w-full"}),!r&&!l&&h==="video"&&S&&s.jsx("video",{controls:!0,preload:"metadata",src:S,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(iG,{content:d,format:h==="text"?"text":h,className:"text-sm"})})]})]})}),document.body)}function gG({path:e}){const t=mG(e),[n,r]=k.useState(null),o=U0(),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(pG,{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 $h=null;function bG(){return $h||($h=qr(()=>import("./mermaid.core-CSfwY1-0.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),$h}function xG(){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 yG(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 vG(){return xG()}function wG(){return k.useSyncExternalStore(yG,vG)}function e3({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=wG();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 bG();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 kG="/assets/viz-global-C_AyN6D9.js";let dd=!1,Fh=null;function SG(){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=kG,r.onload=()=>{dd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function NG(){return Fh||(Fh=SG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),Fh}let $2=Promise.resolve();function CG(e,t){const n=$2.then(()=>new Promise((r,o)=>{NG().then(({renderToString:l})=>{const u=e.split(/\r\n|\r|\n/);l(u,r,o,{dark:t})}).catch(o)}));return $2=n.then(()=>{},()=>{}),n}function TG(){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 AG(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 EG(){return k.useSyncExternalStore(AG,()=>TG())}function t3({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,u]=k.useState(!0),d=k.useRef(null),m=EG();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),CG(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 _G(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 Og(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 jG(e,t,n,r){const o=_G(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 Og(n),method:"text"}}}function Pp({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 Og(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 MG(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const fd="#mention:";function RG(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 n3="#entity:",OG=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),DG=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function LG(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function IG(e){return e.replace(DG,(t,n,r)=>`[${n}](${n3}${r})`)}function PG(e){return e.replace(OG,(t,n,r)=>LG(e,r)?t:`[${t}](${n3}${t})`)}function zG(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const BG=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function UG(e){return BG.test(e.trim())}const HG={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 $G(e){return HG[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function FG(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const qG=[e3,t3];function GG(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return FG(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 VG({children:e}){const{t}=ft("common"),n=GG(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)&&qG.includes(p.type))){const p=rc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Pp,{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:$G(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 r3="markus-copy-typography",F2={fontFamily:"default",fontSize:15,headingScale:"standard"};function a3(){try{const e=localStorage.getItem(r3);if(e)return{...F2,...JSON.parse(e)}}catch{}return F2}function KG(e){localStorage.setItem(r3,JSON.stringify(e))}function WG(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 YG({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(a3);k.useEffect(()=>{KG(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 XG=k.lazy(()=>qr(()=>Promise.resolve().then(()=>m3),void 0).then(e=>({default:e.MarkdownMessage}))),QG={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},q2={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 ZG({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=QG[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=q2[e.status]??q2.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(XG,{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 JG={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function s3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const i3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},o3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},eV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function zp(e){return eV.test(e.trim())}function tV(e){const t=e.split("_")[0]?.toLowerCase();return t?JG[t]:void 0}function l3(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 qh=new Map,hd=new Map;async function nV(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 c3(e,t){const n=t??tV(e),[r,o]=k.useState(()=>qh.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=qh.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let u=!0,d=hd.get(e);return d||(d=nV(e,n),hd.set(e,d)),d.then(m=>{qh.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 u3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function l0({id:e,type:t,label:n}){const r=c3(e,t),o=U0(),l=i3[r.type]??"🔗",u=n??(r.loading||r.notFound?u3(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}l3(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:`${o3[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 rV({id:e,type:t,label:n}){const r=c3(e,t),[o,l]=k.useState(!1),u=U0(),d=i3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}l3(e)},h=r.loading?u3(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:o3[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(ZG,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:p=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:p})}})]})}class aV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!sV(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 sV(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 iV=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function G2(e){return iV.test(e)?e:Z5(e)}const V2=[Nw,W$,Tk],K2=[[AF,{strict:"ignore"}],[Zk,{detect:!0,ignoreMissing:!0}]],oV=/<think>([\s\S]*?)(<\/think>|$)/g;function lV(e){const t=[];let n=e.replace(oV,(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 W2="#mention:",c0="#entity:",cV=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,d3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Bp(e){return e.type==="text"?e.value??"":(e.children??[]).map(Bp).join("")}function uV(e){return e.type==="text"&&(e.value??"").trim()===""}function dV(e){if(!e?.children)return null;const t=e.children.filter(r=>!uV(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=Bp(n);if(r.startsWith(c0))return{id:r.slice(c0.length)};const l=r.match(d3);return l&&l[1]!=="workflow"?{id:l[2],type:s3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Bp(n).trim();if(zp(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(zp(r))return{id:r}}return null}const mV={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")||zG(r))return s.jsx(Pp,{code:r,language:"plantuml",children:s.jsx(t3,{code:r})});if(t?.includes("language-mermaid")||!t&&UG(r))return s.jsx(Pp,{code:r,language:"mermaid",children:s.jsx(e3,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(zp(n))return s.jsx(l0,{id:n.trim()});const o=n.match(cV);return o?s.jsx(l0,{id:o[2],label:o[1]}):hG(n)?s.jsx(gG,{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(VG,{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})},fV=/^(?:\/[\w.\-@+ ]|~\/|\.\.?\/|[A-Z]:\\)/,hV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function pV(e){return fV.test(e)&&hV.test(e)}function gV(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 bV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const wo=new Map;function xV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>pV(e)?bV(gV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),u=wo.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),[S,T]=k.useState(0),C=k.useRef(0),j=k.useCallback(()=>{wo.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 _=wo.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 X=`HTTP ${z.status}`;try{const ee=await z.json();ee.error&&(X=ee.error)}catch{}throw new Error(X)}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);wo.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,S]),k.useEffect(()=>{l||(m(o),p(!!wo.get(o)),x(!1),w(null))},[o,l,S]),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||wo.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 Y2(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function yV(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 vV(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 wV({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 Y2(e),y=await yV(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 Y2(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=vV(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 kV(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 SV({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=kV();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 Og(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},S=async T=>{const C=t.current?.firstElementChild;if(!C)return;const j=a3(),_=WG(j),O=await jG(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(YG,{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:()=>S("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:()=>S("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Er=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:u,rest:d}=lV(t),m=k.useRef(null),[h,p]=k.useState(null),g=k.useCallback(w=>{let S=md(w,MG);return S=md(S,IG),S=md(S,PG),S=md(S,T=>RG(T,o)),S},[o]),x=k.useMemo(()=>g(d),[d,g]),y=k.useMemo(()=>({...mV,img:({src:w,alt:S})=>s.jsx(xV,{src:w??"",alt:S,onPreview:p,basePath:l},w??""),p:({children:w,node:S})=>{const T=dV(S);return T?s.jsx(rV,{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:S})=>{if(w?.startsWith(W2)){const T=decodeURIComponent(w.slice(W2.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:S})}if(w?.startsWith(c0))return s.jsx(l0,{id:w.slice(c0.length)});{const T=w?.match(d3);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:S})]});const _=s3(C);if(_)return s.jsx(l0,{id:j,type:_,label:S})}}return s.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:S})}}),[r,l]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(SV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(aV,{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
|
`),S=w.split(`
|
|
651
651
|
`)[0]??"",T=S.length>80?S.slice(0,80)+"…":S;return s.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[s.jsxs("summary",{className:"cursor-pointer select-none px-3 py-2 text-xs text-fg-secondary hover:text-fg-secondary transition-colors flex items-center gap-1.5 min-w-0",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),s.jsx("span",{className:"shrink-0",children:"Thinking"}),s.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children: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(yp,{remarkPlugins:V2,rehypePlugins:K2,components:y,urlTransform:G2,children:g(w)})})})]})})(),s.jsx(yp,{remarkPlugins:V2,rehypePlugins:K2,components:y,urlTransform:G2,children:x})]})})}),h&&s.jsx(wV,{src:h,onClose:()=>p(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&NV(e.knownNames,t.knownNames));function NV(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 m3=Object.freeze(Object.defineProperty({__proto__:null,MarkdownMessage:Er},Symbol.toStringTag,{value:"Module"})),Up={suppressAdjustUntil:0};function bc(e=2500){const t=typeof performance<"u"?performance.now():Date.now();Up.suppressAdjustUntil=Math.max(Up.suppressAdjustUntil,t+e)}function _W(){return(typeof performance<"u"?performance.now():Date.now())<Up.suppressAdjustUntil}const X2={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:"🔍"}},Q2={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=X2[t]??X2[e],r=Q2[t]??Q2[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 CV(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 Hp(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function Z2(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function f3(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 TV(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 jW(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 J2(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 h3(e){const t=CV(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 p3(e,t){if(e!=="task_create"&&e!=="create_task"||!t)return null;try{const n=JSON.parse(t);if(!n.task)return null;const r=n.task;return{taskId:r.id,title:r.title,description:r.description,assignedAgentId:r.assignedAgentId,priority:r.priority}}catch{return null}}function g3(e,t){if(e!=="requirement_propose"||!t)return null;try{const n=JSON.parse(t);if(n.status!=="success"||!n.requirement)return null;const r=n.requirement;return r.status!=="pending"?null:{requirementId:r.id,title:r.title,description:r.description,priority:r.priority}}catch{return null}}const b3={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 AV(e){return!!e&&e in b3}function Vo({name:e,size:t=24,className:n=""}){const r=b3[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 e4={"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"},t4={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Ld(e,t){const n=(e||"").toLowerCase();return e4[n]?e4[n]:t&&t4[t]?t4[t]:"layers"}function EV(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 x3(){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 _V(){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 n4({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(x3,{})]})}function jV({activities:e,isActive:t,persistent:n}){const{t:r}=ft("common"),o=EV(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,S=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:S})}),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(n4,{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(_V,{})]});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(S=>!S)},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(x3,{})]}),l&&s.jsx("div",{className:"mt-1 space-y-0.5",children:o.map((w,S)=>s.jsx(n4,{item:w,idx:S,total:o.length},w.key))})]})}const MV={"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"],RV=new Set(["completed","failed","cancelled","timeout"]),r4={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function OV(e){return MV[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function DV(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 LV(e){if(e==="completed"||RV.has(e))return Mo.length;const t=Mo.indexOf(e);return t>=0?t:0}function IV({session:e,className:t}){const n=OV(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(()=>DV(e,l),[e,l]),g=LV(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:r4[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,S)=>{const T=g>S||g===S&&!d&&h,C=g===S&&d,j=m&&S===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:r4[w]}),S<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 PV({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 a4=150;function zV({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>=a4?(o.current=d,r(e)):l.current||(l.current=setTimeout(()=>{o.current=Date.now(),l.current=null,r(e)},a4-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(Er,{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 u0=8e3,pd=120;function Gh({text:e,className:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),l=e.length>u0,u=!l||r?e:`${e.slice(0,u0)}
|
|
@@ -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>u0?e.liveOutput.slice(e.liveOutput.length-u0):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(BV,{info:e,time:t})})]}),l&&!n&&(()=>{const _=p3(e.tool,e.result);if(_)return s.jsx(v3,{info:_});const O=g3(e.tool,e.result);return O?s.jsx(w3,{info:O}):null})()]})}function GV({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(Er,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})}const c4=k.memo(VV);function VV({entry:e,showTime:t,isLast:n,defaultThinkingExpanded:r,hideApprovalCards:o}){const{t:l}=ft("common");if(e.type==="tool")return s.jsx(qV,{info:e.info,showTime:t,time:e.time,isLast:n,hideApprovalCards:o},e.key);if(e.type==="thinking")return s.jsx(GV,{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(Er,{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 MW({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,S=o&&y.size>1;let T,C,j=null;if(n)if(t)T="✍",C=u("execution.compact.writingResponse"),j=Hp(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=`$ ${Hp(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(Er,{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")]}),S&&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 KV(e){const t=new Map;for(const n of e){const r=n.executionRound??1;t.has(r)||t.set(r,[]);const o=h3(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 WV({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=KV(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),_})},S=y?null:e.map(h3).filter(C=>C!==null),T=S?J2(S):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),_=J2(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(c4,{entry:z,showTime:!1,isLast:D===_.length-1,defaultThinkingExpanded:!!u,hideApprovalCards:d},D))})]},C.round)}):T&&T.map((C,j)=>s.jsx(c4,{entry:C,showTime:!1,isLast:j===T.length-1,defaultThinkingExpanded:!!u,hideApprovalCards:d},j)),n&&t&&s.jsx(zV,{content:t}),n&&!t&&s.jsx(PV,{})]})]})}function RW({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 OW({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 DW({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 YV(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const k3="markus:credit-notif-muted";let u4=0;function LW(){try{if(localStorage.getItem(k3))return}catch{}const e=Date.now();e-u4<5*6e4||(u4=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function XV(){try{localStorage.setItem(k3,"1")}catch{}}function IW(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(YV(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 PW({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 d4(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=""},S=()=>{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),S(),p=!0,O=z+T.length)}};for(const _ of e)if(y=h(_),_.type==="tool"){p||S();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||S(),g+=_.thinking,w()),j(_.content);return p?w():S(),r}const zW=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?d4(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):"",S=y?y.reduce((_,O)=>_+(O.type==="tool"?O.subagentLogs?.length??0:0),0):0,T=k.useMemo(()=>n?x:y&&y.length>0?d4(y,t.agentId,t.rawCreatedAt):x,[n,w,S,t.agentId,t.rawCreatedAt,x]);if(d!==void 0&&d.length>0){const _=d.some($=>$.type==="tool"),O=d.filter($=>$.type==="text"),z=n?null:O.map($=>$.content).join(""),D=$=>$.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,X=(z?D(z):null)||(!n&&t.text?D(t.text):null),ee=[];for(const $ of d){if($.type!=="tool")continue;const K=p3($.tool,$.result);if(K){ee.push({key:`task-${K.taskId}`,kind:"task",info:K});continue}const re=g3($.tool,$.result);re&&ee.push({key:`req-${re.requirementId}`,kind:"req",info:re})}return s.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[_||n?s.jsx(WV,{entries:T,isActive:n,embedded:!0,hideApprovalCards:!0}):X&&s.jsx(Er,{content:X,onMentionClick:o,knownNames:l}),ee.map($=>$.kind==="task"?s.jsx(v3,{info:$.info},$.key):s.jsx(w3,{info:$.info},$.key)),!n&&!X&&!_&&ee.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($=>$.type==="text"&&$.content&&($.content===t.text||$.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(jV,{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(Er,{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 QV(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 ZV({approval:e,submitting:t,readOnly:n,onClose:r,onSubmit:o}){const{t:l}=ft(["team","common"]);zo(!0);const u=k.useMemo(()=>QV(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:""},S=(z,D)=>{p(H=>({...H,[z]:{...w(z),...D}}))},T=(z,D)=>{const H=w(z.id);if(z.allowMultiple){const X=H.selectedOptionIds.includes(D);S(z.id,{selectedOptionIds:X?H.selectedOptionIds.filter(ee=>ee!==D):[...H.selectedOptionIds,D],text:X?H.text:""})}else{const X=H.selectedOptionIds.includes(D);S(z.id,{selectedOptionIds:X?[]:[D],text:X?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 ee=z[0];H=ee?.selectedOptionIds?.[0]??(ee?.text?"custom":void 0),D=H!=="reject"&&H!=="request_changes"}const X=z.map(ee=>ee.text).filter(Boolean).join(`
|
|
657
|
-
`)||void 0;o({approved:D,comment:X,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(Er,{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(Er,{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(Er,{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;S(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"},ko={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"},m4={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 So(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 f4="markus:template-updates-ack";let Vh=!1,xd=null;function JV(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function h4(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 Kh(){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 eK({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([]),[S,T]=k.useState([]),[C,j]=k.useState(null),[_,O]=k.useState(null),[z,D]=k.useState(null),[H,X]=k.useState({}),[ee,$]=k.useState(0),K=k.useRef(null),re=k.useRef(null),[W,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),Z=k.useRef(null),B=k.useRef(!1),[Q,ae]=k.useState(!0),[ke,U]=k.useState(!1),G=k.useRef(null),le=k.useRef("approvals"),[I,Ae]=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($(_e),ae(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=Ue),T(oe.approvals),!B.current){const de=oe.approvals.filter(He=>He.status==="pending").length;Z.current=de,B.current=!0}}catch{}},[t]),We=k.useCallback(async()=>{if(!(ke||!Q)){U(!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))]),ae(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=Ue)}catch{}U(!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(He=>{const qe=He.filter(q=>!q.read&&(_e&&q.metadata?.taskId===_e||de&&q.metadata?.requirementId===de));if(qe.length===0)return He;for(const q of qe)Ce.notifications.markRead(q.id).catch(()=>{});return $(q=>Math.max(0,q-qe.length)),He.map(q=>qe.some(ie=>ie.id===q.id)?{...q,read:!0}:q)})},[]),dt=k.useRef(y);dt.current=y;const At=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(),Kh()}catch{}},[Oe,m]),gt=k.useCallback(async()=>{if(!Vh){Vh=!0;try{const{updates:R}=await Ce.skills.updates();if(!R.length)return;const oe=JV(R);try{if(localStorage.getItem(f4)===oe)return}catch{}if(xd===oe||dt.current.some(de=>!de.read&&h4(de,oe)))return;try{const He=(await Ce.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(qe=>h4(qe,oe)).sort((qe,q)=>new Date(q.createdAt).getTime()-new Date(qe.createdAt).getTime());if(He.length>0){for(const qe of He.slice(1))Ce.notifications.markRead(qe.id).catch(()=>{});He.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(),Kh()}catch{xd=null}finally{Vh=!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(),He=()=>{p(!0),Oe()};window.addEventListener("markus:notifications-changed",de),window.addEventListener("markus:mark-read-by-ref",st),window.addEventListener("markus:open-notifications",He),window.addEventListener("markus:credit-exhausted",At);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",He),window.removeEventListener("markus:credit-exhausted",At),qe(),q()}},[Oe,st,At]),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(!K.current)return;const R=K.current.getBoundingClientRect(),oe=window.innerWidth,_e=window.innerHeight,de=Math.min(448,oe-16),He=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+He>_e-8&&(q=Math.max(8,_e-He-8)),F({top:q,left:qe,width:de,maxHeight:He})},[]);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=>{K.current?.contains(oe.target)||re.current?.contains(oe.target)||p(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[h]),k.useEffect(()=>{if(!h)return;const R=S.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(S.filter(R=>R.status==="pending").map(R=>R.id)),Rt=new Set(S.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,ee-Me),ot=Jt.size,mt=Ge+ot;k.useEffect(()=>{Z.current!==null&&ot>Z.current&&Kh(),Z.current=ot},[ot]);const se=async R=>{await Ce.notifications.markRead(R),w(oe=>oe.map(_e=>_e.id===R?{..._e,read:!0}:_e)),$(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 He=typeof de=="string"?JSON.parse(de):de;if(He.agentId){const qe={agentId:He.agentId};He.sessionId&&(qe.sessionId=He.sessionId),at.navigate(me.TEAM,qe);return}}catch{}if(_e==="navigate"&&de)try{const He=typeof de=="string"?JSON.parse(de):de;if(He.path){if(He.path.startsWith("/team")){const qe={},q=new URLSearchParams(He.path.split("?")[1]||"");for(const[ie,Ne]of q.entries())qe[ie]=Ne;at.navigate(me.TEAM,qe);return}if(He.path.startsWith("/work")){const qe={},q=new URLSearchParams(He.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 He=oe.approvalId,qe=He?S.find(Le=>Le.id===He):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){Ae(!0);return}if(oe.templateUpdates){const He=oe.templateUpdatesFingerprint;if(He)try{localStorage.setItem(f4,He)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(me.STORE);return}if(oe.agentId){const He={agentId:oe.agentId};oe.sessionId&&(He.sessionId=oe.sessionId),at.navigate(me.TEAM,He)}else at.navigate(me.TEAM);break}case"direct_message":{const He=oe.senderId;He?at.navigate(me.TEAM,{dm:He}):at.navigate(me.TEAM);break}case"group_message":{const He=oe.channel;He?at.navigate(me.TEAM,{channel:He}):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||se(R.id);const oe=R.metadata??{},_e=oe.taskId,de=oe.requirementId;if(_e||de){const He=y.filter(qe=>qe.id!==R.id&&!qe.read&&(_e&&qe.metadata?.taskId===_e||de&&qe.metadata?.requirementId===de));for(const qe of He)se(qe.id)}ze(R)},Ve=async(R,oe,_e,de,He)=>{j(R);try{const{approval:qe}=await Ce.approvals.respond(R,oe,t,_e,de,He);T(Le=>Le.map(Je=>Je.id===R?qe:Je)),O(null),D(null),X(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)),$(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}))),$(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}))),$(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 He=R.details?.requirementId;return He&&!de&&oe.push(`Req ${He.slice(0,8)}`),oe.join(" · ")},V=[...S].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(ZV,{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"&&ee>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"&&(S.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:ko.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:So(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:_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,He=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=>X(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")})]})]}):He?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=>X(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=>X(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:So(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=m4[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:ko[R.type]??ko.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(Er,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:So(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&&XV()},[]),ct=k.useCallback(R=>{Dt(R),Ae(!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:()=>Ae(!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,He=0;return{onTouchStart:qe=>{de=qe.touches[0].clientX,He=qe.touches[0].clientY},onTouchEnd:qe=>{const q=qe.changedTouches[0].clientX-de,ie=qe.changedTouches[0].clientY-He;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"&&ee>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:S.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 He=de.details?.command,qe=He?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:ko.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:So(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(Er,{content:qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),He&&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:He})]}),(()=>{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=>X(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=>X(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=>X(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:So(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 He=m4[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:He,children:s.jsx("path",{d:ko[de.type]??ko.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(Er,{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:So(de.createdAt,m)}),yd(de,m)&&s.jsx("span",{className:`text-[10px] font-medium ${He}`,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:K,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:re,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:W.top,left:W.left,width:W.width,maxHeight:W.maxHeight},children:xt}),document.body),Xt]})}return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:K,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:re,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:W.top,left:W.left,width:W.width,maxHeight:W.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 Wh=200;function tK({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(()=>sa()),[S,T]=k.useState({top:0,left:0}),C=k.useRef(null),j=k.useRef(null),_=k.useCallback(W=>{if(w(sa()),!it.isAuthenticated()){x(!1);return}if(!W?.validate){x(!0);return}s5().then(F=>{x(F),w(sa())})},[]);k.useEffect(()=>{_({validate:!0});const W=()=>_(),F=()=>_({validate:!0});return window.addEventListener("markus:hub-auth",W),window.addEventListener("focus",F),()=>{window.removeEventListener("markus:hub-auth",W),window.removeEventListener("focus",F)}},[_]);const O=k.useCallback(()=>{if(!C.current)return;const W=C.current.getBoundingClientRect(),F=window.innerWidth,Z=window.innerHeight,B=j.current?.offsetHeight??220;let Q=W.right+8;Q+Wh>F-8&&(Q=Math.max(8,W.left-Wh-8));let ae=W.top-B-8;ae<8&&(ae=Math.min(W.bottom+8,Z-B-8)),T({top:Math.max(8,ae),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const W=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(W)},[d,O,o]),k.useEffect(()=>{if(!d)return;const W=Z=>{const B=Z.target;C.current?.contains(B)||j.current?.contains(B)||m(!1)},F=()=>O();return document.addEventListener("mousedown",W),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",W),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=l5(e?.avatarUrl,y?.avatarUrl),X=g?"bg-emerald-500":"bg-fg-muted",ee=g?y?.username?u("sidebar.hubConnectedAs",{username:y.username}):u("sidebar.hubConnected"):u("sidebar.hubDisconnected"),$=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),K=()=>{m(!1),_({validate:!0}),at.navigate(me.SETTINGS,{tab:"account"})},re=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:S.top,left:S.left,width:Wh},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:K,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 ${X}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:ee}),$&&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(W=>!W),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 ${X}`,title:ee})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.0-rc.7"]}),re,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 nK({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 rK({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:YO.map((d,m)=>{const h=XO.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(eK,{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(nK,{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(tK,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const aK=6e4;let Ps={},bi={};const $p=new Set,Fp=new Set;let S3=0,ac=null,wd=0,Id=null;function d0(){for(const e of $p)e()}async function qp(){try{const e=await Ce.unread.getCounts();Ps=e.counts??{},bi=e.sessionAgentMap??{},d0()}catch{}}function sK(){ac||(qp(),ac=setInterval(qp,aK),Id=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!Fp.has(t)&&Date.now()>S3&&(Ps[t]=(Ps[t]??0)+1,d0())}))}function iK(){ac&&(clearInterval(ac),ac=null),Id&&(Id(),Id=null)}function oK(e){const t=e?.enabled??!0,[n,r]=k.useState(Ps),[o,l]=k.useState(bi),u=k.useCallback(async()=>{await qp()},[]),d=k.useCallback(async w=>{const S=new Date().toISOString();delete Ps[w],d0();try{await Ce.unread.markRead(w,S)}catch{}},[]),m=k.useCallback(async()=>{Ps={},d0();try{await Ce.unread.markAllRead()}catch{}},[]),h=k.useCallback(w=>{Fp.add(w)},[]),p=k.useCallback(w=>{Fp.delete(w),S3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;wd++,sK();let w=bi;const S=()=>{r({...Ps}),w!==bi&&(w=bi,l({...bi}))};return $p.add(S),r({...Ps}),l({...bi}),()=>{$p.delete(S),wd--,wd<=0&&(wd=0,iK())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,S)=>w+S,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 BW(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 lK({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:u}=oK({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:QO.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 m0=new Map;function pi(e,t){m0.has(e)||m0.set(e,t().catch(()=>{}))}function wi(e){const t=m0.get(e);return m0.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 N3(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 cK={agent:258,team:205,skill:32,connector:162};function Dg(e,t){const n=cK[e],r=N3(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 p4=["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 C3(e){return p4[N3(e+"g")%p4.length]}function T3(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 uK(e){return!e||T3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function dK(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 g4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const b4={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"}},mK=["development","devops","management","productivity","browser","custom","general"],fK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],hK={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 Yh({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)},S=_=>{_.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:S,className:`${_} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:S,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 pK({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 gK({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 Gp({content:e}){return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
|
|
657
|
+
`)||void 0;o({approved:D,comment:X,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(Er,{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(Er,{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(Er,{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;S(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"},ko={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"},m4={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 So(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 f4="markus:template-updates-ack";let Vh=!1,xd=null;function JV(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function h4(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 Kh(){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 eK({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([]),[S,T]=k.useState([]),[C,j]=k.useState(null),[_,O]=k.useState(null),[z,D]=k.useState(null),[H,X]=k.useState({}),[ee,$]=k.useState(0),K=k.useRef(null),re=k.useRef(null),[W,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),Z=k.useRef(null),B=k.useRef(!1),[Q,ae]=k.useState(!0),[ke,U]=k.useState(!1),G=k.useRef(null),le=k.useRef("approvals"),[I,Ae]=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($(_e),ae(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=Ue),T(oe.approvals),!B.current){const de=oe.approvals.filter(He=>He.status==="pending").length;Z.current=de,B.current=!0}}catch{}},[t]),We=k.useCallback(async()=>{if(!(ke||!Q)){U(!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))]),ae(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=Ue)}catch{}U(!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(He=>{const qe=He.filter(q=>!q.read&&(_e&&q.metadata?.taskId===_e||de&&q.metadata?.requirementId===de));if(qe.length===0)return He;for(const q of qe)Ce.notifications.markRead(q.id).catch(()=>{});return $(q=>Math.max(0,q-qe.length)),He.map(q=>qe.some(ie=>ie.id===q.id)?{...q,read:!0}:q)})},[]),dt=k.useRef(y);dt.current=y;const At=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(),Kh()}catch{}},[Oe,m]),gt=k.useCallback(async()=>{if(!Vh){Vh=!0;try{const{updates:R}=await Ce.skills.updates();if(!R.length)return;const oe=JV(R);try{if(localStorage.getItem(f4)===oe)return}catch{}if(xd===oe||dt.current.some(de=>!de.read&&h4(de,oe)))return;try{const He=(await Ce.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(qe=>h4(qe,oe)).sort((qe,q)=>new Date(q.createdAt).getTime()-new Date(qe.createdAt).getTime());if(He.length>0){for(const qe of He.slice(1))Ce.notifications.markRead(qe.id).catch(()=>{});He.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(),Kh()}catch{xd=null}finally{Vh=!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(),He=()=>{p(!0),Oe()};window.addEventListener("markus:notifications-changed",de),window.addEventListener("markus:mark-read-by-ref",st),window.addEventListener("markus:open-notifications",He),window.addEventListener("markus:credit-exhausted",At);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",He),window.removeEventListener("markus:credit-exhausted",At),qe(),q()}},[Oe,st,At]),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(!K.current)return;const R=K.current.getBoundingClientRect(),oe=window.innerWidth,_e=window.innerHeight,de=Math.min(448,oe-16),He=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+He>_e-8&&(q=Math.max(8,_e-He-8)),F({top:q,left:qe,width:de,maxHeight:He})},[]);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=>{K.current?.contains(oe.target)||re.current?.contains(oe.target)||p(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[h]),k.useEffect(()=>{if(!h)return;const R=S.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(S.filter(R=>R.status==="pending").map(R=>R.id)),Rt=new Set(S.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,ee-Me),ot=Jt.size,mt=Ge+ot;k.useEffect(()=>{Z.current!==null&&ot>Z.current&&Kh(),Z.current=ot},[ot]);const se=async R=>{await Ce.notifications.markRead(R),w(oe=>oe.map(_e=>_e.id===R?{..._e,read:!0}:_e)),$(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 He=typeof de=="string"?JSON.parse(de):de;if(He.agentId){const qe={agentId:He.agentId};He.sessionId&&(qe.sessionId=He.sessionId),at.navigate(me.TEAM,qe);return}}catch{}if(_e==="navigate"&&de)try{const He=typeof de=="string"?JSON.parse(de):de;if(He.path){if(He.path.startsWith("/team")){const qe={},q=new URLSearchParams(He.path.split("?")[1]||"");for(const[ie,Ne]of q.entries())qe[ie]=Ne;at.navigate(me.TEAM,qe);return}if(He.path.startsWith("/work")){const qe={},q=new URLSearchParams(He.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 He=oe.approvalId,qe=He?S.find(Le=>Le.id===He):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){Ae(!0);return}if(oe.templateUpdates){const He=oe.templateUpdatesFingerprint;if(He)try{localStorage.setItem(f4,He)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(me.STORE);return}if(oe.agentId){const He={agentId:oe.agentId};oe.sessionId&&(He.sessionId=oe.sessionId),at.navigate(me.TEAM,He)}else at.navigate(me.TEAM);break}case"direct_message":{const He=oe.senderId;He?at.navigate(me.TEAM,{dm:He}):at.navigate(me.TEAM);break}case"group_message":{const He=oe.channel;He?at.navigate(me.TEAM,{channel:He}):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||se(R.id);const oe=R.metadata??{},_e=oe.taskId,de=oe.requirementId;if(_e||de){const He=y.filter(qe=>qe.id!==R.id&&!qe.read&&(_e&&qe.metadata?.taskId===_e||de&&qe.metadata?.requirementId===de));for(const qe of He)se(qe.id)}ze(R)},Ve=async(R,oe,_e,de,He)=>{j(R);try{const{approval:qe}=await Ce.approvals.respond(R,oe,t,_e,de,He);T(Le=>Le.map(Je=>Je.id===R?qe:Je)),O(null),D(null),X(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)),$(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}))),$(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}))),$(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 He=R.details?.requirementId;return He&&!de&&oe.push(`Req ${He.slice(0,8)}`),oe.join(" · ")},V=[...S].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(ZV,{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"&&ee>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"&&(S.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:ko.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:So(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:_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,He=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=>X(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")})]})]}):He?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=>X(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=>X(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:So(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=m4[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:ko[R.type]??ko.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(Er,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:So(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&&XV()},[]),ct=k.useCallback(R=>{Dt(R),Ae(!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:()=>Ae(!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,He=0;return{onTouchStart:qe=>{de=qe.touches[0].clientX,He=qe.touches[0].clientY},onTouchEnd:qe=>{const q=qe.changedTouches[0].clientX-de,ie=qe.changedTouches[0].clientY-He;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"&&ee>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:S.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 He=de.details?.command,qe=He?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:ko.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:So(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(Er,{content:qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),He&&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:He})]}),(()=>{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=>X(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=>X(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=>X(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:So(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 He=m4[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:He,children:s.jsx("path",{d:ko[de.type]??ko.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(Er,{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:So(de.createdAt,m)}),yd(de,m)&&s.jsx("span",{className:`text-[10px] font-medium ${He}`,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:K,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:re,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:W.top,left:W.left,width:W.width,maxHeight:W.maxHeight},children:xt}),document.body),Xt]})}return s.jsxs(s.Fragment,{children:[nt,s.jsxs("button",{ref:K,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:re,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:W.top,left:W.left,width:W.width,maxHeight:W.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 Wh=200;function tK({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(()=>sa()),[S,T]=k.useState({top:0,left:0}),C=k.useRef(null),j=k.useRef(null),_=k.useCallback(W=>{if(w(sa()),!it.isAuthenticated()){x(!1);return}if(!W?.validate){x(!0);return}s5().then(F=>{x(F),w(sa())})},[]);k.useEffect(()=>{_({validate:!0});const W=()=>_(),F=()=>_({validate:!0});return window.addEventListener("markus:hub-auth",W),window.addEventListener("focus",F),()=>{window.removeEventListener("markus:hub-auth",W),window.removeEventListener("focus",F)}},[_]);const O=k.useCallback(()=>{if(!C.current)return;const W=C.current.getBoundingClientRect(),F=window.innerWidth,Z=window.innerHeight,B=j.current?.offsetHeight??220;let Q=W.right+8;Q+Wh>F-8&&(Q=Math.max(8,W.left-Wh-8));let ae=W.top-B-8;ae<8&&(ae=Math.min(W.bottom+8,Z-B-8)),T({top:Math.max(8,ae),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const W=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(W)},[d,O,o]),k.useEffect(()=>{if(!d)return;const W=Z=>{const B=Z.target;C.current?.contains(B)||j.current?.contains(B)||m(!1)},F=()=>O();return document.addEventListener("mousedown",W),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",W),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=l5(e?.avatarUrl,y?.avatarUrl),X=g?"bg-emerald-500":"bg-fg-muted",ee=g?y?.username?u("sidebar.hubConnectedAs",{username:y.username}):u("sidebar.hubConnected"):u("sidebar.hubDisconnected"),$=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),K=()=>{m(!1),_({validate:!0}),at.navigate(me.SETTINGS,{tab:"account"})},re=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:S.top,left:S.left,width:Wh},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:K,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 ${X}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:ee}),$&&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(W=>!W),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 ${X}`,title:ee})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.0-rc.8"]}),re,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 nK({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 rK({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:YO.map((d,m)=>{const h=XO.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(eK,{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(nK,{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(tK,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const aK=6e4;let Ps={},bi={};const $p=new Set,Fp=new Set;let S3=0,ac=null,wd=0,Id=null;function d0(){for(const e of $p)e()}async function qp(){try{const e=await Ce.unread.getCounts();Ps=e.counts??{},bi=e.sessionAgentMap??{},d0()}catch{}}function sK(){ac||(qp(),ac=setInterval(qp,aK),Id=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!Fp.has(t)&&Date.now()>S3&&(Ps[t]=(Ps[t]??0)+1,d0())}))}function iK(){ac&&(clearInterval(ac),ac=null),Id&&(Id(),Id=null)}function oK(e){const t=e?.enabled??!0,[n,r]=k.useState(Ps),[o,l]=k.useState(bi),u=k.useCallback(async()=>{await qp()},[]),d=k.useCallback(async w=>{const S=new Date().toISOString();delete Ps[w],d0();try{await Ce.unread.markRead(w,S)}catch{}},[]),m=k.useCallback(async()=>{Ps={},d0();try{await Ce.unread.markAllRead()}catch{}},[]),h=k.useCallback(w=>{Fp.add(w)},[]),p=k.useCallback(w=>{Fp.delete(w),S3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;wd++,sK();let w=bi;const S=()=>{r({...Ps}),w!==bi&&(w=bi,l({...bi}))};return $p.add(S),r({...Ps}),l({...bi}),()=>{$p.delete(S),wd--,wd<=0&&(wd=0,iK())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,S)=>w+S,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 BW(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 lK({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:u}=oK({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:QO.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 m0=new Map;function pi(e,t){m0.has(e)||m0.set(e,t().catch(()=>{}))}function wi(e){const t=m0.get(e);return m0.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 N3(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 cK={agent:258,team:205,skill:32,connector:162};function Dg(e,t){const n=cK[e],r=N3(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 p4=["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 C3(e){return p4[N3(e+"g")%p4.length]}function T3(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 uK(e){return!e||T3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function dK(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 g4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const b4={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"}},mK=["development","devops","management","productivity","browser","custom","general"],fK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑💻","👨💼","👩🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑🎨","🧑🏫","👨🚀","🥷","🧑🏭","🧑⚕️","🧑🔧","🧑🍳","👨🎤","🦹","🧝","🧞","🧑✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],hK={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 Yh({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)},S=_=>{_.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:S,className:`${_} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:S,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 pK({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 gK({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 Gp({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(yp,{remarkPlugins:[Nw,Tk],rehypePlugins:[[Zk,{detect:!0,ignoreMissing:!0}]],children:e})})}function Xh({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)},S=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:S}),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(Gp,{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}),S]}),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(Gp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const x4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function bK(e){return[...e].sort(([t],[n])=>{const r=x4[t]??99,o=x4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function f0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>bK(e),[e]),[l,u]=k.useState(0);if(o.length===1)return n?s.jsx(Xh,{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(Xh,{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(Xh,{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 xK({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 yK({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=ft(["builder"]),[u,d]=k.useState(0),m=k.useMemo(()=>{const S=new Set;for(const T of Object.keys(n)){const C=T.match(/^members\/([^/]+)\//);C&&S.add(C[1])}return[...S]},[n]),h=k.useMemo(()=>{const S=new Map,T=new Set;for(let _=0;_<e.length;_++){const O=Vd(e[_].name);m.includes(O)&&!T.has(O)&&(S.set(_,O),T.add(O))}for(let _=0;_<e.length;_++){if(S.has(_))continue;const O=e[_].roleName;if(O){const z=Vd(O);m.includes(z)&&!T.has(z)&&(S.set(_,z),T.add(z))}}for(let _=0;_<e.length;_++){if(S.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()))){S.set(_,z),T.add(z);break}}}const C=m.filter(_=>!T.has(_));let j=0;for(let _=0;_<e.length;_++)S.has(_)||j<C.length&&(S.set(_,C[j]),j++);return S},[e,m,n]),p=k.useCallback((S,T)=>{const C=h.get(T);return C?Object.entries(n).filter(([j])=>j.startsWith(`members/${C}/`)):[]},[n,h]),g=k.useMemo(()=>{const S=[{label:l("detail.overview")}];for(const T of e)S.push({label:T.name,role:T.role});return S},[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((S,T)=>{const C=T===u,j=S.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:(S.label[0]??"?").toUpperCase()}),S.label]},T)})}),s.jsx("div",{className:"p-5",children:u===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(f0,{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((S,T)=>{const C=S.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:(S.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:S.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:S.role}),S.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",S.count]})]}),S.skills&&S.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[S.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)),S.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",S.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(S=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:S},S))}),(()=>{const S=p(x.name,y);return S.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(f0,{noHeader:!0,readOnly:o,files:S.map(([T,C])=>[T.replace(/^members\/[^/]+\//,""),C]),onSave:(T,C)=>{const j=S.find(([_])=>_.endsWith(`/${T}`));j&&r(j[0],C)}})})()]}):null})]});function w(S,T){r(S,T)}}function Ei({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,S]=k.useState({}),[T,C]=k.useState(null),[j,_]=k.useState(""),[O,z]=k.useState("idle"),[D,H]=k.useState({shared:!1}),[X,ee]=k.useState(!1),[$,K]=k.useState(!1),[re,W]=k.useState(!1),[F,Z]=k.useState(!1),[B,Q]=k.useState(!1),[ae,ke]=k.useState(!1),[U,G]=k.useState(null),[le,I]=k.useState(""),[Ae,Ue]=k.useState(""),[Oe,We]=k.useState(""),[st,dt]=k.useState(""),[At,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||""),S(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,"",Ni(me.BUILDER,`${e}/${encodeURIComponent(ve)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const Ye=await Ce.builder.artifacts.get(e,ve);S(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&&S(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,K(!0)):he==="description"?(Ue(ve),Ye.description=ve,K(!0)):he==="version"?(We(ve),Ye.version=ve,K(!1),W(!1)):he==="category"?(dt(ve),Ye.category=ve,K(!0)):he==="tags"?(gt(ve),Ye.tags=ve,K(!0)):he==="icon"&&(Jt(ve),Ye.icon=ve||void 0,K(!0)),ot({...T,...Ye})},[T,ot]),se=k.useCallback(async(he,ve)=>{try{const Ye={...w,[he]:ve};S(Ye);const nt={...T,files:Ye};await Ce.builder.artifacts.save(e,nt),z("saved"),K(!0),setTimeout(()=>z(xt=>xt==="saved"?"idle":xt),2e3)}catch{z("error")}},[w,e,T]),ze=k.useCallback(async he=>{if(T){ee(!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,"",Ni(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 He=[],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&&(He.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:He.length>0?He: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}),K(!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{ee(!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(),K(!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(),K(!0)}catch(ve){console.error("Image remove failed:",ve)}},et=b4[e]??b4.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=>{Kd()&&(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:X,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:X?m("share.updating"):m("share.updateVersion",{version:Ye})})]})})(),!o&&!D.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:X,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(X?"share.sharing":"share.toHub")})]})]}),!o&&$&&!re&&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:()=>W(!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&&re&&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:()=>W(!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(!ae),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:C3(le||t||e),fill:Ye})})})()}),!o&&ae&&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)}K(!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:fK.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(Yh,{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(Yh,{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(Yh,{value:Ae,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(pK,{value:st,options:mK,onChange:he=>mt("category",he),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(gK,{tags:At,onChange:he=>mt("tags",he),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(xK,{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(yK,{members:T.team.members,teamTopFiles:ye,files:w,onFileSave:se,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(f0,{noHeader:!0,files:V,onSave:se,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=hK[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(Gp,{content:pe})})]})]}),Qe.length>0&&s.jsx(f0,{files:Qe,onSave:se,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(wK,{onClose:()=>Z(!1),onConfirm:(he,ve)=>{Z(!1),ze({donationsEnabled:!1,priceCents:he==="paid"?ve:void 0})},isUpdate:D.shared}),!o&&B&&s.jsx(vK,{onClose:()=>Q(!1),onConfirm:(he,ve,Ye,nt)=>{Q(!1),ze({visibility:he,orgId:ve,priceCents:Ye,donationsEnabled:nt})}}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.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 vK({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 S=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))})]}),S&&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:A3.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")})]})]}),S&&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,S&&g>0?g:void 0,S?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 A3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function wK({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:A3.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 h0(e,t){return!e||!T3(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function kK({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:u="rounded-xl"}){const d=Ko(e),m=h0(n,r),h=k.useMemo(()=>Dg(d,t),[d,t]),p=k.useMemo(()=>C3(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}`}):uK(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&&AV(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 p0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:u}){const d=t||e||"markus",m=h0(n,r),[h,p]=k.useState(!1),g=m&&!h?m:dK(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 SK({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 y4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",className:n<t?"text-amber-400":"text-fg-muted/40",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z"})},n))})}function ia(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:u,hubBase:d,author:m,authorLabel:h,version:p,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:S=0,priceCents:T,currency:C="usd",installed:j,glowing:_,selected:O,showTypeBadge:z=!0,hideStats:D=!1,cornerLabel:H,actions:X,footerLeft:ee,headerAction:$,onClick:K,className:re=""}=e,W=Ko(t),F=Ti[W],Z=o||n,B=(T??0)>0,Q=!!h0(u||void 0,d),ae=Dg(W,Z),ke=h??m?.displayName??m?.username??"",[U,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:g4(T,C)}):null;if(Q){const I=h0(u||void 0,d);return s.jsxs("div",{onClick:K,style:{aspectRatio:U??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${K?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${re}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Ae=>{const Ue=Ae.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(SK,{type:W})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ae=>Ae.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}):$?null:s.jsx("span",{className:B?"badge-paid":"badge-free",children:g4(T,C)}),$]})]}),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(p0,{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(Ae=>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:Ae},Ae))]}),(!D||X)&&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(y4,{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(S)]})]}),X&&s.jsx("div",{className:"flex items-center gap-2",onClick:Ae=>Ae.stopPropagation(),children:X})]})]})]})}return s.jsxs("div",{onClick:K,className:`group asset-card card-shine relative flex flex-col ${K?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${re}`,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:ae}}),$&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:$}),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(kK,{type:W,seed:Z,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 ${$?"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(p0,{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=ee??(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(y4,{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(S)]})]}));return!I&&!X?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:Ae=>Ae.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),X&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:X})]})})()]})]})}function Ar({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 NK(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const CK=[{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 TK(){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 E3="markus_builder_shared_map";function AK(){try{const e=localStorage.getItem(E3);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(E3,JSON.stringify(Object.fromEntries(e)))}catch{}}function _3({authUser:e}={}){const{t}=ft(["builder","common"]),n=Bo(),r=TK(),[o,l]=k.useState([]),[u,d]=k.useState([]),[m,h]=k.useState(!1),[p,g]=k.useState("all"),[x,y]=k.useState(null),[w,S]=k.useState(new Map),[T,C]=k.useState(null),[j,_]=k.useState(null),[O,z]=k.useState(null),[D,H]=k.useState(AK),[X,ee]=k.useState(null),[$,K]=k.useState(null),[re,W]=k.useState(null),[F,Z]=k.useState(null),[B,Q]=k.useState(null),[ae,ke]=k.useState("creations"),[U,G]=k.useState([]),[le,I]=k.useState(""),[Ae,Ue]=k.useState([]),[Oe,We]=k.useState(!1),[st,dt]=k.useState("all"),At=k.useCallback(()=>{h(!0),Promise.all([(wi(Tr.builderArtifacts)??Ce.builder.artifacts.list()).then(se=>se?.artifacts??[]).catch(()=>[]),(wi(Tr.builderAgents)??Ce.agents.list()).then(se=>se?.agents??[]).catch(()=>[]),(wi(Tr.builderHubMyItems)??it.myItems()).then(se=>se?.items??[]).catch(()=>[]),(wi(Tr.builderInstalled)??Ce.builder.artifacts.installed()).then(se=>se?.installed??{}).catch(()=>({}))]).then(([se,ze,Xe,Ve])=>{if(d(se),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 se)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 se){const pe=`${yt.type}/${yt.name}`,V=Ve[pe];V&&et.set(pe,{agentId:V.agentId,agentIds:V.agentIds,teamId:V.teamId})}S(et)}).finally(()=>h(!1))},[]);k.useEffect(()=>{At();const se=ze=>{ze.detail?.page===me.BUILDER&&At()};return window.addEventListener("markus:navigate",se),()=>window.removeEventListener("markus:navigate",se)},[At]);const gt=se=>{const ze=o.find(Xe=>Xe.role==="Secretary"||Xe.name==="Secretary");ze?at.navigate(me.TEAM,{agentId:ze.id,prefillMessage:se}):at.navigate(me.TEAM,{prefillMessage:se})},jt=async se=>{const ze=`${se.type}/${se.name}`;if(!w.has(ze)){y({key:ze,action:"install"});try{const Xe=await Ce.builder.artifacts.install(se.type,se.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)),S(et=>new Map(et).set(ze,Ve)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Install failed:",Xe),K({title:t("common:install"),message:t("installFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Jt=async se=>{const ze=`${se.type}/${se.name}`;if(w.has(ze)){y({key:ze,action:"uninstall"});try{await Ce.builder.artifacts.uninstall(se.type,se.name),S(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),K({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Rt=async(se,ze)=>{const Xe=`${se.type}/${se.name}`;y({key:Xe,action:"share"});try{const Ve=await Ce.builder.artifacts.ensureSlugSafe(se.type,se.name,se.meta.displayName||se.meta.name||se.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=`${se.type}/${et}`;Ve.converted&&(d(oe=>oe.map(_e=>_e.type===se.type&&_e.name===se.name?{..._e,name:et,path:Ve.path,meta:{..._e.meta,name:et,displayName:Ve.displayName??_e.meta.displayName??se.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}),S(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(se.type,et);let ye={...se.meta,name:et,displayName:Ve.displayName??se.meta.displayName??se.name};try{const oe=V.files?.[`${se.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/${se.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(oe)}`);if(_e.ok){const de=await _e.blob(),He=new File([de],oe,{type:de.type}),qe=await it.uploadImage(He);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 He=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(de)}`);if(He.ok){const qe=await He.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:se.type==="team"?"team":se.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)?K({title:t("common:share"),message:Ve.converted?t("share.convertedAndSubmitted",{previous:se.name,slug:yt}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):Ve.converted&&K({title:t("common:share"),message:t("share.convertedSlug",{previous:se.name,slug:yt}),variant:"primary"}))}catch(Ve){console.error("Share failed:",Ve),K({title:t("common:share"),message:t("shareFailed",{error:Ve instanceof Error?Ve.message:String(Ve)}),variant:"danger"})}finally{y(null)}},be=async()=>{if(!X)return;const{key:se}=X,ze=D.get(se);if(ee(null),!ze)return;const Xe=ze.id;y({key:se,action:"hubDelete"});try{await it.deleteItem(Xe),H(Ve=>{const et=new Map(Ve);return et.delete(se),kd(et),et})}catch(Ve){console.error("Hub delete failed:",Ve),K({title:t("unshare"),message:t("hubDeleteFailed",{error:String(Ve)}),variant:"danger"})}finally{y(null)}},Me=async()=>{if(!T)return;const se=T,ze=`${se.type}/${se.name}`;C(null),y({key:ze,action:"delete"});try{await Ce.builder.artifacts.delete(se.type,se.name),d(Xe=>Xe.filter(Ve=>!(Ve.type===se.type&&Ve.name===se.name))),S(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(se=>se.type===p);k.useEffect(()=>{ae!=="orgAssets"||U.length>0||it.myOrgs().then(se=>{G(se.memberships),se.memberships.length>0&&!le&&I(se.memberships[0].id)}).catch(()=>{})},[ae,U.length,le]),k.useEffect(()=>{ae!=="orgAssets"||!le||(We(!0),it.browseItems({orgId:le,limit:100}).then(se=>Ue(se.items??[])).catch(()=>Ue([])).finally(()=>We(!1)))},[ae,le]);const ot=st==="all"?Ae:Ae.filter(se=>se.itemType===st),mt=se=>{history.pushState(null,"",Ni(me.BUILDER,`${se.type}/${encodeURIComponent(se.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Ei,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Ni(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:At,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:CK.map(se=>{const ze=t(`prompts.${se.id}Prompt`),Xe=t(`prompts.${se.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 ${se.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 ${se.bgColor} flex items-center justify-center shrink-0`,children:se.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${se.color} bg-clip-text text-transparent`,children:t(`prompts.${se.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${se.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))})]})]})},se.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 ${ae==="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 ${ae==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),ae==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>g(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${p===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))}),ae==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>dt(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${st===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))})]})}),ae==="orgAssets"&&U.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:U.map(se=>s.jsx("button",{onClick:()=>I(se.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${le===se.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:se.name},se.id))}),ae==="orgAssets"&&(U.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(Ar,{children:ot.map(se=>{const ze=se.author?.username&&se.slug?`${it.getUrl()}/@${encodeURIComponent(se.author.username)}/${encodeURIComponent(se.slug)}`:null;return s.jsx(ia,{type:se.itemType,name:se.name,description:se.description,seed:se.slug||se.id||se.name,icon:se.icon,cover:se.thumbnailUrl,hubBase:it.getUrl(),author:se.author,version:se.version,rating:parseFloat(se.avgRating)||0,ratingCount:se.ratingCount,downloadCount:se.downloadCount,actions:ze?s.jsxs("a",{href:ze,target:"_blank",rel:"noopener noreferrer",onClick:Xe=>{Xe.stopPropagation(),Kd()&&(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},se.id)})})),ae==="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(Ar,{children:Ge.map(se=>{const ze=se.meta.displayName||se.meta.name||se.name,Xe=se.meta.description||"",Ve=`${se.type}/${se.name}`,et=x?.key===Ve?x.action:null,yt=D.get(Ve),pe=se.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(se),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:()=>_(se),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(se,{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();Kd()&&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:()=>ee({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(se.meta.screenshots)&&se.meta.screenshots.length>0?Q(se):W(se)},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(se),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=se.meta.icon,Dt=!!nt&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)?nt.startsWith("http")||nt.startsWith("/")?nt:`/api/builder/artifacts/${se.type}s/${encodeURIComponent(se.name)}/images/${encodeURIComponent(nt.split("/").pop()??"")}`:nt;return s.jsx(ia,{type:se.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(se.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:se.path,children:NK(se.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(se.updatedAt).toLocaleDateString()})]}),headerAction:Ye,actions:ve,onClick:()=>mt(se)},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 se=j;_(null),jt(se)},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 se=O;z(null),Jt(se)},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)}),X&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:X.name}),confirmLabel:t("unshare"),onConfirm:()=>{be()},onCancel:()=>ee(null)}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>K(null),onCancel:()=>K(null)}),re&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>W(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:se=>se.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 se=re;W(null),Q(se)},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 se=re;W(null),mt(se)},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:()=>Z(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:se=>se.stopPropagation(),children:s.jsx(_K,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>Z(null),onConfirm:(se,ze)=>{const Xe=F;Z(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:se=>se.stopPropagation(),children:s.jsx(EK,{onCancel:()=>Q(null),onConfirm:(se,ze,Xe,Ve)=>{const et=B;Q(null),Rt(et,{visibility:se,orgId:ze,priceCents:Xe,donationsEnabled:Ve})}})})})]})})}function EK({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 S=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))})]}),S&&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:j3.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")})]})]}),S&&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,S&&g>0?g:void 0,S?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 j3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function _K({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:j3.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 jK=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:_3},Symbol.toStringTag,{value:"Module"}));async function M3(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 MK(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 g0(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}const RK={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function OK({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,S]=k.useState({}),[T,C]=k.useState(!1),[j,_]=k.useState(!0),[O,z]=k.useState(new Map),[D,H]=k.useState(new Set),[X,ee]=k.useState(null),[$,K]=k.useState(null),re=k.useCallback(async()=>{try{const[Z,B]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const ae of Z.artifacts){if(ae.type!=="agent")continue;const ke=!!B.installed[`agent/${ae.name}`];Q.set(ae.name,{installed:ke,localVersion:ae.meta.version||void 0,localUpdatedAt:ae.updatedAt})}z(Q)}catch{}},[]),W=k.useCallback(async()=>{_(!0);try{const Z=u?it.search({type:"agent",q:u,limit:50}):wi(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:[]})),[ae,ke]=await Promise.all([Z.catch(()=>({items:[],total:0})),Q,re(),it.isAuthenticated()?it.purchases.mine().then(G=>H(new Set(G.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),U=await M3(ae?.items??[],t);g(U.items),h(Array.isArray(ke.templates)?ke.templates:[]),U.missing&&n?.()}catch{h([]),g([])}finally{_(!1)}},[u,re,t,n]);k.useEffect(()=>{W()},[W]),k.useEffect(()=>{if(!x){S({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(Z=>Z.json()).then(Z=>S(Z.files??{})).catch(()=>S({}))},[x]);const F=async(Z,B,Q)=>{try{const ae=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:Z,name:B,orgId:"default",teamId:Q})});if(!ae.ok)throw new Error(`Failed: ${ae.status}`);C(!1),y(null)}catch(ae){K({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${ae}`,variant:"danger"})}};if(X)return s.jsx(Ei,{type:X.type,name:X.name,onBack:()=>ee(null)});if(x){const Z={type:"agent",name:x.id,displayName:g0(x,l),version:x.version,description:v4(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 ${RK[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,ae)=>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})]})]},ae))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ei,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:Z,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(w4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"danger",title:$.title,message:$.message,onConfirm:()=>K(null),onCancel:()=>K(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:Z=>d(Z.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((Z,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(Ar,{columns:3,children:m.map(Z=>s.jsx(ia,{type:"agent",name:g0(Z,l),description:v4(Z,l),seed:Z.id,icon:Z.icon,version:Z.version,category:Z.category,tags:Z.tags,authorLabel:Z.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>y(Z)},Z.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Ar,{columns:3,children:p.map(Z=>s.jsx(DK,{item:Z,localInfo:O.get(Cc(Z)),purchased:Fd(Z,D),onStatusChange:re,highlight:Z.id===t,onHighlightDone:n,onViewDetail:B=>ee({type:"agent",name:B})},Z.id))})]})]})}),T&&x&&s.jsx(w4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"danger",title:$.title,message:$.message,onConfirm:()=>K(null),onCancel:()=>K(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 Vd(n||e.name,"hub-pkg")}function ki(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 Lg(e,t){t("checking"),await it.ensureAuth();const n=await it.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await ki(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 ki(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 ki(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 ki(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function DK({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 X=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(X)}},[o,l]);const S=t?.installed??!1,T=S&&e.version&&t?.localVersion&&MK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=async X=>{if(X.stopPropagation(),!m){h(!0),g("");try{await ki(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(ee){const $=ee instanceof Error?ee.message:"";$.includes("402")||$.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},_=async X=>{if(X.stopPropagation(),!m){h(!0),g("");try{await Lg(e,$=>{$==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(ee){g(ee instanceof Error?ee.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=()=>{S&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:X=>{j(X)},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})}):S?s.jsxs("button",{onClick:X=>{j(X)},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:X=>{_(X)},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:X=>{j(X)},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(ia,{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:S,glowing:y,onClick:D,actions:H})})}function w4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,u]=k.useState(`${g0(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:g0(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 Qh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function k4(e,t){return e.i18n?.[t]?.description||e.description}function S4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function LK(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 IK({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({}),[S,T]=k.useState(!0),[C,j]=k.useState(!1),[_,O]=k.useState(null),[z,D]=k.useState(new Map),[H,X]=k.useState(new Set),[ee,$]=k.useState(null),K=k.useCallback(async()=>{try{const[F,Z]=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 ae=!!Z.installed[`team/${Q.name}`];B.set(Q.name,{installed:ae,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(B)}catch{}},[]),re=k.useCallback(async()=>{T(!0);try{const F=l?it.search({type:"team",q:l,limit:50}):wi(Tr.hubTeams)??it.search({type:"team",limit:50}),[Z,B]=await Promise.all([F.catch(()=>({items:[],total:0})),Ce.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),K(),it.isAuthenticated()?it.purchases.mine().then(ae=>X(new Set(ae.purchases.map(ke=>ke.itemId)))).catch(()=>{}):Promise.resolve()]),Q=await M3(Z?.items??[],e);p(Q.items),m(B?.templates??[]),Q.missing&&t?.()}catch{m([]),p([])}finally{T(!1)}},[l,K,e,t]);k.useEffect(()=>{re()},[re]),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 W=async F=>{j(!0),O(null);try{const B=(await Ce.teams.create(F.name,F.description)).team.id;let Q,ae=0;const ke=[];for(const G of F.members){const le=G.count??1;for(let I=0;I<le;I++){const Ae=G.name??`${F.name} Agent ${I+1}`,Ue=le>1?`${Ae} ${I+1}`:Ae,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){ae++;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 U=ke.length>0?` (${ke.length} failed: ${ke[0]})`:"";O({ok:ae>0,message:`Team "${Qh(F,o)}" deployed with ${ae} agent(s)${U}`})}catch(Z){O({ok:!1,message:`Failed: ${Z}`})}finally{j(!1)}};if(ee)return s.jsx(Ei,{type:ee.type,name:ee.name,onBack:()=>$(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const Z={type:"team",name:g.id,displayName:Qh(g,o),version:g.version,description:k4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(Q=>({name:S4(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,ae)=>{const ke=S4(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(U=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:U},U)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},ae)})})]});return s.jsx(s.Fragment,{children:s.jsx(Ei,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:Z,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:()=>{W(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:S?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,Z)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Z))}):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(Ar,{columns:2,children:d.map(F=>s.jsx(ia,{type:"team",name:Qh(F,o),description:k4(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(Ar,{columns:2,children:h.map(F=>s.jsx(PK,{item:F,localInfo:z.get(Cc(F)),purchased:Fd(F,H),onStatusChange:K,highlight:F.id===e,onHighlightDone:t,onViewDetail:Z=>$({type:"team",name:Z})},F.id))})]})]})})]})}function PK({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 X=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(X)}},[o,l]);const S=t?.installed??!1,T=S&&e.version&&t?.localVersion&&LK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async X=>{if(X.stopPropagation(),!m){h(!0),g("");try{await ki(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(ee){const $=ee instanceof Error?ee.message:"";$.includes("402")||$.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},O=async X=>{if(X.stopPropagation(),!m){h(!0),g("");try{await Lg(e,$=>{$==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(ee){g(ee instanceof Error?ee.message:d("card.failed"))}finally{h(!1)}}},z=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{S&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:X=>{_(X)},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})}):S?s.jsxs("button",{onClick:X=>{_(X)},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:X=>{O(X)},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:X=>{_(X)},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(ia,{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:S,glowing:y,onClick:D,actions:H})})}function Zh(e,t){return e.i18n?.[t]?.displayName||e.name}function Jh(e,t){return e.i18n?.[t]?.description||e.description||""}function R3(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 zK={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 BK({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&&R3(e.version,h.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),S=async()=>{if(!u){d(!0),w("");try{await ki(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 Lg(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:()=>{S()},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:()=>{S()},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 N4({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(ia,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Ld(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(BK,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function UK({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,S]=k.useState(null),[T,C]=k.useState([]),[j,_]=k.useState(0),[O,z]=k.useState(1),[D,H]=k.useState([]),[X,ee]=k.useState(""),[$,K]=k.useState("score"),[re,W]=k.useState(""),[F,Z]=k.useState(!1),[B,Q]=k.useState([]),[ae,ke]=k.useState(!1),[U,G]=k.useState([]),[le,I]=k.useState(""),[Ae,Ue]=k.useState(!1),[Oe,We]=k.useState([]),[st,dt]=k.useState([]),[At,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)},[]),se=k.useCallback(async V=>{Z(!0);try{const ye=await Ce.skills.registrySkillhub({q:V?.q,category:V?.category,page:V?.page??1,limit:24,sort:V?.sort??$});C(ye.skills),_(ye.total),ye.categories?.length&&H(ye.categories)}catch{}Z(!1)},[$]),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}):wi(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(),se(),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=U.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:Zh(V,o),version:V.version,description:Jh(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&&R3(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 ${zK[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(Ei,{type:"skill",name:V.name,onBack:()=>S(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=>Zh(ve,o).toLowerCase().includes(V)||Jh(ve,o).toLowerCase().includes(V)):B,Qe=ae&&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(Ar,{columns:3,children:ye.map(ve=>s.jsx(ia,{type:"skill",name:Zh(ve,o),description:Jh(ve,o),seed:ve.name,icon:Ld(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:()=>S(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(Ar,{columns:3,children:Oe.map(ve=>s.jsx(N4,{item:ve,installedSkills:x,purchased:Fd(ve,At),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(Ar,{columns:3,children:st.map(ve=>s.jsx(N4,{item:ve,type:"connector",installedSkills:x,purchased:Fd(ve,At),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:X,onChange:V=>{ee(V.target.value),z(1),se({q:re||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:$,onChange:V=>{K(V.target.value),z(1),se({q:re||void 0,category:X||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:re,onChange:V=>W(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(z(1),se({q:re||void 0,category:X||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),se({q:re||void 0,category:X||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(Ar,{columns:3,children:T.map(V=>{const ye=x.some(Qe=>Qe.name===V.name||Qe.name===V.slug);return s.jsx(ia,{type:"skill",name:V.name,description:V.description_zh??V.description??"",seed:V.slug,icon:Ld(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),se({q:re||void 0,category:X||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),se({q:re||void 0,category:X||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")})})]}),Ae?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(Ar,{columns:3,children:pe.map(V=>{const ye=x.some(Qe=>Qe.name===V.name);return s.jsx(ia,{type:"skill",name:V.name,description:V.description||"",seed:`${V.author}-${V.name}`,icon:Ld(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 HK=["agent","team","skill","connector"];function ep({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 $K({item:e,onOpen:t}){const n=Ko(e.subtype==="connector"?"connector":e.itemType),r=Dg(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(p0,{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 C4({items:e,onOpen:t}){return s.jsx(Ar,{columns:3,children:e.map(n=>s.jsx(ia,{type:n.subtype==="connector"?"connector":n.itemType,name:n.name,description:n.description,seed:n.slug||n.name,icon:n.icon,cover:n.thumbnailUrl,hubBase: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 T4(){return s.jsx(Ar,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function FK({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:HK.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($K,{item:g,onOpen:()=>p(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(ep,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(T4,{}):d.length>0?s.jsx(C4,{items:d,onOpen:p}):s.jsx(qK,{})]}),s.jsxs("section",{children:[s.jsx(ep,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(T4,{}):m.length>0?s.jsx(C4,{items:m,onOpen:p}):null]}),h.length>0&&s.jsxs("section",{children:[s.jsx(ep,{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(p0,{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 qK(){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 GK(){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,S]=k.useState(""),[T,C]=k.useState("all"),[j,_]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[H,X,ee,$]=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:[]}))]),K={};for(const F of ee.updates)K[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(K);const re=H.artifacts.filter(F=>{const Z=`${F.type}/${F.name}`;return!!X.installed[Z]}),W=new Set(re.filter(F=>F.type==="skill").map(F=>F.name));for(const F of $.skills)!F.installed||W.has(F.name)||!(X.installed[`skill/${F.name}`]||K[F.name])&&!F.updateAvailable||!X.installed[`skill/${F.name}`]&&!K[F.name]||(re.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:""}),W.add(F.name));for(const[F,Z]of Object.entries(K))W.has(F)||(re.push({type:"skill",name:F,meta:{displayName:Z.displayName||F,description:Z.description||"",version:Z.installedVersion},path:"",updatedAt:""}),W.add(F));l(re)}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,X)=>{if(!m.has(H)){h(ee=>new Set(ee).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:X}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:H}),type:"error"})}h(ee=>{const $=new Set(ee);return $.delete(H),$})}},D=o.filter(H=>{if(T!=="all"&&H.type!==T)return!1;if(!w)return!0;const X=w.toLowerCase(),ee=(Sd(H.meta,"displayName",r)||H.meta.displayName||H.name).toLowerCase(),$=(Sd(H.meta,"description",r)||H.meta.description||"").toLowerCase();return ee.includes(X)||$.includes(X)}).sort((H,X)=>{const ee=H.type==="skill"&&u[H.name]?1:0;return(X.type==="skill"&&u[X.name]?1:0)-ee});return j?s.jsx(Ei,{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=>S(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(Ar,{columns:3,children:D.map(H=>{const X=Sd(H.meta,"displayName",r)||H.meta.displayName||H.name,ee=Sd(H.meta,"description",r)||H.meta.description||"",$=H.meta.version||"",K=H.meta.author||"",re=H.meta.tags??[],W=H.meta.category||"",F=H.meta.icon,Z=H.type==="skill"?u[H.name]:void 0;return s.jsx(ia,{type:H.type,name:X,description:ee,seed:H.name,icon:F,author:null,authorLabel:K||void 0,version:Z?Z.installedVersion:$,category:W,tags:re,installed:!Z,hideStats:!0,cornerLabel:Z?e("installedTab.updateAvailable"):void 0,onClick:()=>{H.path&&_({type:H.type,name:H.name})},actions:Z?s.jsx("button",{type:"button",disabled:m.has(H.name),onClick:()=>{z(H.name,Z.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:Z.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 VK=50,KK=30;function WK(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<VK||Math.atan2(x,g)*(180/Math.PI)>KK)return;if(r?.scrollContainerRef?.current){const S=r.scrollContainerRef.current,T=S.scrollLeft<=1,C=S.scrollLeft+S.clientWidth>=S.scrollWidth-1;if(h>0&&!T||h<0&&!C)return}const w=e.findIndex(S=>S.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 YK=["builder","discover","agents","teams","skills","installed"],XK={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Vp(e){return!!e&&YK.includes(e)}function A4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Vp(t)?t:"builder",installId:e}}function QK({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(A4),[o,l]=k.useState(r.tab),[u,d]=k.useState(r.installId),m=WK(n,o,l);k.useEffect(()=>{const p=A4();p.installId&&(d(p.installId),Vp(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");Vp(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(XK[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(d5,{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(_3,{authUser:e}),o==="discover"&&s.jsx(FK,{onOpenType:h}),o==="agents"&&s.jsx(OK,{authUser:e,highlightItemId:u,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(IK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(UK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(GK,{})]})]})}const E4="usageType",tp="profile";function ZK({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,S]=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&&K(Ge=>Ge||l("usageType.defaultOrgName",{name:Me}))}).catch(()=>{}),Ce.settings.getOrg().then(({org:be})=>{be?.name&&be.name!=="My Organization"&&K(be.name)}).catch(()=>{}),yn()&&Ce.hubOrgs.invitations().then(be=>{be.invitations?.length>0&&ke(be.invitations)}).catch(()=>{})},[]);const[X,ee]=k.useState(null),[$,K]=k.useState(""),[re,W]=k.useState(!1),[F,Z]=k.useState(!1),[B,Q]=k.useState(""),[ae,ke]=k.useState([]),[U,G]=k.useState(null),[le,I]=k.useState(null),Ae=async()=>{const be=$.trim();if(be){W(!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)}Z(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{W(!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(I7,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:E4,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:()=>{ee("personal"),Z(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${X==="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:()=>{ee("organization"),Z(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${X==="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."})})]})]})]}),X==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[ae.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")}),ae.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),Z(!0)}catch{}finally{G(null)}},disabled:U===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"):U===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:$,onChange:be=>{K(be.target.value),Z(!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:()=>{Ae()},disabled:re||!$.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(re?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:tp,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(u5,{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=>S(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")})]})]})}],At=r?dt.filter(be=>be.id!==tp):dt,gt=At.findIndex(be=>be.id===E4),jt=At.findIndex(be=>be.id===tp),Jt=()=>{u===gt&>>=0&&!X||u===gt&&X==="organization"&&!F||u===jt&&jt>=0&&!O||(u<At.length-1?d(u+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})}).catch(()=>{}),e()))},Rt=At[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:At.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&&(!X||X==="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&&(!X||X==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:u===At.length-1?l("getStarted"):l("common:next")})]})]})})})}const _4="markus:legal-consent",JK="https://markus.global";function eW({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,S]=k.useState(!1),[T,C]=k.useState(!1),j=K=>{const re=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${JK}${K}${re}`},_=()=>{try{localStorage.setItem(_4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(_(),!0):(S(!1),requestAnimationFrame(()=>S(!0)),!1),z=async()=>{const K=yn(),re=sa();if(!K||!re){d(n("login.hubUnavailable"));return}const W=await Ce.auth.hubLogin(K,re);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),W.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",W.cloudAiError?n("login.cloudAiNotReady",{error:W.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(W.user,W.needsOnboarding??!1,{fromHub:!0})},D=async(K,re=!1)=>{if(!(!re&&!O())){d(""),l(K??"hub");try{if(re&&yn()&&sa()){await z();return}await na(K),await z()}catch(W){const F=W instanceof Error?W.message:"";if(!F.includes("cancelled")){if(!re&&yn())return D(K,!0);d(F||n("login.hubUnavailable"))}}finally{l(null)}}},H=()=>{iD(),l(null),d("")};k.useEffect(()=>{const K=window.markusDesktop;if(!K?.peekPendingDeepLinkAuth&&!K?.consumePendingDeepLinkAuth)return;let re=!1;return(async()=>{const W=K.peekPendingDeepLinkAuth?await K.peekPendingDeepLinkAuth():null;if(re||!W)return;let F=!1;try{F=!!localStorage.getItem(_4)}catch{}if(!T&&!F){d(n("login.consentRequired"));return}F&&!T&&C(!0),_();const Z=K.consumePendingDeepLinkAuth?await K.consumePendingDeepLinkAuth():W;if(!(re||!Z)){d(""),l("hub");try{if(!await sD(Z)||!yn()||!sa()){d(n("login.hubUnavailable"));return}await z()}catch{d(n("login.hubUnavailable"))}finally{re||l(null)}}})().catch(()=>{}),()=>{re=!0}},[T]);const X=async K=>{if(K.preventDefault(),!(!p.trim()||!x)&&O()){d(""),l("local");try{const{user:re,needsOnboarding:W}=await Ce.auth.login(p.trim(),x);e(re,W??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},ee=n(t?"login.welcomeBack":"login.getStarted"),$="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return 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:ee})]}),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:X,className:"space-y-3",children:[s.jsx("input",{type:"email",value:p,onChange:K=>g(K.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:K=>y(K.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:()=>D("google"),disabled:!!o,className:$,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:()=>D("github"),disabled:!!o,className:$,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:()=>D("email"),disabled:!!o,className:$,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(o==="email"?"login.connectingHub":"login.withEmail")]}),o&&(o==="google"||o==="github"||o==="email"||o==="hub")&&s.jsxs("div",{className:"px-3 py-2.5 bg-brand-500/10 border border-brand-500/30 rounded-lg text-xs text-fg-secondary space-y-2",children:[s.jsx("p",{children:n("login.browserOpened")}),s.jsx("button",{type:"button",onClick:H,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),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:()=>S(!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:K=>{C(K.target.checked),K.target.checked&&S(!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 tW({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),[S,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:S?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 nW({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 rW({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[u,d]=k.useState(()=>{try{const S=localStorage.getItem(`${l}_w`);if(S)return Math.max(n,Math.min(r,parseInt(S,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(S=>Math.max(n,Math.min(r,S)))},[n,r]);const y=k.useCallback(S=>{S.preventDefault(),p.current=!0;const T=S.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(S=>!S),[]);return{width:m?o:u,rawWidth:u,collapsed:m,toggle:w,setCollapsed:h,setWidth:d,onResizeStart:y}}const UW=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Kp="markus-theme";function j4(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 aW(){try{const e=localStorage.getItem(Kp);if(e==="midnight")return localStorage.setItem(Kp,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function sW(){const[e,t]=k.useState(aW),n=k.useCallback(r=>{t(r);try{localStorage.setItem(Kp,r)}catch{}j4(r)},[]);return k.useEffect(()=>{j4(e)},[e]),{mode:e,setMode:n}}const Pd={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},iW={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},oW=["agents","tasks","requirements","projects","deliverables","workflows"];let M4="",R4="all",O4=Pd,D4=!1;function lW({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);zo(!0);const[r,o]=k.useState(M4),[l,u]=k.useState(R4),[d,m]=k.useState(O4),[h,p]=k.useState(!1),[g,x]=k.useState(D4),[y,w]=k.useState(-1);k.useEffect(()=>{M4=r},[r]),k.useEffect(()=>{R4=l},[l]),k.useEffect(()=>{O4=d},[d]),k.useEffect(()=>{D4=g},[g]);const S=k.useRef(null),T=k.useRef(void 0),C=k.useRef(null),j=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{S.current?.focus(),S.current?.select()},100)},[]);const _=k.useCallback(async W=>{if(!W.trim()){m(Pd),x(!1),w(-1);return}p(!0),x(!0),w(-1);const F=W.toLowerCase();try{const[Z,B,Q,ae,ke,U]=await Promise.allSettled([Ce.agents.list(),Ce.tasks.list({search:W,pageSize:20}),Ce.requirements.list(),Ce.projects.list(),Ce.deliverables.search({q:W,limit:20}),Ce.teams.list()]),G=Z.status==="fulfilled"?Z.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)):[],Ae=ae.status==="fulfilled"?ae.value.projects.filter(We=>We.name?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],Ue=ke.status==="fulfilled"?ke.value.results:[],Oe=[];if(U.status==="fulfilled"){const We=await Promise.allSettled(U.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:Ae,deliverables:Ue,workflows:Oe})}catch{m(Pd)}finally{p(!1)}},[]),O=W=>{o(W),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>_(W),400)},z=k.useCallback((W,F)=>{e(),at.navigate(W,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(()=>iW[t||""]||oW,[t]),X=k.useMemo(()=>{const W=[],F=l==="all"?8:void 0,Z=B=>{if(l!=="all"&&l!==B)return;const Q=d[B].length;if(B==="workflows"){const ae=F?d.workflows.slice(0,F):d.workflows;for(const ke of ae)W.push({id:ke.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const ae=d[B],ke=F?ae.slice(0,F):ae;for(const U of ke)switch(B){case"agents":W.push({id:U.id,type:"agent",page:me.TEAM,params:{agentId:U.id}});break;case"tasks":W.push({id:U.id,type:"task",page:me.WORK,params:{openTask:U.id}});break;case"requirements":W.push({id:U.id,type:"requirement",page:me.WORK,params:{openRequirement:U.id}});break;case"projects":W.push({id:U.id,type:"project",page:me.WORK,params:{projectId:U.id}});break;case"deliverables":W.push({id:U.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:U.id}});break}}F&&Q>F&&W.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:Q})};for(const B of H)Z(B);return W},[d,l,H]),ee=k.useCallback(W=>{if(W.type==="showMore"&&W.expandCategory){u(W.expandCategory),w(-1);return}z(W.page,W.params)},[z]);k.useEffect(()=>{const W=j.current;if(!W||y<0)return;const F=W.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const $=k.useCallback(W=>{if(W.key==="Escape"){e();return}if(W.key==="Tab"){W.preventDefault();const B=D.map(ke=>ke.id),Q=B.indexOf(l),ae=W.shiftKey?Q<=0?B.length-1:Q-1:Q>=B.length-1?0:Q+1;u(B[ae]),w(-1);return}const F=W.ctrlKey&&W.key==="n"||W.key==="ArrowDown",Z=W.ctrlKey&&W.key==="p"||W.key==="ArrowUp";if(F||Z){W.preventDefault(),w(B=>{const Q=X.length-1;return Q<0?-1:F?B>=Q?0:B+1:B<=0?Q:B-1});return}W.key==="Enter"&&(W.preventDefault(),y>=0&&y<X.length&&ee(X[y]))},[e,X,y,ee,D,l]);k.useEffect(()=>(document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)),[$]);const K=X.length>0;let re=0;return s.jsx("div",{ref:C,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:W=>{W.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:S,value:r,onChange:W=>O(W.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(Pd),x(!1),w(-1),S.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(W=>s.jsx("button",{onClick:()=>{u(W.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===W.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:W.label},W.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&&!K&&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&&K&&s.jsx("div",{className:"space-y-4",children:H.map(W=>{if(l!=="all"&&l!==W)return null;const F=l==="all"?8:void 0,Z=B=>{const Q=re++,ae=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:"查看全部"})," (",ae,")"]})};return W==="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=re++;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(cW,{status:B.status})]},B.id)})}),F&&d.agents.length>F&&Z("agents")]},"agents"):W==="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=re++;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(uW,{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&&Z("tasks")]},"tasks"):W==="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=re++;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&&Z("requirements")]},"requirements"):W==="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=re++;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&&Z("projects")]},"projects"):W==="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=re++;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&&Z("deliverables")]},"deliverables"):W==="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=re++;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&&Z("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 cW({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 uW({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 dW({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(()=>l5(e.avatarUrl,sa()?.avatarUrl)),S=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:S,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(u5,{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 L4=k.lazy(()=>qr(()=>import("./Team-Jgmy2XLK.js"),__vite__mapDeps([2,3,4,5])).then(e=>({default:e.TeamPage}))),I4=k.lazy(()=>qr(()=>import("./Settings-DXRyCb9R.js"),[]).then(e=>({default:e.Settings}))),mW=k.lazy(()=>qr(()=>import("./Store-Csz6HWC-.js"),[]).then(e=>({default:e.StorePage}))),fW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>jK),void 0).then(e=>({default:e.AgentBuilder}))),P4=k.lazy(()=>qr(()=>import("./Work-D1xxd9Cj.js"),__vite__mapDeps([6,4,1,7,3,8])).then(e=>({default:e.WorkPage}))),z4=k.lazy(()=>qr(()=>import("./Deliverables-C8pzzt4r.js"),__vite__mapDeps([9,4,5])).then(e=>({default:e.DeliverablesPage}))),hW=k.lazy(()=>qr(()=>import("./Notifications-BqOlKcov.js"),[]).then(e=>({default:e.NotificationsPage}))),pW=k.lazy(()=>qr(()=>import("./Search-MQIbxh2k.js"),[]).then(e=>({default:e.SearchPage}))),gW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function bW(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 xW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const yW=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:gW,children:s.jsx(k.Suspense,{fallback:s.jsx(xW,{}),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 O3(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?e5[e]??e:e}function B4(){return O3(lc())}function vW(){const{t:e}=ft("common"),[t,n]=k.useState(B4),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,u]=k.useState(!0),d=Bo(),m=sW(),h=rW({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[p,g]=k.useState(()=>new Set([B4()])),[x,y]=k.useState("loading"),[w,S]=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),[X,ee]=k.useState(null),[$,K]=k.useState(!1),[re,W]=k.useState(null),[F,Z]=k.useState(()=>{const be=localStorage.getItem("markus_update_dismissed");return be||null}),[B,Q]=k.useState(!1),ae=U0(),ke=ae?.leftCollapsed??!1,U=ae?.toggleLeftCollapsed,G=ae?.toggleRightPanel,le=ae?.openRightPanel,I=ae?.closeRightPanelTab,Ae=ae?.updateRightPanelBrowserTab,Ue=k.useRef(ae?.rightPanelTabs);Ue.current=ae?.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&&Ae&&Ae(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,Ae]);const Oe=ae?.rightPanelOpen??!1;k.useLayoutEffect(()=>{const be=t===me.TEAM&&Oe;th(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||!U||!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(),U()):mt==="l"&&(Ge.preventDefault(),G())};return document.addEventListener("keydown",Me),()=>document.removeEventListener("keydown",Me)},[d,U,G]);const st=k.useCallback((be,Me)=>{let Ge=oc(be);d?Ge=e5[Ge]??Ge:Ge===me.NOTIFICATIONS&&(Ge=me.HOME),Ge!==me.TEAM&&th(!1);const ot=lc(),mt=window.location.hash.slice(1);if(mt!==ip(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 se=Ge!==me.WORK?Nd[Ge]:void 0;se&&se!==ip(Ge)?(history.pushState(null,"",Ni(Ge)),history.pushState(null,"","#"+se)):history.pushState(null,"",Ni(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=()=>S(!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);ee(Me)}}).catch(()=>{})},[]),At=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 se=mt.toString();window.history.replaceState(null,"",`${window.location.pathname}?${se}${Ni(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&&At(Me,be.get("type"));const Ge=window.markusDesktop;Ge?.onDeepLinkInstall?.(({id:se,type:ze})=>At(se,ze)),Ge?.consumePendingDeepLinkInstall?.().then(se=>{se?.id&&At(se.id,se.type)}),Ce.auth.me().then(({user:se})=>{y(se),C(!0),bW(se),va.connect(se.id),dt(),Ce.health().then(Xe=>{Xe.updateAvailable&&Xe.latestVersion&&W({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:se,hasOwner:ze,hasMultipleUsers:Xe})=>{C(se),_({hasOwner:ze,hasMultipleUsers:Xe})}).catch(()=>C(!0))}),va.connect();const ot=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),mt=()=>{const se=O3(lc());se!==me.TEAM&&th(!1),n(se),g(ze=>ze.has(se)?ze:new Set([...ze,se]))};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(Yy,{authUser:gt}),[me.TEAM]:s.jsx(L4,{authUser:gt}),[me.BUILDER]:s.jsx(QK,{authUser:gt}),[me.SETTINGS]:s.jsx(I4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Eo(),y(null)},onUserUpdated:be=>y(be)}),[me.WORK]:s.jsx(P4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(z4,{authUser:gt}),[me.NOTIFICATIONS]:s.jsx(hW,{authUser:gt}),[me.SEARCH]:s.jsx(pW,{})}:{[me.HOME]:s.jsx(Yy,{authUser:gt}),[me.TEAM]:s.jsx(L4,{authUser:gt}),[me.SETTINGS]:s.jsx(I4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Eo(),y(null)},onUserUpdated:be=>y(be)}),[me.STORE]:s.jsx(mW,{authUser:gt}),[me.BUILDER]:s.jsx(fW,{authUser:gt}),[me.WORK]:s.jsx(P4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(z4,{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(tW,{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(eW,{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(nW,{onComplete:()=>H(!1),isFirstTime:!0}):r?s.jsx(ZK,{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(rK,{currentPage:t,onNavigate:be=>{st(be),u(!1)},authUser:x,collapsed:h.collapsed,onToggleCollapse:h.toggle,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Eo(),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:[X===!1&&!$&&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:()=>K(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),re&&F!==re.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:re.latestVersion,current:re.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:()=>{Z(re.latestVersion),localStorage.setItem("markus_update_dismissed",re.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(yW,{id:be,activePage:t,children:jt[be]},be):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(lK,{currentPage:t,onNavigate:st,userId:gt?.id}),d&&s.jsx(mD,{authUser:gt,onNavigate:st}),!d&&B&&s.jsx(lW,{onClose:()=>Q(!1),currentPage:t}),w&>&&s.jsx(dW,{authUser:gt,onClose:()=>S(!1),onUserUpdated:be=>y(be),onSaved:be=>{S(!1),y(be)}})]})}qS.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(sG,{children:s.jsx(vW,{})})}));export{DW as $,Us as A,ZG as B,dr as C,QG as D,VV as E,TW as F,MW as G,WV as H,GK as I,CW as J,Ci as K,Vo as L,d5 as M,eK as N,U0 as O,me as P,oK as Q,BW as R,FK as S,OK as T,_W as U,Wa as V,OW as W,aV as X,RW as Y,PW as Z,qr as _,Bo as a,ZV as a0,YV as a1,LW as a2,b0 as a3,z7 as a4,wW as a5,zo as a6,Ni as a7,JO as a8,h3 as a9,jW as aa,J2 as ab,c4 as ac,zV as ad,PV as ae,Kd as af,UW as ag,kW as ah,sa as ai,yn as aj,na as ak,EW as al,m3 as am,WK as b,IK as c,UK as d,Ja as e,Ce as f,IW as g,it as h,ki as i,s as j,zW as k,Er as l,dD as m,at as n,rW as o,oc as p,Og as q,k as r,xc as s,I7 as t,ft as u,SW as v,va as w,NW as x,Vd as y,q2 as z};
|
|
666
|
+
prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(yp,{remarkPlugins:[Nw,Tk],rehypePlugins:[[Zk,{detect:!0,ignoreMissing:!0}]],children:e})})}function Xh({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)},S=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:S}),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(Gp,{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}),S]}),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(Gp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const x4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function bK(e){return[...e].sort(([t],[n])=>{const r=x4[t]??99,o=x4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function f0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>bK(e),[e]),[l,u]=k.useState(0);if(o.length===1)return n?s.jsx(Xh,{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(Xh,{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(Xh,{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 xK({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 yK({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=ft(["builder"]),[u,d]=k.useState(0),m=k.useMemo(()=>{const S=new Set;for(const T of Object.keys(n)){const C=T.match(/^members\/([^/]+)\//);C&&S.add(C[1])}return[...S]},[n]),h=k.useMemo(()=>{const S=new Map,T=new Set;for(let _=0;_<e.length;_++){const O=Vd(e[_].name);m.includes(O)&&!T.has(O)&&(S.set(_,O),T.add(O))}for(let _=0;_<e.length;_++){if(S.has(_))continue;const O=e[_].roleName;if(O){const z=Vd(O);m.includes(z)&&!T.has(z)&&(S.set(_,z),T.add(z))}}for(let _=0;_<e.length;_++){if(S.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()))){S.set(_,z),T.add(z);break}}}const C=m.filter(_=>!T.has(_));let j=0;for(let _=0;_<e.length;_++)S.has(_)||j<C.length&&(S.set(_,C[j]),j++);return S},[e,m,n]),p=k.useCallback((S,T)=>{const C=h.get(T);return C?Object.entries(n).filter(([j])=>j.startsWith(`members/${C}/`)):[]},[n,h]),g=k.useMemo(()=>{const S=[{label:l("detail.overview")}];for(const T of e)S.push({label:T.name,role:T.role});return S},[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((S,T)=>{const C=T===u,j=S.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:(S.label[0]??"?").toUpperCase()}),S.label]},T)})}),s.jsx("div",{className:"p-5",children:u===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(f0,{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((S,T)=>{const C=S.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:(S.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:S.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:S.role}),S.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",S.count]})]}),S.skills&&S.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[S.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)),S.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",S.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(S=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:S},S))}),(()=>{const S=p(x.name,y);return S.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(f0,{noHeader:!0,readOnly:o,files:S.map(([T,C])=>[T.replace(/^members\/[^/]+\//,""),C]),onSave:(T,C)=>{const j=S.find(([_])=>_.endsWith(`/${T}`));j&&r(j[0],C)}})})()]}):null})]});function w(S,T){r(S,T)}}function Ei({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,S]=k.useState({}),[T,C]=k.useState(null),[j,_]=k.useState(""),[O,z]=k.useState("idle"),[D,H]=k.useState({shared:!1}),[X,ee]=k.useState(!1),[$,K]=k.useState(!1),[re,W]=k.useState(!1),[F,Z]=k.useState(!1),[B,Q]=k.useState(!1),[ae,ke]=k.useState(!1),[U,G]=k.useState(null),[le,I]=k.useState(""),[Ae,Ue]=k.useState(""),[Oe,We]=k.useState(""),[st,dt]=k.useState(""),[At,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||""),S(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,"",Ni(me.BUILDER,`${e}/${encodeURIComponent(ve)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const Ye=await Ce.builder.artifacts.get(e,ve);S(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&&S(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,K(!0)):he==="description"?(Ue(ve),Ye.description=ve,K(!0)):he==="version"?(We(ve),Ye.version=ve,K(!1),W(!1)):he==="category"?(dt(ve),Ye.category=ve,K(!0)):he==="tags"?(gt(ve),Ye.tags=ve,K(!0)):he==="icon"&&(Jt(ve),Ye.icon=ve||void 0,K(!0)),ot({...T,...Ye})},[T,ot]),se=k.useCallback(async(he,ve)=>{try{const Ye={...w,[he]:ve};S(Ye);const nt={...T,files:Ye};await Ce.builder.artifacts.save(e,nt),z("saved"),K(!0),setTimeout(()=>z(xt=>xt==="saved"?"idle":xt),2e3)}catch{z("error")}},[w,e,T]),ze=k.useCallback(async he=>{if(T){ee(!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,"",Ni(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 He=[],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&&(He.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:He.length>0?He: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}),K(!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{ee(!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(),K(!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(),K(!0)}catch(ve){console.error("Image remove failed:",ve)}},et=b4[e]??b4.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=>{Kd()&&(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:X,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:X?m("share.updating"):m("share.updateVersion",{version:Ye})})]})})(),!o&&!D.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:X,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(X?"share.sharing":"share.toHub")})]})]}),!o&&$&&!re&&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:()=>W(!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&&re&&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:()=>W(!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(!ae),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:C3(le||t||e),fill:Ye})})})()}),!o&&ae&&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)}K(!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:fK.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(Yh,{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(Yh,{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(Yh,{value:Ae,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(pK,{value:st,options:mK,onChange:he=>mt("category",he),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(gK,{tags:At,onChange:he=>mt("tags",he),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(xK,{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(yK,{members:T.team.members,teamTopFiles:ye,files:w,onFileSave:se,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(f0,{noHeader:!0,files:V,onSave:se,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=hK[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(Gp,{content:pe})})]})]}),Qe.length>0&&s.jsx(f0,{files:Qe,onSave:se,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(wK,{onClose:()=>Z(!1),onConfirm:(he,ve)=>{Z(!1),ze({donationsEnabled:!1,priceCents:he==="paid"?ve:void 0})},isUpdate:D.shared}),!o&&B&&s.jsx(vK,{onClose:()=>Q(!1),onConfirm:(he,ve,Ye,nt)=>{Q(!1),ze({visibility:he,orgId:ve,priceCents:Ye,donationsEnabled:nt})}}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.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 vK({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 S=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))})]}),S&&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:A3.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")})]})]}),S&&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,S&&g>0?g:void 0,S?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 A3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function wK({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:A3.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 h0(e,t){return!e||!T3(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function kK({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:u="rounded-xl"}){const d=Ko(e),m=h0(n,r),h=k.useMemo(()=>Dg(d,t),[d,t]),p=k.useMemo(()=>C3(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}`}):uK(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&&AV(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 p0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:u}){const d=t||e||"markus",m=h0(n,r),[h,p]=k.useState(!1),g=m&&!h?m:dK(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 SK({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 y4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",className:n<t?"text-amber-400":"text-fg-muted/40",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z"})},n))})}function ia(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:u,hubBase:d,author:m,authorLabel:h,version:p,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:S=0,priceCents:T,currency:C="usd",installed:j,glowing:_,selected:O,showTypeBadge:z=!0,hideStats:D=!1,cornerLabel:H,actions:X,footerLeft:ee,headerAction:$,onClick:K,className:re=""}=e,W=Ko(t),F=Ti[W],Z=o||n,B=(T??0)>0,Q=!!h0(u||void 0,d),ae=Dg(W,Z),ke=h??m?.displayName??m?.username??"",[U,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:g4(T,C)}):null;if(Q){const I=h0(u||void 0,d);return s.jsxs("div",{onClick:K,style:{aspectRatio:U??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${K?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${re}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Ae=>{const Ue=Ae.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(SK,{type:W})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ae=>Ae.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}):$?null:s.jsx("span",{className:B?"badge-paid":"badge-free",children:g4(T,C)}),$]})]}),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(p0,{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(Ae=>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:Ae},Ae))]}),(!D||X)&&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(y4,{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(S)]})]}),X&&s.jsx("div",{className:"flex items-center gap-2",onClick:Ae=>Ae.stopPropagation(),children:X})]})]})]})}return s.jsxs("div",{onClick:K,className:`group asset-card card-shine relative flex flex-col ${K?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${re}`,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:ae}}),$&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:$}),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(kK,{type:W,seed:Z,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 ${$?"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(p0,{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=ee??(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(y4,{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(S)]})]}));return!I&&!X?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:Ae=>Ae.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),X&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:X})]})})()]})]})}function Ar({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 NK(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const CK=[{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 TK(){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 E3="markus_builder_shared_map";function AK(){try{const e=localStorage.getItem(E3);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(E3,JSON.stringify(Object.fromEntries(e)))}catch{}}function _3({authUser:e}={}){const{t}=ft(["builder","common"]),n=Bo(),r=TK(),[o,l]=k.useState([]),[u,d]=k.useState([]),[m,h]=k.useState(!1),[p,g]=k.useState("all"),[x,y]=k.useState(null),[w,S]=k.useState(new Map),[T,C]=k.useState(null),[j,_]=k.useState(null),[O,z]=k.useState(null),[D,H]=k.useState(AK),[X,ee]=k.useState(null),[$,K]=k.useState(null),[re,W]=k.useState(null),[F,Z]=k.useState(null),[B,Q]=k.useState(null),[ae,ke]=k.useState("creations"),[U,G]=k.useState([]),[le,I]=k.useState(""),[Ae,Ue]=k.useState([]),[Oe,We]=k.useState(!1),[st,dt]=k.useState("all"),At=k.useCallback(()=>{h(!0),Promise.all([(wi(Tr.builderArtifacts)??Ce.builder.artifacts.list()).then(se=>se?.artifacts??[]).catch(()=>[]),(wi(Tr.builderAgents)??Ce.agents.list()).then(se=>se?.agents??[]).catch(()=>[]),(wi(Tr.builderHubMyItems)??it.myItems()).then(se=>se?.items??[]).catch(()=>[]),(wi(Tr.builderInstalled)??Ce.builder.artifacts.installed()).then(se=>se?.installed??{}).catch(()=>({}))]).then(([se,ze,Xe,Ve])=>{if(d(se),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 se)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 se){const pe=`${yt.type}/${yt.name}`,V=Ve[pe];V&&et.set(pe,{agentId:V.agentId,agentIds:V.agentIds,teamId:V.teamId})}S(et)}).finally(()=>h(!1))},[]);k.useEffect(()=>{At();const se=ze=>{ze.detail?.page===me.BUILDER&&At()};return window.addEventListener("markus:navigate",se),()=>window.removeEventListener("markus:navigate",se)},[At]);const gt=se=>{const ze=o.find(Xe=>Xe.role==="Secretary"||Xe.name==="Secretary");ze?at.navigate(me.TEAM,{agentId:ze.id,prefillMessage:se}):at.navigate(me.TEAM,{prefillMessage:se})},jt=async se=>{const ze=`${se.type}/${se.name}`;if(!w.has(ze)){y({key:ze,action:"install"});try{const Xe=await Ce.builder.artifacts.install(se.type,se.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)),S(et=>new Map(et).set(ze,Ve)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Xe){console.error("Install failed:",Xe),K({title:t("common:install"),message:t("installFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Jt=async se=>{const ze=`${se.type}/${se.name}`;if(w.has(ze)){y({key:ze,action:"uninstall"});try{await Ce.builder.artifacts.uninstall(se.type,se.name),S(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),K({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(Xe)}),variant:"danger"})}finally{y(null)}}},Rt=async(se,ze)=>{const Xe=`${se.type}/${se.name}`;y({key:Xe,action:"share"});try{const Ve=await Ce.builder.artifacts.ensureSlugSafe(se.type,se.name,se.meta.displayName||se.meta.name||se.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=`${se.type}/${et}`;Ve.converted&&(d(oe=>oe.map(_e=>_e.type===se.type&&_e.name===se.name?{..._e,name:et,path:Ve.path,meta:{..._e.meta,name:et,displayName:Ve.displayName??_e.meta.displayName??se.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}),S(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(se.type,et);let ye={...se.meta,name:et,displayName:Ve.displayName??se.meta.displayName??se.name};try{const oe=V.files?.[`${se.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/${se.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(oe)}`);if(_e.ok){const de=await _e.blob(),He=new File([de],oe,{type:de.type}),qe=await it.uploadImage(He);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 He=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(et)}/images/${encodeURIComponent(de)}`);if(He.ok){const qe=await He.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:se.type==="team"?"team":se.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)?K({title:t("common:share"),message:Ve.converted?t("share.convertedAndSubmitted",{previous:se.name,slug:yt}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):Ve.converted&&K({title:t("common:share"),message:t("share.convertedSlug",{previous:se.name,slug:yt}),variant:"primary"}))}catch(Ve){console.error("Share failed:",Ve),K({title:t("common:share"),message:t("shareFailed",{error:Ve instanceof Error?Ve.message:String(Ve)}),variant:"danger"})}finally{y(null)}},be=async()=>{if(!X)return;const{key:se}=X,ze=D.get(se);if(ee(null),!ze)return;const Xe=ze.id;y({key:se,action:"hubDelete"});try{await it.deleteItem(Xe),H(Ve=>{const et=new Map(Ve);return et.delete(se),kd(et),et})}catch(Ve){console.error("Hub delete failed:",Ve),K({title:t("unshare"),message:t("hubDeleteFailed",{error:String(Ve)}),variant:"danger"})}finally{y(null)}},Me=async()=>{if(!T)return;const se=T,ze=`${se.type}/${se.name}`;C(null),y({key:ze,action:"delete"});try{await Ce.builder.artifacts.delete(se.type,se.name),d(Xe=>Xe.filter(Ve=>!(Ve.type===se.type&&Ve.name===se.name))),S(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(se=>se.type===p);k.useEffect(()=>{ae!=="orgAssets"||U.length>0||it.myOrgs().then(se=>{G(se.memberships),se.memberships.length>0&&!le&&I(se.memberships[0].id)}).catch(()=>{})},[ae,U.length,le]),k.useEffect(()=>{ae!=="orgAssets"||!le||(We(!0),it.browseItems({orgId:le,limit:100}).then(se=>Ue(se.items??[])).catch(()=>Ue([])).finally(()=>We(!1)))},[ae,le]);const ot=st==="all"?Ae:Ae.filter(se=>se.itemType===st),mt=se=>{history.pushState(null,"",Ni(me.BUILDER,`${se.type}/${encodeURIComponent(se.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Ei,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Ni(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:At,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:CK.map(se=>{const ze=t(`prompts.${se.id}Prompt`),Xe=t(`prompts.${se.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 ${se.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 ${se.bgColor} flex items-center justify-center shrink-0`,children:se.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${se.color} bg-clip-text text-transparent`,children:t(`prompts.${se.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${se.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))})]})]})},se.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 ${ae==="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 ${ae==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),ae==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>g(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${p===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))}),ae==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>dt(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${st===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))})]})}),ae==="orgAssets"&&U.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:U.map(se=>s.jsx("button",{onClick:()=>I(se.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${le===se.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:se.name},se.id))}),ae==="orgAssets"&&(U.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(Ar,{children:ot.map(se=>{const ze=se.author?.username&&se.slug?`${it.getUrl()}/@${encodeURIComponent(se.author.username)}/${encodeURIComponent(se.slug)}`:null;return s.jsx(ia,{type:se.itemType,name:se.name,description:se.description,seed:se.slug||se.id||se.name,icon:se.icon,cover:se.thumbnailUrl,hubBase:it.getUrl(),author:se.author,version:se.version,rating:parseFloat(se.avgRating)||0,ratingCount:se.ratingCount,downloadCount:se.downloadCount,actions:ze?s.jsxs("a",{href:ze,target:"_blank",rel:"noopener noreferrer",onClick:Xe=>{Xe.stopPropagation(),Kd()&&(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},se.id)})})),ae==="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(Ar,{children:Ge.map(se=>{const ze=se.meta.displayName||se.meta.name||se.name,Xe=se.meta.description||"",Ve=`${se.type}/${se.name}`,et=x?.key===Ve?x.action:null,yt=D.get(Ve),pe=se.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(se),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:()=>_(se),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(se,{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();Kd()&&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:()=>ee({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(se.meta.screenshots)&&se.meta.screenshots.length>0?Q(se):W(se)},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(se),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=se.meta.icon,Dt=!!nt&&/\.(png|jpe?g|gif|webp|svg)$/i.test(nt)?nt.startsWith("http")||nt.startsWith("/")?nt:`/api/builder/artifacts/${se.type}s/${encodeURIComponent(se.name)}/images/${encodeURIComponent(nt.split("/").pop()??"")}`:nt;return s.jsx(ia,{type:se.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(se.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:se.path,children:NK(se.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(se.updatedAt).toLocaleDateString()})]}),headerAction:Ye,actions:ve,onClick:()=>mt(se)},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 se=j;_(null),jt(se)},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 se=O;z(null),Jt(se)},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)}),X&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:X.name}),confirmLabel:t("unshare"),onConfirm:()=>{be()},onCancel:()=>ee(null)}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>K(null),onCancel:()=>K(null)}),re&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>W(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:se=>se.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 se=re;W(null),Q(se)},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 se=re;W(null),mt(se)},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:()=>Z(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:se=>se.stopPropagation(),children:s.jsx(_K,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>Z(null),onConfirm:(se,ze)=>{const Xe=F;Z(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:se=>se.stopPropagation(),children:s.jsx(EK,{onCancel:()=>Q(null),onConfirm:(se,ze,Xe,Ve)=>{const et=B;Q(null),Rt(et,{visibility:se,orgId:ze,priceCents:Xe,donationsEnabled:Ve})}})})})]})})}function EK({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 S=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))})]}),S&&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:j3.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")})]})]}),S&&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,S&&g>0?g:void 0,S?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 j3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function _K({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:j3.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 jK=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:_3},Symbol.toStringTag,{value:"Module"}));async function M3(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 MK(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 g0(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}const RK={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function OK({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,S]=k.useState({}),[T,C]=k.useState(!1),[j,_]=k.useState(!0),[O,z]=k.useState(new Map),[D,H]=k.useState(new Set),[X,ee]=k.useState(null),[$,K]=k.useState(null),re=k.useCallback(async()=>{try{const[Z,B]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const ae of Z.artifacts){if(ae.type!=="agent")continue;const ke=!!B.installed[`agent/${ae.name}`];Q.set(ae.name,{installed:ke,localVersion:ae.meta.version||void 0,localUpdatedAt:ae.updatedAt})}z(Q)}catch{}},[]),W=k.useCallback(async()=>{_(!0);try{const Z=u?it.search({type:"agent",q:u,limit:50}):wi(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:[]})),[ae,ke]=await Promise.all([Z.catch(()=>({items:[],total:0})),Q,re(),it.isAuthenticated()?it.purchases.mine().then(G=>H(new Set(G.purchases.map(le=>le.itemId)))).catch(()=>{}):Promise.resolve()]),U=await M3(ae?.items??[],t);g(U.items),h(Array.isArray(ke.templates)?ke.templates:[]),U.missing&&n?.()}catch{h([]),g([])}finally{_(!1)}},[u,re,t,n]);k.useEffect(()=>{W()},[W]),k.useEffect(()=>{if(!x){S({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(Z=>Z.json()).then(Z=>S(Z.files??{})).catch(()=>S({}))},[x]);const F=async(Z,B,Q)=>{try{const ae=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:Z,name:B,orgId:"default",teamId:Q})});if(!ae.ok)throw new Error(`Failed: ${ae.status}`);C(!1),y(null)}catch(ae){K({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${ae}`,variant:"danger"})}};if(X)return s.jsx(Ei,{type:X.type,name:X.name,onBack:()=>ee(null)});if(x){const Z={type:"agent",name:x.id,displayName:g0(x,l),version:x.version,description:v4(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 ${RK[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,ae)=>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})]})]},ae))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ei,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:Z,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(w4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"danger",title:$.title,message:$.message,onConfirm:()=>K(null),onCancel:()=>K(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:Z=>d(Z.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((Z,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(Ar,{columns:3,children:m.map(Z=>s.jsx(ia,{type:"agent",name:g0(Z,l),description:v4(Z,l),seed:Z.id,icon:Z.icon,version:Z.version,category:Z.category,tags:Z.tags,authorLabel:Z.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>y(Z)},Z.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Ar,{columns:3,children:p.map(Z=>s.jsx(DK,{item:Z,localInfo:O.get(Cc(Z)),purchased:Fd(Z,D),onStatusChange:re,highlight:Z.id===t,onHighlightDone:n,onViewDetail:B=>ee({type:"agent",name:B})},Z.id))})]})]})}),T&&x&&s.jsx(w4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"danger",title:$.title,message:$.message,onConfirm:()=>K(null),onCancel:()=>K(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 Vd(n||e.name,"hub-pkg")}function ki(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 Lg(e,t){t("checking"),await it.ensureAuth();const n=await it.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await ki(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 ki(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 ki(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 ki(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function DK({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 X=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(X)}},[o,l]);const S=t?.installed??!1,T=S&&e.version&&t?.localVersion&&MK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=async X=>{if(X.stopPropagation(),!m){h(!0),g("");try{await ki(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(ee){const $=ee instanceof Error?ee.message:"";$.includes("402")||$.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},_=async X=>{if(X.stopPropagation(),!m){h(!0),g("");try{await Lg(e,$=>{$==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(ee){g(ee instanceof Error?ee.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=()=>{S&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:X=>{j(X)},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})}):S?s.jsxs("button",{onClick:X=>{j(X)},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:X=>{_(X)},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:X=>{j(X)},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(ia,{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:S,glowing:y,onClick:D,actions:H})})}function w4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,u]=k.useState(`${g0(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:g0(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 Qh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function k4(e,t){return e.i18n?.[t]?.description||e.description}function S4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function LK(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 IK({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({}),[S,T]=k.useState(!0),[C,j]=k.useState(!1),[_,O]=k.useState(null),[z,D]=k.useState(new Map),[H,X]=k.useState(new Set),[ee,$]=k.useState(null),K=k.useCallback(async()=>{try{const[F,Z]=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 ae=!!Z.installed[`team/${Q.name}`];B.set(Q.name,{installed:ae,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(B)}catch{}},[]),re=k.useCallback(async()=>{T(!0);try{const F=l?it.search({type:"team",q:l,limit:50}):wi(Tr.hubTeams)??it.search({type:"team",limit:50}),[Z,B]=await Promise.all([F.catch(()=>({items:[],total:0})),Ce.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),K(),it.isAuthenticated()?it.purchases.mine().then(ae=>X(new Set(ae.purchases.map(ke=>ke.itemId)))).catch(()=>{}):Promise.resolve()]),Q=await M3(Z?.items??[],e);p(Q.items),m(B?.templates??[]),Q.missing&&t?.()}catch{m([]),p([])}finally{T(!1)}},[l,K,e,t]);k.useEffect(()=>{re()},[re]),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 W=async F=>{j(!0),O(null);try{const B=(await Ce.teams.create(F.name,F.description)).team.id;let Q,ae=0;const ke=[];for(const G of F.members){const le=G.count??1;for(let I=0;I<le;I++){const Ae=G.name??`${F.name} Agent ${I+1}`,Ue=le>1?`${Ae} ${I+1}`:Ae,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){ae++;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 U=ke.length>0?` (${ke.length} failed: ${ke[0]})`:"";O({ok:ae>0,message:`Team "${Qh(F,o)}" deployed with ${ae} agent(s)${U}`})}catch(Z){O({ok:!1,message:`Failed: ${Z}`})}finally{j(!1)}};if(ee)return s.jsx(Ei,{type:ee.type,name:ee.name,onBack:()=>$(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const Z={type:"team",name:g.id,displayName:Qh(g,o),version:g.version,description:k4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(Q=>({name:S4(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,ae)=>{const ke=S4(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(U=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:U},U)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},ae)})})]});return s.jsx(s.Fragment,{children:s.jsx(Ei,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:Z,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:()=>{W(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:S?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,Z)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Z))}):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(Ar,{columns:2,children:d.map(F=>s.jsx(ia,{type:"team",name:Qh(F,o),description:k4(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(Ar,{columns:2,children:h.map(F=>s.jsx(PK,{item:F,localInfo:z.get(Cc(F)),purchased:Fd(F,H),onStatusChange:K,highlight:F.id===e,onHighlightDone:t,onViewDetail:Z=>$({type:"team",name:Z})},F.id))})]})]})})]})}function PK({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 X=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(X)}},[o,l]);const S=t?.installed??!1,T=S&&e.version&&t?.localVersion&&LK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async X=>{if(X.stopPropagation(),!m){h(!0),g("");try{await ki(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(ee){const $=ee instanceof Error?ee.message:"";$.includes("402")||$.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},O=async X=>{if(X.stopPropagation(),!m){h(!0),g("");try{await Lg(e,$=>{$==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):$==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(ee){g(ee instanceof Error?ee.message:d("card.failed"))}finally{h(!1)}}},z=e.slug&&e.author?.username?`${it.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{S&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:X=>{_(X)},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})}):S?s.jsxs("button",{onClick:X=>{_(X)},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:X=>{O(X)},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:X=>{_(X)},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(ia,{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:S,glowing:y,onClick:D,actions:H})})}function Zh(e,t){return e.i18n?.[t]?.displayName||e.name}function Jh(e,t){return e.i18n?.[t]?.description||e.description||""}function R3(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 zK={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 BK({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&&R3(e.version,h.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),S=async()=>{if(!u){d(!0),w("");try{await ki(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 Lg(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:()=>{S()},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:()=>{S()},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 N4({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(ia,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Ld(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(BK,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function UK({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,S]=k.useState(null),[T,C]=k.useState([]),[j,_]=k.useState(0),[O,z]=k.useState(1),[D,H]=k.useState([]),[X,ee]=k.useState(""),[$,K]=k.useState("score"),[re,W]=k.useState(""),[F,Z]=k.useState(!1),[B,Q]=k.useState([]),[ae,ke]=k.useState(!1),[U,G]=k.useState([]),[le,I]=k.useState(""),[Ae,Ue]=k.useState(!1),[Oe,We]=k.useState([]),[st,dt]=k.useState([]),[At,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)},[]),se=k.useCallback(async V=>{Z(!0);try{const ye=await Ce.skills.registrySkillhub({q:V?.q,category:V?.category,page:V?.page??1,limit:24,sort:V?.sort??$});C(ye.skills),_(ye.total),ye.categories?.length&&H(ye.categories)}catch{}Z(!1)},[$]),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}):wi(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(),se(),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=U.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:Zh(V,o),version:V.version,description:Jh(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&&R3(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 ${zK[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(Ei,{type:"skill",name:V.name,onBack:()=>S(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=>Zh(ve,o).toLowerCase().includes(V)||Jh(ve,o).toLowerCase().includes(V)):B,Qe=ae&&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(Ar,{columns:3,children:ye.map(ve=>s.jsx(ia,{type:"skill",name:Zh(ve,o),description:Jh(ve,o),seed:ve.name,icon:Ld(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:()=>S(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(Ar,{columns:3,children:Oe.map(ve=>s.jsx(N4,{item:ve,installedSkills:x,purchased:Fd(ve,At),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(Ar,{columns:3,children:st.map(ve=>s.jsx(N4,{item:ve,type:"connector",installedSkills:x,purchased:Fd(ve,At),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:X,onChange:V=>{ee(V.target.value),z(1),se({q:re||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:$,onChange:V=>{K(V.target.value),z(1),se({q:re||void 0,category:X||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:re,onChange:V=>W(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(z(1),se({q:re||void 0,category:X||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),se({q:re||void 0,category:X||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(Ar,{columns:3,children:T.map(V=>{const ye=x.some(Qe=>Qe.name===V.name||Qe.name===V.slug);return s.jsx(ia,{type:"skill",name:V.name,description:V.description_zh??V.description??"",seed:V.slug,icon:Ld(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),se({q:re||void 0,category:X||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),se({q:re||void 0,category:X||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")})})]}),Ae?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(Ar,{columns:3,children:pe.map(V=>{const ye=x.some(Qe=>Qe.name===V.name);return s.jsx(ia,{type:"skill",name:V.name,description:V.description||"",seed:`${V.author}-${V.name}`,icon:Ld(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 HK=["agent","team","skill","connector"];function ep({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 $K({item:e,onOpen:t}){const n=Ko(e.subtype==="connector"?"connector":e.itemType),r=Dg(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(p0,{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 C4({items:e,onOpen:t}){return s.jsx(Ar,{columns:3,children:e.map(n=>s.jsx(ia,{type:n.subtype==="connector"?"connector":n.itemType,name:n.name,description:n.description,seed:n.slug||n.name,icon:n.icon,cover:n.thumbnailUrl,hubBase: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 T4(){return s.jsx(Ar,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function FK({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:HK.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($K,{item:g,onOpen:()=>p(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(ep,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(T4,{}):d.length>0?s.jsx(C4,{items:d,onOpen:p}):s.jsx(qK,{})]}),s.jsxs("section",{children:[s.jsx(ep,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(T4,{}):m.length>0?s.jsx(C4,{items:m,onOpen:p}):null]}),h.length>0&&s.jsxs("section",{children:[s.jsx(ep,{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(p0,{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 qK(){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 GK(){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,S]=k.useState(""),[T,C]=k.useState("all"),[j,_]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[H,X,ee,$]=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:[]}))]),K={};for(const F of ee.updates)K[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(K);const re=H.artifacts.filter(F=>{const Z=`${F.type}/${F.name}`;return!!X.installed[Z]}),W=new Set(re.filter(F=>F.type==="skill").map(F=>F.name));for(const F of $.skills)!F.installed||W.has(F.name)||!(X.installed[`skill/${F.name}`]||K[F.name])&&!F.updateAvailable||!X.installed[`skill/${F.name}`]&&!K[F.name]||(re.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:""}),W.add(F.name));for(const[F,Z]of Object.entries(K))W.has(F)||(re.push({type:"skill",name:F,meta:{displayName:Z.displayName||F,description:Z.description||"",version:Z.installedVersion},path:"",updatedAt:""}),W.add(F));l(re)}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,X)=>{if(!m.has(H)){h(ee=>new Set(ee).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:X}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:H}),type:"error"})}h(ee=>{const $=new Set(ee);return $.delete(H),$})}},D=o.filter(H=>{if(T!=="all"&&H.type!==T)return!1;if(!w)return!0;const X=w.toLowerCase(),ee=(Sd(H.meta,"displayName",r)||H.meta.displayName||H.name).toLowerCase(),$=(Sd(H.meta,"description",r)||H.meta.description||"").toLowerCase();return ee.includes(X)||$.includes(X)}).sort((H,X)=>{const ee=H.type==="skill"&&u[H.name]?1:0;return(X.type==="skill"&&u[X.name]?1:0)-ee});return j?s.jsx(Ei,{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=>S(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(Ar,{columns:3,children:D.map(H=>{const X=Sd(H.meta,"displayName",r)||H.meta.displayName||H.name,ee=Sd(H.meta,"description",r)||H.meta.description||"",$=H.meta.version||"",K=H.meta.author||"",re=H.meta.tags??[],W=H.meta.category||"",F=H.meta.icon,Z=H.type==="skill"?u[H.name]:void 0;return s.jsx(ia,{type:H.type,name:X,description:ee,seed:H.name,icon:F,author:null,authorLabel:K||void 0,version:Z?Z.installedVersion:$,category:W,tags:re,installed:!Z,hideStats:!0,cornerLabel:Z?e("installedTab.updateAvailable"):void 0,onClick:()=>{H.path&&_({type:H.type,name:H.name})},actions:Z?s.jsx("button",{type:"button",disabled:m.has(H.name),onClick:()=>{z(H.name,Z.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:Z.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 VK=50,KK=30;function WK(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<VK||Math.atan2(x,g)*(180/Math.PI)>KK)return;if(r?.scrollContainerRef?.current){const S=r.scrollContainerRef.current,T=S.scrollLeft<=1,C=S.scrollLeft+S.clientWidth>=S.scrollWidth-1;if(h>0&&!T||h<0&&!C)return}const w=e.findIndex(S=>S.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 YK=["builder","discover","agents","teams","skills","installed"],XK={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Vp(e){return!!e&&YK.includes(e)}function A4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Vp(t)?t:"builder",installId:e}}function QK({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(A4),[o,l]=k.useState(r.tab),[u,d]=k.useState(r.installId),m=WK(n,o,l);k.useEffect(()=>{const p=A4();p.installId&&(d(p.installId),Vp(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");Vp(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(XK[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(d5,{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(_3,{authUser:e}),o==="discover"&&s.jsx(FK,{onOpenType:h}),o==="agents"&&s.jsx(OK,{authUser:e,highlightItemId:u,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(IK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(UK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(GK,{})]})]})}const E4="usageType",tp="profile";function ZK({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,S]=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&&K(Ge=>Ge||l("usageType.defaultOrgName",{name:Me}))}).catch(()=>{}),Ce.settings.getOrg().then(({org:be})=>{be?.name&&be.name!=="My Organization"&&K(be.name)}).catch(()=>{}),yn()&&Ce.hubOrgs.invitations().then(be=>{be.invitations?.length>0&&ke(be.invitations)}).catch(()=>{})},[]);const[X,ee]=k.useState(null),[$,K]=k.useState(""),[re,W]=k.useState(!1),[F,Z]=k.useState(!1),[B,Q]=k.useState(""),[ae,ke]=k.useState([]),[U,G]=k.useState(null),[le,I]=k.useState(null),Ae=async()=>{const be=$.trim();if(be){W(!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)}Z(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{W(!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(I7,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:E4,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:()=>{ee("personal"),Z(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${X==="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:()=>{ee("organization"),Z(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${X==="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."})})]})]})]}),X==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[ae.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")}),ae.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),Z(!0)}catch{}finally{G(null)}},disabled:U===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"):U===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:$,onChange:be=>{K(be.target.value),Z(!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:()=>{Ae()},disabled:re||!$.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(re?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:tp,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(u5,{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=>S(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")})]})]})}],At=r?dt.filter(be=>be.id!==tp):dt,gt=At.findIndex(be=>be.id===E4),jt=At.findIndex(be=>be.id===tp),Jt=()=>{u===gt&>>=0&&!X||u===gt&&X==="organization"&&!F||u===jt&&jt>=0&&!O||(u<At.length-1?d(u+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})}).catch(()=>{}),e()))},Rt=At[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:At.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&&(!X||X==="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&&(!X||X==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:u===At.length-1?l("getStarted"):l("common:next")})]})]})})})}const _4="markus:legal-consent",JK="https://markus.global";function eW({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,S]=k.useState(!1),[T,C]=k.useState(!1),j=K=>{const re=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${JK}${K}${re}`},_=()=>{try{localStorage.setItem(_4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(_(),!0):(S(!1),requestAnimationFrame(()=>S(!0)),!1),z=async()=>{const K=yn(),re=sa();if(!K||!re){d(n("login.hubUnavailable"));return}const W=await Ce.auth.hubLogin(K,re);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),W.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",W.cloudAiError?n("login.cloudAiNotReady",{error:W.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(W.user,W.needsOnboarding??!1,{fromHub:!0})},D=async(K,re=!1)=>{if(!(!re&&!O())){d(""),l(K??"hub");try{if(re&&yn()&&sa()){await z();return}await na(K),await z()}catch(W){const F=W instanceof Error?W.message:"";if(!F.includes("cancelled")){if(!re&&yn())return D(K,!0);d(F||n("login.hubUnavailable"))}}finally{l(null)}}},H=()=>{iD(),l(null),d("")};k.useEffect(()=>{const K=window.markusDesktop;if(!K?.peekPendingDeepLinkAuth&&!K?.consumePendingDeepLinkAuth)return;let re=!1;return(async()=>{const W=K.peekPendingDeepLinkAuth?await K.peekPendingDeepLinkAuth():null;if(re||!W)return;let F=!1;try{F=!!localStorage.getItem(_4)}catch{}if(!T&&!F){d(n("login.consentRequired"));return}F&&!T&&C(!0),_();const Z=K.consumePendingDeepLinkAuth?await K.consumePendingDeepLinkAuth():W;if(!(re||!Z)){d(""),l("hub");try{if(!await sD(Z)||!yn()||!sa()){d(n("login.hubUnavailable"));return}await z()}catch{d(n("login.hubUnavailable"))}finally{re||l(null)}}})().catch(()=>{}),()=>{re=!0}},[T]);const X=async K=>{if(K.preventDefault(),!(!p.trim()||!x)&&O()){d(""),l("local");try{const{user:re,needsOnboarding:W}=await Ce.auth.login(p.trim(),x);e(re,W??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},ee=n(t?"login.welcomeBack":"login.getStarted"),$="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return 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:ee})]}),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:X,className:"space-y-3",children:[s.jsx("input",{type:"email",value:p,onChange:K=>g(K.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:K=>y(K.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:()=>D("google"),disabled:!!o,className:$,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:()=>D("github"),disabled:!!o,className:$,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:()=>D("email"),disabled:!!o,className:$,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),n(o==="email"?"login.connectingHub":"login.withEmail")]}),o&&(o==="google"||o==="github"||o==="email"||o==="hub")&&s.jsxs("div",{className:"px-3 py-2.5 bg-brand-500/10 border border-brand-500/30 rounded-lg text-xs text-fg-secondary space-y-2",children:[s.jsx("p",{children:n("login.browserOpened")}),s.jsx("button",{type:"button",onClick:H,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),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:()=>S(!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:K=>{C(K.target.checked),K.target.checked&&S(!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 tW({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),[S,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:S?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 nW({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 rW({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[u,d]=k.useState(()=>{try{const S=localStorage.getItem(`${l}_w`);if(S)return Math.max(n,Math.min(r,parseInt(S,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(S=>Math.max(n,Math.min(r,S)))},[n,r]);const y=k.useCallback(S=>{S.preventDefault(),p.current=!0;const T=S.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(S=>!S),[]);return{width:m?o:u,rawWidth:u,collapsed:m,toggle:w,setCollapsed:h,setWidth:d,onResizeStart:y}}const UW=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Kp="markus-theme";function j4(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 aW(){try{const e=localStorage.getItem(Kp);if(e==="midnight")return localStorage.setItem(Kp,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function sW(){const[e,t]=k.useState(aW),n=k.useCallback(r=>{t(r);try{localStorage.setItem(Kp,r)}catch{}j4(r)},[]);return k.useEffect(()=>{j4(e)},[e]),{mode:e,setMode:n}}const Pd={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},iW={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},oW=["agents","tasks","requirements","projects","deliverables","workflows"];let M4="",R4="all",O4=Pd,D4=!1;function lW({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);zo(!0);const[r,o]=k.useState(M4),[l,u]=k.useState(R4),[d,m]=k.useState(O4),[h,p]=k.useState(!1),[g,x]=k.useState(D4),[y,w]=k.useState(-1);k.useEffect(()=>{M4=r},[r]),k.useEffect(()=>{R4=l},[l]),k.useEffect(()=>{O4=d},[d]),k.useEffect(()=>{D4=g},[g]);const S=k.useRef(null),T=k.useRef(void 0),C=k.useRef(null),j=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{S.current?.focus(),S.current?.select()},100)},[]);const _=k.useCallback(async W=>{if(!W.trim()){m(Pd),x(!1),w(-1);return}p(!0),x(!0),w(-1);const F=W.toLowerCase();try{const[Z,B,Q,ae,ke,U]=await Promise.allSettled([Ce.agents.list(),Ce.tasks.list({search:W,pageSize:20}),Ce.requirements.list(),Ce.projects.list(),Ce.deliverables.search({q:W,limit:20}),Ce.teams.list()]),G=Z.status==="fulfilled"?Z.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)):[],Ae=ae.status==="fulfilled"?ae.value.projects.filter(We=>We.name?.toLowerCase().includes(F)||We.description?.toLowerCase().includes(F)):[],Ue=ke.status==="fulfilled"?ke.value.results:[],Oe=[];if(U.status==="fulfilled"){const We=await Promise.allSettled(U.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:Ae,deliverables:Ue,workflows:Oe})}catch{m(Pd)}finally{p(!1)}},[]),O=W=>{o(W),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>_(W),400)},z=k.useCallback((W,F)=>{e(),at.navigate(W,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(()=>iW[t||""]||oW,[t]),X=k.useMemo(()=>{const W=[],F=l==="all"?8:void 0,Z=B=>{if(l!=="all"&&l!==B)return;const Q=d[B].length;if(B==="workflows"){const ae=F?d.workflows.slice(0,F):d.workflows;for(const ke of ae)W.push({id:ke.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const ae=d[B],ke=F?ae.slice(0,F):ae;for(const U of ke)switch(B){case"agents":W.push({id:U.id,type:"agent",page:me.TEAM,params:{agentId:U.id}});break;case"tasks":W.push({id:U.id,type:"task",page:me.WORK,params:{openTask:U.id}});break;case"requirements":W.push({id:U.id,type:"requirement",page:me.WORK,params:{openRequirement:U.id}});break;case"projects":W.push({id:U.id,type:"project",page:me.WORK,params:{projectId:U.id}});break;case"deliverables":W.push({id:U.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:U.id}});break}}F&&Q>F&&W.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:Q})};for(const B of H)Z(B);return W},[d,l,H]),ee=k.useCallback(W=>{if(W.type==="showMore"&&W.expandCategory){u(W.expandCategory),w(-1);return}z(W.page,W.params)},[z]);k.useEffect(()=>{const W=j.current;if(!W||y<0)return;const F=W.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const $=k.useCallback(W=>{if(W.key==="Escape"){e();return}if(W.key==="Tab"){W.preventDefault();const B=D.map(ke=>ke.id),Q=B.indexOf(l),ae=W.shiftKey?Q<=0?B.length-1:Q-1:Q>=B.length-1?0:Q+1;u(B[ae]),w(-1);return}const F=W.ctrlKey&&W.key==="n"||W.key==="ArrowDown",Z=W.ctrlKey&&W.key==="p"||W.key==="ArrowUp";if(F||Z){W.preventDefault(),w(B=>{const Q=X.length-1;return Q<0?-1:F?B>=Q?0:B+1:B<=0?Q:B-1});return}W.key==="Enter"&&(W.preventDefault(),y>=0&&y<X.length&&ee(X[y]))},[e,X,y,ee,D,l]);k.useEffect(()=>(document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)),[$]);const K=X.length>0;let re=0;return s.jsx("div",{ref:C,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:W=>{W.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:S,value:r,onChange:W=>O(W.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(Pd),x(!1),w(-1),S.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(W=>s.jsx("button",{onClick:()=>{u(W.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===W.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:W.label},W.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&&!K&&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&&K&&s.jsx("div",{className:"space-y-4",children:H.map(W=>{if(l!=="all"&&l!==W)return null;const F=l==="all"?8:void 0,Z=B=>{const Q=re++,ae=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:"查看全部"})," (",ae,")"]})};return W==="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=re++;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(cW,{status:B.status})]},B.id)})}),F&&d.agents.length>F&&Z("agents")]},"agents"):W==="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=re++;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(uW,{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&&Z("tasks")]},"tasks"):W==="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=re++;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&&Z("requirements")]},"requirements"):W==="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=re++;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&&Z("projects")]},"projects"):W==="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=re++;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&&Z("deliverables")]},"deliverables"):W==="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=re++;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&&Z("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 cW({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 uW({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 dW({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(()=>l5(e.avatarUrl,sa()?.avatarUrl)),S=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:S,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(u5,{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 L4=k.lazy(()=>qr(()=>import("./Team-Bp5j4tGQ.js"),__vite__mapDeps([2,3,4,5])).then(e=>({default:e.TeamPage}))),I4=k.lazy(()=>qr(()=>import("./Settings-Bo7g6_tg.js"),[]).then(e=>({default:e.Settings}))),mW=k.lazy(()=>qr(()=>import("./Store-B_9bFi_v.js"),[]).then(e=>({default:e.StorePage}))),fW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>jK),void 0).then(e=>({default:e.AgentBuilder}))),P4=k.lazy(()=>qr(()=>import("./Work-CBpfr_rN.js"),__vite__mapDeps([6,4,1,7,3,8])).then(e=>({default:e.WorkPage}))),z4=k.lazy(()=>qr(()=>import("./Deliverables-DCXoaQpj.js"),__vite__mapDeps([9,4,5])).then(e=>({default:e.DeliverablesPage}))),hW=k.lazy(()=>qr(()=>import("./Notifications-BTkCe_FT.js"),[]).then(e=>({default:e.NotificationsPage}))),pW=k.lazy(()=>qr(()=>import("./Search-DJMnvmW4.js"),[]).then(e=>({default:e.SearchPage}))),gW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function bW(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 xW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const yW=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:gW,children:s.jsx(k.Suspense,{fallback:s.jsx(xW,{}),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 O3(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?e5[e]??e:e}function B4(){return O3(lc())}function vW(){const{t:e}=ft("common"),[t,n]=k.useState(B4),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,u]=k.useState(!0),d=Bo(),m=sW(),h=rW({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[p,g]=k.useState(()=>new Set([B4()])),[x,y]=k.useState("loading"),[w,S]=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),[X,ee]=k.useState(null),[$,K]=k.useState(!1),[re,W]=k.useState(null),[F,Z]=k.useState(()=>{const be=localStorage.getItem("markus_update_dismissed");return be||null}),[B,Q]=k.useState(!1),ae=U0(),ke=ae?.leftCollapsed??!1,U=ae?.toggleLeftCollapsed,G=ae?.toggleRightPanel,le=ae?.openRightPanel,I=ae?.closeRightPanelTab,Ae=ae?.updateRightPanelBrowserTab,Ue=k.useRef(ae?.rightPanelTabs);Ue.current=ae?.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&&Ae&&Ae(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,Ae]);const Oe=ae?.rightPanelOpen??!1;k.useLayoutEffect(()=>{const be=t===me.TEAM&&Oe;th(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||!U||!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(),U()):mt==="l"&&(Ge.preventDefault(),G())};return document.addEventListener("keydown",Me),()=>document.removeEventListener("keydown",Me)},[d,U,G]);const st=k.useCallback((be,Me)=>{let Ge=oc(be);d?Ge=e5[Ge]??Ge:Ge===me.NOTIFICATIONS&&(Ge=me.HOME),Ge!==me.TEAM&&th(!1);const ot=lc(),mt=window.location.hash.slice(1);if(mt!==ip(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 se=Ge!==me.WORK?Nd[Ge]:void 0;se&&se!==ip(Ge)?(history.pushState(null,"",Ni(Ge)),history.pushState(null,"","#"+se)):history.pushState(null,"",Ni(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=()=>S(!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);ee(Me)}}).catch(()=>{})},[]),At=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 se=mt.toString();window.history.replaceState(null,"",`${window.location.pathname}?${se}${Ni(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&&At(Me,be.get("type"));const Ge=window.markusDesktop;Ge?.onDeepLinkInstall?.(({id:se,type:ze})=>At(se,ze)),Ge?.consumePendingDeepLinkInstall?.().then(se=>{se?.id&&At(se.id,se.type)}),Ce.auth.me().then(({user:se})=>{y(se),C(!0),bW(se),va.connect(se.id),dt(),Ce.health().then(Xe=>{Xe.updateAvailable&&Xe.latestVersion&&W({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:se,hasOwner:ze,hasMultipleUsers:Xe})=>{C(se),_({hasOwner:ze,hasMultipleUsers:Xe})}).catch(()=>C(!0))}),va.connect();const ot=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),mt=()=>{const se=O3(lc());se!==me.TEAM&&th(!1),n(se),g(ze=>ze.has(se)?ze:new Set([...ze,se]))};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(Yy,{authUser:gt}),[me.TEAM]:s.jsx(L4,{authUser:gt}),[me.BUILDER]:s.jsx(QK,{authUser:gt}),[me.SETTINGS]:s.jsx(I4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Eo(),y(null)},onUserUpdated:be=>y(be)}),[me.WORK]:s.jsx(P4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(z4,{authUser:gt}),[me.NOTIFICATIONS]:s.jsx(hW,{authUser:gt}),[me.SEARCH]:s.jsx(pW,{})}:{[me.HOME]:s.jsx(Yy,{authUser:gt}),[me.TEAM]:s.jsx(L4,{authUser:gt}),[me.SETTINGS]:s.jsx(I4,{theme:m.mode,onThemeChange:m.setMode,authUser:gt,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Eo(),y(null)},onUserUpdated:be=>y(be)}),[me.STORE]:s.jsx(mW,{authUser:gt}),[me.BUILDER]:s.jsx(fW,{authUser:gt}),[me.WORK]:s.jsx(P4,{authUser:gt}),[me.DELIVERABLES]:s.jsx(z4,{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(tW,{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(eW,{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(nW,{onComplete:()=>H(!1),isFirstTime:!0}):r?s.jsx(ZK,{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(rK,{currentPage:t,onNavigate:be=>{st(be),u(!1)},authUser:x,collapsed:h.collapsed,onToggleCollapse:h.toggle,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Eo(),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:[X===!1&&!$&&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:()=>K(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),re&&F!==re.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:re.latestVersion,current:re.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:()=>{Z(re.latestVersion),localStorage.setItem("markus_update_dismissed",re.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(yW,{id:be,activePage:t,children:jt[be]},be):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(lK,{currentPage:t,onNavigate:st,userId:gt?.id}),d&&s.jsx(mD,{authUser:gt,onNavigate:st}),!d&&B&&s.jsx(lW,{onClose:()=>Q(!1),currentPage:t}),w&>&&s.jsx(dW,{authUser:gt,onClose:()=>S(!1),onUserUpdated:be=>y(be),onSaved:be=>{S(!1),y(be)}})]})}qS.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(sG,{children:s.jsx(vW,{})})}));export{DW as $,Us as A,ZG as B,dr as C,QG as D,VV as E,TW as F,MW as G,WV as H,GK as I,CW as J,Ci as K,Vo as L,d5 as M,eK as N,U0 as O,me as P,oK as Q,BW as R,FK as S,OK as T,_W as U,Wa as V,OW as W,aV as X,RW as Y,PW as Z,qr as _,Bo as a,ZV as a0,YV as a1,LW as a2,b0 as a3,z7 as a4,wW as a5,zo as a6,Ni as a7,JO as a8,h3 as a9,jW as aa,J2 as ab,c4 as ac,zV as ad,PV as ae,Kd as af,UW as ag,kW as ah,sa as ai,yn as aj,na as ak,EW as al,m3 as am,WK as b,IK as c,UK as d,Ja as e,Ce as f,IW as g,it as h,ki as i,s as j,zW as k,Er as l,dD as m,at as n,rW as o,oc as p,Og as q,k as r,xc as s,I7 as t,ft as u,SW as v,va as w,NW as x,Vd as y,q2 as z};
|