@tianshu-ai/tianshu 0.4.20 → 0.4.21

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/bundle-web-CK5GMDdN.js","assets/rolldown-runtime-QTnfLwEv.js","assets/papaparse.min-BQRX_pWo.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/bundle-web-hHh7gz2L.js","assets/rolldown-runtime-QTnfLwEv.js","assets/papaparse.min-BQRX_pWo.js"])))=>i.map(i=>d[i]);
2
2
  import{n as e,r as t,t as n}from"./rolldown-runtime-QTnfLwEv.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var r=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ee(e,t){return E(e.type,t,e.props)}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function te(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ne=/\/+/g;function re(e,t){return typeof e==`object`&&e&&e.key!=null?te(``+e.key):t.toString(36)}function ie(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ae(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ae(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+re(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ne,`$&/`)+`/`),ae(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=ee(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ne,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+re(a,u),c+=ae(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+re(a,u++),c+=ae(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ae(ie(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function oe(e,t,n){if(e==null)return e;var r=[],i=0;return ae(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function se(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var O=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},k={map:oe,forEach:function(e,t,n){oe(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return oe(e,function(){t++}),t},toArray:function(e){return oe(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=k,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:se}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,O)}catch(e){O(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),i=n(((e,t)=>{t.exports=r()})),a=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,D());else{var t=n(l);t!==null&&re(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function ee(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&re(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(ee)};else if(typeof MessageChannel<`u`){var te=new MessageChannel,ne=te.port2;te.port1.onmessage=ee,D=function(){ne.postMessage(null)}}else D=function(){_(ee,0)};function re(t,n){C=_(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,re(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),o=n(((e,t)=>{t.exports=a()})),s=n((e=>{var t=i();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var a={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.7`})),c=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=n((e=>{var t=o(),n=i(),r=c();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(a(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return f(i),e;if(o===r)return f(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=o;break}if(c===r){s=!0,r=i,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,r=i;break}if(c===r){s=!0,r=o,n=i;break}c=c.sibling}if(!s)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),te=Symbol.for(`react.activity`),ne=Symbol.for(`react.memo_cache_sentinel`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case te:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ee:return t=e.displayName||null,t===null?oe(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var se=Array.isArray,O=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,k=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce={pending:!1,data:null,method:null,action:null},le=[],ue=-1;function de(e){return{current:e}}function fe(e){0>ue||(e.current=le[ue],le[ue]=null,ue--)}function pe(e,t){ue++,le[ue]=e.current,e.current=t}var me=de(null),he=de(null),ge=de(null),_e=de(null);function ve(e,t){switch(pe(ge,t),pe(he,e),pe(me,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Jd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Jd(t),e=Yd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}fe(me),pe(me,e)}function ye(){fe(me),fe(he),fe(ge)}function be(e){e.memoizedState!==null&&pe(_e,e);var t=me.current,n=Yd(t,e.type);t!==n&&(pe(he,e),pe(me,n))}function xe(e){he.current===e&&(fe(me),fe(he)),_e.current===e&&(fe(_e),ap._currentValue=ce)}var Se,Ce;function we(e){if(Se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Se=t&&t[1]||``,Ce=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+Se+e+Ce}var Te=!1;function Ee(e,t){if(!e||Te)return``;Te=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -35,7 +35,7 @@ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.expo
35
35
  The chosen QR Code version cannot contain this amount of data.
36
36
  Minimum version required to store current data is: `+c+`.
37
37
  `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),FI=n((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),II=n((e=>{var t=FI();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),LI=n((e=>{var t=FI();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
38
- `;return typeof a==`function`&&a(null,p),p}})),RI=t(n((e=>{var t=dI(),n=PI(),r=II(),i=LI();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1),zI=`/api/p/wechat`;async function BI(e,t){return fetch(`${zI}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers??{}},...t})}function VI({status:e,detail:t}){let n={running:{label:`Connected`,tone:`bg-success/10 text-success border-success/30`},starting:{label:`Starting`,tone:`bg-warning/10 text-warning border-warning/30`},idle:{label:`Idle`,tone:`bg-bg-hover text-fg-muted border-border-default`},stopped:{label:`Stopped`,tone:`bg-bg-hover text-fg-muted border-border-default`},error:{label:`Error`,tone:`bg-danger/10 text-danger border-danger/30`}}[e];return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] ${n.tone}`,title:t??void 0,children:[e===`starting`&&(0,J.jsx)(q,{className:`h-3 w-3 animate-spin`}),n.label]})}function HI({onClose:e,onBound:t}){let{Modal:n}=mF(),[r,i]=(0,d.useState)(`model`),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)([]),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(``),v=(0,d.useRef)({cancelled:!1});(0,d.useEffect)(()=>((async()=>{try{let e=await(await fetch(`/api/models`,{credentials:`include`})).json(),t=(e.models??[]).map(e=>({id:e.id,displayName:e.displayName??e.label??e.id}));p(t),h(e.defaultModel??null),_(e.defaultModel??t[0]?.id??``)}catch{}})(),()=>{v.current.cancelled=!0}),[]);let y=(0,d.useCallback)(async()=>{i(`loading`);try{let e=await BI(`/login/start`,{method:`POST`,body:`{}`}),t=await e.json();if(!e.ok||!t.ok){c(t.error??`HTTP ${e.status}`),i(`error`);return}o(t),i(`qr`)}catch(e){c(e instanceof Error?e.message:String(e)),i(`error`)}},[]);return(0,d.useEffect)(()=>{if(r!==`qr`||!a)return;v.current={cancelled:!1};let e=v.current;return(async()=>{for(;!e.cancelled;)try{let t=await BI(`/login/poll`,{method:`POST`,body:JSON.stringify({qrcode:a.qrcode,modelId:g||void 0})}),n=await t.json();if(e.cancelled)return;if(!t.ok||!n.ok){c(n.error??`HTTP ${t.status}`),i(`error`);return}if(n.scanned&&n.binding){u(n.binding),i(`scanned`);return}await UI(1e3)}catch(t){if(e.cancelled)return;c(t instanceof Error?t.message:String(t)),i(`error`);return}})(),()=>{e.cancelled=!0}},[r,a]),(0,d.useEffect)(()=>{if(r!==`scanned`)return;t();let n=setTimeout(e,1500);return()=>clearTimeout(n)},[r,t,e]),(0,J.jsx)(n,{isOpen:!0,onClose:e,title:`Add WeChat account`,size:`sm`,children:(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-4 p-6`,children:[r===`model`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Choose which model this WeChat account routes to:`}),(0,J.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`w-full max-w-sm rounded-md border border-border-default bg-bg-elevated px-3 py-2 text-sm text-fg-default`,children:[f.length===0&&(0,J.jsx)(`option`,{value:``,children:`(no models registered)`}),f.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.displayName,m===e.id?` (default)`:``]},e.id))]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void y(),disabled:f.length===0||!g,className:`mt-2 inline-flex items-center gap-1.5 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-fg-on-accent hover:bg-accent-hover disabled:opacity-50`,children:`Continue → Scan QR`}),(0,J.jsx)(`div`,{className:`text-[11px] text-fg-fainter`,children:`You can change the model later by re-scanning.`})]}),r===`loading`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(q,{className:`h-6 w-6 animate-spin text-fg-faint`}),(0,J.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Requesting QR code…`})]}),r===`qr`&&a&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Scan with WeChat to authorise`}),(0,J.jsx)(WI,{value:a.qrCodeImageUrl}),(0,J.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:`Open WeChat → Scan → Confirm`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-fg-fainter`,children:[(0,J.jsx)(q,{className:`h-3 w-3 animate-spin`}),`waiting for scan…`]})]}),r===`scanned`&&l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ql,{className:`h-10 w-10 text-success`}),(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg-default`,children:`Connected`}),(0,J.jsx)(`div`,{className:`text-xs text-fg-muted`,children:l.displayName??l.config.username??`WeChat account`})]}),r===`error`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(AP,{className:`h-10 w-10 text-danger`}),(0,J.jsx)(`div`,{className:`text-sm text-fg-default`,children:`Login failed`}),(0,J.jsx)(`div`,{className:`max-w-xs break-words text-xs text-fg-muted`,children:s})]})]})})}function UI(e){return new Promise(t=>setTimeout(t,e))}function WI({value:e}){let t=(0,d.useId)(),n=(0,d.useRef)(null),[r,i]=(0,d.useState)(null);return(0,d.useEffect)(()=>{let t=!1,r=n.current;if(r)return i(null),RI.toCanvas(r,e,{width:224,margin:2,color:{dark:`#000000`,light:`#ffffff`},errorCorrectionLevel:`M`}).catch(e=>{t||i(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e]),r?(0,J.jsxs)(`div`,{className:`flex h-56 w-56 items-center justify-center rounded-md border border-danger/30 bg-danger/10 p-3 text-center text-xs text-danger`,children:[`QR render failed: `,r]}):(0,J.jsx)(`canvas`,{ref:n,"aria-label":`WeChat login QR`,id:`wechat-qr-${t}`,className:`h-56 w-56 rounded-md border border-border-default bg-white p-2`})}function GI(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),{setViewingSession:s}=yF(),c=(0,d.useCallback)(async()=>{try{let e=await BI(`/bindings`),t=await e.json();if(!e.ok||!t.ok){i(t.error??`HTTP ${e.status}`);return}i(null),n(t.bindings??[])}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,d.useEffect)(()=>{c()},[c]);let l=(0,d.useCallback)(async e=>{if(confirm(`Disconnect this WeChat account from tianshu? Existing chat history with this account will be deleted too.`))try{let t=await BI(`/bindings/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok){i((await t.json().catch(()=>({}))).error??`HTTP ${t.status}`);return}s(null),await c()}catch(e){i(e instanceof Error?e.message:String(e))}},[c,s]);return(0,J.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-6 text-fg-default`,children:[(0,J.jsxs)(`header`,{className:`mb-6 flex items-center justify-between border-b border-border-subtle pb-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(Fx,{className:`h-6 w-6 text-success`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`WeChat`}),(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Connect your WeChat so direct messages route to your agent.`})]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void c(),className:`rounded p-1.5 text-fg-muted hover:bg-bg-hover hover:text-fg-default`,title:`Refresh`,children:(0,J.jsx)(GT,{className:`h-4 w-4`})})]}),r&&(0,J.jsx)(`div`,{className:`mb-4 rounded-md border border-danger/30 bg-danger/10 px-3 py-2 text-sm text-danger`,children:r}),t===null?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,J.jsx)(q,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):t.length===0?(0,J.jsxs)(`div`,{className:`rounded-md border border-dashed border-border-default px-6 py-10 text-center`,children:[(0,J.jsx)(Fx,{className:`mx-auto mb-3 h-8 w-8 text-fg-fainter`}),(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg-default`,children:`No WeChat connected`}),(0,J.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:`Scan a QR with the WeChat app to start routing your direct messages through tianshu.`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`mt-4 inline-flex items-center gap-1.5 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-fg-on-accent hover:bg-accent-hover`,children:`Connect WeChat`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`One account connected. Re-scan to switch model or refresh the token.`}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`inline-flex items-center gap-1.5 rounded-md border border-border-default px-2.5 py-1 text-[11px] text-fg-muted hover:bg-bg-hover hover:text-fg-default`,children:[(0,J.jsx)(GT,{className:`h-3 w-3`}),`Re-scan`]})]}),(0,J.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center justify-between rounded-md border border-border-subtle bg-bg-elevated px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg-default`,children:e.displayName??e.config.username??`WeChat account`}),(0,J.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[11px] text-fg-faint`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:e.id}),(0,J.jsx)(VI,{status:e.status,detail:e.statusDetail}),typeof e.config.modelId==`string`&&e.config.modelId&&(0,J.jsx)(`span`,{className:`rounded bg-bg-hover px-1 py-px font-mono text-[10px] text-fg-muted`,title:`Model this binding routes inbound DMs to`,children:String(e.config.modelId)}),(0,J.jsxs)(`span`,{children:[`· bound `,new Date(e.createdAt).toLocaleDateString()]})]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void l(e.id),className:`rounded p-1.5 text-fg-muted hover:bg-danger/10 hover:text-danger`,title:`Disconnect`,children:(0,J.jsx)(pM,{className:`h-4 w-4`})})]},e.id))})]}),a&&(0,J.jsx)(HI,{onClose:()=>o(!1),onBound:()=>void c()})]})}function KI(e){let[t,n]=(0,d.useState)(null),{viewingSessionId:r,setViewingSession:i}=yF(),a=(0,d.useCallback)(async()=>{try{let e=await(await BI(`/sessions`)).json();e.ok&&n(e.sessions??[])}catch{}},[]);if((0,d.useEffect)(()=>{a();let e=SF(`channel_session_changed`,e=>{e.channelId===`wechat`&&a()}),t=setInterval(()=>void a(),3e4);return()=>{e(),clearInterval(t)}},[a]),t===null||t.length===0)return null;function o(e){if(!e)return`(untitled)`;let t=e.match(/^([^:]+):(dm|group):(.+)$/);if(!t)return e;let n=t[3].length>18?`${t[3].slice(0,16)}…`:t[3];return`${t[2]===`dm`?`DM`:`群`} · ${n}`}return(0,J.jsx)(J.Fragment,{children:t.map(e=>{let t=e.id===r;return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`flex w-full items-center gap-2 rounded-lg px-3 py-1.5 text-left transition-colors ${t?`bg-bg-hover text-fg-default border border-border-default`:`text-fg-muted hover:bg-bg-hover hover:text-fg-default border border-transparent`}`,title:e.title??e.channelChatId,children:[(0,J.jsx)(`span`,{className:`flex-shrink-0 rounded bg-success/15 px-1 py-px text-[9px] uppercase tracking-wider text-success`,children:`wechat`}),(0,J.jsx)(`span`,{className:`flex-1 truncate text-xs`,children:o(e.title)}),t&&(0,J.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-fg-faint`,children:`active`})]},e.id)})})}var qI={components:{WeChatAdminPage:GI,WeChatSidebarSection:KI}};qI.components;function JI(){let[e,t]=(0,d.useState)([]),[n,r]=(0,d.useState)([]),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(()=>new Set),_=(0,d.useCallback)(e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[v,y]=(0,d.useState)(null),b=(0,d.useCallback)(async(e,n)=>{y(e),f(null);try{let r=await fetch(`/api/p/workboard/agents/${encodeURIComponent(e)}/enabled`,{method:`PATCH`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:!n})});if(!r.ok){let t=await r.text().catch(()=>``);f(`PATCH /agents/${e}/enabled → HTTP ${r.status}${t?`: `+t:``}`);return}t(t=>t.map(t=>t.id===e?{...t,enabled:!n}:t))}catch(e){f(e instanceof Error?e.message:String(e))}finally{y(null)}},[]),x=(0,d.useCallback)(async()=>{l(!0),f(null);try{let[e,n,i]=await Promise.all([fetch(`/api/p/workboard/agents`,{credentials:`include`}),fetch(`/api/tools`,{credentials:`include`}),fetch(`/api/skills`,{credentials:`include`})]);if(!e.ok){f(`GET /agents → HTTP ${e.status}`);return}let o=await e.json();t(o.agents),r(o.kinds),n.ok&&a((await n.json()).tools??[]),i.ok&&s((await i.json()).skills??[])}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[]);(0,d.useEffect)(()=>{x()},[x]);let S=e=>n.find(t=>t.id===e)?.displayName??e,C=e=>`tenant-config:///workers/${e.builtinKey??e.id}/`;return(0,J.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6`,children:[(0,J.jsxs)(`div`,{className:`mb-4 rounded-md border border-amber-900/40 bg-amber-950/30 px-3 py-2 text-[12px] leading-relaxed text-amber-200/90`,children:[(0,J.jsx)(`div`,{className:`font-semibold text-amber-100`,children:`Read-only listing — edit on disk`}),(0,J.jsxs)(`p`,{className:`mt-1 text-amber-200/70`,children:[`Worker config lives at`,` `,(0,J.jsx)(`code`,{className:`rounded bg-amber-950/60 px-1 py-0.5 text-amber-100`,children:`_tenant/config/workers/<slug>/`}),`. Each worker is a directory with`,` `,(0,J.jsx)(`code`,{className:`text-amber-100`,children:`agent.json`}),` and an optional`,` `,(0,J.jsx)(`code`,{className:`text-amber-100`,children:`SOUL.md`}),` /`,` `,(0,J.jsx)(`code`,{className:`text-amber-100`,children:`skills/`}),`. Edit the files directly, or ask the chat agent to do it via`,` `,(0,J.jsx)(`code`,{className:`text-amber-100`,children:`tenant_config_write`}),`. Pool picks up changes on next activate; a fs watcher follow-up will make this live.`]})]}),(0,J.jsxs)(`div`,{className:`mb-6 flex items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold text-fg-default`,children:[(0,J.jsx)(Es,{size:18,className:`text-brand-400`}),`Worker agents`]}),(0,J.jsx)(`p`,{className:`mt-1 max-w-3xl text-[12px] leading-relaxed text-fg-faint`,children:`Inventory the workboard pool currently sees. Filesystem rows shadow same-slug DB rows; legacy DB rows still present here haven't been edited or aren't yet picked up by the merger.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>m(!0),className:`flex items-center gap-1 rounded-md border border-border-default px-2.5 py-1.5 text-[12px] text-fg-muted hover:bg-bg-raised`,title:`Edit pool concurrency caps and worker type defaults`,children:[(0,J.jsx)(vD,{size:12}),`Configure`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>void x(),disabled:c,className:`flex items-center gap-1 rounded-md border border-border-default px-2.5 py-1.5 text-[12px] text-fg-muted hover:bg-bg-raised disabled:opacity-50`,title:`Reload`,children:[(0,J.jsx)(GT,{size:12,className:c?`animate-spin`:``}),`Reload`]})]})]}),(0,J.jsx)($I,{open:p,onClose:()=>m(!1)}),u&&(0,J.jsx)(`div`,{className:`mb-4 rounded-md border border-red-900/40 bg-red-950/40 px-3 py-2 text-[12px] text-red-300`,children:u}),(0,J.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border-subtle`,children:(0,J.jsxs)(`table`,{className:`min-w-full divide-y divide-gray-800 text-[12px]`,children:[(0,J.jsx)(`thead`,{className:`bg-bg-elevated/60 text-[11px] font-semibold uppercase tracking-wide text-fg-muted`,children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`State`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Name`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Kind`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Source`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Model`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Slug`})]})}),(0,J.jsx)(`tbody`,{className:`divide-y divide-gray-800`,children:e.length===0?(0,J.jsx)(`tr`,{children:(0,J.jsx)(`td`,{colSpan:6,className:`px-3 py-8 text-center text-fg-faint`,children:c?`Loading…`:`No worker agents.`})}):e.flatMap(e=>{let t=h.has(e.id);return[(0,J.jsxs)(`tr`,{className:`cursor-pointer hover:bg-bg-elevated/40`,onClick:()=>_(e.id),children:[(0,J.jsx)(`td`,{className:`px-3 py-2`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t?(0,J.jsx)(Al,{size:12,className:`text-fg-faint`}):(0,J.jsx)(Pl,{size:12,className:`text-fg-faint`}),(0,J.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,disabled:v===e.id,onClick:t=>{t.stopPropagation(),b(e.id,e.enabled)},className:`relative inline-flex h-4 w-7 shrink-0 cursor-pointer items-center rounded-full border transition-colors ${e.enabled?`border-emerald-500/60 bg-emerald-500/80 hover:bg-emerald-500`:`border-border-default bg-bg-hover hover:bg-border-strong`} disabled:cursor-not-allowed disabled:opacity-50`,title:e.enabled?`Enabled — click to disable. The pool will stop claiming new tasks for this agent.`:`Disabled — click to enable. The pool will resume claiming tasks.`,children:[(0,J.jsxs)(`span`,{className:`sr-only`,children:[e.enabled?`Disable`:`Enable`,` `,e.name]}),(0,J.jsx)(`span`,{className:`pointer-events-none inline-block h-3 w-3 transform rounded-full bg-white shadow transition-transform ${e.enabled?`translate-x-3`:`translate-x-0.5`}`})]})]})}),(0,J.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,J.jsx)(`div`,{className:`font-medium text-fg-default`,children:e.name}),e.description&&(0,J.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:e.description})]}),(0,J.jsx)(`td`,{className:`px-3 py-2`,children:(0,J.jsx)(`code`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-[11px] text-fg-muted`,children:S(e.kind)})}),(0,J.jsx)(`td`,{className:`px-3 py-2`,children:e.source===`builtin`?(0,J.jsx)(`span`,{className:`rounded bg-indigo-950 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-indigo-300`,children:`builtin`}):(0,J.jsx)(`span`,{className:`rounded bg-bg-raised px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-fg-muted`,children:`user`})}),(0,J.jsx)(`td`,{className:`px-3 py-2 font-mono text-[11px] text-fg-muted`,children:e.modelId??`—`}),(0,J.jsx)(`td`,{className:`px-3 py-2 font-mono text-[11px] text-fg-faint`,children:e.builtinKey??e.id})]},`${e.id}-row`),t?(0,J.jsx)(`tr`,{className:`bg-bg-base`,children:(0,J.jsx)(`td`,{colSpan:6,className:`px-3 pb-4 pt-1`,children:(0,J.jsx)(ZI,{agent:e,slotUri:C(e),toolCatalog:i,skillCatalog:o})})},`${e.id}-detail`):null]})})]})})]})}var YI=new Set([`task_list`,`task_create`,`task_update`,`task_move`,`task_delete`,`task_get_history`]);function XI(e,t,n){return e?{kind:`explicit`,items:(n?e.filter(e=>!YI.has(e)):[...e]).sort()}:t===null?{kind:`unknown`}:{kind:`effective`,items:t.map(e=>e.name).filter(e=>n?!YI.has(e):!0).sort()}}function ZI({agent:e,slotUri:t,toolCatalog:n,skillCatalog:r}){let i=(0,d.useMemo)(()=>XI(e.toolsAllow,n,!0),[e.toolsAllow,n]),a=(0,d.useMemo)(()=>{if(e.effectiveSkills){let t=[...e.effectiveSkills].sort();return e.skills?{kind:`explicit`,items:t}:{kind:`effective`,items:t}}return XI(e.skills,r,!1)},[e.effectiveSkills,e.skills,r]);return(0,J.jsxs)(`div`,{className:`mt-1 space-y-3 rounded-md border border-border-subtle bg-bg-elevated/40 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-fg-faint`,children:[(0,J.jsxs)(`span`,{children:[`slot:`,` `,(0,J.jsx)(`code`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-fg-muted`,children:t})]}),e.modelId&&(0,J.jsxs)(`span`,{children:[`model:`,` `,(0,J.jsx)(`code`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-fg-muted`,children:e.modelId})]})]}),(0,J.jsx)(QI,{title:`Allowed tools`,data:i}),(0,J.jsx)(QI,{title:`Allowed skills`,data:a}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-fg-muted`,children:`System prompt (SOUL.md)`}),e.systemPrompt?(0,J.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap rounded bg-bg-base p-2 text-[11px] leading-relaxed text-fg-muted`,children:e.systemPrompt}):(0,J.jsx)(`div`,{className:`text-[11px] italic text-fg-faint`,children:`(none — worker uses the kind default)`})]})]})}function QI({title:e,data:t}){let n=null;return t.kind===`explicit`?n=(0,J.jsx)(`span`,{className:`rounded bg-emerald-950 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-success`,title:`agent.json declared this list explicitly`,children:`explicit`}):t.kind===`effective`&&(n=(0,J.jsx)(`span`,{className:`rounded bg-amber-950 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-warning`,title:`agent.json has no allow-list — worker sees every entry below`,children:`effective (no restriction)`})),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-fg-muted`,children:e}),t.kind!==`unknown`&&(0,J.jsx)(`span`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-[10px] text-fg-muted`,children:t.items.length}),n]}),t.kind===`unknown`?(0,J.jsx)(`div`,{className:`text-[11px] italic text-fg-faint`,children:`(catalog not loaded — reload the page)`}):t.items.length===0?(0,J.jsx)(`div`,{className:`text-[11px] italic text-fg-faint`,children:`(empty list — worker can call nothing)`}):(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.items.map(e=>(0,J.jsx)(`code`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e))})]})}function $I({open:e,onClose:t}){return e?(0,J.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-6`,onClick:t,children:(0,J.jsxs)(`div`,{className:`flex max-h-[85vh] w-full max-w-lg flex-col overflow-hidden rounded-lg border border-border-subtle bg-bg-base shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border-subtle px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg-default`,children:`Workboard configuration`}),(0,J.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,children:`Pool caps apply on the next run acquire. Worker type defaults (echo / llm) re-activate the plugin so changes take effect on the next request.`})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,className:`rounded p-1 text-fg-muted hover:bg-bg-raised hover:text-fg-default`,"aria-label":`Close configure dialog`,children:(0,J.jsx)(AP,{size:14})})]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 pt-3 [&>div>div>div:last-child]:sticky [&>div>div>div:last-child]:bottom-0 [&>div>div>div:last-child]:z-10 [&>div>div>div:last-child]:-mx-4 [&>div>div>div:last-child]:px-4 [&>div>div>div:last-child]:pb-3 [&>div>div>div:last-child]:bg-bg-base [&>div>div>div:last-child]:shadow-[0_-8px_8px_-8px_rgba(0,0,0,0.4)] `,children:(0,J.jsx)(uF,{pluginId:`workboard`})})]})}):null}var eL=`/api/p/workboard`,tL=`***`,nL=[{status:`ready`,label:`Ready`,color:`border-indigo-500/40 bg-indigo-500/5`,dot:`bg-indigo-400`},{status:`in_progress`,label:`In progress`,color:`border-amber-500/40 bg-amber-500/5`,dot:`bg-amber-400 animate-pulse`},{status:`done`,label:`Done`,color:`border-emerald-500/40 bg-emerald-500/5`,dot:`bg-emerald-400`}];async function rL(e){let t=await fetch(e,{credentials:`include`});if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return await t.json()}async function iL(e,t,n=`POST`){let r={method:n,credentials:`include`};n!==`DELETE`&&(r.headers={"Content-Type":`application/json`},r.body=JSON.stringify(t??{}));let i=await fetch(e,r);if(!i.ok){let e=`${i.status} ${i.statusText}`;try{let t=await i.json();t.error&&(e+=` (${t.error})`)}catch{}throw Error(e)}if(i.status!==204)return await i.json()}function aL(e){if(!e)return``;let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function oL(e,t){let n=e=>{let n=0;return t.includes(`ready`)&&(n+=e.ready),t.includes(`in_progress`)&&(n+=e.inProgress),t.includes(`done`)&&(n+=e.done),n},r=e.map(e=>({key:e.project,label:e.project,count:n(e)})).filter(e=>e.count>0),i=r.filter(e=>e.key!==tL).sort((e,t)=>e.label.localeCompare(t.label)),a=r.filter(e=>e.key===tL);return[...i,...a.map(e=>({...e,label:`Inbox`}))]}function sL(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(()=>new Map),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null),m=(0,d.useRef)(null),h=(0,d.useCallback)(async()=>{try{let t=new URLSearchParams;e.includeArchived&&t.set(`include_aborted`,`1`);let r=[rL(t.toString().length===0?`${eL}/tasks`:`${eL}/tasks?${t.toString()}`),rL(`${eL}/projects`),rL(`${eL}/agents`)];e.withWorker&&r.push(rL(`${eL}/workers/status`));let a=await Promise.all(r);n(a[0].tasks),i(a[1].projects);let s=a[2].agents;c(new Map(s.map(e=>[e.id,e.name]))),e.withWorker&&o(a[3]),u(null)}catch(e){u(e instanceof Error?e.message:String(e))}},[e.includeArchived,e.withWorker]);(0,d.useEffect)(()=>{h();let e=window.setInterval(()=>void h(),3e3);return()=>window.clearInterval(e)},[h]);let g=(0,d.useCallback)(async(e,t)=>{n(n=>n&&n.map(n=>n.id===e?{...n,status:t}:n)),p(e);try{await iL(`${eL}/tasks/${e}`,{status:t},`PATCH`)}catch(e){u(e instanceof Error?e.message:String(e))}finally{p(null),await h()}},[h]);return{tasks:t,projects:r,worker:a,agentNames:s,error:l,busyId:f,reload:h,moveTask:g,addTaskInColumn:(0,d.useCallback)(async(e,t)=>{try{let n=e.project&&e.project!==tL?e.project:void 0,r=(await iL(`${eL}/tasks`,{tasks:[{title:e.title,status:t,project:n,priority:e.priority||0,workerRole:e.workerRole||null,description:e.description||null}]}))?.results?.[0];if(r&&!r.ok)throw Error(r.error??`create_failed`);await h()}catch(e){u(e instanceof Error?e.message:String(e))}},[h]),patchTask:(0,d.useCallback)(async(e,t)=>{p(e);try{await iL(`${eL}/tasks/${e}`,t,`PATCH`)}catch(e){u(e instanceof Error?e.message:String(e))}finally{p(null),await h()}},[h]),deleteTask:(0,d.useCallback)(async e=>{p(e);try{let t=(await iL(`${eL}/tasks/delete`,{ids:[e]}))?.results?.[0];if(t&&!t.ok)throw Error(t.error??`delete_failed`)}catch(e){u(e instanceof Error?e.message:String(e))}finally{p(null),await h()}},[h]),bindDrag:(0,d.useCallback)(()=>({onDragStart:(e,t)=>{m.current=t,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},onDragEnd:()=>{m.current=null},onDrop:(e,n)=>{let r=m.current||e.dataTransfer.getData(`text/plain`);if(!r)return;let i=(t??[]).find(e=>e.id===r);!i||i.status===n||g(r,n)}}),[t,g])}}function cL(e){let t=sL({includeArchived:!1,withWorker:!1}),[n,r]=(0,d.useState)(``),i=(0,d.useMemo)(()=>t.tasks?n?t.tasks.filter(e=>(e.project||tL)===n):t.tasks:null,[t.tasks,n]),a=(0,d.useMemo)(()=>oL(t.projects,[`ready`,`in_progress`,`done`]),[t.projects]),o=t.bindDrag();return(0,J.jsxs)(`div`,{className:`flex flex-col h-full bg-bg-base text-fg-default`,children:[(0,J.jsxs)(`header`,{className:`flex items-center justify-between px-3 py-2 border-b border-border-subtle flex-shrink-0`,children:[(0,J.jsxs)(`h2`,{className:`flex items-center gap-1.5 font-semibold text-sm`,children:[(0,J.jsx)(Uv,{className:`w-4 h-4`}),` Tasks`]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void t.reload(),className:`text-[10px] uppercase tracking-wide text-fg-muted hover:text-fg-default`,children:`Refresh`})]}),a.length>1&&(0,J.jsx)(EL,{chips:a,active:n,onPick:r}),t.error&&(0,J.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] bg-red-900/40 border-b border-red-800 text-red-100 flex-shrink-0`,children:t.error}),(0,J.jsx)(`div`,{className:`flex-1 overflow-x-auto overflow-y-hidden`,children:t.tasks===null?(0,J.jsx)(`div`,{className:`flex items-center justify-center text-fg-faint py-8 h-full`,children:(0,J.jsx)(q,{className:`w-4 h-4 animate-spin`})}):(0,J.jsx)(`div`,{className:`flex gap-1.5 p-2 h-full items-stretch`,children:nL.map(e=>(0,J.jsx)(lL,{column:e,tasks:(i??[]).filter(t=>t.status===e.status).sort((t,n)=>e.status===`done`?n.createdAt-t.createdAt:t.createdAt-n.createdAt),busyId:t.busyId,compact:!0,onAddTask:r=>void t.addTaskInColumn({...r,project:r.project??n},e.status),projects:t.projects,workerRoles:SL,agentNames:t.agentNames,allTasks:t.tasks??[],onPatchTask:t.patchTask,onDragStart:o.onDragStart,onDragEnd:o.onDragEnd,onDrop:o.onDrop},e.status))})})]})}function lL({column:e,tasks:t,allTasks:n,busyId:r,compact:i,onAddTask:a,onPatchTask:o,projects:s,workerRoles:c,agentNames:l,onDragStart:u,onDragEnd:f,onDrop:p}){let[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1);return(0,J.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-[160px] rounded-lg border transition-colors ${g?`border-blue-500/60 bg-bg-elevated/80`:e.color}`,onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:t=>{t.preventDefault(),_(!1),p(t,e.status)},children:[(0,J.jsxs)(`header`,{className:`px-2 py-1.5 border-b border-border-subtle/60 flex items-center gap-1.5 sticky top-0`,children:[(0,J.jsx)(`span`,{className:`w-2 h-2 rounded-full ${e.dot}`}),(0,J.jsx)(`span`,{className:`${i?`text-[11px]`:`text-xs`} font-medium`,children:e.label}),(0,J.jsx)(`span`,{className:`ml-auto ${i?`text-[10px]`:`text-[11px]`} text-fg-faint`,children:t.length}),e.status===`ready`&&(0,J.jsx)(`button`,{type:`button`,title:`Add task`,onClick:()=>h(!0),className:`p-0.5 text-fg-fainter hover:text-fg-default rounded`,children:(0,J.jsx)(Gw,{className:`w-3 h-3`})})]}),(0,J.jsxs)(`ul`,{className:`flex-1 overflow-y-auto p-1.5 space-y-1.5 min-h-[40px]`,children:[t.map(e=>(0,J.jsx)(dL,{task:e,meta:uL(e,n),busy:r===e.id,compact:i,agentNames:l,onDragStart:u,onDragEnd:f,onPatch:o},e.id)),m&&(0,J.jsx)(CL,{projects:s,workerRoles:c,allTasks:n,onSubmit:e=>{a(e),h(!1)},onCancel:()=>h(!1)}),!m&&t.length===0&&(0,J.jsx)(`li`,{className:`text-center text-[10px] text-fg-fainter py-3 ${e.status===`ready`?`cursor-pointer hover:text-fg-muted`:``}`,onClick:e.status===`ready`?()=>h(!0):void 0,children:e.status===`ready`?`empty - click to add`:`empty`})]})]})}function uL(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[],i=[];for(let t of e.dependsOn??[]){let e=n.get(t);e&&(r.push(e),e.status!==`done`&&i.push(e))}let a=(e.dependsOn?.length??0)-r.length;return{deps:r,pendingDeps:i,blocked:e.status===`ready`&&(i.length>0||a>0)}}function dL({task:e,meta:t,busy:n,compact:r,agentNames:i,onDragStart:a,onDragEnd:o,onPatch:s}){let[c,l]=(0,d.useState)(!1),u=!!e.description?.trim()||!!e.resultSummary?.trim()||t.deps.length>0||!!e.sessionId||e.status===`in_progress`;return(0,J.jsxs)(`li`,{draggable:!0,onDragStart:t=>{t.currentTarget.style.opacity=`0.4`,a(t,e.id)},onDragEnd:e=>{e.currentTarget.style.opacity=`1`,o()},onClick:e=>{e.stopPropagation(),u&&l(e=>!e)},className:`rounded border bg-bg-elevated/60 hover:border-border-default ${t.blocked?`border-indigo-500/40`:`border-border-subtle`} ${u?`cursor-pointer`:`cursor-grab`} ${n?`opacity-60`:``}`,children:[(0,J.jsxs)(`div`,{className:`px-2 py-1.5 flex items-start gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[(0,J.jsx)(`span`,{className:`${r?`text-[11.5px]`:`text-xs`} font-medium text-fg-default break-words`,children:e.title}),e.priority>0&&(0,J.jsxs)(`span`,{className:`text-[9px] px-1 rounded bg-amber-900/50 text-amber-100`,children:[`p`,e.priority]}),e.workerAgentId&&(0,J.jsxs)(`span`,{className:`text-[9px] px-1 rounded bg-indigo-900/50 text-indigo-100`,title:`Assigned to ${e.workerAgentId} (slug)`,children:[`@`,i.get(e.workerAgentId)??e.workerAgentId]}),!e.workerAgentId&&e.workerRole&&(0,J.jsx)(`span`,{className:`text-[9px] px-1 rounded bg-bg-raised text-fg-muted`,title:`Legacy: dispatched by kind, not pinned to a slug`,children:e.workerRole}),e.project&&e.project!==tL&&(0,J.jsxs)(`span`,{className:`text-[9px] px-1 rounded bg-bg-raised text-fg-muted`,children:[`#`,e.project]}),(e.dependsOn?.length??0)>0&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] px-1 rounded border ${t.blocked?`text-indigo-200 bg-indigo-500/15 border-indigo-500/40`:`text-fg-muted bg-bg-hover/30 border-border-default`}`,title:t.blocked?`Waiting on: ${t.pendingDeps.map(e=>e.title).join(`, `)}`:`${t.deps.length} dependenc${t.deps.length===1?`y`:`ies`} satisfied`,children:[t.blocked?(0,J.jsx)(mb,{className:`w-2.5 h-2.5`}):(0,J.jsx)(Ly,{className:`w-2.5 h-2.5`}),t.blocked?`${t.pendingDeps.length}/${e.dependsOn.length}`:e.dependsOn.length]})]}),(e.labels??[]).includes(`awaiting-intervention`)&&(0,J.jsxs)(`div`,{className:`mt-1 flex items-start gap-1 rounded border border-rose-500/50 bg-rose-500/10 px-1.5 py-1 text-[10px] text-danger`,title:e.interventionReason??e.failureReason??``,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(SM,{className:`w-3 h-3 mt-px shrink-0`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words line-clamp-3`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`awaiting intervention`}),e.interventionAt?` (${jL(e.interventionAt)})`:``,e.interventionReason??e.failureReason?`: ${e.interventionReason??e.failureReason}`:``]}),(0,J.jsx)(`button`,{type:`button`,disabled:n,onClick:t=>{t.stopPropagation(),s(e.id,{labels:(e.labels??[]).filter(e=>e!==`awaiting-intervention`&&e!==`stalled`),attempts:0,failureReason:null,interventionReason:null,interventionAt:null})},className:`shrink-0 rounded border border-rose-500/40 px-1 py-px text-[9.5px] font-medium text-rose-100 hover:bg-rose-500/20 disabled:opacity-50`,children:`Retry`})]}),(e.labels??[]).includes(`stalled`)&&(0,J.jsxs)(`div`,{className:`mt-1 flex items-start gap-1 rounded border border-orange-500/40 bg-orange-500/5 px-1.5 py-1 text-[10px] text-orange-200`,title:e.failureReason??``,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(SM,{className:`w-3 h-3 mt-px shrink-0`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words line-clamp-3`,children:[`stalled`,(e.attempts??0)>0?` after ${e.attempts} attempts`:``,e.failureReason?`: ${e.failureReason}`:``]}),(0,J.jsx)(`button`,{type:`button`,disabled:n,onClick:t=>{t.stopPropagation(),s(e.id,{labels:(e.labels??[]).filter(e=>e!==`stalled`),attempts:0,failureReason:null})},className:`shrink-0 rounded border border-orange-500/40 px-1 py-px text-[9.5px] font-medium text-orange-100 hover:bg-orange-500/15 disabled:opacity-50`,children:`Retry`})]}),(e.labels??[]).includes(`draft`)&&(0,J.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`span`,{className:`inline-block rounded border border-yellow-500/40 bg-yellow-500/5 px-1.5 py-px text-[10px] text-yellow-200`,children:`draft - pool will skip`}),(0,J.jsx)(`button`,{type:`button`,disabled:n,onClick:t=>{t.stopPropagation(),s(e.id,{labels:(e.labels??[]).filter(e=>e!==`draft`)})},className:`rounded border border-yellow-500/40 px-1 py-px text-[9.5px] font-medium text-yellow-100 hover:bg-yellow-500/15 disabled:opacity-50`,children:`Publish`})]}),e.description&&!c&&(0,J.jsx)(`div`,{className:`text-[10.5px] text-fg-muted mt-0.5 line-clamp-2 whitespace-pre-line`,children:e.description}),e.resultSummary&&!c&&(0,J.jsxs)(`div`,{className:`${r?`text-[10px]`:`text-[10.5px]`} text-success/90 mt-0.5 italic line-clamp-2 whitespace-pre-line`,children:[`→ `,e.resultSummary]}),(0,J.jsxs)(`div`,{className:`text-[9.5px] text-fg-faint mt-0.5 flex items-center gap-1`,children:[(0,J.jsx)(fd,{className:`w-2.5 h-2.5`}),aL(e.endedAt??e.startedAt??e.createdAt)]})]}),u&&(0,J.jsx)(Al,{className:`w-3 h-3 mt-0.5 text-fg-faint shrink-0 transition-transform ${c?`rotate-180`:``}`}),n&&(0,J.jsx)(q,{className:`w-3 h-3 animate-spin text-fg-muted`})]}),c&&(0,J.jsxs)(`div`,{className:`px-2 pb-2 pt-0 border-t border-border-subtle/60 space-y-1.5`,onClick:e=>e.stopPropagation(),children:[e.description&&(0,J.jsx)(bL,{label:`Description`,children:(0,J.jsx)(`div`,{className:`text-[10.5px] text-fg-muted whitespace-pre-line break-words max-h-48 overflow-y-auto`,children:e.description})}),e.resultSummary&&(0,J.jsx)(bL,{label:`Result`,children:(0,J.jsxs)(`div`,{className:`text-[10.5px] text-success italic whitespace-pre-line break-words max-h-48 overflow-y-auto`,children:[`→ `,e.resultSummary]})}),e.resultFiles.length>0&&(0,J.jsx)(bL,{label:`Files (${e.resultFiles.length})`,children:(0,J.jsx)(`ul`,{className:`space-y-0.5`,children:e.resultFiles.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(xL,{path:e})},e))})}),t.deps.length>0&&(0,J.jsx)(bL,{label:`Depends on`,children:(0,J.jsx)(`ul`,{className:`space-y-0.5`,children:t.deps.map(e=>(0,J.jsxs)(`li`,{className:`text-[10px] flex items-center gap-1`,children:[e.status===`done`?(0,J.jsx)(Ql,{className:`w-2.5 h-2.5 text-success shrink-0`}):(0,J.jsx)(mb,{className:`w-2.5 h-2.5 text-indigo-400 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate ${e.status===`done`?`text-fg-muted line-through`:`text-indigo-200`}`,children:e.title}),(0,J.jsx)(`span`,{className:`ml-auto text-[9px] text-fg-fainter shrink-0`,children:e.status.replace(`_`,` `)})]},e.id))})}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-0 text-[9.5px] text-fg-faint pt-1`,children:[(0,J.jsxs)(`div`,{children:[`Created`,(0,J.jsx)(`span`,{className:`text-fg-muted`,children:new Date(e.createdAt).toLocaleString()})]}),e.startedAt&&(0,J.jsxs)(`div`,{children:[`Started`,(0,J.jsx)(`span`,{className:`text-fg-muted`,children:new Date(e.startedAt).toLocaleString()})]}),e.endedAt&&(0,J.jsxs)(`div`,{children:[`Ended`,(0,J.jsx)(`span`,{className:`text-fg-muted`,children:new Date(e.endedAt).toLocaleString()})]})]}),(0,J.jsx)(fL,{task:e})]})]})}function fL({task:e}){let[t,n]=(0,d.useState)(!1);return e.status===`in_progress`||e.sessionId?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`pt-1`,children:(0,J.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n(!0)},className:`inline-flex items-center gap-1.5 rounded border border-border-default px-1.5 py-0.5 text-[10px] text-fg-muted hover:border-border-strong hover:bg-bg-raised`,children:[(0,J.jsx)($E,{className:`w-3 h-3`}),`View transcript`,e.status===`in_progress`&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,J.jsx)(`span`,{className:`w-1 h-1 rounded-full bg-amber-400 animate-pulse`}),`live`]})]})}),t&&(0,J.jsx)(pL,{task:e,onClose:()=>n(!1)})]}):null}function pL({task:e,onClose:t}){let{Modal:n}=mF(),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(!0),m=(0,d.useCallback)(async()=>{if(e.id){o(!0);try{let t=await rL(`${eL}/tasks/${e.id}/history`);i(t.entries??[]),u(t.sessionId??null),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}}},[e.id]);(0,d.useEffect)(()=>{m()},[m]),(0,d.useEffect)(()=>{if(e.status!==`in_progress`)return;let t=setInterval(()=>void m(),3e3);return()=>clearInterval(t)},[e.status,m]),(0,d.useEffect)(()=>{if(!p.current)return;let e=f.current;e&&(e.scrollTop=e.scrollHeight)},[r]);let h=e=>{let t=e.currentTarget;p.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},g=(0,d.useMemo)(()=>mL(r??[]),[r]);return(0,J.jsx)(n,{isOpen:!0,onClose:t,title:e.title,size:`lg`,className:`bg-bg-base`,children:(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,onDragStart:e=>e.stopPropagation(),children:[(0,J.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border-subtle px-4 py-2 text-[10px] text-fg-faint`,children:[(0,J.jsx)($E,{className:`h-3.5 w-3.5 text-fg-faint`}),(0,J.jsx)(`span`,{children:`worker transcript`}),l&&(0,J.jsxs)(`span`,{className:`font-mono text-fg-fainter`,children:[`· `,l]}),e.status===`in_progress`&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[`·`,(0,J.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-amber-400`}),`tailing`]}),(0,J.jsx)(`div`,{className:`ml-auto`,children:(0,J.jsx)(`button`,{type:`button`,onClick:()=>void m(),disabled:a,className:`rounded p-1 text-fg-muted hover:bg-bg-raised hover:text-fg-default disabled:opacity-50`,title:`Refresh`,children:(0,J.jsx)(GT,{className:`h-3.5 w-3.5 ${a?`animate-spin`:``}`})})})]}),(0,J.jsxs)(`div`,{ref:f,onScroll:h,className:`flex-1 space-y-3 overflow-y-auto p-4`,children:[s&&(0,J.jsx)(`div`,{className:`rounded border border-rose-700/40 bg-rose-950/30 px-3 py-2 text-xs text-danger`,children:s}),r===null&&a&&(0,J.jsx)(`div`,{className:`text-xs italic text-fg-faint`,children:`Loading…`}),r!==null&&g.length===0&&!a&&(0,J.jsx)(`div`,{className:`text-xs italic text-fg-faint`,children:e.sessionId?`No messages yet.`:`Worker hasn't started yet.`}),g.map(e=>(0,J.jsx)(hL,{row:e},e.id))]})]})})}function mL(e){let t=new Map;for(let n of e)n.role===`tool`&&n.toolResult?.callId&&t.set(n.toolResult.callId,n.toolResult);let n=[];for(let r of e){if(r.role===`tool`)continue;let e=(r.toolCalls??[]).map(e=>({call:e,result:t.get(e.callId)}));n.push({id:r.id,createdAt:r.createdAt,role:r.role===`user`?`user`:r.role===`assistant`?`assistant`:`system`,text:r.text,calls:e})}return n}function hL({row:e}){let t=e.role===`user`;return(0,J.jsx)(`div`,{className:t?`flex justify-end`:`flex justify-start`,children:(0,J.jsxs)(`div`,{className:`flex max-w-[85%] flex-col ${t?`items-end`:`items-start`}`,children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-fg-faint`,children:[t?(0,J.jsx)(vN,{className:`h-3 w-3`}):(0,J.jsx)(Es,{className:`h-3 w-3 text-link`}),(0,J.jsx)(`span`,{children:t?`you`:e.role}),(0,J.jsx)(`span`,{className:`text-fg-fainter`,children:`·`}),(0,J.jsx)(`span`,{className:`text-fg-fainter`,children:new Date(e.createdAt).toLocaleTimeString()})]}),e.text&&(0,J.jsx)(`div`,{className:`whitespace-pre-line break-words rounded-lg border px-3 py-2 text-[13px] leading-relaxed ${t?`border-brand-400/30 bg-brand-500/10 text-fg-default`:`border-border-subtle bg-bg-elevated/60 text-fg-default`}`,children:e.text}),e.calls.length>0&&(0,J.jsx)(`div`,{className:`mt-1.5 flex flex-col gap-1 ${t?`items-end`:`items-start`}`,children:e.calls.map((e,t)=>(0,J.jsx)(gL,{...e},e.call.callId||`c${t}`))})]})})}function gL({call:e,result:t}){let[n,r]=(0,d.useState)(!1),i=!t,a=!!t&&t.ok===!1;return(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>!i&&r(e=>!e),className:`flex select-none items-center gap-1.5 py-0.5 text-xs ${i?`cursor-default text-fg-faint`:`cursor-pointer text-fg-faint hover:text-fg-muted`}`,children:[i?(0,J.jsx)(q,{className:`h-3 w-3 animate-spin text-warning`}):a?(0,J.jsx)(Mu,{className:`h-3 w-3 text-rose-400/70`}):(0,J.jsx)(Ql,{className:`h-3 w-3 text-emerald-500/60`}),(0,J.jsx)(`code`,{className:`font-mono text-[12px] text-link`,children:e.toolName}),(0,J.jsx)(`span`,{className:`font-mono text-[11px] text-fg-fainter`,children:_L(e.argsJson)}),i?(0,J.jsx)(`span`,{className:`text-[11px] text-fg-fainter`,children:`running…`}):n?(0,J.jsx)(Al,{className:`h-3 w-3 text-fg-fainter`}):(0,J.jsx)(Pl,{className:`h-3 w-3 text-fg-fainter`})]}),n&&t&&(0,J.jsx)(`pre`,{className:`mt-1 max-h-64 max-w-2xl overflow-auto whitespace-pre-wrap break-all rounded-md border px-3 py-2 text-[11px] ${a?`border-rose-700/40 bg-rose-950/30 text-danger`:`border-border-subtle/60 bg-bg-elevated/60 text-fg-muted`}`,children:yL(t.text||`(empty)`,4e3)})]})}function _L(e){if(!e)return`()`;let t;try{t=JSON.parse(e)}catch{return e.length>60?`(${e.slice(0,57)}…)`:`(${e})`}if(!t||typeof t!=`object`)return`(${e})`;let n=t,r=Object.keys(n);return r.length===0?`()`:r.slice(0,3).map(e=>`${e}=${vL(n[e])}`).join(` `)}function vL(e){return typeof e==`string`?e.length>40?`"${e.slice(0,37)}…"`:`"${e}"`:typeof e==`number`||typeof e==`boolean`||e==null?String(e):JSON.stringify(e).slice(0,40)}function yL(e,t){return e.length<=t?e:e.slice(0,t-1)+`
38
+ `;return typeof a==`function`&&a(null,p),p}})),RI=t(n((e=>{var t=dI(),n=PI(),r=II(),i=LI();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1),zI=`/api/p/wechat`;async function BI(e,t){return fetch(`${zI}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers??{}},...t})}function VI({status:e,detail:t}){let n={running:{label:`Connected`,tone:`bg-success/10 text-success border-success/30`},starting:{label:`Starting`,tone:`bg-warning/10 text-warning border-warning/30`},idle:{label:`Idle`,tone:`bg-bg-hover text-fg-muted border-border-default`},stopped:{label:`Stopped`,tone:`bg-bg-hover text-fg-muted border-border-default`},error:{label:`Error`,tone:`bg-danger/10 text-danger border-danger/30`}}[e];return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] ${n.tone}`,title:t??void 0,children:[e===`starting`&&(0,J.jsx)(q,{className:`h-3 w-3 animate-spin`}),n.label]})}function HI({onClose:e,onBound:t}){let{Modal:n}=mF(),[r,i]=(0,d.useState)(`model`),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)([]),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(``),v=(0,d.useRef)({cancelled:!1});(0,d.useEffect)(()=>((async()=>{try{let e=await(await fetch(`/api/models`,{credentials:`include`})).json(),t=(e.models??[]).map(e=>({id:e.id,displayName:e.displayName??e.label??e.id}));p(t),h(e.defaultModel??null),_(e.defaultModel??t[0]?.id??``)}catch{}})(),()=>{v.current.cancelled=!0}),[]);let y=(0,d.useCallback)(async()=>{i(`loading`);try{let e=await BI(`/login/start`,{method:`POST`,body:`{}`}),t=await e.json();if(!e.ok||!t.ok){c(t.error??`HTTP ${e.status}`),i(`error`);return}o(t),i(`qr`)}catch(e){c(e instanceof Error?e.message:String(e)),i(`error`)}},[]);return(0,d.useEffect)(()=>{if(r!==`qr`||!a)return;v.current={cancelled:!1};let e=v.current;return(async()=>{for(;!e.cancelled;)try{let t=await BI(`/login/poll`,{method:`POST`,body:JSON.stringify({qrcode:a.qrcode,modelId:g||void 0})}),n=await t.json();if(e.cancelled)return;if(!t.ok||!n.ok){c(n.error??`HTTP ${t.status}`),i(`error`);return}if(n.scanned&&n.binding){u(n.binding),i(`scanned`);return}await UI(1e3)}catch(t){if(e.cancelled)return;c(t instanceof Error?t.message:String(t)),i(`error`);return}})(),()=>{e.cancelled=!0}},[r,a]),(0,d.useEffect)(()=>{if(r!==`scanned`)return;t();let n=setTimeout(e,1500);return()=>clearTimeout(n)},[r,t,e]),(0,J.jsx)(n,{isOpen:!0,onClose:e,title:`Add WeChat account`,size:`sm`,children:(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-4 p-6`,children:[r===`model`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Choose which model this WeChat account routes to:`}),(0,J.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`w-full max-w-sm rounded-md border border-border-default bg-bg-elevated px-3 py-2 text-sm text-fg-default`,children:[f.length===0&&(0,J.jsx)(`option`,{value:``,children:`(no models registered)`}),f.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.displayName,m===e.id?` (default)`:``]},e.id))]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void y(),disabled:f.length===0||!g,className:`mt-2 inline-flex items-center gap-1.5 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-fg-on-accent hover:bg-accent-hover disabled:opacity-50`,children:`Continue → Scan QR`}),(0,J.jsx)(`div`,{className:`text-[11px] text-fg-fainter`,children:`You can change the model later by re-scanning.`})]}),r===`loading`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(q,{className:`h-6 w-6 animate-spin text-fg-faint`}),(0,J.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Requesting QR code…`})]}),r===`qr`&&a&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Scan with WeChat to authorise`}),(0,J.jsx)(WI,{value:a.qrCodeImageUrl}),(0,J.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:`Open WeChat → Scan → Confirm`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-fg-fainter`,children:[(0,J.jsx)(q,{className:`h-3 w-3 animate-spin`}),`waiting for scan…`]})]}),r===`scanned`&&l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ql,{className:`h-10 w-10 text-success`}),(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg-default`,children:`Connected`}),(0,J.jsx)(`div`,{className:`text-xs text-fg-muted`,children:l.displayName??l.config.username??`WeChat account`})]}),r===`error`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(AP,{className:`h-10 w-10 text-danger`}),(0,J.jsx)(`div`,{className:`text-sm text-fg-default`,children:`Login failed`}),(0,J.jsx)(`div`,{className:`max-w-xs break-words text-xs text-fg-muted`,children:s})]})]})})}function UI(e){return new Promise(t=>setTimeout(t,e))}function WI({value:e}){let t=(0,d.useId)(),n=(0,d.useRef)(null),[r,i]=(0,d.useState)(null);return(0,d.useEffect)(()=>{let t=!1,r=n.current;if(r)return i(null),RI.toCanvas(r,e,{width:224,margin:2,color:{dark:`#000000`,light:`#ffffff`},errorCorrectionLevel:`M`}).catch(e=>{t||i(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e]),r?(0,J.jsxs)(`div`,{className:`flex h-56 w-56 items-center justify-center rounded-md border border-danger/30 bg-danger/10 p-3 text-center text-xs text-danger`,children:[`QR render failed: `,r]}):(0,J.jsx)(`canvas`,{ref:n,"aria-label":`WeChat login QR`,id:`wechat-qr-${t}`,className:`h-56 w-56 rounded-md border border-border-default bg-white p-2`})}function GI(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),{setViewingSession:s}=yF(),c=(0,d.useCallback)(async()=>{try{let e=await BI(`/bindings`),t=await e.json();if(!e.ok||!t.ok){i(t.error??`HTTP ${e.status}`);return}i(null),n(t.bindings??[])}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,d.useEffect)(()=>{c()},[c]);let l=(0,d.useCallback)(async e=>{if(confirm(`Disconnect this WeChat account from tianshu? Existing chat history with this account will be deleted too.`))try{let t=await BI(`/bindings/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok){i((await t.json().catch(()=>({}))).error??`HTTP ${t.status}`);return}s(null),await c()}catch(e){i(e instanceof Error?e.message:String(e))}},[c,s]);return(0,J.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-6 text-fg-default`,children:[(0,J.jsxs)(`header`,{className:`mb-6 flex items-center justify-between border-b border-border-subtle pb-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(Fx,{className:`h-6 w-6 text-success`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`WeChat`}),(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Connect your WeChat so direct messages route to your agent.`})]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void c(),className:`rounded p-1.5 text-fg-muted hover:bg-bg-hover hover:text-fg-default`,title:`Refresh`,children:(0,J.jsx)(GT,{className:`h-4 w-4`})})]}),r&&(0,J.jsx)(`div`,{className:`mb-4 rounded-md border border-danger/30 bg-danger/10 px-3 py-2 text-sm text-danger`,children:r}),t===null?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,J.jsx)(q,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):t.length===0?(0,J.jsxs)(`div`,{className:`rounded-md border border-dashed border-border-default px-6 py-10 text-center`,children:[(0,J.jsx)(Fx,{className:`mx-auto mb-3 h-8 w-8 text-fg-fainter`}),(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg-default`,children:`No WeChat connected`}),(0,J.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:`Scan a QR with the WeChat app to start routing your direct messages through tianshu.`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`mt-4 inline-flex items-center gap-1.5 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-fg-on-accent hover:bg-accent-hover`,children:`Connect WeChat`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`One account connected. Re-scan to switch model or refresh the token.`}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`inline-flex items-center gap-1.5 rounded-md border border-border-default px-2.5 py-1 text-[11px] text-fg-muted hover:bg-bg-hover hover:text-fg-default`,children:[(0,J.jsx)(GT,{className:`h-3 w-3`}),`Re-scan`]})]}),(0,J.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center justify-between rounded-md border border-border-subtle bg-bg-elevated px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg-default`,children:e.displayName??e.config.username??`WeChat account`}),(0,J.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[11px] text-fg-faint`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:e.id}),(0,J.jsx)(VI,{status:e.status,detail:e.statusDetail}),typeof e.config.modelId==`string`&&e.config.modelId&&(0,J.jsx)(`span`,{className:`rounded bg-bg-hover px-1 py-px font-mono text-[10px] text-fg-muted`,title:`Model this binding routes inbound DMs to`,children:String(e.config.modelId)}),(0,J.jsxs)(`span`,{children:[`· bound `,new Date(e.createdAt).toLocaleDateString()]})]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void l(e.id),className:`rounded p-1.5 text-fg-muted hover:bg-danger/10 hover:text-danger`,title:`Disconnect`,children:(0,J.jsx)(pM,{className:`h-4 w-4`})})]},e.id))})]}),a&&(0,J.jsx)(HI,{onClose:()=>o(!1),onBound:()=>void c()})]})}function KI(e){let[t,n]=(0,d.useState)(null),{viewingSessionId:r,setViewingSession:i}=yF(),a=(0,d.useCallback)(async()=>{try{let e=await(await BI(`/sessions`)).json();e.ok&&n(e.sessions??[])}catch{}},[]);if((0,d.useEffect)(()=>{a();let e=SF(`channel_session_changed`,e=>{e.channelId===`wechat`&&a()}),t=setInterval(()=>void a(),3e4);return()=>{e(),clearInterval(t)}},[a]),t===null||t.length===0)return null;function o(e){if(!e)return`(untitled)`;let t=e.match(/^([^:]+):(dm|group):(.+)$/);if(!t)return e;let n=t[3].length>18?`${t[3].slice(0,16)}…`:t[3];return`${t[2]===`dm`?`DM`:`群`} · ${n}`}return(0,J.jsx)(J.Fragment,{children:t.map(e=>{let t=e.id===r;return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`flex w-full items-center gap-2 rounded-lg px-3 py-1.5 text-left transition-colors ${t?`bg-bg-hover text-fg-default border border-border-default`:`text-fg-muted hover:bg-bg-hover hover:text-fg-default border border-transparent`}`,title:e.title??e.channelChatId,children:[(0,J.jsx)(`span`,{className:`flex-shrink-0 rounded bg-success/15 px-1 py-px text-[9px] uppercase tracking-wider text-success`,children:`wechat`}),(0,J.jsx)(`span`,{className:`flex-1 truncate text-xs`,children:o(e.title)}),t&&(0,J.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-fg-faint`,children:`active`})]},e.id)})})}var qI={components:{WeChatAdminPage:GI,WeChatSidebarSection:KI}};qI.components;function JI(){let[e,t]=(0,d.useState)([]),[n,r]=(0,d.useState)([]),[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(()=>new Set),_=(0,d.useCallback)(e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[v,y]=(0,d.useState)(null),b=(0,d.useCallback)(async(e,n)=>{y(e),f(null);try{let r=await fetch(`/api/p/workboard/agents/${encodeURIComponent(e)}/enabled`,{method:`PATCH`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:!n})});if(!r.ok){let t=await r.text().catch(()=>``);f(`PATCH /agents/${e}/enabled → HTTP ${r.status}${t?`: `+t:``}`);return}t(t=>t.map(t=>t.id===e?{...t,enabled:!n}:t))}catch(e){f(e instanceof Error?e.message:String(e))}finally{y(null)}},[]),x=(0,d.useCallback)(async()=>{l(!0),f(null);try{let[e,n,i]=await Promise.all([fetch(`/api/p/workboard/agents`,{credentials:`include`}),fetch(`/api/tools`,{credentials:`include`}),fetch(`/api/skills`,{credentials:`include`})]);if(!e.ok){f(`GET /agents → HTTP ${e.status}`);return}let o=await e.json();t(o.agents),r(o.kinds),n.ok&&a((await n.json()).tools??[]),i.ok&&s((await i.json()).skills??[])}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[]);(0,d.useEffect)(()=>{x()},[x]);let S=e=>n.find(t=>t.id===e)?.displayName??e,C=e=>`tenant-config:///workers/${e.builtinKey??e.id}/`;return(0,J.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6`,children:[(0,J.jsxs)(`div`,{className:`mb-4 rounded-md border border-amber-900/40 bg-amber-950/30 px-3 py-2 text-[12px] leading-relaxed text-amber-200/90`,children:[(0,J.jsx)(`div`,{className:`font-semibold text-amber-100`,children:`Read-only listing — edit on disk`}),(0,J.jsxs)(`p`,{className:`mt-1 text-amber-200/70`,children:[`Worker config lives at`,` `,(0,J.jsx)(`code`,{className:`rounded bg-amber-950/60 px-1 py-0.5 text-amber-100`,children:`_tenant/config/workers/<slug>/`}),`. Each worker is a directory with`,` `,(0,J.jsx)(`code`,{className:`text-amber-100`,children:`agent.json`}),` and an optional`,` `,(0,J.jsx)(`code`,{className:`text-amber-100`,children:`SOUL.md`}),` /`,` `,(0,J.jsx)(`code`,{className:`text-amber-100`,children:`skills/`}),`. Edit the files directly, or ask the chat agent to do it via`,` `,(0,J.jsx)(`code`,{className:`text-amber-100`,children:`tenant_config_write`}),`. Pool picks up changes on next activate; a fs watcher follow-up will make this live.`]})]}),(0,J.jsxs)(`div`,{className:`mb-6 flex items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold text-fg-default`,children:[(0,J.jsx)(Es,{size:18,className:`text-brand-400`}),`Worker agents`]}),(0,J.jsx)(`p`,{className:`mt-1 max-w-3xl text-[12px] leading-relaxed text-fg-faint`,children:`Inventory the workboard pool currently sees. Filesystem rows shadow same-slug DB rows; legacy DB rows still present here haven't been edited or aren't yet picked up by the merger.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>m(!0),className:`flex items-center gap-1 rounded-md border border-border-default px-2.5 py-1.5 text-[12px] text-fg-muted hover:bg-bg-raised`,title:`Edit pool concurrency caps and worker type defaults`,children:[(0,J.jsx)(vD,{size:12}),`Configure`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>void x(),disabled:c,className:`flex items-center gap-1 rounded-md border border-border-default px-2.5 py-1.5 text-[12px] text-fg-muted hover:bg-bg-raised disabled:opacity-50`,title:`Reload`,children:[(0,J.jsx)(GT,{size:12,className:c?`animate-spin`:``}),`Reload`]})]})]}),(0,J.jsx)($I,{open:p,onClose:()=>m(!1)}),u&&(0,J.jsx)(`div`,{className:`mb-4 rounded-md border border-red-900/40 bg-red-950/40 px-3 py-2 text-[12px] text-red-300`,children:u}),(0,J.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border-subtle`,children:(0,J.jsxs)(`table`,{className:`min-w-full divide-y divide-gray-800 text-[12px]`,children:[(0,J.jsx)(`thead`,{className:`bg-bg-elevated/60 text-[11px] font-semibold uppercase tracking-wide text-fg-muted`,children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`State`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Name`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Kind`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Source`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Model`}),(0,J.jsx)(`th`,{className:`px-3 py-2 text-left`,children:`Slug`})]})}),(0,J.jsx)(`tbody`,{className:`divide-y divide-gray-800`,children:e.length===0?(0,J.jsx)(`tr`,{children:(0,J.jsx)(`td`,{colSpan:6,className:`px-3 py-8 text-center text-fg-faint`,children:c?`Loading…`:`No worker agents.`})}):e.flatMap(e=>{let t=h.has(e.id);return[(0,J.jsxs)(`tr`,{className:`cursor-pointer hover:bg-bg-elevated/40`,onClick:()=>_(e.id),children:[(0,J.jsx)(`td`,{className:`px-3 py-2`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t?(0,J.jsx)(Al,{size:12,className:`text-fg-faint`}):(0,J.jsx)(Pl,{size:12,className:`text-fg-faint`}),(0,J.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,disabled:v===e.id,onClick:t=>{t.stopPropagation(),b(e.id,e.enabled)},className:`relative inline-flex h-4 w-7 shrink-0 cursor-pointer items-center rounded-full border transition-colors ${e.enabled?`border-emerald-500/60 bg-emerald-500/80 hover:bg-emerald-500`:`border-border-default bg-bg-hover hover:bg-border-strong`} disabled:cursor-not-allowed disabled:opacity-50`,title:e.enabled?`Enabled — click to disable. The pool will stop claiming new tasks for this agent.`:`Disabled — click to enable. The pool will resume claiming tasks.`,children:[(0,J.jsxs)(`span`,{className:`sr-only`,children:[e.enabled?`Disable`:`Enable`,` `,e.name]}),(0,J.jsx)(`span`,{className:`pointer-events-none inline-block h-3 w-3 transform rounded-full bg-white shadow transition-transform ${e.enabled?`translate-x-3`:`translate-x-0.5`}`})]})]})}),(0,J.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,J.jsx)(`div`,{className:`font-medium text-fg-default`,children:e.name}),e.description&&(0,J.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:e.description})]}),(0,J.jsx)(`td`,{className:`px-3 py-2`,children:(0,J.jsx)(`code`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-[11px] text-fg-muted`,children:S(e.kind)})}),(0,J.jsx)(`td`,{className:`px-3 py-2`,children:e.source===`builtin`?(0,J.jsx)(`span`,{className:`rounded bg-indigo-950 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-indigo-300`,children:`builtin`}):(0,J.jsx)(`span`,{className:`rounded bg-bg-raised px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-fg-muted`,children:`user`})}),(0,J.jsx)(`td`,{className:`px-3 py-2 font-mono text-[11px] text-fg-muted`,children:e.modelId??`—`}),(0,J.jsx)(`td`,{className:`px-3 py-2 font-mono text-[11px] text-fg-faint`,children:e.builtinKey??e.id})]},`${e.id}-row`),t?(0,J.jsx)(`tr`,{className:`bg-bg-base`,children:(0,J.jsx)(`td`,{colSpan:6,className:`px-3 pb-4 pt-1`,children:(0,J.jsx)(ZI,{agent:e,slotUri:C(e),toolCatalog:i,skillCatalog:o})})},`${e.id}-detail`):null]})})]})})]})}var YI=new Set([`task_list`,`task_create`,`task_update`,`task_move`,`task_delete`,`task_get_history`]);function XI(e,t,n){return e?{kind:`explicit`,items:(n?e.filter(e=>!YI.has(e)):[...e]).sort()}:t===null?{kind:`unknown`}:{kind:`effective`,items:t.map(e=>e.name).filter(e=>n?!YI.has(e):!0).sort()}}function ZI({agent:e,slotUri:t,toolCatalog:n,skillCatalog:r}){let i=(0,d.useMemo)(()=>XI(e.toolsAllow,n,!0),[e.toolsAllow,n]),a=(0,d.useMemo)(()=>{if(e.effectiveSkills){let t=[...e.effectiveSkills].sort();return e.skills?{kind:`explicit`,items:t}:{kind:`effective`,items:t}}return XI(e.skills,r,!1)},[e.effectiveSkills,e.skills,r]);return(0,J.jsxs)(`div`,{className:`mt-1 space-y-3 rounded-md border border-border-subtle bg-bg-elevated/40 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-fg-faint`,children:[(0,J.jsxs)(`span`,{children:[`slot:`,` `,(0,J.jsx)(`code`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-fg-muted`,children:t})]}),e.modelId&&(0,J.jsxs)(`span`,{children:[`model:`,` `,(0,J.jsx)(`code`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-fg-muted`,children:e.modelId})]})]}),(0,J.jsx)(QI,{title:`Allowed tools`,data:i}),(0,J.jsx)(QI,{title:`Allowed skills`,data:a}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-fg-muted`,children:`System prompt (SOUL.md)`}),e.systemPrompt?(0,J.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap rounded bg-bg-base p-2 text-[11px] leading-relaxed text-fg-muted`,children:e.systemPrompt}):(0,J.jsx)(`div`,{className:`text-[11px] italic text-fg-faint`,children:`(none — worker uses the kind default)`})]})]})}function QI({title:e,data:t}){let n=null;return t.kind===`explicit`?n=(0,J.jsx)(`span`,{className:`rounded bg-emerald-950 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-success`,title:`agent.json declared this list explicitly`,children:`explicit`}):t.kind===`effective`&&(n=(0,J.jsx)(`span`,{className:`rounded bg-amber-950 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-warning`,title:`agent.json has no allow-list — worker sees every entry below`,children:`effective (no restriction)`})),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-fg-muted`,children:e}),t.kind!==`unknown`&&(0,J.jsx)(`span`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-[10px] text-fg-muted`,children:t.items.length}),n]}),t.kind===`unknown`?(0,J.jsx)(`div`,{className:`text-[11px] italic text-fg-faint`,children:`(catalog not loaded — reload the page)`}):t.items.length===0?(0,J.jsx)(`div`,{className:`text-[11px] italic text-fg-faint`,children:`(empty list — worker can call nothing)`}):(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.items.map(e=>(0,J.jsx)(`code`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e))})]})}function $I({open:e,onClose:t}){return e?(0,J.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-black/60 p-6`,onClick:t,children:(0,J.jsxs)(`div`,{className:`flex max-h-[85vh] w-full max-w-lg flex-col overflow-hidden rounded-lg border border-border-subtle bg-bg-base shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border-subtle px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg-default`,children:`Workboard configuration`}),(0,J.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,children:`Pool caps apply on the next run acquire. Worker type defaults (echo / llm) re-activate the plugin so changes take effect on the next request.`})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,className:`rounded p-1 text-fg-muted hover:bg-bg-raised hover:text-fg-default`,"aria-label":`Close configure dialog`,children:(0,J.jsx)(AP,{size:14})})]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 pt-3 [&>div>div>div:last-child]:sticky [&>div>div>div:last-child]:bottom-0 [&>div>div>div:last-child]:z-10 [&>div>div>div:last-child]:-mx-4 [&>div>div>div:last-child]:px-4 [&>div>div>div:last-child]:pb-3 [&>div>div>div:last-child]:bg-bg-base [&>div>div>div:last-child]:shadow-[0_-8px_8px_-8px_rgba(0,0,0,0.4)] `,children:(0,J.jsx)(uF,{pluginId:`workboard`})})]})}):null}var eL=`/api/p/workboard`,tL=`***`,nL=[{status:`ready`,label:`Ready`,color:`border-indigo-500/40 bg-indigo-500/5`,dot:`bg-indigo-400`},{status:`in_progress`,label:`In progress`,color:`border-amber-500/40 bg-amber-500/5`,dot:`bg-amber-400 animate-pulse`},{status:`done`,label:`Done`,color:`border-emerald-500/40 bg-emerald-500/5`,dot:`bg-emerald-400`}];async function rL(e){let t=await fetch(e,{credentials:`include`});if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return await t.json()}async function iL(e,t,n=`POST`){let r={method:n,credentials:`include`};n!==`DELETE`&&(r.headers={"Content-Type":`application/json`},r.body=JSON.stringify(t??{}));let i=await fetch(e,r);if(!i.ok){let e=`${i.status} ${i.statusText}`;try{let t=await i.json();t.error&&(e+=` (${t.error})`)}catch{}throw Error(e)}if(i.status!==204)return await i.json()}function aL(e){if(!e)return``;let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function oL(e,t){let n=e=>{let n=0;return t.includes(`ready`)&&(n+=e.ready),t.includes(`in_progress`)&&(n+=e.inProgress),t.includes(`done`)&&(n+=e.done),n},r=e.map(e=>({key:e.project,label:e.project,count:n(e)})).filter(e=>e.count>0),i=r.filter(e=>e.key!==tL).sort((e,t)=>e.label.localeCompare(t.label)),a=r.filter(e=>e.key===tL);return[...i,...a.map(e=>({...e,label:`Inbox`}))]}function sL(e){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(()=>new Map),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null),m=(0,d.useRef)(null),h=(0,d.useCallback)(async()=>{try{let t=new URLSearchParams;e.includeArchived&&t.set(`include_aborted`,`1`);let r=[rL(t.toString().length===0?`${eL}/tasks`:`${eL}/tasks?${t.toString()}`),rL(`${eL}/projects`),rL(`${eL}/agents`)];e.withWorker&&r.push(rL(`${eL}/workers/status`));let a=await Promise.all(r);n(a[0].tasks),i(a[1].projects);let s=a[2].agents;c(new Map(s.map(e=>[e.id,e.name]))),e.withWorker&&o(a[3]),u(null)}catch(e){u(e instanceof Error?e.message:String(e))}},[e.includeArchived,e.withWorker]);(0,d.useEffect)(()=>{h();let e=window.setInterval(()=>void h(),3e3);return()=>window.clearInterval(e)},[h]);let g=(0,d.useCallback)(async(e,t)=>{n(n=>n&&n.map(n=>n.id===e?{...n,status:t}:n)),p(e);try{await iL(`${eL}/tasks/${e}`,{status:t},`PATCH`)}catch(e){u(e instanceof Error?e.message:String(e))}finally{p(null),await h()}},[h]);return{tasks:t,projects:r,worker:a,agentNames:s,error:l,busyId:f,reload:h,moveTask:g,addTaskInColumn:(0,d.useCallback)(async(e,t)=>{try{let n=e.project&&e.project!==tL?e.project:void 0,r=(await iL(`${eL}/tasks`,{tasks:[{title:e.title,status:t,project:n,priority:e.priority||0,workerRole:e.workerRole||null,description:e.description||null}]}))?.results?.[0];if(r&&!r.ok)throw Error(r.error??`create_failed`);await h()}catch(e){u(e instanceof Error?e.message:String(e))}},[h]),patchTask:(0,d.useCallback)(async(e,t)=>{p(e);try{await iL(`${eL}/tasks/${e}`,t,`PATCH`)}catch(e){u(e instanceof Error?e.message:String(e))}finally{p(null),await h()}},[h]),deleteTask:(0,d.useCallback)(async e=>{p(e);try{let t=(await iL(`${eL}/tasks/delete`,{ids:[e]}))?.results?.[0];if(t&&!t.ok)throw Error(t.error??`delete_failed`)}catch(e){u(e instanceof Error?e.message:String(e))}finally{p(null),await h()}},[h]),bindDrag:(0,d.useCallback)(()=>({onDragStart:(e,t)=>{m.current=t,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},onDragEnd:()=>{m.current=null},onDrop:(e,n)=>{let r=m.current||e.dataTransfer.getData(`text/plain`);if(!r)return;let i=(t??[]).find(e=>e.id===r);!i||i.status===n||g(r,n)}}),[t,g])}}function cL(e){let t=sL({includeArchived:!1,withWorker:!1}),[n,r]=(0,d.useState)(``),i=(0,d.useMemo)(()=>t.tasks?n?t.tasks.filter(e=>(e.project||tL)===n):t.tasks:null,[t.tasks,n]),a=(0,d.useMemo)(()=>oL(t.projects,[`ready`,`in_progress`,`done`]),[t.projects]),o=t.bindDrag();return(0,J.jsxs)(`div`,{className:`flex flex-col h-full bg-bg-base text-fg-default`,children:[(0,J.jsxs)(`header`,{className:`flex items-center justify-between px-3 py-2 border-b border-border-subtle flex-shrink-0`,children:[(0,J.jsxs)(`h2`,{className:`flex items-center gap-1.5 font-semibold text-sm`,children:[(0,J.jsx)(Uv,{className:`w-4 h-4`}),` Tasks`]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void t.reload(),className:`text-[10px] uppercase tracking-wide text-fg-muted hover:text-fg-default`,children:`Refresh`})]}),a.length>1&&(0,J.jsx)(EL,{chips:a,active:n,onPick:r}),t.error&&(0,J.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] bg-red-900/40 border-b border-red-800 text-red-100 flex-shrink-0`,children:t.error}),(0,J.jsx)(`div`,{className:`flex-1 overflow-x-auto overflow-y-hidden`,children:t.tasks===null?(0,J.jsx)(`div`,{className:`flex items-center justify-center text-fg-faint py-8 h-full`,children:(0,J.jsx)(q,{className:`w-4 h-4 animate-spin`})}):(0,J.jsx)(`div`,{className:`flex gap-1.5 p-2 h-full items-stretch`,children:nL.map(e=>(0,J.jsx)(lL,{column:e,tasks:(i??[]).filter(t=>t.status===e.status).sort((t,n)=>e.status===`done`?n.createdAt-t.createdAt:t.createdAt-n.createdAt),busyId:t.busyId,compact:!0,onAddTask:r=>void t.addTaskInColumn({...r,project:r.project??n},e.status),projects:t.projects,workerRoles:SL,agentNames:t.agentNames,allTasks:t.tasks??[],onPatchTask:t.patchTask,onDragStart:o.onDragStart,onDragEnd:o.onDragEnd,onDrop:o.onDrop},e.status))})})]})}function lL({column:e,tasks:t,allTasks:n,busyId:r,compact:i,onAddTask:a,onPatchTask:o,projects:s,workerRoles:c,agentNames:l,onDragStart:u,onDragEnd:f,onDrop:p}){let[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1);return(0,J.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-[160px] rounded-lg border transition-colors ${g?`border-blue-500/60 bg-bg-elevated/80`:e.color}`,onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:t=>{t.preventDefault(),_(!1),p(t,e.status)},children:[(0,J.jsxs)(`header`,{className:`px-2 py-1.5 border-b border-border-subtle/60 flex items-center gap-1.5 sticky top-0`,children:[(0,J.jsx)(`span`,{className:`w-2 h-2 rounded-full ${e.dot}`}),(0,J.jsx)(`span`,{className:`${i?`text-[11px]`:`text-xs`} font-medium`,children:e.label}),(0,J.jsx)(`span`,{className:`ml-auto ${i?`text-[10px]`:`text-[11px]`} text-fg-faint`,children:t.length}),e.status===`ready`&&(0,J.jsx)(`button`,{type:`button`,title:`Add task`,onClick:()=>h(!0),className:`p-0.5 text-fg-fainter hover:text-fg-default rounded`,children:(0,J.jsx)(Gw,{className:`w-3 h-3`})})]}),(0,J.jsxs)(`ul`,{className:`flex-1 overflow-y-auto p-1.5 space-y-1.5 min-h-[40px]`,children:[t.map(e=>(0,J.jsx)(dL,{task:e,meta:uL(e,n),busy:r===e.id,compact:i,agentNames:l,onDragStart:u,onDragEnd:f,onPatch:o},e.id)),m&&(0,J.jsx)(CL,{projects:s,workerRoles:c,allTasks:n,onSubmit:e=>{a(e),h(!1)},onCancel:()=>h(!1)}),!m&&t.length===0&&(0,J.jsx)(`li`,{className:`text-center text-[10px] text-fg-fainter py-3 ${e.status===`ready`?`cursor-pointer hover:text-fg-muted`:``}`,onClick:e.status===`ready`?()=>h(!0):void 0,children:e.status===`ready`?`empty - click to add`:`empty`})]})]})}function uL(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[],i=[];for(let t of e.dependsOn??[]){let e=n.get(t);e&&(r.push(e),e.status!==`done`&&i.push(e))}let a=(e.dependsOn?.length??0)-r.length;return{deps:r,pendingDeps:i,blocked:e.status===`ready`&&(i.length>0||a>0)}}function dL({task:e,meta:t,busy:n,compact:r,agentNames:i,onDragStart:a,onDragEnd:o,onPatch:s}){let[c,l]=(0,d.useState)(!1),u=!!e.description?.trim()||!!e.resultSummary?.trim()||t.deps.length>0||!!e.sessionId||e.status===`in_progress`;return(0,J.jsxs)(`li`,{draggable:!0,onDragStart:t=>{t.currentTarget.style.opacity=`0.4`,a(t,e.id)},onDragEnd:e=>{e.currentTarget.style.opacity=`1`,o()},onClick:e=>{e.stopPropagation(),u&&l(e=>!e)},className:`rounded border bg-bg-elevated/60 hover:border-border-default ${t.blocked?`border-indigo-500/40`:`border-border-subtle`} ${u?`cursor-pointer`:`cursor-grab`} ${n?`opacity-60`:``}`,children:[(0,J.jsxs)(`div`,{className:`px-2 py-1.5 flex items-start gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[(0,J.jsx)(`span`,{className:`${r?`text-[11.5px]`:`text-xs`} font-medium text-fg-default break-words`,children:e.title}),e.priority>0&&(0,J.jsxs)(`span`,{className:`text-[9px] px-1 rounded bg-amber-900/50 text-amber-100`,children:[`p`,e.priority]}),e.workerAgentId&&(0,J.jsxs)(`span`,{className:`text-[9px] px-1 rounded bg-indigo-900/50 text-indigo-100`,title:`Assigned to ${e.workerAgentId} (slug)`,children:[`@`,i.get(e.workerAgentId)??e.workerAgentId]}),!e.workerAgentId&&e.workerRole&&(0,J.jsx)(`span`,{className:`text-[9px] px-1 rounded bg-bg-raised text-fg-muted`,title:`Legacy: dispatched by kind, not pinned to a slug`,children:e.workerRole}),e.project&&e.project!==tL&&(0,J.jsxs)(`span`,{className:`text-[9px] px-1 rounded bg-bg-raised text-fg-muted`,children:[`#`,e.project]}),(e.dependsOn?.length??0)>0&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] px-1 rounded border ${t.blocked?`text-indigo-200 bg-indigo-500/15 border-indigo-500/40`:`text-fg-muted bg-bg-hover/30 border-border-default`}`,title:t.blocked?`Waiting on: ${t.pendingDeps.map(e=>e.title).join(`, `)}`:`${t.deps.length} dependenc${t.deps.length===1?`y`:`ies`} satisfied`,children:[t.blocked?(0,J.jsx)(mb,{className:`w-2.5 h-2.5`}):(0,J.jsx)(Ly,{className:`w-2.5 h-2.5`}),t.blocked?`${t.pendingDeps.length}/${e.dependsOn.length}`:e.dependsOn.length]})]}),(e.labels??[]).includes(`awaiting-intervention`)&&(0,J.jsxs)(`div`,{className:`mt-1 flex items-start gap-1 rounded border border-rose-500/50 bg-rose-500/10 px-1.5 py-1 text-[10px] text-danger`,title:e.interventionReason??e.failureReason??``,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(SM,{className:`w-3 h-3 mt-px shrink-0`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words line-clamp-3`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`awaiting intervention`}),e.interventionAt?` (${jL(e.interventionAt)})`:``,e.interventionReason??e.failureReason?`: ${e.interventionReason??e.failureReason}`:``]}),(0,J.jsx)(`button`,{type:`button`,disabled:n,onClick:t=>{t.stopPropagation(),s(e.id,{labels:(e.labels??[]).filter(e=>e!==`awaiting-intervention`&&e!==`stalled`),attempts:0,failureReason:null,interventionReason:null,interventionAt:null})},className:`shrink-0 rounded bg-rose-600 px-1.5 py-px text-[9.5px] font-medium text-white hover:bg-rose-500 disabled:opacity-50`,children:`Retry`})]}),(e.labels??[]).includes(`stalled`)&&(0,J.jsxs)(`div`,{className:`mt-1 flex items-start gap-1 rounded border border-orange-500/40 bg-orange-500/5 px-1.5 py-1 text-[10px] text-orange-200`,title:e.failureReason??``,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(SM,{className:`w-3 h-3 mt-px shrink-0`}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words line-clamp-3`,children:[`stalled`,(e.attempts??0)>0?` after ${e.attempts} attempts`:``,e.failureReason?`: ${e.failureReason}`:``]}),(0,J.jsx)(`button`,{type:`button`,disabled:n,onClick:t=>{t.stopPropagation(),s(e.id,{labels:(e.labels??[]).filter(e=>e!==`stalled`),attempts:0,failureReason:null})},className:`shrink-0 rounded bg-orange-600 px-1.5 py-px text-[9.5px] font-medium text-white hover:bg-orange-500 disabled:opacity-50`,children:`Retry`})]}),(e.labels??[]).includes(`draft`)&&(0,J.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`span`,{className:`inline-block rounded border border-yellow-500/40 bg-yellow-500/5 px-1.5 py-px text-[10px] text-yellow-200`,children:`draft - pool will skip`}),(0,J.jsx)(`button`,{type:`button`,disabled:n,onClick:t=>{t.stopPropagation(),s(e.id,{labels:(e.labels??[]).filter(e=>e!==`draft`)})},className:`rounded border border-yellow-500/40 px-1 py-px text-[9.5px] font-medium text-yellow-100 hover:bg-yellow-500/15 disabled:opacity-50`,children:`Publish`})]}),e.description&&!c&&(0,J.jsx)(`div`,{className:`text-[10.5px] text-fg-muted mt-0.5 line-clamp-2 whitespace-pre-line`,children:e.description}),e.resultSummary&&!c&&(0,J.jsxs)(`div`,{className:`${r?`text-[10px]`:`text-[10.5px]`} text-success/90 mt-0.5 italic line-clamp-2 whitespace-pre-line`,children:[`→ `,e.resultSummary]}),(0,J.jsxs)(`div`,{className:`text-[9.5px] text-fg-faint mt-0.5 flex items-center gap-1`,children:[(0,J.jsx)(fd,{className:`w-2.5 h-2.5`}),aL(e.endedAt??e.startedAt??e.createdAt)]})]}),u&&(0,J.jsx)(Al,{className:`w-3 h-3 mt-0.5 text-fg-faint shrink-0 transition-transform ${c?`rotate-180`:``}`}),n&&(0,J.jsx)(q,{className:`w-3 h-3 animate-spin text-fg-muted`})]}),c&&(0,J.jsxs)(`div`,{className:`px-2 pb-2 pt-0 border-t border-border-subtle/60 space-y-1.5`,onClick:e=>e.stopPropagation(),children:[e.description&&(0,J.jsx)(bL,{label:`Description`,children:(0,J.jsx)(`div`,{className:`text-[10.5px] text-fg-muted whitespace-pre-line break-words max-h-48 overflow-y-auto`,children:e.description})}),e.resultSummary&&(0,J.jsx)(bL,{label:`Result`,children:(0,J.jsxs)(`div`,{className:`text-[10.5px] text-success italic whitespace-pre-line break-words max-h-48 overflow-y-auto`,children:[`→ `,e.resultSummary]})}),e.resultFiles.length>0&&(0,J.jsx)(bL,{label:`Files (${e.resultFiles.length})`,children:(0,J.jsx)(`ul`,{className:`space-y-0.5`,children:e.resultFiles.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(xL,{path:e})},e))})}),t.deps.length>0&&(0,J.jsx)(bL,{label:`Depends on`,children:(0,J.jsx)(`ul`,{className:`space-y-0.5`,children:t.deps.map(e=>(0,J.jsxs)(`li`,{className:`text-[10px] flex items-center gap-1`,children:[e.status===`done`?(0,J.jsx)(Ql,{className:`w-2.5 h-2.5 text-success shrink-0`}):(0,J.jsx)(mb,{className:`w-2.5 h-2.5 text-indigo-400 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate ${e.status===`done`?`text-fg-muted line-through`:`text-indigo-200`}`,children:e.title}),(0,J.jsx)(`span`,{className:`ml-auto text-[9px] text-fg-fainter shrink-0`,children:e.status.replace(`_`,` `)})]},e.id))})}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-0 text-[9.5px] text-fg-faint pt-1`,children:[(0,J.jsxs)(`div`,{children:[`Created`,(0,J.jsx)(`span`,{className:`text-fg-muted`,children:new Date(e.createdAt).toLocaleString()})]}),e.startedAt&&(0,J.jsxs)(`div`,{children:[`Started`,(0,J.jsx)(`span`,{className:`text-fg-muted`,children:new Date(e.startedAt).toLocaleString()})]}),e.endedAt&&(0,J.jsxs)(`div`,{children:[`Ended`,(0,J.jsx)(`span`,{className:`text-fg-muted`,children:new Date(e.endedAt).toLocaleString()})]})]}),(0,J.jsx)(fL,{task:e})]})]})}function fL({task:e}){let[t,n]=(0,d.useState)(!1);return e.status===`in_progress`||e.sessionId?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`pt-1`,children:(0,J.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n(!0)},className:`inline-flex items-center gap-1.5 rounded border border-border-default px-1.5 py-0.5 text-[10px] text-fg-muted hover:border-border-strong hover:bg-bg-raised`,children:[(0,J.jsx)($E,{className:`w-3 h-3`}),`View transcript`,e.status===`in_progress`&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,J.jsx)(`span`,{className:`w-1 h-1 rounded-full bg-amber-400 animate-pulse`}),`live`]})]})}),t&&(0,J.jsx)(pL,{task:e,onClose:()=>n(!1)})]}):null}function pL({task:e,onClose:t}){let{Modal:n}=mF(),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(!0),m=(0,d.useCallback)(async()=>{if(e.id){o(!0);try{let t=await rL(`${eL}/tasks/${e.id}/history`);i(t.entries??[]),u(t.sessionId??null),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}}},[e.id]);(0,d.useEffect)(()=>{m()},[m]),(0,d.useEffect)(()=>{if(e.status!==`in_progress`)return;let t=setInterval(()=>void m(),3e3);return()=>clearInterval(t)},[e.status,m]),(0,d.useEffect)(()=>{if(!p.current)return;let e=f.current;e&&(e.scrollTop=e.scrollHeight)},[r]);let h=e=>{let t=e.currentTarget;p.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},g=(0,d.useMemo)(()=>mL(r??[]),[r]);return(0,J.jsx)(n,{isOpen:!0,onClose:t,title:e.title,size:`lg`,className:`bg-bg-base`,children:(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,onDragStart:e=>e.stopPropagation(),children:[(0,J.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border-subtle px-4 py-2 text-[10px] text-fg-faint`,children:[(0,J.jsx)($E,{className:`h-3.5 w-3.5 text-fg-faint`}),(0,J.jsx)(`span`,{children:`worker transcript`}),l&&(0,J.jsxs)(`span`,{className:`font-mono text-fg-fainter`,children:[`· `,l]}),e.status===`in_progress`&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[`·`,(0,J.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-amber-400`}),`tailing`]}),(0,J.jsx)(`div`,{className:`ml-auto`,children:(0,J.jsx)(`button`,{type:`button`,onClick:()=>void m(),disabled:a,className:`rounded p-1 text-fg-muted hover:bg-bg-raised hover:text-fg-default disabled:opacity-50`,title:`Refresh`,children:(0,J.jsx)(GT,{className:`h-3.5 w-3.5 ${a?`animate-spin`:``}`})})})]}),(0,J.jsxs)(`div`,{ref:f,onScroll:h,className:`flex-1 space-y-3 overflow-y-auto p-4`,children:[s&&(0,J.jsx)(`div`,{className:`rounded border border-rose-700/40 bg-rose-950/30 px-3 py-2 text-xs text-danger`,children:s}),r===null&&a&&(0,J.jsx)(`div`,{className:`text-xs italic text-fg-faint`,children:`Loading…`}),r!==null&&g.length===0&&!a&&(0,J.jsx)(`div`,{className:`text-xs italic text-fg-faint`,children:e.sessionId?`No messages yet.`:`Worker hasn't started yet.`}),g.map(e=>(0,J.jsx)(hL,{row:e},e.id))]})]})})}function mL(e){let t=new Map;for(let n of e)n.role===`tool`&&n.toolResult?.callId&&t.set(n.toolResult.callId,n.toolResult);let n=[];for(let r of e){if(r.role===`tool`)continue;let e=(r.toolCalls??[]).map(e=>({call:e,result:t.get(e.callId)}));n.push({id:r.id,createdAt:r.createdAt,role:r.role===`user`?`user`:r.role===`assistant`?`assistant`:`system`,text:r.text,calls:e})}return n}function hL({row:e}){let t=e.role===`user`;return(0,J.jsx)(`div`,{className:t?`flex justify-end`:`flex justify-start`,children:(0,J.jsxs)(`div`,{className:`flex max-w-[85%] flex-col ${t?`items-end`:`items-start`}`,children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-fg-faint`,children:[t?(0,J.jsx)(vN,{className:`h-3 w-3`}):(0,J.jsx)(Es,{className:`h-3 w-3 text-link`}),(0,J.jsx)(`span`,{children:t?`you`:e.role}),(0,J.jsx)(`span`,{className:`text-fg-fainter`,children:`·`}),(0,J.jsx)(`span`,{className:`text-fg-fainter`,children:new Date(e.createdAt).toLocaleTimeString()})]}),e.text&&(0,J.jsx)(`div`,{className:`whitespace-pre-line break-words rounded-lg border px-3 py-2 text-[13px] leading-relaxed ${t?`border-brand-400/30 bg-brand-500/10 text-fg-default`:`border-border-subtle bg-bg-elevated/60 text-fg-default`}`,children:e.text}),e.calls.length>0&&(0,J.jsx)(`div`,{className:`mt-1.5 flex flex-col gap-1 ${t?`items-end`:`items-start`}`,children:e.calls.map((e,t)=>(0,J.jsx)(gL,{...e},e.call.callId||`c${t}`))})]})})}function gL({call:e,result:t}){let[n,r]=(0,d.useState)(!1),i=!t,a=!!t&&t.ok===!1;return(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>!i&&r(e=>!e),className:`flex select-none items-center gap-1.5 py-0.5 text-xs ${i?`cursor-default text-fg-faint`:`cursor-pointer text-fg-faint hover:text-fg-muted`}`,children:[i?(0,J.jsx)(q,{className:`h-3 w-3 animate-spin text-warning`}):a?(0,J.jsx)(Mu,{className:`h-3 w-3 text-rose-400/70`}):(0,J.jsx)(Ql,{className:`h-3 w-3 text-emerald-500/60`}),(0,J.jsx)(`code`,{className:`font-mono text-[12px] text-link`,children:e.toolName}),(0,J.jsx)(`span`,{className:`font-mono text-[11px] text-fg-fainter`,children:_L(e.argsJson)}),i?(0,J.jsx)(`span`,{className:`text-[11px] text-fg-fainter`,children:`running…`}):n?(0,J.jsx)(Al,{className:`h-3 w-3 text-fg-fainter`}):(0,J.jsx)(Pl,{className:`h-3 w-3 text-fg-fainter`})]}),n&&t&&(0,J.jsx)(`pre`,{className:`mt-1 max-h-64 max-w-2xl overflow-auto whitespace-pre-wrap break-all rounded-md border px-3 py-2 text-[11px] ${a?`border-rose-700/40 bg-rose-950/30 text-danger`:`border-border-subtle/60 bg-bg-elevated/60 text-fg-muted`}`,children:yL(t.text||`(empty)`,4e3)})]})}function _L(e){if(!e)return`()`;let t;try{t=JSON.parse(e)}catch{return e.length>60?`(${e.slice(0,57)}…)`:`(${e})`}if(!t||typeof t!=`object`)return`(${e})`;let n=t,r=Object.keys(n);return r.length===0?`()`:r.slice(0,3).map(e=>`${e}=${vL(n[e])}`).join(` `)}function vL(e){return typeof e==`string`?e.length>40?`"${e.slice(0,37)}…"`:`"${e}"`:typeof e==`number`||typeof e==`boolean`||e==null?String(e):JSON.stringify(e).slice(0,40)}function yL(e,t){return e.length<=t?e:e.slice(0,t-1)+`
39
39
  …(truncated)`}function bL({label:e,children:t}){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-fg-faint mb-0.5`,children:e}),t]})}function xL({path:e}){let t=dF(),n=e.replace(/^workspace:\/\/+/,`/`),r=n.split(`/`).filter(Boolean).pop()||n;return(0,J.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t(n)},className:`inline-flex items-center gap-1 max-w-full text-[10.5px] font-mono text-success hover:underline truncate`,title:n,children:[(0,J.jsx)(qm,{className:`w-3 h-3 shrink-0 opacity-70`}),(0,J.jsx)(`span`,{className:`truncate`,children:r})]})}var SL=[`echo`,`qianliyan`,`luban`,`xihe`,`nvwa`];function CL({projects:e,workerRoles:t,allTasks:n,onSubmit:r,onCancel:i}){let[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(0),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)([]),[v,y]=(0,d.useState)(!1),b=(0,d.useRef)(null);(0,d.useEffect)(()=>{b.current?.focus()},[]);let x=()=>{let e=a.trim();if(!e){i();return}r({title:e,description:s.trim()||void 0,project:l.trim()||void 0,priority:f||void 0,workerRole:m.trim()||void 0,dependsOn:g.length>0?g:void 0})};return(0,J.jsxs)(`li`,{className:`rounded border border-blue-500/50 bg-bg-elevated/70 p-1.5 space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`input`,{ref:b,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||e.keyCode===229||(e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),x()):e.key===`Escape`&&i())},placeholder:`Task title...`,className:`flex-1 min-w-0 bg-bg-raised border border-border-default rounded px-2 py-1 text-[11.5px] text-fg-default outline-none focus:border-blue-500`}),(0,J.jsx)(`button`,{type:`button`,title:v?`Less`:`More fields`,onClick:()=>y(e=>!e),className:`p-0.5 text-fg-faint hover:text-fg-default`,children:(0,J.jsx)(Al,{className:`w-3 h-3 transition-transform ${v?`rotate-180`:``}`})}),(0,J.jsx)(`button`,{type:`button`,onClick:i,className:`p-0.5 text-fg-faint hover:text-fg-default`,title:`Cancel`,children:(0,J.jsx)(AP,{className:`w-3 h-3`})})]}),v&&(0,J.jsxs)(`div`,{className:`space-y-2 pt-0.5`,children:[(0,J.jsx)(wL,{label:`Description`,children:(0,J.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`Optional notes for the worker...`,rows:2,className:`w-full bg-bg-raised border border-border-default rounded px-2 py-1 text-[11px] text-fg-default outline-none focus:border-blue-500 resize-y`})}),(0,J.jsx)(wL,{label:`Project`,children:(0,J.jsx)(`input`,{list:`workboard-add-projects`,value:l,onChange:e=>u(e.target.value),placeholder:`inbox`,className:`w-full bg-bg-raised border border-border-default rounded px-2 py-1 text-[11px] text-fg-default outline-none focus:border-blue-500`})}),(0,J.jsxs)(`div`,{className:`grid grid-cols-[1fr_72px] gap-2`,children:[(0,J.jsx)(wL,{label:`Worker`,children:(0,J.jsx)(`input`,{list:`workboard-add-roles`,value:m,onChange:e=>h(e.target.value),placeholder:`any`,className:`w-full bg-bg-raised border border-border-default rounded px-2 py-1 text-[11px] text-fg-default outline-none focus:border-blue-500`})}),(0,J.jsx)(wL,{label:`Priority`,children:(0,J.jsx)(`input`,{type:`number`,value:f,onChange:e=>p(Number(e.target.value)||0),className:`w-full bg-bg-raised border border-border-default rounded px-2 py-1 text-[11px] text-fg-default outline-none focus:border-blue-500`})})]}),(0,J.jsx)(wL,{label:`Depends on`,children:(0,J.jsx)(TL,{value:g,onChange:_,candidates:n,project:l})}),(0,J.jsx)(`datalist`,{id:`workboard-add-roles`,children:t.map(e=>(0,J.jsx)(`option`,{value:e},e))}),(0,J.jsx)(`datalist`,{id:`workboard-add-projects`,children:e.map(e=>(0,J.jsx)(`option`,{value:e.project},e.project))})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 pt-1`,children:[(0,J.jsx)(`span`,{className:`text-[9.5px] text-fg-fainter truncate`,children:v?`Enter saves`:`Enter · Esc cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:x,disabled:!a.trim(),className:`ml-auto px-2.5 py-0.5 text-[10.5px] rounded bg-blue-700 hover:bg-blue-600 text-white disabled:opacity-50 disabled:cursor-not-allowed`,children:`Add`})]})]})}function wL({label:e,children:t}){return(0,J.jsxs)(`label`,{className:`block`,children:[(0,J.jsx)(`span`,{className:`block text-[9px] uppercase tracking-wide text-fg-faint mb-0.5`,children:e}),t]})}function TL({value:e,onChange:t,candidates:n,project:r,excludeId:i}){let a=(0,d.useMemo)(()=>new Map(n.map(e=>[e.id,e])),[n]),o=(0,d.useMemo)(()=>{let t=(r??``).trim();return n.filter(n=>n.id===i||e.includes(n.id)?!1:t?t===tL?!n.project||n.project===tL:n.project===t:!0)},[n,r,e,i]),s=n=>t(e.filter(e=>e!==n)),c=n=>{!n||e.includes(n)||t([...e,n])};return(0,J.jsxs)(`div`,{className:`space-y-1`,children:[e.length>0&&(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>{let t=a.get(e),n=t?t.title:`${e.slice(0,6)}... (deleted)`,r=t?.status===`done`;return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded border ${r?`text-success bg-success/10 border-success/30`:`text-indigo-200 bg-indigo-500/15 border-indigo-500/40`}`,title:t?`${t.status} · ${t.id}`:e,children:[r?(0,J.jsx)(Ql,{className:`w-2.5 h-2.5`}):(0,J.jsx)(mb,{className:`w-2.5 h-2.5`}),(0,J.jsx)(`span`,{className:`truncate max-w-[140px]`,children:n}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>s(e),className:`text-fg-muted hover:text-fg-default`,title:`Remove`,children:(0,J.jsx)(AP,{className:`w-2.5 h-2.5`})})]},e)})}),(0,J.jsxs)(`select`,{value:``,onChange:e=>{e.target.value&&(c(e.target.value),e.target.value=``)},className:`w-full bg-bg-raised border border-border-default rounded px-2 py-1 text-[11px] text-fg-default outline-none focus:border-blue-500`,children:[(0,J.jsx)(`option`,{value:``,children:o.length===0?e.length===0?`(no other tasks)`:`(no more candidates)`:`Add prerequisite...`}),o.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[`[`,e.status,`] `,e.title]},e.id))]})]})}function EL({chips:e,active:t,onPick:n,showAll:r,rightExtras:i}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 border-b border-border-subtle bg-bg-base/40 overflow-x-auto scrollbar-none flex-shrink-0`,children:[r&&(0,J.jsx)(DL,{active:!t,label:`All`,count:e.reduce((e,t)=>e+t.count,0),onClick:()=>n(``)}),e.map(e=>(0,J.jsx)(DL,{active:t===e.key,label:e.label,count:e.count,onClick:()=>n(t===e.key?``:e.key)},e.key||`all`)),i]})}function DL({active:e,label:t,count:n,onClick:r}){return(0,J.jsxs)(`button`,{onClick:r,className:[`shrink-0 inline-flex items-center gap-1 rounded-full text-[11px] transition-colors px-2.5 py-0.5`,e?`bg-blue-500/20 border border-blue-400/50 text-blue-200`:`text-fg-muted hover:text-fg-default hover:bg-bg-raised/60 border border-transparent`].join(` `),children:[(0,J.jsx)(`span`,{children:t}),(0,J.jsx)(`span`,{className:e?`text-blue-300/80`:`text-fg-fainter`,children:n})]})}function OL(e){let[t,n]=(0,d.useState)(null),r=(0,d.useCallback)(async()=>{try{n(await rL(`${eL}/workers/status`))}catch{n(null)}},[]);(0,d.useEffect)(()=>{r();let e=window.setInterval(()=>void r(),5e3);return()=>window.clearInterval(e)},[r]);let i=t?.workers??[],a=i.filter(e=>e.busy).length;return(0,J.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,J.jsx)(MP,{size:14,className:`flex-shrink-0 text-fg-fainter`}),(0,J.jsx)(`span`,{className:`flex-1 text-sm font-medium text-fg-muted`,children:`Workers`}),(0,J.jsxs)(`span`,{className:`rounded bg-bg-raised px-1.5 py-0.5 text-[9px] text-fg-fainter`,children:[a,`/`,i.length,` busy`]})]}),(0,J.jsx)(`div`,{className:`space-y-1.5`,children:i.length===0?(0,J.jsx)(`div`,{className:`text-[10px] text-fg-fainter px-1`,children:`No workers running. Toggle echo on under Settings → Plugins → Workboard.`}):i.map(e=>(0,J.jsx)(kL,{name:e.name,kind:e.kind,busy:e.busy},e.agentId))})]})}function kL({name:e,kind:t,busy:n}){let r=AL(t);return(0,J.jsxs)(`div`,{className:`flex cursor-default items-center gap-2 rounded py-0.5 pl-1 hover:bg-bg-hover/30`,title:`Agent: ${e}\nWorker type: ${t}`,children:[(0,J.jsx)(`span`,{className:`w-5 flex-shrink-0 text-center text-base`,children:r}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`truncate text-xs font-medium text-fg-default`,children:e}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate rounded bg-bg-raised/80 px-1 py-px font-mono text-[9px] font-semibold uppercase tracking-wide text-fg-muted`,children:t}),(0,J.jsx)(`span`,{className:`rounded px-1 py-px text-[9px] ${n?`bg-blue-900/40 text-blue-100 border border-blue-700`:`bg-bg-raised/60 text-fg-fainter`}`,children:n?`busy`:`idle`})]})]})]})}function AL(e){return e===`echo`?`🔁`:`⚙️`}function jL(e){let t=Math.max(0,Date.now()-e),n=Math.round(t/1e3);if(n<60)return`${n}s ago`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}var ML={components:{WorkboardPanel:cL,WorkersSidebarSection:OL,WorkerAgentsPage:JI}};ML.components;var NL=`/api/p/workforce-studio`;async function PL(e,t){let n=await fetch(`${NL}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`},...t}),r=await n.json();if(!r.ok)throw Error(r.error||`HTTP ${n.status}`);return r}function FL(e){let t={executionBias:null,replyStyle:null,userOnboarding:null};for(let n of e)n.overrideKey&&n.overridden&&(t[n.overrideKey]=n.text);return t}function IL(e){return e.filter(e=>e.customFragmentId).map(e=>({id:e.customFragmentId,title:e.title,body:e.text}))}function LL(e,t,n){let r={};for(let i of e){let e=n[i.slug]?.blocks.find(e=>e.overrideKey===`executionBias`);r[i.slug]={name:i.name,description:i.description,modelId:i.modelId,enabled:i.enabled,soul:t[i.slug]??``,executionBias:e?.overridden?e.text:null,skillsDeny:new Set,toolsDeny:new Set}}return r}function RL(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function zL(e,t,n){let{spec:r}=e,[i,a]=(0,d.useState)(r.name),[o,s]=(0,d.useState)(r.description),[c,l]=(0,d.useState)(e.tenantPrompt??``),[u,f]=(0,d.useState)(()=>new Set(r.mainAgent.skillsDeny)),[p,m]=(0,d.useState)(()=>new Set(r.mainAgent.toolsDeny??[])),[h,g]=(0,d.useState)(()=>FL(e.mainBlocks)),[_,v]=(0,d.useState)(()=>IL(e.mainBlocks)),[y,b]=(0,d.useState)(()=>LL(r.workers,e.workerPrompts,e.workerViews)),[x,S]=(0,d.useState)(()=>new Set(r.plugins.enabled)),[C,w]=(0,d.useState)(null),[T,E]=(0,d.useState)(!1),[ee,D]=(0,d.useState)(!1),[te,ne]=(0,d.useState)(null),re=(0,d.useCallback)(()=>ne(null),[]);(0,d.useEffect)(()=>{S(new Set(r.plugins.enabled))},[r.slug,r.plugins.enabled]),(0,d.useEffect)(()=>{b(LL(r.workers,e.workerPrompts,e.workerViews))},[r.slug,r.workers,e.workerPrompts,e.workerViews]),(0,d.useEffect)(()=>{a(r.name),s(r.description),l(e.tenantPrompt??``),f(new Set(r.mainAgent.skillsDeny)),m(new Set(r.mainAgent.toolsDeny??[])),g(FL(e.mainBlocks)),v(IL(e.mainBlocks)),w(null)},[r.slug,r.name,r.description,e.tenantPrompt,e.mainBlocks,r.mainAgent.skillsDeny,r.mainAgent.toolsDeny]);let ie=(0,d.useCallback)(async()=>{E(!0);try{w((await PL(`/solutions/${encodeURIComponent(r.slug)}/diff?against=reality`)).diff)}finally{E(!1)}},[r.slug]),ae=(0,d.useCallback)(()=>{D(!0)},[]),oe=(0,d.useCallback)(()=>{D(!1)},[]),se=(0,d.useCallback)(async()=>{D(!1),E(!0);try{let e=await PL(`/solutions/${encodeURIComponent(r.slug)}/activate`,{method:`POST`});ne({kind:`success`,text:`“${r.name}” is now the active solution. Workers updated: ${e.appliedWorkers.length}. Takes effect on the next agent turn.`}),n?.()}catch(e){ne({kind:`error`,text:`Activate failed: ${e instanceof Error?e.message:String(e)}`})}finally{E(!1)}},[r.slug,r.name,n]);return{name:i,setName:a,description:o,setDescription:s,tenantPrompt:c,setTenantPrompt:l,skillsDeny:u,setSkillsDeny:f,toolsDeny:p,setToolsDeny:m,overrides:h,setOverrides:g,fragments:_,setFragments:v,workerEdits:y,setWorkerEdits:b,pluginsEnabled:x,setPluginsEnabled:S,diff:C,setDiff:w,busy:T,runDiff:ie,save:(0,d.useCallback)(async()=>{E(!0);try{let n={slug:r.slug,name:i,description:o,plugins:{enabled:[...x].sort()},mainAgent:{tenantPrompt:c.trim().length>0?c:null,skillsAllow:null,skillsDeny:[...u].sort(),toolsAllow:null,toolsDeny:[...p].sort(),overrides:{executionBias:h.executionBias,replyStyle:h.replyStyle,userOnboarding:h.userOnboarding},customFragments:_.map(e=>({id:e.id,title:e.title,body:e.body}))},workers:r.workers.map(t=>{let n=y[t.slug],r=e.workerViews[t.slug];if(!n||!r)return{slug:t.slug,kind:t.kind,name:t.name,description:t.description,modelId:t.modelId,enabled:t.enabled,systemPrompt:e.workerPrompts[t.slug]??null,toolsAllow:t.toolsAllow,skillsAllow:t.skillsAllow,overrides:{executionBias:null},source:t.source};let i=(e,t)=>e.filter(e=>!t.has(e.name)).map(e=>e.name).sort();return{slug:t.slug,kind:t.kind,name:n.name,description:n.description,modelId:n.modelId,enabled:n.enabled,systemPrompt:n.soul.trim().length>0?n.soul:null,toolsAllow:i(r.availableTools,n.toolsDeny),skillsAllow:i(r.availableSkills,n.skillsDeny),overrides:{executionBias:n.executionBias&&n.executionBias.trim().length>0?n.executionBias:null},source:t.source}})};await PL(`/solutions/save`,{method:`POST`,body:JSON.stringify(n)}),t()}finally{E(!1)}},[r,i,o,e,c,u,p,h,_,y,x,t]),activatePending:ee,requestActivate:ae,confirmActivate:se,cancelActivate:oe,notice:te,clearNotice:re}}var BL=`tianshu.workforce-studio.solution`;function VL(e){let{spec:t}=e,n=FL(e.mainBlocks),r=IL(e.mainBlocks).filter(e=>e.body.trim().length>0);return{slug:t.slug,name:t.name,description:t.description,plugins:{enabled:[...t.plugins.enabled].sort()},mainAgent:{tenantPrompt:e.tenantPrompt&&e.tenantPrompt.trim().length>0?e.tenantPrompt:null,skillsAllow:null,skillsDeny:[...t.mainAgent.skillsDeny].sort(),toolsAllow:null,toolsDeny:[...t.mainAgent.toolsDeny??[]].sort(),overrides:{executionBias:n.executionBias,replyStyle:n.replyStyle,userOnboarding:n.userOnboarding},customFragments:r},workers:t.workers.map(t=>{let n=e.workerViews[t.slug]?.blocks.find(e=>e.overrideKey===`executionBias`);return{slug:t.slug,kind:t.kind,name:t.name,description:t.description,modelId:t.modelId,enabled:t.enabled,systemPrompt:e.workerPrompts?.[t.slug]??null,toolsAllow:t.toolsAllow??null,skillsAllow:t.skillsAllow??null,overrides:{executionBias:n?.overridden?n.text:null},source:t.source}})}}function HL(e){let t={format:BL,version:1,exportedAt:new Date().toISOString(),spec:VL(e)};return{filename:`${e.spec.slug}.solution.json`,json:JSON.stringify(t,null,2)}}function UL(e){let{filename:t,json:n}=HL(e),r=new Blob([n],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(i),0)}function WL(e){let t;try{t=JSON.parse(e)}catch{throw Error(`Not valid JSON.`)}if(!t||typeof t!=`object`)throw Error(`File is empty or not an object.`);let n=t,r=n;if(typeof n.format==`string`||`spec`in n){if(n.format&&n.format!==`tianshu.workforce-studio.solution`)throw Error(`Unrecognised file format "${String(n.format)}". Expected a Workforce Studio solution export.`);if(typeof n.version==`number`&&n.version>1)throw Error(`File version ${n.version} is newer than this build supports (1). Upgrade Tianshu.`);r=n.spec}if(!r||typeof r!=`object`)throw Error(`Missing solution spec.`);let i=r;if(typeof i.slug!=`string`||i.slug.length===0)throw Error(`Spec has no slug.`);if(typeof i.name!=`string`)throw Error(`Spec has no name.`);if(!i.plugins||typeof i.plugins!=`object`)throw Error(`Spec has no plugins block.`);if(!Array.isArray(i.workers))throw Error(`Spec has no workers array.`);if(!i.mainAgent||typeof i.mainAgent!=`object`)throw Error(`Spec has no mainAgent block.`);return r}function GL(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64)}function KL(e,t){let n=GL(e)||`imported-solution`;if(!t.has(n))return n;for(let e=2;e<1e3;e++){let r=`${n}-${e}`;if(!t.has(r))return r}return`${n}-${Date.now()}`}var qL={executionBias:{icon:`⚙`,label:`Execution bias`},replyStyle:{icon:`💬`,label:`Reply style`},userOnboarding:{icon:`👋`,label:`User onboarding`}};function JL(e,t,n){let{spec:r}=e,i=[];if(i.push({id:`root`,label:t.name||r.name,icon:`📦`,depth:0}),i.push({id:`plugins`,label:`Plugins`,icon:`🧩`,depth:1,count:`${t.pluginsEnabled.size}/${e.availablePlugins.length}`}),i.push({id:`main`,label:`Main agent`,icon:`🤖`,depth:1,expandable:!0}),n.has(`main`)){i.push({id:`main:tenant-prompt`,label:`Tenant prompt`,icon:`📝`,depth:2});for(let e of Object.keys(qL)){let n=qL[e],r=t.overrides[e]!==null;i.push({id:`main:override:${e}`,label:n.label,icon:n.icon,depth:2,badge:r?{kind:`overridden`,text:`overridden`}:void 0})}for(let e of t.fragments)i.push({id:`main:fragment:${e.id}`,label:`Custom: ${e.title||`untitled`}`,icon:`➕`,depth:2});i.push({id:`main:tools`,label:`Tools`,icon:`🔧`,depth:2,count:`${e.availableTools.length}`,badge:YL(t.toolsDeny.size)}),i.push({id:`main:skills`,label:`Skills`,icon:`📚`,depth:2,count:`${e.availableSkills.length}`,badge:YL(t.skillsDeny.size)})}if(i.push({id:`workers`,label:`Workers`,icon:`👥`,depth:1,count:`${r.workers.length}`,expandable:!0}),n.has(`workers`))for(let a of r.workers){let r=t.workerEdits[a.slug],o=e.workerViews[a.slug],s=r?!r.enabled:!a.enabled,c=`worker:${a.slug}`;if(i.push({id:c,label:r?.name||a.name,icon:XL(a.kind),depth:1,excluded:s,expandable:!0,badge:s?{kind:`excluded`,text:`excluded`}:void 0}),n.has(c)){i.push({id:`${c}:soul`,label:`SOUL.md`,icon:`📝`,depth:2});let e=!!r&&r.executionBias!==null;i.push({id:`${c}:override:executionBias`,label:`Execution bias`,icon:`⚙`,depth:2,badge:e?{kind:`overridden`,text:`overridden`}:void 0}),i.push({id:`${c}:tools`,label:`Tools`,icon:`🔧`,depth:2,count:o?`${o.availableTools.length}`:void 0,badge:YL(r?.toolsDeny.size??0)}),i.push({id:`${c}:skills`,label:`Skills`,icon:`📚`,depth:2,count:o?`${o.availableSkills.length}`:void 0,badge:YL(r?.skillsDeny.size??0)})}}return i}function YL(e){return e>0?{kind:`excluded`,text:String(e)}:void 0}function XL(e){let t=e.toLowerCase();return t.includes(`research`)?`🔎`:t.includes(`cod`)||t.includes(`dev`)?`💻`:t.includes(`review`)?`📋`:`🤖`}function ZL(e){let t=new Set([`main`,`workers`]);for(let n of e.spec.workers)t.add(`worker:${n.slug}`);return t}function QL({detail:e,edits:t,expanded:n,onToggleExpand:r,selected:i,onSelect:a}){return(0,J.jsx)(`div`,{className:`py-2`,children:JL(e,t,n).map(e=>(0,J.jsx)($L,{node:e,isSelected:i===e.id,isExpanded:n.has(e.id),onToggleExpand:r,onSelect:a},e.id))})}function $L({node:e,isSelected:t,isExpanded:n,onToggleExpand:r,onSelect:i}){let a=e.depth===0?`pl-2`:e.depth===1?`pl-5`:`pl-9`,o=e.id===`root`;return(0,J.jsxs)(`div`,{className:`flex w-full items-center gap-1 border-l-2 ${a} pr-2 py-1 text-xs whitespace-nowrap ${t?`border-info-fg bg-bg-hover text-fg-default`:`border-transparent hover:bg-bg-hover`}`,children:[e.expandable?(0,J.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.id)},className:`flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-bg-base hover:text-fg-default`,"aria-label":n?`Collapse`:`Expand`,children:n?(0,J.jsx)(Al,{className:`size-3.5`}):(0,J.jsx)(Pl,{className:`size-3.5`})}):(0,J.jsx)(`span`,{className:`size-5 shrink-0`}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{e.expandable&&!n&&r(e.id),i(e.id)},className:`flex flex-1 items-center gap-1.5 text-left`,children:[(0,J.jsx)(`span`,{className:`w-4 text-center opacity-80`,children:e.icon}),(0,J.jsx)(`span`,{className:`${o?`font-semibold`:``} ${e.excluded?`text-fg-muted line-through`:``}`,children:e.label}),e.count?(0,J.jsx)(`span`,{className:`text-[10px] text-fg-muted`,children:e.count}):null,e.badge?(0,J.jsx)(eR,{badge:e.badge}):null]})]})}function eR({badge:e}){return(0,J.jsx)(`span`,{className:`ml-auto rounded-full px-1.5 py-0.5 text-[9px] font-medium ${e.kind===`overridden`?`bg-warning-fg/15 text-warning-fg`:e.kind===`excluded`?`bg-danger-fg/15 text-danger-fg`:`bg-fg-muted/15 text-fg-muted`}`,children:e.text})}var tR={executionBias:`Execution bias`,replyStyle:`Reply style`,userOnboarding:`User onboarding`};function nR({selected:e,detail:t,edits:n,onSelect:r}){let i=t.isCurrent;return e===`root`||e===`main`?(0,J.jsx)(aR,{detail:t,edits:n,onSelect:r}):e===`plugins`?(0,J.jsx)(oR,{detail:t,edits:n}):e===`main:tenant-prompt`?(0,J.jsx)(sR,{edits:n,isCurrent:i}):e.startsWith(`main:override:`)?(0,J.jsx)(cR,{okey:e.slice(14),detail:t,edits:n,isCurrent:i}):e.startsWith(`main:fragment:`)?(0,J.jsx)(lR,{fragmentId:e.slice(14),edits:n,isCurrent:i}):e===`main:tools`?(0,J.jsx)(rR,{title:`🔧 Tools`,sub:`Tools available to the main agent. Plugin / host tools are locked in; exclude tenant-owned tools you don't want.`,children:(0,J.jsx)(mR,{title:`Tools`,options:t.availableTools,excluded:n.toolsDeny,disabled:i,onToggle:e=>n.setToolsDeny(t=>RL(t,e))})}):e===`main:skills`?(0,J.jsx)(rR,{title:`📚 Skills`,sub:`Skills available to the main agent. Plugin / host skills are locked in; exclude tenant-owned skills you don't want.`,children:(0,J.jsx)(mR,{title:`Skills`,options:t.availableSkills,excluded:n.skillsDeny,disabled:i,onToggle:e=>n.setSkillsDeny(t=>RL(t,e))})}):e===`workers`?(0,J.jsx)(uR,{detail:t,edits:n}):e.startsWith(`worker:`)?(0,J.jsx)(dR,{selected:e,detail:t,edits:n}):(0,J.jsx)(rR,{title:`—`,sub:`Select a node from the Explorer.`,children:(0,J.jsx)(`div`,{className:`text-xs text-fg-muted`,children:`Nothing selected.`})})}function rR({title:e,sub:t,children:n}){return(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`h2`,{className:`text-[15px] font-semibold`,children:e}),t?(0,J.jsx)(`div`,{className:`mb-4 mt-1 text-xs text-fg-muted`,children:t}):null,(0,J.jsx)(`div`,{className:`flex flex-col gap-3`,children:n})]})}function iR({label:e,children:t}){return(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-fg-muted`,children:e}),t]})}function aR({detail:e,edits:t,onSelect:n}){let{spec:r,isCurrent:i}=e;return(0,J.jsxs)(rR,{title:`📦 ${t.name||r.name}`,sub:r.extractedFrom?`Extracted from tenant ${r.extractedFrom.tenantId} · v${r.extractedFrom.tianshuVersion}`:`Hand-authored solution.`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,J.jsx)(iR,{label:`Name`,children:(0,J.jsx)(`input`,{value:t.name,disabled:i,onChange:e=>t.setName(e.target.value),className:`w-full rounded border border-border-subtle bg-bg-base px-2 py-1 text-xs disabled:opacity-60`})}),(0,J.jsx)(iR,{label:`Description`,children:(0,J.jsx)(`input`,{value:t.description,disabled:i,onChange:e=>t.setDescription(e.target.value),className:`w-full rounded border border-border-subtle bg-bg-base px-2 py-1 text-xs disabled:opacity-60`})})]}),(0,J.jsxs)(`div`,{className:`rounded border border-info-fg/30 bg-info-fg/5 px-3 py-2 text-[11px] text-info-fg`,children:[(0,J.jsx)(`strong`,{children:`Save`}),` writes this solution to disk (no runtime effect). `,(0,J.jsx)(`strong`,{children:`Apply`}),` writes it into the running system — main-agent prompt / skills / tools + worker files take effect on the next agent turn. Plugin enable/disable is not applied in this phase.`]}),i?null:(0,J.jsx)(`button`,{type:`button`,onClick:()=>{let e=`frag-${Date.now()}`;t.setFragments(t=>[...t,{id:e,title:`Custom fragment`,body:``}]),n(`main:fragment:${e}`)},className:`self-start rounded-md border border-dashed border-border-subtle px-3 py-1.5 text-xs text-fg-muted hover:border-fg-muted hover:text-fg-default`,children:`+ Add custom fragment`}),i?(0,J.jsxs)(`div`,{className:`rounded border border-info-fg/30 bg-info-fg/5 px-3 py-2 text-[11px] text-info-fg`,children:[`This is the live `,(0,J.jsx)(`strong`,{children:`Current`}),` mirror — read-only. Click `,(0,J.jsx)(`strong`,{children:`Extract`}),` in the Solutions list to create an editable named solution.`]}):null]})}function oR({detail:e,edits:t}){let n=e.isCurrent;return(0,J.jsx)(rR,{title:`🧩 Plugins`,sub:`Which plugins this solution activates. Plugins decide what tools, skills and prompt fragments the rest of the solution can use.`,children:(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.availablePlugins.map(e=>{let r=t.pluginsEnabled.has(e.id);return(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 rounded border border-border-subtle bg-bg-elevated px-2 py-1.5 text-xs`,children:[(0,J.jsx)(`span`,{className:r?`font-medium`:`text-fg-muted line-through`,children:e.displayName}),(0,J.jsx)(`code`,{className:`text-[10px] text-fg-muted`,children:e.id}),(0,J.jsx)(pR,{origin:e.origin}),e.state===`active`?null:(0,J.jsx)(`span`,{className:`rounded bg-danger-fg/10 px-1.5 py-0.5 text-[10px] text-danger-fg`,children:e.state}),(0,J.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>t.setPluginsEnabled(t=>RL(t,e.id)),className:`ml-auto rounded-md border px-2 py-0.5 text-[10px] font-medium shadow-sm transition-colors active:translate-y-px disabled:opacity-50 ${r?`border-border-subtle bg-bg-elevated text-fg-default hover:border-danger-fg/40 hover:bg-danger-fg/10 hover:text-danger-fg`:`border-success-fg/40 bg-success-fg/10 text-success-fg hover:bg-success-fg/20`}`,title:r?`Included — click to exclude from this solution.`:`Excluded — click to include.`,children:r?`Exclude`:`Include`})]},e.id)})})})}function sR({edits:e,isCurrent:t}){return(0,J.jsx)(rR,{title:`📝 Tenant prompt`,sub:`The main-agent prompt text for this solution.`,children:(0,J.jsx)(`textarea`,{value:e.tenantPrompt,disabled:t,onChange:t=>e.setTenantPrompt(t.target.value),rows:18,placeholder:t?``:`Main-agent prompt text for this solution. Leave empty for none.`,className:`w-full rounded border border-border-subtle bg-bg-elevated px-2 py-1.5 font-mono text-[11px] leading-snug disabled:opacity-60`})})}function cR({okey:e,detail:t,edits:n,isCurrent:r}){let i=t.mainBlocks.find(t=>t.overrideKey===e),a=n.overrides[e],o=a!=null,s=i?.defaultText??i?.text??``,c=t=>n.setOverrides(n=>({...n,[e]:t}));return(0,J.jsxs)(rR,{title:`⚙ ${tR[e]}`,sub:`Host-provided block. Override it for this solution, or keep the host default.`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${o?`bg-warning-fg/15 text-warning-fg`:`bg-fg-muted/15 text-fg-muted`}`,children:o?`overridden`:`host default`}),r?null:o?(0,J.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded border border-border-subtle px-2 py-0.5 text-[10px] hover:bg-bg-raised`,children:`Reset to host default`}):(0,J.jsx)(`button`,{type:`button`,onClick:()=>c(s),className:`rounded border border-border-subtle px-2 py-0.5 text-[10px] hover:bg-bg-raised`,children:`Override…`})]}),o?(0,J.jsx)(`textarea`,{value:a??``,disabled:r,onChange:e=>c(e.target.value),rows:16,className:`w-full rounded border border-border-subtle bg-bg-elevated px-2 py-1.5 font-mono text-[11px] leading-snug disabled:opacity-60`}):(0,J.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded border border-border-subtle bg-bg-elevated p-2 font-mono text-[11px] leading-snug`,children:s})]})}function lR({fragmentId:e,edits:t,isCurrent:n}){let r=t.fragments.find(t=>t.id===e);if(!r)return(0,J.jsx)(rR,{title:`➕ Custom fragment`,sub:`This fragment was removed.`,children:(0,J.jsx)(`div`,{className:`text-xs text-fg-muted`,children:`Fragment not found.`})});let i=n=>t.setFragments(t=>t.map(t=>t.id===e?{...t,...n}:t));return(0,J.jsxs)(rR,{title:`➕ Custom fragment`,sub:`Extra text injected into the main-agent prompt.`,children:[(0,J.jsx)(iR,{label:`Title`,children:(0,J.jsx)(`input`,{value:r.title,disabled:n,onChange:e=>i({title:e.target.value}),placeholder:`Fragment title`,className:`w-full rounded border border-border-subtle bg-bg-elevated px-2 py-1 text-xs disabled:opacity-60`})}),(0,J.jsx)(`textarea`,{value:r.body,disabled:n,onChange:e=>i({body:e.target.value}),rows:14,placeholder:`Fragment text injected into the main agent prompt…`,className:`w-full rounded border border-border-subtle bg-bg-elevated px-2 py-1.5 font-mono text-[11px] leading-snug disabled:opacity-60`}),n?null:(0,J.jsx)(`button`,{type:`button`,onClick:()=>t.setFragments(t=>t.filter(t=>t.id!==e)),className:`self-start rounded border border-danger-fg/40 px-2 py-0.5 text-[10px] text-danger-fg hover:bg-danger-fg/5`,children:`Remove fragment`})]})}function uR({detail:e,edits:t}){let{spec:n}=e,r=e.isCurrent;return(0,J.jsx)(rR,{title:`👥 Workers`,sub:`Include or exclude a worker here; expand it in the Explorer to edit its prompt / tools / skills. Excluded workers are dropped from the applied solution.`,children:(0,J.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[n.workers.map(e=>{let n=t.workerEdits[e.slug],i=n?!n.enabled:!e.enabled;return(0,J.jsxs)(`li`,{className:`flex items-center gap-2 rounded border border-border-subtle bg-bg-elevated px-2 py-1.5 text-xs`,children:[(0,J.jsx)(`span`,{className:`font-medium ${i?`text-fg-muted line-through`:``}`,children:n?.name||e.name}),(0,J.jsx)(`code`,{className:`text-[10px] text-fg-muted`,children:e.slug}),(0,J.jsx)(`span`,{className:`text-[10px] text-fg-muted`,children:e.kind}),(0,J.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>{let n=t.workerEdits[e.slug];n&&t.setWorkerEdits(t=>({...t,[e.slug]:{...n,enabled:!n.enabled}}))},className:`ml-auto rounded-md border px-2 py-0.5 text-[10px] font-medium shadow-sm transition-colors active:translate-y-px disabled:opacity-50 ${i?`border-success-fg/40 bg-success-fg/10 text-success-fg hover:bg-success-fg/20`:`border-border-subtle bg-bg-raised text-fg-default hover:border-danger-fg/40 hover:bg-danger-fg/10 hover:text-danger-fg`}`,title:i?`Excluded from this solution — click to include.`:`Included — click to exclude this worker from the solution.`,children:i?`Include`:`Exclude`})]},e.slug)}),n.workers.length===0?(0,J.jsx)(`li`,{className:`text-xs text-fg-muted`,children:`No workers.`}):null]})})}function dR({selected:e,detail:t,edits:n}){let r=t.isCurrent,[i,a]=fR(e.slice(7)),o=t.spec.workers.find(e=>e.slug===i),s=t.workerViews[i],c=n.workerEdits[i];if(!o||!s||!c)return(0,J.jsx)(rR,{title:`Worker`,sub:`Worker not found.`,children:(0,J.jsx)(`div`,{className:`text-xs text-fg-muted`,children:`No such worker.`})});let l=e=>n.setWorkerEdits(t=>({...t,[i]:{...c,...e}})),u=!c.enabled;if(a===`soul`)return(0,J.jsx)(rR,{title:`📝 ${c.name} — SOUL.md`,sub:`The worker's persona + rules.`,children:(0,J.jsx)(`textarea`,{value:c.soul,disabled:r,onChange:e=>l({soul:e.target.value}),rows:18,placeholder:r?``:`Worker SOUL.md — the worker's persona + rules.`,className:`w-full rounded border border-border-subtle bg-bg-elevated px-2 py-1.5 font-mono text-[11px] leading-snug disabled:opacity-60`})});if(a===`override:executionBias`){let e=s.blocks.find(e=>e.overrideKey===`executionBias`),t=e?.defaultText??e?.text??``,n=c.executionBias!==null&&c.executionBias!==void 0;return(0,J.jsx)(rR,{title:`⚙ ${c.name} — Execution bias`,sub:`Host behaviour rules for this worker. Override to replace them just for this worker; reset to fall back to the host default.`,children:(0,J.jsxs)(`div`,{className:`rounded border border-border-subtle bg-bg-elevated`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs`,children:[(0,J.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${n?`bg-warning-fg/15 text-warning-fg`:`bg-fg-muted/15 text-fg-muted`}`,children:n?`overridden`:`host default`}),r?null:n?(0,J.jsx)(`button`,{type:`button`,onClick:()=>l({executionBias:null}),className:`ml-auto rounded border border-border-subtle px-2 py-0.5 text-[10px] hover:bg-bg-raised`,children:`Reset to host default`}):(0,J.jsx)(`button`,{type:`button`,onClick:()=>l({executionBias:t}),className:`ml-auto rounded border border-border-subtle px-2 py-0.5 text-[10px] hover:bg-bg-raised`,children:`Override…`})]}),n?(0,J.jsx)(`textarea`,{value:c.executionBias??``,disabled:r,onChange:e=>l({executionBias:e.target.value}),rows:14,className:`w-full border-t border-border-subtle bg-bg-base px-2 py-1.5 font-mono text-[11px] leading-snug disabled:opacity-60`}):(0,J.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words border-t border-border-subtle bg-bg-base p-2 font-mono text-[11px] leading-snug`,children:t})]})})}return a===`tools`?(0,J.jsx)(rR,{title:`🔧 ${c.name} — Tools`,sub:`Tools this worker may use.`,children:(0,J.jsx)(mR,{title:`Tools`,options:s.availableTools,excluded:c.toolsDeny,disabled:r,onToggle:e=>l({toolsDeny:RL(c.toolsDeny,e)})})}):a===`skills`?(0,J.jsx)(rR,{title:`📚 ${c.name} — Skills`,sub:`Skills this worker may use.`,children:(0,J.jsx)(mR,{title:`Skills`,options:s.availableSkills,excluded:c.skillsDeny,disabled:r,onToggle:e=>l({skillsDeny:RL(c.skillsDeny,e)})})}):(0,J.jsxs)(rR,{title:`${u?`📋`:`🤖`} ${c.name}`,sub:`Worker fields. Expand sub-nodes in the Explorer for SOUL, tools, and skills.`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`text-[10px] text-fg-muted`,children:o.slug}),(0,J.jsx)(`span`,{className:`text-[10px] text-fg-muted`,children:o.kind}),(0,J.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>l({enabled:!c.enabled}),className:`ml-auto rounded-md border px-2 py-0.5 text-[10px] font-medium shadow-sm transition-colors active:translate-y-px disabled:opacity-50 ${u?`border-success-fg/40 bg-success-fg/10 text-success-fg hover:bg-success-fg/20`:`border-border-subtle bg-bg-elevated text-fg-default hover:border-danger-fg/40 hover:bg-danger-fg/10 hover:text-danger-fg`}`,title:u?`Excluded from this solution — click to include.`:`Included — click to exclude this worker from the solution.`,children:u?`Include`:`Exclude`})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,J.jsx)(iR,{label:`Name`,children:(0,J.jsx)(`input`,{value:c.name,disabled:r,onChange:e=>l({name:e.target.value}),className:`w-full rounded border border-border-subtle bg-bg-elevated px-2 py-1 text-xs disabled:opacity-60`})}),(0,J.jsx)(iR,{label:`Model id (empty = default)`,children:(0,J.jsx)(`input`,{value:c.modelId??``,disabled:r,onChange:e=>l({modelId:e.target.value.trim().length>0?e.target.value:null}),className:`w-full rounded border border-border-subtle bg-bg-elevated px-2 py-1 font-mono text-xs disabled:opacity-60`})}),(0,J.jsx)(iR,{label:`Description`,children:(0,J.jsx)(`input`,{value:c.description??``,disabled:r,onChange:e=>l({description:e.target.value.trim().length>0?e.target.value:null}),className:`w-full rounded border border-border-subtle bg-bg-elevated px-2 py-1 text-xs disabled:opacity-60`})})]})]})}function fR(e){let t=e.indexOf(`:`);return t===-1?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}function pR({origin:e}){let{label:t,className:n}={core:{label:`core`,className:`bg-info-fg/10 text-info-fg`},"builtin-plugin":{label:`built-in`,className:`bg-success-fg/10 text-success-fg`},"tenant-plugin":{label:`tenant plugin`,className:`bg-warning-fg/10 text-warning-fg`},host:{label:`host`,className:`bg-info-fg/10 text-info-fg`},workspace:{label:`workspace`,className:`bg-warning-fg/10 text-warning-fg`},tenant:{label:`tenant`,className:`bg-warning-fg/10 text-warning-fg`}}[e];return(0,J.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${n}`,children:t})}function mR({title:e,options:t,excluded:n,disabled:r,onToggle:i}){let a=t.filter(e=>!e.locked&&n.has(e.name)).length,o=new Map;for(let e of t){let t=e.pluginId||gR(e.origin),n=o.get(t);n?n.push(e):o.set(t,[e])}let s=[...o.keys()].sort((e,t)=>{let n=e=>e===`core`||e===`host`?0:1;return n(e)===n(t)?e.localeCompare(t):n(e)-n(t)});return(0,J.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border-subtle`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 bg-bg-elevated px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:e}),(0,J.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:t.length}),a>0?(0,J.jsxs)(`span`,{className:`ml-auto rounded-full bg-danger-fg/10 px-2 py-0.5 text-[10px] font-medium text-danger-fg`,children:[a,` excluded`]}):null]}),(0,J.jsxs)(`div`,{className:`max-h-[60vh] overflow-auto bg-bg-base`,children:[s.map(e=>{let t=o.get(e);return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 bg-bg-base/95 px-3 pb-1 pt-2 backdrop-blur`,children:[(0,J.jsx)(`span`,{className:`text-[11px] font-semibold text-fg-default`,children:_R(e)}),(0,J.jsx)(`span`,{className:`rounded-full bg-fg-muted/10 px-1.5 text-[10px] text-fg-muted`,children:t.length})]}),(0,J.jsx)(`ul`,{className:`px-1.5 pb-1`,children:t.map(e=>(0,J.jsx)(hR,{option:e,isExcluded:n.has(e.name),disabled:r,onToggle:i},e.name))})]},e)}),t.length===0?(0,J.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:`None.`}):null]})]})}function hR({option:e,isExcluded:t,disabled:n,onToggle:r}){return(0,J.jsxs)(`li`,{className:`group flex items-center gap-2 rounded px-2 py-1 ${e.locked?``:`hover:bg-bg-elevated`}`,children:[(0,J.jsx)(`code`,{className:`font-mono text-[11px] ${t?`text-fg-muted line-through`:e.locked?`text-fg-muted`:`text-fg-default`}`,children:e.name}),e.locked?(0,J.jsx)(`span`,{className:`ml-auto`,title:`Contributed by a plugin or the host — always included.`,children:(0,J.jsx)(mb,{className:`size-3 text-fg-muted/50`,"aria-label":`locked`})}):(0,J.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>r(e.name),className:`ml-auto rounded-md border px-2 py-0.5 text-[10px] font-medium shadow-sm transition-colors active:translate-y-px disabled:opacity-50 ${t?`border-success-fg/40 bg-success-fg/10 text-success-fg hover:bg-success-fg/20`:`border-border-subtle bg-bg-elevated text-fg-default hover:border-danger-fg/40 hover:bg-danger-fg/10 hover:text-danger-fg`}`,title:t?`Currently excluded — click to include again.`:`Currently included — click to exclude from this solution.`,children:t?`Include`:`Exclude`})]})}function gR(e){return e===`core`?`core`:`host`}function _R(e){return e===`core`?`Core`:e===`host`?`Host`:e}function vR({selected:e,detail:t,edits:n}){return(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(yR,{title:`Inspector`,children:(0,J.jsx)(`div`,{className:`text-xs text-fg-default`,children:bR(e,t,n)})}),(0,J.jsx)(yR,{title:`Diff vs reality`,children:n.diff===null?(0,J.jsx)(`button`,{type:`button`,onClick:()=>void n.runDiff(),disabled:n.busy,className:`rounded border border-border-subtle px-2 py-1 text-[11px] hover:bg-bg-raised disabled:opacity-50`,children:`Compute diff`}):n.diff.entries.length===0?(0,J.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:`No differences — solution matches reality.`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:n.diff.entries.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center gap-1.5 py-0.5 font-mono text-[11px]`,children:[(0,J.jsx)(`span`,{className:`rounded px-1 text-[9px] ${e.op===`add`?`bg-success-fg/15 text-success-fg`:e.op===`remove`?`bg-danger-fg/15 text-danger-fg`:`bg-warning-fg/15 text-warning-fg`}`,children:e.op===`add`?`add`:e.op===`remove`?`rem`:`chg`}),(0,J.jsx)(`code`,{className:`truncate`,children:e.path})]},e.path))})}),(0,J.jsx)(yR,{title:`Rendered preview`,children:(0,J.jsx)(`pre`,{className:`max-h-[40vh] overflow-auto whitespace-pre-wrap break-words rounded border border-border-subtle bg-bg-base p-2.5 font-mono text-[11px] leading-relaxed text-fg-muted`,children:xR(e,t,n)||`—`})})]})}function yR({title:e,children:t}){return(0,J.jsxs)(`div`,{className:`border-b border-border-subtle px-3.5 py-3`,children:[(0,J.jsx)(`h3`,{className:`mb-2 text-[11px] font-semibold uppercase tracking-wide text-fg-muted`,children:e}),t]})}function bR(e,t,n){if(e===`plugins`)return`Plugin set drives the available tools (${t.availableTools.length}), skills (${t.availableSkills.length}) and prompt fragments below. ${n.pluginsEnabled.size} of ${t.availablePlugins.length} enabled.`;if(e===`root`||e===`main`)return`Main agent: ${t.mainBlocks.length} prompt blocks, ${t.availableTools.length} tools, ${t.availableSkills.length} skills, ${t.spec.workers.length} workers.`;if(e===`main:tenant-prompt`)return`The tenant prompt is the editable body of the main-agent system prompt for this solution.`;if(e.startsWith(`main:override:`)){let t=e.slice(14);return n.overrides[t]===null?`Using the host default. Override it to customise this block for the solution.`:`Overridden for this solution. The host default is replaced by your text below.`}if(e.startsWith(`main:fragment:`))return`A custom prompt fragment appended to the main-agent prompt.`;if(e===`main:tools`)return`${t.availableTools.length} tools available · ${n.toolsDeny.size} excluded.`;if(e===`main:skills`)return`${t.availableSkills.length} skills available · ${n.skillsDeny.size} excluded.`;if(e===`workers`){let e=t.spec.workers.filter(e=>{let t=n.workerEdits[e.slug];return t?!t.enabled:!e.enabled}).length;return`${t.spec.workers.length} workers · ${e} excluded.`}if(e.startsWith(`worker:`)){let r=e.slice(7),i=r.includes(`:`)?r.slice(0,r.indexOf(`:`)):r,a=t.workerViews[i],o=n.workerEdits[i];if(a&&o){let e=!o.enabled;return`${o.name}${e?` (excluded)`:``}: ${a.availableTools.length} tools, ${a.availableSkills.length} skills. ${o.toolsDeny.size+o.skillsDeny.size} excluded.`}return`Worker node.`}return`Select a node to inspect.`}function xR(e,t,n){if(e===`main:tenant-prompt`)return n.tenantPrompt;if(e.startsWith(`main:override:`)){let r=e.slice(14),i=n.overrides[r];if(i!=null)return i;let a=t.mainBlocks.find(e=>e.overrideKey===r);return a?.defaultText??a?.text??``}if(e.startsWith(`main:fragment:`)){let t=e.slice(14);return n.fragments.find(e=>e.id===t)?.body??``}if(e===`root`||e===`main`)return t.mainBlocks.map(e=>e.kind===`tenant-prompt`?n.tenantPrompt:e.overrideKey?n.overrides[e.overrideKey]??e.defaultText??e.text:e.customFragmentId?n.fragments.find(t=>t.id===e.customFragmentId)?.body??e.text:e.text).filter(e=>e&&e.trim().length>0).join(`
40
40
 
41
41
  `);if(e.startsWith(`worker:`)){let r=e.slice(7),i=r.indexOf(`:`),a=i===-1?r:r.slice(0,i),o=i===-1?void 0:r.slice(i+1),s=t.workerViews[a],c=n.workerEdits[a];if(!s||!c)return``;if(o===`soul`)return c.soul;if(o===`override:executionBias`){let e=s.blocks.find(e=>e.overrideKey===`executionBias`);return c.executionBias===null?e?.defaultText??e?.text??``:c.executionBias}return o===`tools`||o===`skills`?``:s.blocks.map(e=>e.kind===`worker-soul`?c.soul:e.overrideKey===`executionBias`&&c.executionBias!==null?c.executionBias:e.text).filter(e=>e&&e.trim().length>0).join(`
@@ -69,7 +69,7 @@ Minimum version required to store current data is: `+c+`.
69
69
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
70
70
  `,...a.current()});return/^[\t ]/.test(l)&&(l=dY(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}_Y.peek=vY;function _Y(e){return e.value||``}function vY(){return`<`}yY.peek=bY;function yY(e,t,n,r){let i=cY(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function bY(){return`!`}xY.peek=SY;function xY(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function SY(){return`!`}CY.peek=wY;function CY(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function wY(){return"`"}function TY(e,t){let n=eU(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}EY.peek=DY;function EY(e,t,n,r){let i=cY(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(TY(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function DY(e,t,n){return TY(e,n)?`<`:`[`}OY.peek=kY;function OY(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function kY(){return`[`}function AY(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function jY(e){let t=AY(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function MY(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function NY(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function PY(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?MY(n):AY(n),s=e.ordered?o===`.`?`)`:`.`:jY(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),NY(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function FY(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function IY(e,t,n,r){let i=FY(n),a=n.bulletCurrent||AY(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function LY(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var RY=pK([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function zY(e,t,n,r){return(e.children.some(function(e){return RY(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function BY(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}VY.peek=HY;function VY(e,t,n,r){let i=BY(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=fY(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=dY(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=fY(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+dY(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function HY(e,t,n){return n.options.strong||`*`}function UY(e,t,n,r){return n.safe(e.value,r)}function WY(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function GY(e,t,n){let r=(NY(n)+(n.options.ruleSpaces?` `:``)).repeat(WY(n));return n.options.ruleSpaces?r.slice(0,-1):r}var KY={blockquote:QJ,break:nY,code:oY,definition:lY,emphasis:pY,hardBreak:nY,heading:gY,html:_Y,image:yY,imageReference:xY,inlineCode:CY,link:EY,linkReference:OY,list:PY,listItem:IY,paragraph:LY,root:zY,strong:VY,text:UY,thematicBreak:GY};function qY(){return{enter:{table:JY,tableData:QY,tableHeader:QY,tableRow:XY},exit:{codeText:$Y,table:YY,tableData:ZY,tableHeader:ZY,tableRow:ZY}}}function JY(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function YY(e){this.exit(e),this.data.inTable=void 0}function XY(e){this.enter({type:`tableRow`,children:[]},e)}function ZY(e){this.exit(e)}function QY(e){this.enter({type:`tableCell`,children:[]},e)}function $Y(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,eX));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function eX(e,t){return t===`|`?t:e}function tX(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
71
71
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
72
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return YJ(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=KY.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function nX(){return{exit:{taskListCheckValueChecked:iX,taskListCheckValueUnchecked:iX,paragraph:aX}}}function rX(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:oX}}}function iX(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function aX(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function oX(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=KY.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function sX(){return[pJ(),LJ(),HJ(),qY(),nX()]}function cX(e){return{extensions:[mJ(),RJ(e),UJ(),tX(e),rX()]}}var lX={tokenize:CX,partial:!0},uX={tokenize:wX,partial:!0},dX={tokenize:TX,partial:!0},fX={tokenize:EX,partial:!0},pX={tokenize:DX,partial:!0},mX={name:`wwwAutolink`,tokenize:xX,previous:OX},hX={name:`protocolAutolink`,tokenize:SX,previous:kX},gX={name:`emailAutolink`,tokenize:bX,previous:AX},_X={};function vX(){return{text:_X}}for(var yX=48;yX<123;)_X[yX]=gX,yX++,yX===58?yX=65:yX===91&&(yX=97);_X[43]=gX,_X[45]=gX,_X[46]=gX,_X[95]=gX,_X[72]=[gX,hX],_X[104]=[gX,hX],_X[87]=[gX,mX],_X[119]=[gX,mX];function bX(e,t,n){let r=this,i,a;return o;function o(t){return!jX(t)||!AX.call(r,r.previous)||MX(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return jX(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(pX,u,l)(t):t===45||t===95||dU(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&uU(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function xX(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!OX.call(r,r.previous)||MX(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(lX,e.attempt(uX,e.attempt(dX,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function SX(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&kX.call(r,r.previous)&&!MX(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(uU(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||pU(t)||_U(t)||yU(t)||vU(t)?n(t):e.attempt(uX,e.attempt(dX,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function CX(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function wX(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(fX,c,s)(t):t===null||_U(t)||yU(t)||t!==45&&vU(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function TX(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(fX,t,a)(o):o===null||_U(o)||yU(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function EX(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||_U(o)||yU(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||_U(e)||yU(e)?t(e):r(e)}function a(e){return uU(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):uU(t)?(e.consume(t),o):n(t)}}function DX(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return dU(e)?n(e):t(e)}}function OX(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||_U(e)}function kX(e){return!uU(e)}function AX(e){return!(e===47||jX(e))}function jX(e){return e===43||e===45||e===46||e===95||dU(e)}function MX(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var NX={tokenize:VX,partial:!0};function PX(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:RX,continuation:{tokenize:zX},exit:BX}},text:{91:{name:`gfmFootnoteCall`,tokenize:LX},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:FX,resolveTo:IX}}}}function FX(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=vW(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function IX(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function LX(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||_U(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(vW(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return _U(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function RX(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||_U(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=vW(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return _U(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),$(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function zX(e,t,n){return e.check(FU,t,e.attempt(NX,t,n))}function BX(e){e.exit(`gfmFootnoteDefinition`)}function VX(e,t,n){let r=this;return $(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function HX(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&iU(o,o.length,0,OU(s,e.slice(r+1,n),t)),iU(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),iU(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=DU(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=DU(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var UX=class{constructor(){this.map=[]}add(e,t,n){WX(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function WX(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function GX(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function KX(){return{flow:{null:{name:`table`,tokenize:qX,resolveAll:JX}}}}function qX(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Z(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Q(t)?$(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||_U(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Q(t)?$(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Q(t)?$(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Z(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Q(t)?$(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Z(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Z(n)?(e.exit(`tableRow`),t(n)):Q(n)?$(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||_U(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function JX(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new UX;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(XX(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=YX(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=YX(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=YX(f,t,o,i,n,d)):(o[0]=o[1],d=YX(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&XX(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=GX(t.events,n))}return e}function YX(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},ZX(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=ZX(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=ZX(t.events,n[2]),a=ZX(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},ZX(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function XX(e,t,n,r,i){let a=[],o=ZX(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function ZX(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var QX={name:`tasklistCheck`,tokenize:eZ};function $X(){return{text:{91:QX}}}function eZ(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return _U(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Z(r)?t(r):Q(r)?e.check({tokenize:tZ},t,n)(r):n(r)}}function tZ(e,t,n){return $(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function nZ(e){return sU([vX(),PX(),HX(e),KX(),$X()])}var rZ={};function iZ(e){let t=this,n=e||rZ,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(nZ(n)),a.push(sX()),o.push(cX(n))}function aZ(e){if(!e||e.startsWith(`data:`)||/^https?:\/\//i.test(e))return e;let t=e.match(/^workspace:\/\/\/(.*)$/);if(t||=e.match(/^workspace:\/\/(.*)$/),!t)return e;let n=t[1]??``,r=n.startsWith(`/`)?n:`/`+n;return`/api/p/files/raw?path=${encodeURIComponent(r)}`}function oZ(e){return e&&aZ(e)}function sZ(e){let{src:t,alt:n,...r}=e;return(0,J.jsx)(`img`,{src:t,alt:n??``,loading:`lazy`,className:`my-2 max-h-96 max-w-full rounded-lg border border-border-default/50`,...r})}var cZ={img:sZ},lZ=`prose prose-sm max-w-none text-[14px] leading-relaxed`;function uZ({children:e,className:t=``,noProse:n=!1}){let r=`${lZ}${oz(e=>e.resolved===`dark`)?` prose-invert`:``}`;return(0,J.jsx)(`div`,{className:n?t:`${r} ${t}`.trim(),children:(0,J.jsx)(eJ,{remarkPlugins:[iZ],urlTransform:oZ,components:cZ,children:e})})}var dZ=null;async function fZ(){return dZ||=(async()=>{let{createHighlighter:e}=await _(async()=>{let{createHighlighter:e}=await import(`./bundle-web-CK5GMDdN.js`);return{createHighlighter:e}},__vite__mapDeps([0,1]));return await e({themes:[`github-dark`,`github-light`],langs:[`plaintext`]})})(),dZ}var pZ={sh:`bash`,bash:`bash`,zsh:`bash`,h:`c`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,kt:`kotlin`,yml:`yaml`,htm:`html`,conf:`ini`},mZ=new Set(`ts.tsx.js.jsx.mjs.cjs.py.rb.php.go.rs.java.kt.swift.scala.c.cpp.cc.cxx.h.hpp.cs.m.mm.sh.bash.zsh.fish.ps1.json.yaml.yml.toml.ini.conf.xml.css.scss.sass.less.html.htm.sql.graphql.proto.lua.perl.pl.dockerfile.makefile`.split(`.`));function hZ(e){let t=e.toLowerCase();if(t===`dockerfile`||t.endsWith(`/dockerfile`))return`docker`;if(t===`makefile`||t.endsWith(`/makefile`))return`makefile`;let n=t.lastIndexOf(`.`);if(n<0)return null;let r=t.slice(n+1);return mZ.has(r)?pZ[r]??r:null}function gZ({code:e,lang:t,className:n=``}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1),o=oz(e=>e.resolved===`light`?`github-light`:`github-dark`);(0,d.useEffect)(()=>(a.current=!1,(async()=>{try{let n=await fZ();n.getLoadedLanguages().includes(t)||await n.loadLanguage(t);let r=n.codeToHtml(e,{lang:t,theme:o});a.current||i(r)}catch(e){console.warn(`[CodeBlock] highlight failed (${t}): ${e instanceof Error?e.message:String(e)}`)}})(),()=>{a.current=!0}),[e,t,o]);let s=(0,d.useMemo)(()=>{if(e.length===0)return 1;let t=e.split(`
72
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return YJ(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=KY.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function nX(){return{exit:{taskListCheckValueChecked:iX,taskListCheckValueUnchecked:iX,paragraph:aX}}}function rX(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:oX}}}function iX(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function aX(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function oX(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=KY.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function sX(){return[pJ(),LJ(),HJ(),qY(),nX()]}function cX(e){return{extensions:[mJ(),RJ(e),UJ(),tX(e),rX()]}}var lX={tokenize:CX,partial:!0},uX={tokenize:wX,partial:!0},dX={tokenize:TX,partial:!0},fX={tokenize:EX,partial:!0},pX={tokenize:DX,partial:!0},mX={name:`wwwAutolink`,tokenize:xX,previous:OX},hX={name:`protocolAutolink`,tokenize:SX,previous:kX},gX={name:`emailAutolink`,tokenize:bX,previous:AX},_X={};function vX(){return{text:_X}}for(var yX=48;yX<123;)_X[yX]=gX,yX++,yX===58?yX=65:yX===91&&(yX=97);_X[43]=gX,_X[45]=gX,_X[46]=gX,_X[95]=gX,_X[72]=[gX,hX],_X[104]=[gX,hX],_X[87]=[gX,mX],_X[119]=[gX,mX];function bX(e,t,n){let r=this,i,a;return o;function o(t){return!jX(t)||!AX.call(r,r.previous)||MX(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return jX(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(pX,u,l)(t):t===45||t===95||dU(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&uU(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function xX(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!OX.call(r,r.previous)||MX(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(lX,e.attempt(uX,e.attempt(dX,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function SX(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&kX.call(r,r.previous)&&!MX(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(uU(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||pU(t)||_U(t)||yU(t)||vU(t)?n(t):e.attempt(uX,e.attempt(dX,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function CX(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function wX(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(fX,c,s)(t):t===null||_U(t)||yU(t)||t!==45&&vU(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function TX(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(fX,t,a)(o):o===null||_U(o)||yU(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function EX(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||_U(o)||yU(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||_U(e)||yU(e)?t(e):r(e)}function a(e){return uU(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):uU(t)?(e.consume(t),o):n(t)}}function DX(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return dU(e)?n(e):t(e)}}function OX(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||_U(e)}function kX(e){return!uU(e)}function AX(e){return!(e===47||jX(e))}function jX(e){return e===43||e===45||e===46||e===95||dU(e)}function MX(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var NX={tokenize:VX,partial:!0};function PX(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:RX,continuation:{tokenize:zX},exit:BX}},text:{91:{name:`gfmFootnoteCall`,tokenize:LX},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:FX,resolveTo:IX}}}}function FX(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=vW(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function IX(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function LX(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||_U(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(vW(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return _U(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function RX(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||_U(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=vW(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return _U(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),$(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function zX(e,t,n){return e.check(FU,t,e.attempt(NX,t,n))}function BX(e){e.exit(`gfmFootnoteDefinition`)}function VX(e,t,n){let r=this;return $(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function HX(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&iU(o,o.length,0,OU(s,e.slice(r+1,n),t)),iU(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),iU(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=DU(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=DU(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var UX=class{constructor(){this.map=[]}add(e,t,n){WX(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function WX(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function GX(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function KX(){return{flow:{null:{name:`table`,tokenize:qX,resolveAll:JX}}}}function qX(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Z(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Q(t)?$(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||_U(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Q(t)?$(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Q(t)?$(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Z(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Q(t)?$(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Z(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Z(n)?(e.exit(`tableRow`),t(n)):Q(n)?$(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||_U(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function JX(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new UX;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(XX(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=YX(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=YX(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=YX(f,t,o,i,n,d)):(o[0]=o[1],d=YX(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&XX(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=GX(t.events,n))}return e}function YX(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},ZX(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=ZX(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=ZX(t.events,n[2]),a=ZX(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},ZX(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function XX(e,t,n,r,i){let a=[],o=ZX(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function ZX(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var QX={name:`tasklistCheck`,tokenize:eZ};function $X(){return{text:{91:QX}}}function eZ(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return _U(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Z(r)?t(r):Q(r)?e.check({tokenize:tZ},t,n)(r):n(r)}}function tZ(e,t,n){return $(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function nZ(e){return sU([vX(),PX(),HX(e),KX(),$X()])}var rZ={};function iZ(e){let t=this,n=e||rZ,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(nZ(n)),a.push(sX()),o.push(cX(n))}function aZ(e){if(!e||e.startsWith(`data:`)||/^https?:\/\//i.test(e))return e;let t=e.match(/^workspace:\/\/\/(.*)$/);if(t||=e.match(/^workspace:\/\/(.*)$/),!t)return e;let n=t[1]??``,r=n.startsWith(`/`)?n:`/`+n;return`/api/p/files/raw?path=${encodeURIComponent(r)}`}function oZ(e){return e&&aZ(e)}function sZ(e){let{src:t,alt:n,...r}=e;return(0,J.jsx)(`img`,{src:t,alt:n??``,loading:`lazy`,className:`my-2 max-h-96 max-w-full rounded-lg border border-border-default/50`,...r})}var cZ={img:sZ},lZ=`prose prose-sm max-w-none text-[14px] leading-relaxed`;function uZ({children:e,className:t=``,noProse:n=!1}){let r=`${lZ}${oz(e=>e.resolved===`dark`)?` prose-invert`:``}`;return(0,J.jsx)(`div`,{className:n?t:`${r} ${t}`.trim(),children:(0,J.jsx)(eJ,{remarkPlugins:[iZ],urlTransform:oZ,components:cZ,children:e})})}var dZ=null;async function fZ(){return dZ||=(async()=>{let{createHighlighter:e}=await _(async()=>{let{createHighlighter:e}=await import(`./bundle-web-hHh7gz2L.js`);return{createHighlighter:e}},__vite__mapDeps([0,1]));return await e({themes:[`github-dark`,`github-light`],langs:[`plaintext`]})})(),dZ}var pZ={sh:`bash`,bash:`bash`,zsh:`bash`,h:`c`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,kt:`kotlin`,yml:`yaml`,htm:`html`,conf:`ini`},mZ=new Set(`ts.tsx.js.jsx.mjs.cjs.py.rb.php.go.rs.java.kt.swift.scala.c.cpp.cc.cxx.h.hpp.cs.m.mm.sh.bash.zsh.fish.ps1.json.yaml.yml.toml.ini.conf.xml.css.scss.sass.less.html.htm.sql.graphql.proto.lua.perl.pl.dockerfile.makefile`.split(`.`));function hZ(e){let t=e.toLowerCase();if(t===`dockerfile`||t.endsWith(`/dockerfile`))return`docker`;if(t===`makefile`||t.endsWith(`/makefile`))return`makefile`;let n=t.lastIndexOf(`.`);if(n<0)return null;let r=t.slice(n+1);return mZ.has(r)?pZ[r]??r:null}function gZ({code:e,lang:t,className:n=``}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1),o=oz(e=>e.resolved===`light`?`github-light`:`github-dark`);(0,d.useEffect)(()=>(a.current=!1,(async()=>{try{let n=await fZ();n.getLoadedLanguages().includes(t)||await n.loadLanguage(t);let r=n.codeToHtml(e,{lang:t,theme:o});a.current||i(r)}catch(e){console.warn(`[CodeBlock] highlight failed (${t}): ${e instanceof Error?e.message:String(e)}`)}})(),()=>{a.current=!0}),[e,t,o]);let s=(0,d.useMemo)(()=>{if(e.length===0)return 1;let t=e.split(`
73
73
  `).length;return Math.max(1,e.endsWith(`
74
74
  `)?t-1:t)},[e]);return(0,J.jsxs)(`div`,{className:`group relative ${n}`,children:[(0,J.jsx)(_Z,{text:e}),(0,J.jsxs)(`div`,{className:`flex`,children:[(0,J.jsx)(`pre`,{"aria-hidden":!0,className:`select-none border-r border-border-subtle bg-bg-base px-3 py-3 text-right font-mono text-[12px] leading-[1.6] text-fg-fainter`,children:Array.from({length:s},(e,t)=>t+1).join(`
75
75
  `)}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,children:r?(0,J.jsx)(`div`,{className:`shiki-host font-mono text-[12px] leading-[1.6]`,dangerouslySetInnerHTML:{__html:r}}):(0,J.jsx)(`pre`,{className:`whitespace-pre px-3 py-3 font-mono text-[12px] leading-[1.6] text-fg-default`,children:e})})]})]})}function _Z({text:e}){let[t,n]=(0,d.useState)(!1);return(0,J.jsx)(`button`,{type:`button`,className:`absolute right-2 top-2 z-10 rounded-md border border-border-subtle/80 bg-bg-elevated/80 p-1.5 text-fg-muted opacity-0 backdrop-blur transition-opacity hover:bg-bg-raised group-hover:opacity-100`,title:t?`Copied`:`Copy`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)}).catch(()=>{})},children:t?(0,J.jsx)(xl,{size:14}):(0,J.jsx)(df,{size:14})})}function vZ({html:e,className:t=``,initialMode:n=`render`}){let[r,i]=(0,d.useState)(n);return(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${t}`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-end gap-1 border-b border-border-subtle bg-bg-base/50 px-3 py-1.5`,children:(0,J.jsx)(yZ,{mode:r,onChange:i})}),r===`render`?(0,J.jsx)(`iframe`,{srcDoc:e,sandbox:`allow-scripts allow-popups allow-forms allow-modals`,className:`min-h-0 w-full flex-1 border-0 bg-white`,title:`HTML preview`},e.slice(0,64)+e.length):(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,J.jsx)(gZ,{code:e,lang:`html`})})]})}function yZ({mode:e,onChange:t}){return(0,J.jsxs)(`div`,{className:`inline-flex rounded-md border border-border-subtle bg-bg-elevated/60 p-0.5 text-[11px] text-fg-muted`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>t(`render`),className:`flex items-center gap-1 rounded px-2 py-0.5 transition-colors ${e===`render`?`bg-bg-hover text-fg-default`:`hover:bg-bg-hover/60 hover:text-fg-default`}`,title:`Live preview`,children:[(0,J.jsx)(Xp,{size:12}),(0,J.jsx)(`span`,{children:`Render`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>t(`source`),className:`flex items-center gap-1 rounded px-2 py-0.5 transition-colors ${e===`source`?`bg-bg-hover text-fg-default`:`hover:bg-bg-hover/60 hover:text-fg-default`}`,title:`View source`,children:[(0,J.jsx)(Ld,{size:12}),(0,J.jsx)(`span`,{children:`Source`})]})]})}function bZ({src:e,title:t=`PDF preview`,className:n=``}){return(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col ${n}`,children:(0,J.jsx)(`iframe`,{src:e,title:t,className:`h-full w-full border-0 bg-white`})})}function xZ({src:e,className:t=``}){return(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-black ${t}`,children:(0,J.jsx)(`video`,{src:e,controls:!0,className:`max-h-full max-w-full`,children:(0,J.jsx)(`track`,{kind:`captions`})})})}function SZ({src:e,className:t=``}){return(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-bg-base p-6 ${t}`,children:(0,J.jsx)(`audio`,{src:e,controls:!0,className:`w-full max-w-2xl`,children:(0,J.jsx)(`track`,{kind:`captions`})})})}var CZ=`.svg`;function wZ({src:e,filename:t,svgSource:n,className:r=``}){let i=!!t&&t.toLowerCase().endsWith(CZ),[a,o]=(0,d.useState)(`render`);return!i||!n?(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-bg-base ${r}`,children:(0,J.jsx)(`img`,{src:e,alt:t??`image`,className:`max-h-full max-w-full object-contain`})}):(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${r}`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-end gap-1 border-b border-border-subtle bg-bg-base/50 px-3 py-1.5`,children:(0,J.jsx)(TZ,{mode:a,onChange:o})}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:a===`render`?(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center bg-bg-base`,children:(0,J.jsx)(`img`,{src:e,alt:t??`image`,className:`max-h-full max-w-full object-contain`})}):(0,J.jsx)(gZ,{code:n,lang:`xml`})})]})}function TZ({mode:e,onChange:t}){return(0,J.jsxs)(`div`,{className:`inline-flex rounded-md border border-border-subtle bg-bg-elevated/60 p-0.5 text-[11px] text-fg-muted`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>t(`render`),className:`flex items-center gap-1 rounded px-2 py-0.5 transition-colors ${e===`render`?`bg-bg-hover text-fg-default`:`hover:bg-bg-hover/60 hover:text-fg-default`}`,title:`Render`,children:[(0,J.jsx)(Xp,{size:12}),(0,J.jsx)(`span`,{children:`Render`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>t(`source`),className:`flex items-center gap-1 rounded px-2 py-0.5 transition-colors ${e===`source`?`bg-bg-hover text-fg-default`:`hover:bg-bg-hover/60 hover:text-fg-default`}`,title:`View source`,children:[(0,J.jsx)(Ld,{size:12}),(0,J.jsx)(`span`,{children:`Source`})]})]})}var EZ=1e3;function DZ({content:e,delimiter:n=`,`,className:r=``}){let[i,a]=(0,d.useState)(null);(0,d.useEffect)(()=>{let r=!1;return(async()=>{try{let i=(await _(async()=>{let{default:e}=await import(`./papaparse.min-BQRX_pWo.js`).then(e=>t(e.default,1));return{default:e}},__vite__mapDeps([2,1]))).default.parse(e,{delimiter:n,skipEmptyLines:!0});if(r)return;let o=i.data;if(o.length===0){a({headers:[],rows:[],totalRows:0});return}let s=o[0];a({headers:s,rows:o.slice(1,1001),totalRows:o.length-1,error:i.errors[0]?.message})}catch(e){r||a({headers:[],rows:[],totalRows:0,error:e instanceof Error?e.message:String(e)})}})(),()=>{r=!0}},[e,n]);let o=(0,d.useMemo)(()=>{if(!i)return[];let e=i.headers.length;return i.rows.map(t=>{if(t.length>=e)return t;let n=t.slice();for(;n.length<e;)n.push(``);return n})},[i]);if(!i)return(0,J.jsx)(`div`,{className:`p-4 text-sm text-fg-faint ${r}`,children:`Parsing table…`});if(i.error&&i.rows.length===0)return(0,J.jsxs)(`div`,{className:`p-4 text-sm text-danger ${r}`,children:[`Failed to parse table: `,i.error]});if(i.headers.length===0&&i.rows.length===0)return(0,J.jsx)(`div`,{className:`p-4 text-sm text-fg-faint ${r}`,children:`No rows.`});let s=i.totalRows>EZ;return(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${r}`,children:[s&&(0,J.jsxs)(`div`,{className:`mx-3 mt-3 rounded border border-amber-900/40 bg-amber-950/30 px-2 py-1 text-[11px] text-amber-200`,children:[`Showing first `,EZ.toLocaleString(),` of`,` `,i.totalRows.toLocaleString(),` data rows. Download the file to inspect the rest.`]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,J.jsxs)(`table`,{className:`border-collapse text-[12px]`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsx)(`tr`,{className:`bg-bg-elevated text-fg-muted`,children:i.headers.map((e,t)=>(0,J.jsx)(`th`,{className:`sticky top-0 z-10 border-b border-border-default bg-bg-elevated px-2 py-1.5 text-left font-medium`,children:e||`Col ${t+1}`},t))})}),(0,J.jsx)(`tbody`,{children:o.map((e,t)=>(0,J.jsx)(`tr`,{className:`border-b border-border-subtle hover:bg-bg-elevated/40`,children:e.map((e,t)=>(0,J.jsx)(`td`,{className:`max-w-[28rem] truncate border-r border-border-subtle px-2 py-1 text-fg-muted`,title:e,children:e},t))},t))})]})})]})}var OZ=new Set([`md`,`markdown`]),kZ=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`]),AZ=new Set([`mp4`,`webm`,`ogv`,`mov`,`m4v`,`mkv`]),jZ=new Set([`mp3`,`wav`,`ogg`,`flac`,`m4a`,`aac`,`opus`]);function MZ(e){if(!e)return``;let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t+1).toLowerCase()}function NZ(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function PZ({content:e,mimeType:t,filename:n,binary:r,loading:i,error:a,sizeBytes:o,rawUrl:s,className:c=``}){if(i)return(0,J.jsx)(`div`,{className:`flex h-32 items-center justify-center ${c}`,children:(0,J.jsx)(q,{size:20,className:`animate-spin text-fg-faint`})});if(a)return(0,J.jsx)(`div`,{className:`p-6 text-center text-sm text-danger ${c}`,children:a});let l=MZ(n),u=t&&t.startsWith(`image/`)||kZ.has(l),d=l===`pdf`||t===`application/pdf`,f=t&&t.startsWith(`video/`)||AZ.has(l),p=t&&t.startsWith(`audio/`)||jZ.has(l);if((u||d||f||p)&&s){if(u)return(0,J.jsx)(wZ,{src:s,filename:n,svgSource:(l===`svg`||t===`image/svg+xml`)&&e?e:void 0,className:c});if(d)return(0,J.jsx)(bZ,{src:s,title:n,className:c});if(f)return(0,J.jsx)(xZ,{src:s,className:c});if(p)return(0,J.jsx)(SZ,{src:s,className:c})}if(new Set([`doc`,`docx`,`dot`,`dotx`,`xls`,`xlsx`,`xlsm`,`xlsb`,`ppt`,`pptx`,`pps`,`ppsx`,`odt`,`ods`,`odp`,`odg`,`rtf`]).has(l))return(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-8 text-center ${c}`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg-default`,children:`Office preview is coming soon`}),(0,J.jsxs)(`div`,{className:`max-w-md text-[12px] leading-relaxed text-fg-faint`,children:[`In-browser rendering for`,` `,(0,J.jsxs)(`code`,{className:`font-mono text-fg-muted`,children:[`.`,l]}),` files needs a server-side LibreOffice pass that hasn't shipped yet. Use the`,` `,(0,J.jsx)(`span`,{className:`text-fg-muted`,children:`Download`}),` button above to open this file in your local Office / LibreOffice / Pages.`]}),o!=null&&(0,J.jsx)(`div`,{className:`text-[11px] text-fg-fainter`,children:NZ(o)})]});if(r&&!u)return(0,J.jsxs)(`div`,{className:`p-6 text-center text-sm text-fg-faint ${c}`,children:[`Binary file`,o==null?``:` (${NZ(o)})`,`. No preview available.`]});if(e==null)return(0,J.jsx)(`div`,{className:`p-6 text-center text-sm text-fg-faint ${c}`,children:`No content.`});if(l===`csv`||t===`text/csv`)return(0,J.jsx)(DZ,{content:e,delimiter:`,`,className:c});if(l===`tsv`||t===`text/tab-separated-values`)return(0,J.jsx)(DZ,{content:e,delimiter:`\\t`,className:c});if(OZ.has(l)||t===`text/markdown`||t===`text/x-markdown`)return(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4 ${c}`,children:(0,J.jsx)(uZ,{children:e})});if(l===`html`||l===`htm`)return(0,J.jsx)(vZ,{html:e,className:c});let m=n?hZ(n):null;return m?(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto ${c}`,children:(0,J.jsx)(gZ,{code:e,lang:m})}):(0,J.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-all p-4 font-mono text-xs text-fg-default ${c}`,children:e})}IB(),cz(),aF(Qz),lF(GB),pF({Modal:SV,MarkdownBlock:uZ,DocumentViewer:PZ}),gF(()=>({mode:oz(e=>e.mode),resolved:oz(e=>e.resolved),setMode:oz(e=>e.setMode)})),vF(()=>({viewingSessionId:A(e=>e.viewingSessionId),setViewingSession:A(e=>e.selectSession)})),xF({subscribe:(e,t)=>sr.on(e,t)??(()=>{})}),globalThis.__tianshuPluginSdkOpenFile__||sF({open:e=>{let t=e.replace(/^workspace:\/\/+/,`/`),n=`/api/p/files/raw?path=${encodeURIComponent(t)}`;window.open(n,`_blank`,`noopener`)}});var FZ=document.getElementById(`root`);if(!FZ)throw Error(`#root not found`);p.createRoot(FZ).render((0,J.jsx)(d.StrictMode,{children:(0,J.jsx)(yV,{})}));export{aH as a,_ as c,lH as i,uH as n,kV as o,cH as r,CV as s,aJ as t};