@netnodeag/kraftwerk 0.78.0 → 0.79.0

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/editor-DHAdW1g_.js","assets/dist-CYzOYk_e.js","assets/dist-Crnb8VVO.js","assets/dist-CpLdAqFQ.js","assets/dist-BTc878j7.js","assets/dist-BdZ5cNRp.js","assets/editor-CZMrhTTL.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-BQlHN7qT.js","assets/dist-CYzOYk_e.js","assets/dist-cNijUfNl.js","assets/dist-D93lSM0a.js","assets/dist-xLZN2eGO.js","assets/dist-BdZ5cNRp.js","assets/editor-CZMrhTTL.css"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((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.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.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`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ee=/\/+/g;function te(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function j(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(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 M(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,M(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+te(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(ee,`$&/`)+`/`),M(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ee,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+te(a,u),c+=M(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+te(a,u++),c+=M(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return M(j(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 N(e,t,n){if(e==null)return e;var r=[],i=0;return M(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ne(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var re=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)};function P(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,re)}catch(e){re(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function F(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else P(F.bind(null,e))}var I={map:N,forEach:function(e,t,n){N(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return N(e,function(){t++}),t},toArray:function(e){return N(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=I,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=F,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=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.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 D(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)E.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 D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ne}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=P,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.0`})),d=o(((e,t)=>{t.exports=u()})),f=o((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,O());else{var t=n(l);t!==null&&ee(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){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&&ee(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function ee(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,ee(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),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}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();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 i={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},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(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=i,e.browser=function(e){return{$$typeof:o,_reason:e}},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 c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.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,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,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=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.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=u(n,t.crossOrigin);i.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=u(t.as,t.crossOrigin);i.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,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),h=o(((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=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(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 a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(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 c(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 l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),ee=Symbol.for(`react.fragment`),te=Symbol.for(`react.strict_mode`),j=Symbol.for(`react.profiler`),M=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),P=Symbol.for(`react.suspense_list`),F=Symbol.for(`react.memo`),I=Symbol.for(`react.lazy`),ie=Symbol.for(`react.activity`),ae=Symbol.for(`react.legacy_hidden`),oe=Symbol.for(`react.memo_cache_sentinel`),se=Symbol.for(`react.view_transition`),ce=Symbol.for(`react.recoverable`),le=Symbol.iterator;function ue(e){return typeof e!=`object`||!e?null:(e=le&&e[le]||e[`@@iterator`],typeof e==`function`?e:null)}var de=Symbol.for(`react.client.reference`);function fe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===de?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case ee:return`Fragment`;case j:return`Profiler`;case te:return`StrictMode`;case re:return`Suspense`;case P:return`SuspenseList`;case ie:return`Activity`;case se:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case N:return e.displayName||`Context`;case M:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case F:return t=e.displayName||null,t===null?fe(e.type)||`Memo`:t;case I:t=e._payload,e=e._init;try{return fe(e(t))}catch{}}return null}var L=Array.isArray,R=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,pe={pending:!1,data:null,method:null,action:null},me=[],he=-1;function ge(e){return{current:e}}function _e(e){0>he||(e.current=me[he],me[he]=null,he--)}function ve(e,t){he++,me[he]=e.current,e.current=t}var ye=ge(null),be=ge(null),xe=ge(null),Se=ge(null);function Ce(e,t){switch(ve(xe,t),ve(be,e),ve(ye,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}_e(ye),ve(ye,e)}function we(){_e(ye),_e(be),_e(xe)}function Te(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,ve(Se,e)),t=ye.current;var n=dp(t,e.type);t!==n&&(ve(be,e),ve(ye,n))}function Ee(e){be.current===e&&(_e(ye),_e(be)),Se.current===e&&(_e(Se),sh._currentValue=pe)}var De,Oe;function ke(e){if(De===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);De=t&&t[1]||``,Oe=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+De+e+Oe}var Ae=!1;function je(e,t){if(!e||Ae)return``;Ae=!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}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}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(`
@@ -212,14 +212,14 @@ Instructions this agent follows when the skill applies or is invoked with /<name
212
212
  `;function js({slug:e}){let t=M(`agents.skills`,{slug:e})?.skills??[],[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);async function c(t){s(``);let n=await A.request(`agents.skill`,{slug:e,name:t}).catch(()=>null);if(!n)return void s(`could not load skill`);if(!n.ok||!n.data||typeof n.data!=`object`)return void s(n.error??`could not load skill`);r({name:t,content:n.data.content??``,isNew:!1})}async function l(){if(!n)return;a(!0),s(``);let t=await A.request(`agents.saveSkill`,{slug:e,body:{name:n.name,content:n.content}});a(!1),!t.ok||!t.data||typeof t.data!=`object`?s(t.error??`save failed`):r(null)}async function u(t){window.confirm(`Move skill "/${t}" of this agent to the trash?`)&&(await A.request(`agents.deleteSkill`,{slug:e,name:t}).catch(()=>{}),n?.name===t&&r(null))}return(0,P.jsxs)(q,{title:`own skills — only this agent`,actions:!n&&(0,P.jsx)(B,{size:`sm`,icon:`add`,onClick:()=>{r({name:``,content:As,isNew:!0}),s(``)},children:`new skill`}),children:[t.length===0&&!n&&(0,P.jsxs)(W,{className:`px-[18px] py-3 text-xs`,children:[`none — skills in `,(0,P.jsxs)(`code`,{children:[`agents/`,e,`/skills/`]}),` are private to this agent; skills for every agent live in the workspace skills folder.`]}),t.length>0&&!n&&(0,P.jsx)(lt,{children:t.map(e=>(0,P.jsx)(ct,{icon:`extension`,title:`/${e.name}`,action:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{size:`sm`,icon:`edit`,onClick:()=>void c(e.name),children:`edit`}),(0,P.jsx)(V,{icon:`delete`,label:`delete /${e.name}`,variant:`danger`,size:`sm`,onClick:()=>void u(e.name)})]}),children:(0,P.jsx)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:e.description||(0,P.jsx)(`code`,{children:`SKILL.md`})})},e.name))}),n&&(0,P.jsxs)(yt,{className:`max-w-[680px]`,children:[(0,P.jsx)(X,{label:`name — invoked as /<name>`,children:(0,P.jsx)(Y,{className:`font-mono`,value:n.name,placeholder:`e.g. report-html`,disabled:!n.isNew,onChange:e=>r({...n,name:e.target.value})})}),(0,P.jsx)(X,{label:`SKILL.md — frontmatter (description) + the instructions`,children:(0,P.jsx)(_t,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,rows:Math.min(28,Math.max(12,n.content.split(`
213
213
  `).length+2)),value:n.content,spellCheck:!1,onChange:e=>r({...n,content:e.target.value})})}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,P.jsx)(B,{variant:`primary`,busy:i,disabled:!n.name.trim(),onClick:()=>void l(),children:i?`saving…`:`save`}),(0,P.jsx)(B,{variant:`quiet`,disabled:i,onClick:()=>r(null),children:`cancel`})]})]}),o&&(0,P.jsx)(`div`,{className:`px-[18px] pb-3`,children:(0,P.jsx)(K,{tone:`bad`,children:o})})]})}function Ms(e){let t=e.adopted.length;if(t===0)return{note:`nothing to adopt — already running here`,error:``};let n=t===1?`"${e.adopted[0].name}" runs`:`${t} routines run`;return e.commit&&!e.commit.ok?{note:``,error:`${n} on ${e.runsOn} — routines.yml written, but not committed: ${e.commit.error??`git failed`}`}:{note:`${n} on ${e.runsOn} now${e.commit?` — committed`:``}`,error:``}}function Ns({r:e}){return e.runner===`here`?(0,P.jsx)(U,{title:`runs_on: ${e.runsOn} — this machine fires it`,children:`runs here`}):e.runner===`unassigned`?(0,P.jsx)(U,{tone:e.enabled?`ask`:`neutral`,title:`no runs_on — it fires on no machine until one adopts it`,children:`no runner`}):e.retired?(0,P.jsxs)(U,{tone:`ask`,title:`${e.runsOn} is a retired identity of this machine — it fires nowhere until reassigned`,children:[`runs on `,e.runsOn,` · retired`]}):(0,P.jsxs)(U,{title:`another machine fires it, not this one`,children:[`runs on `,e.runsOn]})}function Ps({slug:e}){let[t,n]=(0,v.useState)(0),r=M(`agents.routines`,{slug:e},{refresh:t}),i=M(`identity.get`,{},{interval:6e4}),a=r?.routines??[],[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),g=(It()??[]).filter(e=>e.kind===`runner`),_=g.flatMap(e=>e.routines??[]),y=g.some(e=>e.id.startsWith(`runner:retired:`))||a.some(e=>e.retired),b=a.filter(e=>e.runner===`unassigned`&&e.enabled||e.retired).length,x=_.filter(t=>t.agent!==e).length;async function S(t){l(``);let n=await A.request(`agents.saveRoutine`,{slug:e,body:t});return n.ok?!0:(l(j(n)),!1)}async function C(t){p(t),l(``);let n=await A.request(`agents.runRoutine`,{slug:e,id:t});p(``),n.ok?n.data.chatId&&z(`/agents/${encodeURIComponent(e)}/chat/${n.data.chatId}`):l(j(n))}function w(e){let t=Ms(e);d(t.note),l(t.error),n(e=>e+1),Ft()}async function T(t){h(t),l(``),d(``);let n=await A.request(`agents.adoptRoutine`,{slug:e,id:t});h(``),n.ok?w(n.data):l(j(n))}async function E(){h(`*`),l(``),d(``);let e=await A.request(`routines.adopt`,{body:{retired:y}});h(``),e.ok?w(e.data):l(j(e))}async function D(t){window.confirm(`Delete the scheduled prompt "${t}"?`)&&await A.request(`agents.deleteRoutine`,{slug:e,id:t}).catch(()=>{})}return(0,P.jsxs)(q,{title:`schedule — prompts that run on their own`,actions:!o&&(0,P.jsx)(B,{size:`sm`,icon:`add`,onClick:()=>s({name:``,schedule:`0 9 * * 1-5`,prompt:``,enabled:!0}),children:`schedule a prompt`}),children:[a.length===0&&!o&&(0,P.jsx)(W,{className:`px-[18px] py-3 text-xs`,children:`none — a routine messages this agent on a schedule (cron, server local time) and each run opens a new session with the result.`}),b>0&&(0,P.jsx)(ct,{icon:`event_busy`,title:`${b} routine${b===1?` fires`:`s fire`} nowhere`,action:(0,P.jsx)(B,{size:`sm`,icon:`download_done`,busy:m===`*`,onClick:()=>void E(),children:m===`*`?`adopting…`:`run these here`}),children:(0,P.jsxs)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:[y?`no runner, or a retired identity`:`no runner`,` — makes `,(0,P.jsx)(`code`,{children:i?.identity??`this machine`}),` the runner`,x>0?` of these and ${x} on other agents`:``,` and commits routines.yml`]})}),a.length>0&&(0,P.jsx)(lt,{children:a.map(t=>(0,P.jsx)(ct,{icon:`schedule`,title:(0,P.jsxs)(P.Fragment,{children:[t.name,(0,P.jsx)(Ns,{r:t}),t.lastError&&(0,P.jsx)(`span`,{title:t.lastError,children:(0,P.jsx)(U,{tone:`bad`,children:`error`})}),t.awaitingApproval&&t.lastChatId&&(0,P.jsx)(U,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,tone:`bad`,title:`the last run asked for a permission nobody has answered yet`,children:`needs approval`})]}),action:(0,P.jsxs)(P.Fragment,{children:[t.runner!==`here`&&(0,P.jsx)(B,{size:`sm`,variant:`quiet`,busy:m===t.id,title:`make ${i?.identity??`this machine`} its runner and commit routines.yml`,onClick:()=>void T(t.id),children:m===t.id?`adopting…`:`run here`}),(0,P.jsx)(B,{size:`sm`,icon:`play_arrow`,busy:f===t.id,onClick:()=>C(t.id),children:f===t.id?`starting…`:`run`}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,onClick:()=>s({id:t.id,name:t.name,schedule:t.schedule,prompt:t.prompt,enabled:t.enabled,runsOn:t.runsOn??``,private:t.private??!1}),children:`edit`}),(0,P.jsx)(B,{size:`sm`,variant:`danger`,onClick:()=>void D(t.id),children:`delete`}),(0,P.jsx)(Ct,{checked:t.enabled,label:t.enabled?`enabled — click to pause`:`paused — click to enable`,onChange:()=>void S({id:t.id,name:t.name,schedule:t.schedule,prompt:t.prompt,enabled:!t.enabled})})]}),children:(0,P.jsxs)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:[(0,P.jsx)(`code`,{children:t.schedule}),t.enabled?t.nextRunAt?` · next ${Ge(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,P.jsxs)(ge,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,Ge(t.lastRunAt)]}):`never ran`]})},t.id))}),o&&(0,P.jsxs)(yt,{className:`max-w-[680px]`,children:[(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`name`,className:`flex-1`,children:(0,P.jsx)(Y,{value:o.name,placeholder:`e.g. Morning report`,onChange:e=>s({...o,name:e.target.value})})}),(0,P.jsx)(X,{label:`schedule (cron)`,className:`w-[200px] max-[900px]:w-auto`,children:(0,P.jsx)(Y,{className:`font-mono`,value:o.schedule,placeholder:`0 9 * * 1-5`,onChange:e=>s({...o,schedule:e.target.value})})}),(0,P.jsxs)(`label`,{className:`flex h-9 cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:o.enabled,onChange:e=>s({...o,enabled:e.target.checked})}),`enabled`]})]}),(0,P.jsx)(X,{label:`prompt — what to ask this agent on each run`,children:(0,P.jsx)(_t,{rows:5,value:o.prompt,placeholder:`Check ... and summarize what changed.`,onChange:e=>s({...o,prompt:e.target.value})})}),(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`runs on — the one machine that fires it`,className:`flex-1`,children:(0,P.jsx)(Y,{className:`font-mono`,value:o.runsOn??i?.identity??``,placeholder:`<handle>@<machine> — empty: no runner`,onChange:e=>s({...o,runsOn:e.target.value})})}),(0,P.jsxs)(`label`,{className:`flex h-9 cursor-pointer items-center gap-2 text-sm text-fg`,title:`stored in routines.yml; nothing reads it yet`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:o.private??!1,onChange:e=>s({...o,private:e.target.checked})}),`private`]})]}),i&&(0,P.jsxs)(W,{children:[`This machine is `,(0,P.jsx)(`code`,{children:i.identity}),`. Empty: no runner — it fires nowhere.`]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,P.jsx)(B,{variant:`primary`,disabled:!o.name.trim()||!o.prompt.trim(),onClick:async()=>{let{runsOn:e,...t}=o;await S(e===void 0?t:{...t,runsOn:e.trim()||null})&&s(null)},children:o.id?`save`:`add to the schedule`}),(0,P.jsx)(B,{variant:`quiet`,onClick:()=>(s(null),l(``)),children:`cancel`})]})]}),(c||u)&&(0,P.jsx)(`div`,{className:`px-[18px] pb-3`,children:c?(0,P.jsx)(K,{tone:`bad`,children:c}):(0,P.jsx)(K,{children:u})})]})}function Fs({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(!0),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),b=Te(),x=M(`workflows.list`,{}),S=M(`knowledge.list`,{}),C=M(`vibeables.list`,b.vibeables?{}:null),w=M(`skills.list`,{});(0,v.useEffect)(()=>{let t=!0;return A.call(`agents.get`,{slug:e}).then(e=>t&&n(e)).catch(()=>t&&i(!0)),()=>{t=!1}},[e]);async function T(r){if(t){g(!0),y(``);try{let i=await A.request(`agents.save`,{slug:e,body:{name:t.name,emoji:t.emoji,description:t.description,harness:t.harness,model:t.model,effort:t.effort,group:t.group,system:t.system,workflows:t.workflows,knowledge:t.knowledge,vibeables:t.vibeables,skills:t.skills,...r}});i.ok?(n(i.data),c(``)):y(j(i))}catch(e){y(e.message)}g(!1)}}function E(e,t){f(t?[...d,e]:d.filter(t=>t!==e))}async function D(t){g(!0),y(``);try{let r=await A.request(`agents.archive`,{slug:e,body:{archived:t}});r.ok?n(r.data):y(j(r))}catch(e){y(e.message)}g(!1)}if(r)return(0,P.jsx)(G,{icon:`person_off`,children:`agent not found`});if(!t)return(0,P.jsx)(G,{children:`loading…`});let O=e=>(0,P.jsxs)(`div`,{className:`mt-2 flex items-center gap-2.5`,children:[(0,P.jsx)(B,{variant:`primary`,busy:h,onClick:()=>void T(e),children:h?`saving…`:`save`}),(0,P.jsx)(B,{variant:`quiet`,disabled:h,onClick:()=>(c(``),y(``)),children:`cancel`})]}),k=e=>(0,P.jsx)(B,{size:`sm`,onClick:()=>{e(),y(``)},children:`edit`});return(0,P.jsxs)(`div`,{className:`agent-view flex animate-rise flex-col gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2.5`,children:[(0,P.jsx)(ot,{children:(0,P.jsx)(`span`,{"aria-hidden":!0,children:t.emoji})}),(0,P.jsx)(rt,{size:`lg`,children:t.name}),(0,P.jsx)(U,{children:t.harness}),t.model&&(0,P.jsx)(U,{children:t.model}),t.effort&&(0,P.jsxs)(U,{children:[`effort: `,t.effort]}),t.archived&&(0,P.jsxs)(U,{children:[(0,P.jsx)(F,{name:`inventory_2`,className:`ms-sm mr-1`}),` archived`]}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsx)(B,{href:`/agents/${encodeURIComponent(e)}/edit`,children:`edit`}),t.archived?(0,P.jsx)(B,{variant:`primary`,icon:`unarchive`,busy:h,onClick:()=>void D(!1),children:h?`…`:`unarchive`}):(0,P.jsx)(B,{variant:`quiet`,icon:`archive`,disabled:h,title:`Hide this agent from the roster — restorable any time`,onClick:()=>void D(!0),children:`archive`})]}),(0,P.jsxs)(q,{children:[(0,P.jsxs)(lt,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`button`,{type:`button`,className:`flex w-full cursor-pointer items-center gap-3.5 border-0 bg-transparent px-[18px] py-3 text-left font-[inherit] text-inherit hover:bg-surface-2`,"aria-expanded":a,onClick:()=>o(!a),children:[(0,P.jsx)(st,{name:`badge`}),(0,P.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,P.jsx)(`span`,{className:`text-[13.5px] font-medium text-fg`,children:`role`}),!a&&(0,P.jsx)(`span`,{className:N(`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,`truncate`),children:(t.system||``).trim().split(`
214
214
  `)[0]||`empty — expand to give this agent a role`})]}),(0,P.jsx)(F,{name:`expand_more`,className:N(`ms-sm flex-none text-fg-2 transition-transform`,a&&`rotate-180`)})]}),a&&s!==`role`&&(0,P.jsxs)(`div`,{className:`pr-[18px] pb-4 pl-16`,children:[(0,P.jsx)(`pre`,{className:`m-0 font-mono text-[12.5px] leading-[1.65] whitespace-pre-wrap`,children:t.system||`(empty — click edit to give this agent a role)`}),(0,P.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-2.5`,children:[(0,P.jsx)(B,{size:`sm`,icon:`edit`,onClick:()=>{u(t.system),c(`role`),y(``)},children:`edit role`}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsxs)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:[`agents/`,t.slug,`/system.md`]})]})]}),a&&s===`role`&&(0,P.jsxs)(`div`,{className:`pr-[18px] pb-4 pl-16`,children:[(0,P.jsx)(_t,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,"aria-label":`role`,rows:Math.min(24,Math.max(8,l.split(`
215
- `).length+2)),value:l,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>u(e.target.value),spellCheck:!1}),O({system:l})]})]}),(0,P.jsx)(ct,{icon:`account_tree`,title:`workflows`,action:s!==`workflows`&&k(()=>(f(t.workflows),c(`workflows`))),children:s===`workflows`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(gs,{children:[(x?.workflows??[]).map(e=>(0,P.jsx)(xt,{checked:d.includes(e.slug),onChange:t=>E(e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),(x?.workflows??[]).length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),O({workflows:d})]}):t.workflows.length===0?(0,P.jsx)(`span`,{className:ms,children:`none connected — the agent can run any workflow you connect`}):(0,P.jsx)(hs,{children:t.workflows.map(e=>(0,P.jsx)(U,{href:`/workflows/${encodeURIComponent(e)}`,children:e},e))})}),(0,P.jsx)(ct,{icon:`menu_book`,title:`knowledge`,action:s!==`knowledge`&&k(()=>(f(t.knowledge),c(`knowledge`))),children:s===`knowledge`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(gs,{children:[(S?.bundles??[]).map(e=>(0,P.jsx)(xt,{checked:d.includes(e.name),onChange:t=>E(e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),(S?.bundles??[]).length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),O({knowledge:d})]}):t.knowledge.length===0?(0,P.jsx)(`span`,{className:ms,children:`none connected — connected bundles are read and kept current by the agent`}):(0,P.jsx)(hs,{children:t.knowledge.map(e=>(0,P.jsx)(U,{href:`/knowledge/${encodeURIComponent(e)}`,children:e},e))})}),(b.vibeables||(t.vibeables??[]).length>0)&&(0,P.jsx)(ct,{icon:`web`,title:`apps`,"data-link-kind":`vibeables`,action:s!==`vibeables`&&k(()=>(f(t.vibeables??[]),c(`vibeables`))),children:s===`vibeables`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(gs,{children:[(C?.vibeables??[]).map(e=>(0,P.jsx)(xt,{checked:d.includes(e.slug),onChange:t=>E(e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),d.filter(e=>!(C?.vibeables??[]).some(t=>t.slug===e)).map(e=>(0,P.jsx)(xt,{checked:!0,onChange:t=>E(e,t),hint:`not found in this workspace`,mono:!0,children:e},e)),!b.vibeables&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),b.vibeables&&(C?.vibeables??[]).length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no apps in this workspace yet — create one on the apps page`})]}),O({vibeables:d})]}):(t.vibeables??[]).length===0?(0,P.jsx)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:`none linked — linked apps are the agent's to build and maintain; it knows them from the first message`}):(0,P.jsx)(hs,{children:(t.vibeables??[]).map(e=>{let t=!b.vibeables||!C||C.vibeables.some(t=>t.slug===e);return(0,P.jsxs)(U,{href:`/vibeables/${encodeURIComponent(e)}`,tone:t?`neutral`:`bad`,title:t?void 0:`configured but not found in this workspace`,children:[e,!t&&` · not found`]},e)})})}),(0,P.jsx)(ct,{icon:`extension`,title:`shared skills`,action:s!==`skills`&&k(()=>{m(t.skills===void 0),f(t.skills??[]),c(`skills`)}),children:s===`skills`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(gs,{children:[(0,P.jsx)(xt,{checked:p,onChange:m,hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),!p&&(w?.skills??[]).map(e=>(0,P.jsx)(xt,{checked:d.includes(e.name),onChange:t=>E(e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),!p&&(w?.skills??[]).length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),O({skills:p?void 0:d})]}):t.skills===void 0?(0,P.jsx)(`span`,{className:ms,children:`all discovered skills (default) — invoke with /name in a session`}):t.skills.length===0?(0,P.jsx)(`span`,{className:ms,children:`none — this agent runs without skills`}):(0,P.jsx)(hs,{children:t.skills.map(e=>(0,P.jsxs)(U,{children:[`/`,e]},e))})})]}),_&&(0,P.jsx)(`div`,{className:`px-[18px] pb-3`,children:(0,P.jsx)(K,{tone:`bad`,children:_})})]}),(0,P.jsx)(js,{slug:e}),(0,P.jsx)(Ps,{slug:e})]})}var Is=[`🤖`,`🧑‍💻`,`🎧`,`🛠️`,`📊`,`✍️`,`🔍`,`🧹`,`📦`,`🚀`];function Ls({slug:e}){let[t,n]=(0,v.useState)(e?null:f()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=M(`workflows.list`,{})?.workflows??[],c=M(`knowledge.list`,{})?.bundles??[],l=Te(),u=M(`vibeables.list`,l.vibeables?{}:null)?.vibeables??[],d=M(`skills.list`,{})?.skills??[];(0,v.useEffect)(()=>{e&&A.call(`agents.get`,{slug:e}).then(e=>n({name:e.name,emoji:e.emoji,description:e.description??``,harness:e.harness,model:e.model??``,effort:e.effort??``,group:e.group??``,system:e.system,workflows:e.workflows,knowledge:e.knowledge??[],vibeables:e.vibeables??[],skillsAll:e.skills===void 0,skills:e.skills??[]})).catch(()=>i(`agent not found`))},[e]);function f(){return{name:``,emoji:`🤖`,description:``,harness:`claude`,model:``,effort:``,group:``,system:``,workflows:[],knowledge:[],vibeables:[],skillsAll:!0,skills:[]}}async function p(){if(!t)return;o(!0),i(``);let n={...t,skills:t.skillsAll?void 0:t.skills},r=e?await A.request(`agents.save`,{slug:e,body:n}):await A.request(`agents.create`,{body:n});o(!1),r.ok?z(`/agents/${encodeURIComponent(r.data.slug)}/info`):i(j(r))}async function m(){e&&window.confirm(`Move agent "${e}" to the trash?`)&&(await A.request(`agents.delete`,{slug:e}).catch(()=>{}),z(`/agents`))}if(!t)return(0,P.jsx)(G,{children:r||`loading…`});let h=e=>n({...t,...e}),g=(e,n,r)=>h({[e]:r?[...t[e],n]:t[e].filter(e=>e!==n)});return(0,P.jsxs)(at,{width:`narrow`,children:[(0,P.jsx)(rt,{children:e?`edit ${e}`:`new agent`}),(0,P.jsx)(q,{children:(0,P.jsxs)(yt,{className:`max-w-[680px]`,children:[(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`name`,className:`flex-1`,children:(0,P.jsx)(Y,{value:t.name,placeholder:`e.g. Max`,onChange:e=>h({name:e.target.value})})}),(0,P.jsx)(X,{label:`emoji`,className:`w-[90px] max-[900px]:w-auto`,children:(0,P.jsx)(Y,{value:t.emoji,onChange:e=>h({emoji:e.target.value})})})]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Is.map(e=>(0,P.jsx)(`button`,{type:`button`,"aria-pressed":t.emoji===e,className:N(`cursor-pointer rounded-xl border px-2.5 py-1.5 text-base transition-colors`,t.emoji===e?`border-transparent bg-accent-soft`:`border-line bg-transparent hover:bg-surface-2`),onClick:()=>h({emoji:e}),children:e},e))}),(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`description`,className:`flex-1`,children:(0,P.jsx)(Y,{value:t.description,placeholder:`one line: what this agent is for`,onChange:e=>h({description:e.target.value})})}),(0,P.jsx)(X,{label:`group`,className:`w-[180px] max-[900px]:w-auto`,children:(0,P.jsx)(Y,{value:t.group,placeholder:`none`,onChange:e=>h({group:e.target.value})})})]}),(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`harness`,className:`w-[140px] max-[900px]:w-auto`,children:(0,P.jsxs)(vt,{value:t.harness,onChange:e=>h({harness:e.target.value}),children:[(0,P.jsx)(`option`,{value:`claude`,children:`claude`}),(0,P.jsx)(`option`,{value:`codex`,children:`codex`}),(0,P.jsx)(`option`,{value:`pi`,children:`pi`})]})}),(0,P.jsx)(X,{label:`model`,className:`flex-1`,children:(0,P.jsx)(Y,{className:`font-mono`,value:t.model,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>h({model:e.target.value})})}),(0,P.jsx)(X,{label:`effort`,className:`w-[140px] max-[900px]:w-auto`,children:(0,P.jsx)(vt,{value:t.effort,onChange:e=>h({effort:e.target.value}),children:Je.map(e=>(0,P.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,P.jsx)(X,{label:`system prompt — the agent's role`,children:(0,P.jsx)(_t,{className:_s,rows:10,value:t.system,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>h({system:e.target.value})})}),(0,P.jsxs)(Rs,{label:`connected workflows — autoloaded into the agent's context; it can run them`,children:[s.map(e=>(0,P.jsx)(xt,{checked:t.workflows.includes(e.slug),onChange:t=>g(`workflows`,e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),s.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),(0,P.jsxs)(Rs,{label:`connected knowledge — OKF bundles the agent consults and maintains`,children:[c.map(e=>(0,P.jsx)(xt,{checked:t.knowledge.includes(e.name),onChange:t=>g(`knowledge`,e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),c.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),(l.vibeables||t.vibeables.length>0)&&(0,P.jsxs)(Rs,{label:`apps — small apps the agent builds and maintains`,linkKind:`vibeables`,children:[u.map(e=>(0,P.jsx)(xt,{checked:t.vibeables.includes(e.slug),onChange:t=>g(`vibeables`,e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),t.vibeables.filter(e=>!u.some(t=>t.slug===e)).map(e=>(0,P.jsx)(xt,{checked:!0,onChange:()=>g(`vibeables`,e,!1),hint:`not found in this workspace`,mono:!0,children:e},e)),!l.vibeables&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),l.vibeables&&u.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no vibeables in this workspace yet`})]}),(0,P.jsxs)(Rs,{label:`connected skills — workspace skill packages (see the skills tab); invoked with /name in sessions`,children:[(0,P.jsx)(xt,{checked:t.skillsAll,onChange:e=>h({skillsAll:e}),hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),!t.skillsAll&&d.map(e=>(0,P.jsx)(xt,{checked:t.skills.includes(e.name),onChange:t=>g(`skills`,e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),!t.skillsAll&&d.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),r&&(0,P.jsx)(K,{tone:`bad`,children:r}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,P.jsx)(B,{variant:`primary`,busy:a,disabled:!t.name.trim(),onClick:p,children:a?`saving…`:e?`save`:`create`}),(0,P.jsx)(`span`,{className:`flex-1`}),e&&(0,P.jsx)(B,{variant:`danger`,icon:`delete`,onClick:m,children:`delete agent`})]})]})})]})}function Rs({label:e,linkKind:t,children:n}){return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-link-kind":t,children:[(0,P.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e}),(0,P.jsx)(gs,{children:n})]})}var zs=`bg-accent/7 outline-[1.5px] -outline-offset-[1.5px] outline-accent outline-dashed`,Bs=`px-2.5 pt-1.5 pb-2 text-2xs text-fg-2`;function Vs({seg:e}){let t=e[0]&&e[0]!==`new`&&e[0]!==`chats`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[0]===`chats`?`chats`:e[1]===`edit`?`edit`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`agent`:`home`,r=n===`chats`&&e[1]===`new`,i=n===`chat`?e[2]:n===`chats`&&!r?e[1]:void 0,a=M(`agents.list`,{}),o=xe(),s=Ba(),[c,l]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`kw-agent-groups`)??`[]`);return Array.isArray(e)?e.map(String):[]}catch{return[]}}),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)({}),T=(a?.agents??[]).map(e=>C[e.slug]===void 0?e:{...e,group:C[e.slug]||void 0});(0,v.useEffect)(()=>{w(e=>{let t={...e},n=!1;for(let e of a?.agents??[])t[e.slug]!==void 0&&(e.group??``)===t[e.slug]&&(delete t[e.slug],n=!0);return n?t:e})},[a]);let E=T.filter(e=>!e.archived),D=T.filter(e=>e.archived),[O,k]=(0,v.useState)(!1),ee=[...new Set([...E.map(e=>e.group??``).filter(Boolean),...c])].sort((e,t)=>e.localeCompare(t)),te=E.filter(e=>!e.group);function j(e){l(e);try{localStorage.setItem(`kw-agent-groups`,JSON.stringify(e))}catch{}}function ne(){let e=f.trim();d(!1),p(``),e&&!ee.includes(e)&&j([...c,e])}function re(e,t){h(null);let n=t.trim();if(n&&n!==e){for(let t of T.filter(t=>t.group===e))I(t.slug,n);c.includes(e)&&j([...new Set(c.map(t=>t===e?n:t))])}}async function I(e,t){if((T.find(t=>t.slug===e)?.group??``)!==t){w(n=>({...n,[e]:t}));try{let n=await A.call(`agents.get`,{slug:e});await A.call(`agents.save`,{slug:e,body:{...n,group:t||void 0}})}catch{w(t=>{let n={...t};return delete n[e],n})}}}let ie=e=>o?{onDragOver:t=>{y!=null&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,x!==e&&S(e))},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||y;n&&I(n,e),b(null),S(null)}}:{},ae=e=>(0,P.jsx)(`div`,{className:y===e.slug?`opacity-40`:void 0,onDragStart:t=>{if(!o)return t.preventDefault();t.dataTransfer.setData(`text/plain`,e.slug),t.dataTransfer.effectAllowed=`move`,b(e.slug)},onDragEnd:()=>{b(null),S(null)},children:(0,P.jsx)(J,{href:`/agents/${encodeURIComponent(e.slug)}`,active:e.slug===t,leading:(0,P.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness})},e.slug),oe=e=>(0,P.jsx)(J,{href:`/agents/${encodeURIComponent(e.slug)}/info`,active:e.slug===t,dim:e.slug!==t,leading:(0,P.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness},e.slug),se;se=n===`new`?(0,P.jsx)(Ls,{},`new`):n===`edit`&&t?(0,P.jsx)(Ls,{slug:t},t):n===`chat`&&t&&i===`new`?(0,P.jsx)(Ss,{slug:t,name:T.find(e=>e.slug===t)?.name},t):n===`chat`&&t&&i?(0,P.jsx)(`div`,{className:`chat-main`,children:(0,P.jsx)(No,{id:i,agentName:T.find(e=>e.slug===t)?.name??t,agentDescription:T.find(e=>e.slug===t)?.description},i)}):n===`chats`?i?(0,P.jsx)(`div`,{className:`chat-main`,children:(0,P.jsx)(No,{id:i},i)}):r?(0,P.jsx)(Ro,{}):(0,P.jsx)(Cs,{}):n===`info`&&t?(0,P.jsx)(Fs,{slug:t},t):t?(0,P.jsx)(xs,{slug:t,name:T.find(e=>e.slug===t)?.name},t):a?E.length?(0,P.jsx)(Os,{agents:E}):(0,P.jsx)(ks,{}):(0,P.jsx)(G,{children:`loading…`});let ce=(n===`agent`||n===`info`||n===`chat`)&&t?T.find(e=>e.slug===t)?.knowledge??[]:[],[le,ue]=(0,v.useState)(()=>localStorage.getItem(`kw-kside`)!==`hidden`),[de,fe]=(0,v.useState)(()=>Number(localStorage.getItem(`kw-kside-w`))||460),L=ce.length>0&&le;function R(e){ue(e),localStorage.setItem(`kw-kside`,e?`open`:`hidden`)}function z(e){fe(e),localStorage.setItem(`kw-kside-w`,String(e))}return(0,P.jsxs)(`div`,{className:`runs-screen agents-screen ${t||n===`chats`?`has-tabs`:``} ${(t||n===`chats`)&&s?`has-sessions`:``} ${L?`has-knowledge`:``}`,style:L?{"--kside-w":`${de}px`}:void 0,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`agents`,action:o&&(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`add`,href:`/agents/new`,children:`new`})}),(0,P.jsxs)(Dt,{children:[(0,P.jsx)(`div`,{className:`mb-1.5 border-b border-line pb-1.5`,children:(0,P.jsx)(J,{href:`/agents/chats`,active:n===`chats`,leading:(0,P.jsx)(`span`,{"aria-hidden":!0,children:`🎩`}),title:`Ralv`,sub:`chief of staff of the workspace`})}),(0,P.jsxs)(`div`,{className:N(`rounded-xl`,y&&x===``&&zs),...ie(``),children:[te.map(ae),y!=null&&te.length===0&&(0,P.jsx)(`div`,{className:Bs,children:`no group — drop here`})]}),ee.map(e=>{let t=E.filter(t=>t.group===e);return(0,P.jsxs)(`div`,{className:N(`group/grp mt-3 rounded-xl`,y&&x===e&&zs),...ie(e),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pt-1.5 pb-0.5`,children:[m===e?(0,P.jsx)(Y,{className:`h-7 min-w-0 flex-1 text-2xs`,autoFocus:!0,"aria-label":`group name`,value:g,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Enter`&&re(e,g),t.key===`Escape`&&h(null)},onBlur:()=>re(e,g)}):(0,P.jsx)(tt,{children:e}),(0,P.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-2`,children:t.length}),(0,P.jsx)(`span`,{className:`flex-1`}),o&&m!==e&&(0,P.jsx)(V,{icon:`edit`,label:`Rename group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>{h(e),_(e)}}),o&&t.length===0&&c.includes(e)&&(0,P.jsx)(V,{icon:`close`,label:`Remove empty group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>j(c.filter(t=>t!==e))})]}),t.map(ae),t.length===0&&(0,P.jsx)(`div`,{className:Bs,children:o?`drag agents here`:`no agents`})]},e)}),D.length>0&&(0,P.jsxs)(`div`,{className:`mt-2.5 border-t border-line pt-1`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`group/arch flex w-full cursor-pointer items-center gap-1.5 border-0 bg-transparent px-2.5 pt-1.5 pb-0.5 text-left text-fg-2`,"aria-expanded":O,onClick:()=>k(e=>!e),children:[(0,P.jsx)(tt,{className:`group-hover/arch:text-fg`,children:`archived`}),(0,P.jsx)(`span`,{className:`text-[10px] tabular-nums`,children:D.length}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsx)(F,{name:O?`expand_less`:`expand_more`,className:`ms-sm`})]}),O&&D.map(oe)]}),a&&T.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-2.5`,children:`no agents yet`}),o&&(u?(0,P.jsx)(`div`,{className:`px-2.5 pt-2.5 pb-1`,children:(0,P.jsx)(Y,{className:`h-8 text-sm`,autoFocus:!0,"aria-label":`new group`,value:f,placeholder:`group name, e.g. Team Content`,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ne(),e.key===`Escape`&&(d(!1),p(``))},onBlur:ne})}):(0,P.jsxs)(`button`,{type:`button`,className:`mx-2.5 mt-3 mb-1 flex cursor-pointer items-center gap-1 rounded-lg border border-dashed border-line bg-transparent px-2.5 py-1 text-2xs text-fg-2 hover:text-accent`,onClick:()=>d(!0),children:[(0,P.jsx)(F,{name:`add`,className:`ms-sm`}),` group`]}))]})]}),t&&(0,P.jsx)(ws,{slug:t,chatId:i===`new`?void 0:i}),n===`chats`&&(0,P.jsx)(Ds,{chatId:i}),(0,P.jsx)(`div`,{className:`runs-main`,children:se}),L&&(0,P.jsx)(vs,{bundles:ce,onHide:()=>R(!1),onResize:z}),ce.length>0&&!le&&(0,P.jsxs)(`button`,{type:`button`,className:`kside-reopen fixed top-[60px] right-3.5 z-5 inline-flex cursor-pointer items-center gap-1 rounded-full border border-line bg-surface-2 px-3 py-1 text-2xs text-fg-2 hover:text-fg`,onClick:()=>R(!0),title:`Show knowledge sidebar`,children:[(0,P.jsx)(F,{name:`menu_book`,className:`ms-sm`}),` knowledge`]})]})}function Hs(e){if(!R(e))return null;let t=e.split(`/`).filter(Boolean),n=decodeURIComponent(t[1]),r=t[0]===`agents`||t[0]===`team`;return n===`new`?t[0]===`projects`?(0,P.jsx)(Xo,{},`new-project`):r?(0,P.jsx)(Ls,{},`new-agent`):(0,P.jsx)(ka,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,P.jsx)(rs,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,P.jsx)(Fs,{slug:n},n):r&&t[2]===`edit`?(0,P.jsx)(Ls,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,P.jsx)(ka,{slug:n},n):null}function Us({back:e,children:t}){let n=()=>z(e);return(0,v.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`.palette-backdrop`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,P.jsx)(`div`,{className:`fixed inset-0 z-40 flex animate-fade items-start justify-center bg-black/38 px-4 pt-[6vh] pb-4 max-[800px]:p-0`,onMouseDown:n,children:(0,P.jsxs)(`div`,{className:`edit-modal relative max-h-[88dvh] w-[min(960px,100%)] animate-modal overflow-y-auto rounded-card border border-line bg-surface shadow-modal max-[800px]:max-h-dvh max-[800px]:rounded-none`,role:`dialog`,"aria-label":`edit`,onMouseDown:e=>e.stopPropagation(),children:[(0,P.jsx)(V,{icon:`close`,label:`close (esc)`,className:`absolute top-3 right-3 z-1 rounded-full`,onClick:n}),(0,P.jsx)(`div`,{className:`runs-main min-w-0 pt-[18px] pr-12 pb-10 pl-6`,children:t})]})})}function Ws({runId:e,decision:t}){let{request:n,answer:r}=t,[i,a]=(0,v.useState)(n.options.length===1?n.options[0].value:null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=e=>n.options.find(t=>t.value===e)?.label??e;if(r)return(0,P.jsx)(`section`,{className:N(Gs,`decision-panel is-decided`),"aria-label":`decision`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,P.jsx)(`div`,{className:Ks,children:n.title??`Decision`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-base`,children:[(0,P.jsx)(U,{tone:`ok`,children:f(r.decision)}),r.note&&(0,P.jsxs)(`span`,{className:`text-fg-2`,children:[`“`,r.note,`”`]}),r.decidedAt&&(0,P.jsx)(`span`,{className:`text-xs tabular-nums text-fg-2`,children:Ge(r.decidedAt)})]})]})});let p=!!i&&!c&&(n.note!==`required`||!!o.trim());async function m(){if(!p)return;l(!0),d(null);let t=await A.request(`runs.decide`,{id:e,body:{decision:i,note:o.trim()}}).catch(()=>null);t?.ok||(d(t?.error??`could not save the decision`),l(!1))}return(0,P.jsx)(`section`,{className:N(Gs,`decision-panel`),"aria-label":`decision needed`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,P.jsx)(H,{tone:`working`}),(0,P.jsx)(`div`,{className:Ks,children:n.title??`This run needs your decision`})]}),n.prompt&&(0,P.jsx)(`p`,{className:`m-0 max-w-[80ch] text-base text-fg-2`,children:n.prompt}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2 self-start`,role:`radiogroup`,"aria-label":`options`,children:n.options.map(e=>(0,P.jsx)(B,{role:`radio`,"aria-checked":i===e.value,variant:i===e.value?`primary`:`secondary`,onClick:()=>a(e.value),children:e.label??e.value},e.value))}),n.note!==!1&&(0,P.jsx)(Y,{value:o,placeholder:n.note===`required`?`Note (required)`:`Note`,"aria-label":`note`,className:`max-w-[60ch]`,onChange:e=>s(e.target.value),onKeyDown:e=>e.key===`Enter`&&m()}),u&&(0,P.jsx)(K,{tone:`bad`,children:u}),(0,P.jsx)(`div`,{className:`flex gap-2`,children:(0,P.jsx)(B,{variant:`primary`,onClick:m,disabled:!p,busy:c,children:c?`Saving…`:`Submit decision`})})]})})}var Gs=`mb-[18px] overflow-hidden rounded-card border border-line bg-surface`,Ks=`text-[16px] font-medium text-fg`;function qs(e){return e===`ok`?`ok`:e===`running`?`working`:e===`failed`||e===`blocked`?`bad`:`idle`}function Js({status:e}){return(0,P.jsx)(`span`,{"data-ui":`status`,"data-status":e,className:`inline-flex`,children:(0,P.jsx)(U,{tone:e===`ok`?`ok`:e===`failed`||e===`blocked`?`bad`:e===`running`?`accent`:`neutral`,children:e})})}function Ys(){return(0,P.jsx)(`span`,{"data-ui":`decision`,className:`inline-flex`,children:(0,P.jsx)(U,{tone:`accent`,children:`decision needed`})})}function Xs({label:e,children:t,className:n}){return(0,P.jsxs)(`div`,{className:n,children:[(0,P.jsx)(tt,{className:`mb-px block`,children:e}),(0,P.jsx)(`div`,{className:`font-mono text-md font-medium tabular-nums text-fg`,children:t})]})}var Zs=`mb-[22px] flex flex-wrap gap-[26px]`;function Qs({id:e,workflow:t}){let n=M(`runs.list`,{},{fast:!0}),r=n?.runs??[],[i,a]=(0,v.useState)(t??``),o=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?r.filter(t=>[t.workflow,t.request,t.id].some(t=>t?.toLowerCase().includes(e))):r},[r,i]);return(0,P.jsxs)(`div`,{className:`runs-screen`,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`runs`,back:{href:`/workflows`,label:`back to workflows`},count:i?`${o.length} / ${r.length}`:r.length}),(0,P.jsx)(Et,{icon:`filter_list`,value:i,placeholder:`filter by workflow or request`,"aria-label":`filter runs`,onChange:e=>a(e.target.value)}),(0,P.jsxs)(Dt,{label:`runs list`,children:[o.map(t=>(0,P.jsx)($s,{r:t,active:t.id===e},t.id)),n&&r.length===0&&(0,P.jsx)(Ot,{children:`no runs yet`}),r.length>0&&o.length===0&&(0,P.jsxs)(Ot,{children:[`no run matches “`,i,`”`]})]})]}),(0,P.jsx)(`div`,{className:`runs-main`,children:(0,P.jsx)(ec,{id:e},e)})]})}function $s({r:e,active:t}){return(0,P.jsx)(J,{href:`/runs/${e.id}`,active:t,size:`sm`,leading:(0,P.jsx)(H,{tone:qs(e.status),title:e.status}),title:e.workflow??`unknown`,meta:Ge(e.startedAt),sub:(0,P.jsxs)(`span`,{className:`flex gap-2`,children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.request,children:e.status===`running`&&e.currentPhase?`${e.currentPhase}`:e.request??``}),(0,P.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.status===`running`?(0,P.jsx)(qe,{since:e.startedAt}):Ve(e.durationMs)})]})})}function ec({id:e}){let t=M(`runs.get`,{id:e},{fast:!0}),n=t?.status===`running`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),l=xe();if(!t)return(0,P.jsx)(G,{children:`loading…`});let u=t.files.some(e=>e.name===`runner.json`),d=r??(n?`run`:`artifacts`),f=l?t.files.length:t.files.filter(e=>!sc(e.name)).length;async function p(){o(!0),c(null);let t=await A.request(`runs.stop`,{id:e}).catch(()=>null);t?.ok||(o(!1),c(t?.error??`stop failed`))}async function m(){if(!window.confirm(`Move run ${e} to the trash?`))return;c(null);let n=await A.request(`runs.delete`,{id:e}).catch(()=>null);if(n?.ok){z(t?.workflow?`/workflows/${encodeURIComponent(t.workflow)}`:`/workflows`);return}c(n?.error??`remove failed`)}return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5`,children:[(0,P.jsx)(H,{tone:qs(t.status),title:t.status}),(0,P.jsx)(rt,{size:`lg`,children:t.workflow?(0,P.jsx)(ge,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,className:`text-inherit no-underline hover:text-accent`,children:t.workflow}):`unknown workflow`}),(0,P.jsx)(Js,{status:t.status}),u&&(0,P.jsxs)(U,{children:[(0,P.jsx)(F,{name:`science`,className:`ms-sm mr-1`}),` sandbox`]}),(0,P.jsx)(`span`,{className:`font-mono text-xs text-fg-2`,children:e.replace(/^run-/,``)}),n?(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`stop`,busy:a,onClick:p,children:a?`stopping…`:`stop`}):(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`delete`,onClick:m,title:`delete this run's folder`,children:`remove`}),s&&(0,P.jsx)(`span`,{className:`text-xs text-bad`,children:s}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,title:`chat with an agent about this run`,onClick:()=>void Lo(`claude`,{kind:`run`,runId:e}),children:`⌬ discuss`}),(0,P.jsx)(pt,{className:`border-b-0 px-0`,label:`run sections`,value:d,onChange:i,items:[{id:`run`,label:`run`},{id:`artifacts`,label:`artifacts`,count:f}]})]}),t.request&&(0,P.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:t.request}),d===`run`?(0,P.jsx)(tc,{run:t,live:n}):(0,P.jsx)(lc,{id:e,files:t.files,live:n})]})}function tc({run:e,live:t}){return(0,P.jsxs)(`div`,{className:`max-w-[1080px]`,children:[e.decision&&(0,P.jsx)(Ws,{runId:e.id,decision:e.decision}),(0,P.jsxs)(`div`,{className:Zs,children:[(0,P.jsxs)(Xs,{label:`phases`,children:[e.phasesDone,e.phasesTotal==null?``:` / ${e.phasesTotal}`]}),(0,P.jsx)(Xs,{label:`duration`,children:t?(0,P.jsx)(qe,{since:e.startedAt}):Ve(e.durationMs)}),(0,P.jsx)(Xs,{label:`cost`,children:He(e.costUsd??rc(e.phases))}),(0,P.jsxs)(Xs,{label:`tokens in / out`,children:[Ue(nc(e.phases,`tokensIn`)),` / `,Ue(nc(e.phases,`tokensOut`))]})]}),(0,P.jsx)(q,{title:`phase timeline`,actions:t&&(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-[7px] text-2xs text-fg-2`,children:[(0,P.jsx)(H,{tone:`working`}),` live · polling`]}),children:(0,P.jsx)(`div`,{className:`py-1.5`,children:e.phases.map(e=>(0,P.jsx)(ac,{p:e},e.phase))})})]})}function nc(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function rc(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}var ic=`relative border-line/55 [&+&]:border-t before:absolute before:top-0 before:bottom-0 before:w-px before:bg-line last:before:bottom-auto`;function ac({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,P.jsxs)(`div`,{className:N(ic,`py-2.5 pr-[18px] pl-[42px] before:left-[23px] first:before:top-4 last:before:h-4`),children:[(0,P.jsx)(`span`,{className:`absolute top-4 left-[19px] z-1 grid`,children:(0,P.jsx)(H,{tone:qs(e.status),title:e.status})}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,P.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.phase}),e.kind===`agent`?(0,P.jsxs)(U,{tone:`accent`,children:[e.agent,e.model?` · ${e.model}`:``,e.protocol?` · ${e.protocol}`:``]}):(0,P.jsx)(U,{children:`script`}),e.status===`skipped`&&(0,P.jsx)(Js,{status:`skipped`}),(0,P.jsxs)(`span`,{className:`ml-auto flex gap-3.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[e.attempts>1&&(0,P.jsxs)(`span`,{children:[`att `,e.attempts]}),e.status===`running`?(0,P.jsx)(qe,{since:e.startedAt}):e.durationMs!=null&&(0,P.jsx)(`span`,{children:Ve(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,P.jsxs)(`span`,{children:[Ue(e.tokensIn),` / `,Ue(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,P.jsx)(`span`,{children:He(e.costUsd)})]})]}),e.status===`running`&&e.lastActivity&&(0,P.jsxs)(`div`,{className:`mt-[3px] font-mono text-[11.5px] text-accent`,children:[`▸ `,e.lastActivity]}),e.summary&&e.status!==`running`&&(0,P.jsx)(`div`,{className:`mt-[3px] max-w-[72ch] text-[12.5px] text-fg-2`,children:e.summary}),e.gates.length>0&&(0,P.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,P.jsxs)(`span`,{className:N(`inline-flex items-center gap-[5px] rounded-lg px-2.5 py-0.5 font-mono text-2xs`,e.passed?`bg-ok-soft text-ok`:`bg-bad-soft text-on-bad-soft`),title:e.failure??``,children:[(0,P.jsx)(F,{name:e.passed?`check`:`close`,className:`ms-sm`}),` `,e.gate]},e.gate))}),t.map(e=>(0,P.jsx)(`div`,{className:`mt-1 text-xs text-bad`,children:e.failure},e.gate))]})}var oc=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function sc(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function cc(e){let t=[`report.html`,`recommendation.md`].find(t=>e.some(e=>e.name===t));if(t)return t;let n=e=>{let t=e.split(`.`).pop()?.toLowerCase()??``;return[`html`,`md`,`markdown`,`pdf`].includes(t)||oc.has(t)?0:sc(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function lc({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=xe(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!sc(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&sc(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(cc(o))},[o,r]),(0,P.jsxs)(`div`,{className:`grid h-[calc(100vh-172px)] min-h-[420px] grid-cols-[280px_minmax(0,1fr)] gap-3.5 max-[940px]:h-auto max-[940px]:grid-cols-1`,children:[(0,P.jsx)(q,{title:(0,P.jsxs)(P.Fragment,{children:[`files `,(0,P.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,o.length,`)`]})]}),className:`flex min-h-0 flex-col`,children:(0,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto max-[940px]:max-h-60`,children:[o.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:N(`flex w-full cursor-pointer items-center gap-2.5 border-0 border-b border-line/55 px-[18px] py-2 text-left font-mono text-[12.5px] transition-colors last:border-b-0`,r===e.name?`bg-accent-soft text-on-accent-soft`:`bg-transparent text-fg-2 hover:bg-surface-2 hover:text-fg`),onClick:()=>i(e.name),children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,P.jsx)(`span`,{className:`text-2xs tabular-nums text-fg-2`,children:We(e.size)})]},e.name)),o.length===0&&(0,P.jsx)(W,{className:`px-[18px] py-3`,children:t.length>0?`no result files — raw run files live in expert mode`:`no files yet`})]})}),(0,P.jsx)(q,{title:r??`viewer`,className:`flex min-h-0 flex-col`,actions:r&&(0,P.jsx)(`a`,{className:uc,href:A.url(`runs.file`,{id:e,query:{name:r,raw:!0}}),target:`_blank`,children:`open raw ↗`}),children:r?(0,P.jsx)(hc,{id:e,name:r,live:n}):(0,P.jsx)(G,{className:`flex-1 justify-center`,children:`select a file`})})]})}var uc=`inline-flex h-7 items-center rounded-control px-2.5 text-sm font-medium text-fg-2 no-underline transition-colors hover:bg-surface-2 hover:text-fg`,dc=`flex min-h-0 flex-1 flex-col`,fc=`min-h-0 flex-1`,pc=`m-0 h-full overflow-auto px-[18px] py-3.5 text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,mc=`block h-full min-h-[560px] w-full border-0 bg-white`;function hc({id:e,name:t,live:n}){let r=t.split(`.`).pop()?.toLowerCase()??``,i=A.url(`runs.file`,{id:e,query:{name:t,raw:!0}});return r===`html`?(0,P.jsx)(`div`,{className:dc,children:(0,P.jsx)(`div`,{className:fc,children:(0,P.jsx)(`iframe`,{className:mc,src:i,sandbox:`allow-scripts`,allow:`clipboard-write`,title:t})})}):r===`pdf`?(0,P.jsx)(`div`,{className:dc,children:(0,P.jsx)(`div`,{className:fc,children:(0,P.jsx)(`iframe`,{className:mc,src:i,title:t})})}):oc.has(r)?(0,P.jsx)(`div`,{className:dc,children:(0,P.jsx)(`div`,{className:fc,children:(0,P.jsx)(`img`,{className:`block max-h-full max-w-full object-contain px-[18px] py-3.5`,src:i,alt:t})})}):r===`md`||r===`markdown`?(0,P.jsx)(_c,{id:e,name:t,live:n}):(0,P.jsx)(vc,{id:e,name:t,live:n})}var gc=`flex items-center gap-3 border-b border-line/55 px-[18px] py-1.5 text-2xs text-fg-2`;function _c({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=M(`runs.fileText`,{id:e,query:{name:t}},{fast:n}),o=(0,v.useMemo)(()=>a?pa.sanitize(Q.parse(a.content,{async:!1})):``,[a?.content]);return(0,P.jsxs)(`div`,{className:dc,children:[(0,P.jsxs)(`div`,{className:gc,children:[(0,P.jsx)(pt,{className:`border-b-0 px-0`,label:`markdown view`,value:r,onChange:i,items:[{id:`rendered`,label:`rendered`},{id:`source`,label:`source`}]}),a?.truncated&&(0,P.jsxs)(`span`,{children:[`large file — showing the last `,We(4e5)]})]}),(0,P.jsx)(`div`,{className:N(fc,`overflow-auto`),children:a?r===`rendered`?(0,P.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:{__html:o}}):(0,P.jsx)(`pre`,{className:pc,children:a.content||`(empty)`}):(0,P.jsx)(`pre`,{className:pc,children:`loading…`})})]})}function vc({id:e,name:t,live:n}){let r=M(`runs.fileText`,{id:e,query:{name:t}},{fast:n});return(0,P.jsxs)(`div`,{className:dc,children:[r?.truncated&&(0,P.jsxs)(`div`,{className:gc,children:[`large file — showing the last `,We(4e5)]}),(0,P.jsx)(`div`,{className:fc,children:(0,P.jsx)(`pre`,{className:pc,children:r?r.content||`(empty)`:`loading…`})})]})}function yc(){return M(`workflows.runner`,{slug:`any`},{interval:15e3})}var bc=e=>!!e?.available&&!!e?.image;function xc(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function Sc(e,t){return(await A.call(`workflows.run`,{slug:e,body:t})).runId}function Cc(e,t,n,r){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=yc();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]),(0,v.useEffect)(()=>{m&&!bc(m)&&s(!1)},[m]);let h=!u&&(!t||!!i.trim())&&(!o||bc(m));async function g(){if(h){d(!0),p(null);try{let t=await Sc(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):z(`/runs/${t}`)}catch(e){p(e.message),d(!1)}}}return{request:i,setRequest:a,sandbox:o,setSandbox:s,ssh:c,setSsh:l,busy:u,error:f,docker:m,canRun:h,launch:g}}function wc({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=Cc(e,t,n,r);return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 px-5 pt-4 pb-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-4 max-[700px]:flex-wrap`,children:[t?(0,P.jsx)(Y,{className:`h-11 min-w-0 flex-1 text-md`,value:i.request,placeholder:`Request`,"aria-label":`request`,onChange:e=>i.setRequest(e.target.value),onKeyDown:e=>e.key===`Enter`&&i.launch()}):(0,P.jsx)(`span`,{className:`flex-1 text-base text-fg-2`,children:`This workflow takes no request.`}),(0,P.jsx)(B,{variant:`primary`,icon:`play_arrow`,className:`h-11 px-5 max-[700px]:w-full`,busy:i.busy,onClick:i.launch,disabled:!i.canRun,children:i.busy?`Starting…`:`Run`})]}),(0,P.jsxs)(`div`,{className:`-mx-2 mt-1 flex flex-wrap gap-x-2`,children:[(0,P.jsx)(wt,{label:`Docker sandbox`,hint:xc(i.docker),checked:i.sandbox,onChange:i.setSandbox}),i.sandbox&&(0,P.jsx)(wt,{label:`Forward SSH agent`,hint:`keys and known hosts from this machine`,checked:i.ssh,onChange:i.setSsh})]}),i.error&&(0,P.jsx)(K,{tone:`bad`,children:i.error})]})}var Tc=`\0done`,Ec=5;function Dc(e,t){return e.status===`ok`?Tc:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??Tc}var Oc=[`var(--accent)`,`#4fb8a8`,`#a78bfa`,`#e5793b`];function kc(e){return e==null?`var(--text-2)`:Oc[e%Oc.length]}function Ac({colour:e,children:t,small:n}){return(0,P.jsx)(`span`,{style:{"--aid":e},className:N(`relative z-1 grid flex-none place-items-center rounded-full border font-mono font-bold tabular-nums`,`border-[color-mix(in_srgb,var(--aid)_55%,var(--line))] bg-[color-mix(in_srgb,var(--aid)_18%,var(--surface-1))] text-[var(--aid)]`,n?`size-[22px] text-2xs`:`mt-px size-[26px] text-[11.5px]`),children:t})}function jc({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,Tc].map(e=>[e,[]]));for(let e of t)a.get(Dc(e,i)).push(e);let o=a.get(Tc)??[];return(0,P.jsxs)(`div`,{className:`board flex items-start gap-3 overflow-x-auto px-[18px] pt-3.5 pb-[18px]`,children:[e.steps.map((e,t)=>{let i=a.get(e.name)??[];return(0,P.jsx)(Mc,{step:e.name,index:(0,P.jsx)(Ac,{small:!0,colour:kc(e.agent?n.get(e.agent)??0:null),children:t+1}),count:i.length,children:(0,P.jsx)(Nc,{cards:i,moreHref:r})},e.name)}),(0,P.jsx)(Mc,{step:`done`,name:`done`,done:!0,index:(0,P.jsx)(Ac,{small:!0,colour:`var(--ok)`,children:`✓`}),count:o.length,children:(0,P.jsx)(Nc,{cards:o,moreHref:r})})]})}function Mc({step:e,name:t,done:n,index:r,count:i,children:a}){return(0,P.jsxs)(`div`,{className:N(`board-col flex min-w-60 flex-[0_0_240px] flex-col gap-1.5`,n&&`is-done`),"data-step":e,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 px-0.5 pt-0.5 pb-1`,children:[r,(0,P.jsx)(`span`,{className:`board-col-name min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t??e,children:t??e}),(0,P.jsx)(`span`,{className:`board-col-count ml-auto font-mono text-[11.5px] tabular-nums text-fg-2`,children:i})]}),a]})}function Nc({cards:e,moreHref:t}){return(0,P.jsxs)(`div`,{className:`flex min-h-14 flex-col gap-2 rounded-xl bg-surface-2/60 p-2`,children:[e.slice(0,Ec).map(e=>(0,P.jsx)(Pc,{r:e},e.id)),e.length===0&&(0,P.jsx)(`div`,{className:`board-col-empty py-3.5 text-center text-xs text-fg-2`,children:`—`}),e.length>Ec&&(0,P.jsxs)(ge,{href:t,className:`board-more block p-1.5 text-center text-xs text-fg-2 no-underline hover:text-accent`,children:[`+ `,e.length-Ec,` more ↗`]})]})}function Pc({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,P.jsxs)(ge,{href:`/runs/${e.id}`,className:`board-card block rounded-xl border border-line bg-surface px-3 py-2.5 text-inherit no-underline transition-colors hover:bg-surface-2`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(H,{tone:qs(e.status),title:e.status}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t,children:t})]}),(0,P.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-2.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[(0,P.jsx)(`span`,{children:Ge(e.startedAt)}),(0,P.jsx)(`span`,{children:e.status===`running`?(0,P.jsx)(qe,{since:e.startedAt}):Ve(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,P.jsx)(`span`,{children:He(e.costUsd)})]}),(e.awaitingDecision||e.status===`failed`||e.status===`aborted`)&&(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[e.awaitingDecision&&(0,P.jsx)(Ys,{}),(e.status===`failed`||e.status===`aborted`)&&(0,P.jsx)(Js,{status:e.status})]})]})}function Fc({slug:e,tab:t}){let n=M(`workflows.get`,{slug:e}),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=M(`runs.list`,{},{fast:a>0||Date.now()-r<2e4});if(!n)return(0,P.jsx)(G,{children:`loading…`});if(n.error)return(0,P.jsxs)(G,{children:[(0,P.jsx)(U,{tone:`bad`,children:`broken workflow`}),(0,P.jsx)(`pre`,{className:`mt-3 text-left`,children:n.error}),(0,P.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,P.jsx)(Lc,{slug:n.slug})})]});let c=new Map(n.agents.map((e,t)=>[e.id,t%4])),l=(s?.runs??[]).filter(e=>e.workflow===n.name||e.workflow===n.slug),u=`/workflows/${encodeURIComponent(n.slug)}`,d=l.filter(e=>e.status===`running`).length;return d!==a&&o(d),(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5 in-[.ctx-embed]:mb-3 in-[.ctx-embed]:gap-y-2`,children:[(0,P.jsx)(rt,{size:`lg`,className:`in-[.ctx-embed]:text-xl`,children:n.name??n.slug}),(0,P.jsx)(`span`,{className:`min-w-0 font-mono text-xs [overflow-wrap:anywhere] text-fg-2 in-[.ctx-embed]:hidden`,children:n.dir}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsx)(pt,{bare:!0,label:`workflow sections`,value:t,items:[{id:`overview`,href:u,label:`overview`},{id:`details`,href:`${u}/details`,label:`details`},{id:`runs`,href:`${u}/runs`,label:(0,P.jsxs)(P.Fragment,{children:[`runs `,(0,P.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,`)`]})]})}]})]}),n.description&&(0,P.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:n.description}),t===`overview`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(q,{className:`run-panel mb-[18px]`,children:(0,P.jsx)(wc,{slug:n.slug,usesRequest:n.usesRequest,initialRequest:l[0]?.request,onLaunched:()=>i(Date.now())})}),(0,P.jsx)(q,{title:(0,P.jsxs)(P.Fragment,{children:[`board`,` `,(0,P.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,` runs`,d>0?`, ${d} live`:``,`)`]})]}),actions:l[0]&&(0,P.jsx)(B,{size:`sm`,variant:`quiet`,href:`${u}/runs`,className:`in-[.ctx-embed]:hidden`,children:`all runs ↗`}),children:(0,P.jsx)(jc,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})})]}),t===`details`&&(0,P.jsx)(Ic,{wf:n,agentIdx:c}),t===`runs`&&(0,P.jsx)(Rc,{runs:l})]})}function Ic({wf:e,agentIdx:t}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:Zs,children:[(0,P.jsx)(Xs,{label:`agents`,children:e.agents.length}),(0,P.jsxs)(Xs,{label:`steps`,children:[e.steps.length,` `,(0,P.jsxs)(`span`,{className:`font-normal text-fg-2`,children:[`(`,e.steps.filter(e=>e.kind===`agent`).length,` agent · `,e.steps.filter(e=>e.kind===`script`).length,` script)`]})]}),e.workspace&&(0,P.jsx)(Xs,{label:`workspace`,className:`max-w-[420px]`,children:(0,P.jsx)(`span`,{className:`text-[11.5px] font-normal whitespace-pre-wrap text-fg-2`,children:e.workspace})})]}),(0,P.jsx)(q,{title:`agents`,className:`mb-[18px]`,children:(0,P.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(280px,1fr))]`,children:[e.agents.map(e=>(0,P.jsx)(Bc,{a:e,idx:t.get(e.id)??0},e.id)),e.agents.length===0&&(0,P.jsx)(W,{className:`px-[18px] py-3`,children:`no agents — script-only workflow`})]})}),(0,P.jsxs)(`div`,{className:`grid items-start gap-[18px] grid-cols-[minmax(430px,5fr)_minmax(360px,4fr)] max-[1100px]:grid-cols-1 in-[.ctx-embed]:grid-cols-1`,children:[(0,P.jsx)(q,{title:`pipeline`,children:(0,P.jsx)(`div`,{className:`pipeline py-2`,children:e.steps.map((e,n)=>(0,P.jsx)(Vc,{s:e,i:n,idx:e.agent?t.get(e.agent)??0:null},e.name))})}),(0,P.jsx)(q,{title:(0,P.jsxs)(P.Fragment,{children:[`folder `,(0,P.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,e.files.length,` files)`]})]}),children:(0,P.jsx)(`div`,{className:`max-h-[300px] overflow-auto`,children:e.files.map(e=>(0,P.jsx)(`div`,{className:`truncate border-b border-line/55 px-[18px] py-2 font-mono text-[12.5px] text-fg-2 last:border-b-0`,children:e},e))})})]}),(0,P.jsx)(`div`,{className:`mt-[18px] in-[.ctx-embed]:hidden`,children:(0,P.jsx)(Lc,{slug:e.slug})})]})}function Lc({slug:e}){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=async()=>{i(!0),o(``);try{let t=await A.request(`workflows.delete`,{slug:e});if(!t.ok)throw Error(t.error||`failed`);z(`/workflows`,{replace:!0})}catch(e){o(e.message),n(!1)}finally{i(!1)}};return(0,P.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,P.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:t?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{variant:`danger`,icon:`delete`,busy:r,onClick:()=>void s(),children:`confirm delete`}),(0,P.jsx)(B,{variant:`quiet`,onClick:()=>n(!1),children:`cancel`}),(0,P.jsx)(W,{children:`its runs stay; the trash can put it back`})]}):(0,P.jsx)(B,{variant:`danger`,icon:`delete`,onClick:()=>n(!0),title:`Move the workflow's folder to the trash`,children:`delete workflow`})}),a&&(0,P.jsx)(K,{tone:`bad`,children:a})]})}function Rc({runs:e}){return e.length===0?(0,P.jsx)(G,{children:`no runs of this workflow yet`}):(0,P.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>{let t=e.phasesTotal??0,n=t>0?Math.round(e.phasesDone/t*100):e.status===`ok`?100:0;return(0,P.jsxs)(ge,{href:`/runs/${e.id}`,className:`run-card grid grid-cols-[12px_200px_1fr_auto] items-center gap-x-4 gap-y-2 rounded-card border border-line bg-surface px-5 py-3.5 text-inherit no-underline transition-colors hover:bg-surface-2 max-[900px]:grid-cols-[12px_1fr]`,children:[(0,P.jsx)(H,{tone:qs(e.status),title:e.status}),(0,P.jsx)(`span`,{className:`font-mono text-[12.5px] text-fg-2`,children:e.id.replace(/^run-/,``)}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-fg`,title:e.request,children:e.status===`running`&&e.currentPhase?e.currentPhase:e.request??``}),(0,P.jsxs)(`span`,{className:`flex items-center gap-3.5 font-mono text-xs tabular-nums text-fg-2 max-[900px]:col-span-2`,children:[e.awaitingDecision&&(0,P.jsx)(Ys,{}),(0,P.jsx)(Js,{status:e.status}),(0,P.jsx)(`span`,{className:`h-1 w-[90px] overflow-hidden rounded-full bg-surface-2`,title:`${e.phasesDone}${t?` / ${t}`:``} steps`,children:(0,P.jsx)(`i`,{className:N(`block h-full rounded-full`,e.status===`ok`?`bg-ok`:e.status===`failed`?`bg-bad`:`bg-accent`),style:{width:`${n}%`}})}),(0,P.jsx)(`span`,{children:e.status===`running`?(0,P.jsx)(qe,{since:e.startedAt}):Ve(e.durationMs)}),(0,P.jsx)(`span`,{children:He(e.costUsd)}),(0,P.jsx)(`span`,{children:Ge(e.startedAt)})]})]},e.id)})})}var zc=`border-line/55`;function Bc({a:e,idx:t}){return(0,P.jsxs)(`div`,{className:N(`agent-card border-r border-b px-[18px] py-3.5`,zc),children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`size-2.5 rounded-full`,style:{background:kc(t)}}),(0,P.jsx)(`b`,{className:`text-base font-medium text-fg`,children:e.name??e.id}),(0,P.jsxs)(`code`,{className:`text-2xs text-fg-2`,children:[`[`,e.id,`]`]}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsxs)(U,{children:[e.model??`default`,e.effort?` · ${e.effort}`:``,e.protocol===`acp`?` · acp`:``]})]}),e.tools.length>0&&(0,P.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-[5px]`,children:e.tools.map(e=>(0,P.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-px font-mono text-2xs text-fg-2`,children:e},e))}),e.persona&&(0,P.jsx)(`p`,{className:`mt-2 mb-0 text-xs leading-[1.55] whitespace-pre-wrap text-fg-2`,children:e.persona})]})}function Vc({s:e,i:t,idx:n}){let r=e.kind===`script`?e.script:e.prompt;return(0,P.jsxs)(`div`,{className:N(`step-node flex gap-3.5 px-[18px] py-3 first:before:top-[18px] last:before:h-[18px] before:left-[31px]`,ic),children:[(0,P.jsx)(Ac,{colour:kc(n),children:t+1}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,P.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.name}),e.kind===`agent`?(0,P.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded-full border px-2 text-2xs font-semibold`,style:{color:kc(n??0),borderColor:`color-mix(in srgb, ${kc(n??0)} 50%, var(--line))`},children:[`agent · `,e.agent]}):(0,P.jsxs)(U,{children:[`script`,e.sourceRef?` · ${e.sourceRef}`:``]})]}),r&&(0,P.jsxs)(`details`,{className:`mt-1.5`,children:[(0,P.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-2 select-none hover:text-accent`,children:e.kind===`agent`?`prompt`:`script`}),(0,P.jsx)(`pre`,{className:`mt-1.5 max-h-[360px] overflow-auto rounded-xl bg-surface-2 px-3 py-2.5 text-[11.5px] leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,children:r})]}),e.gates.length>0&&(0,P.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-[5px] rounded-lg bg-surface-2 px-2.5 py-0.5 font-mono text-2xs text-fg-2`,children:[`⛨ `,e]},e))})]})]})}function Hc(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function Uc(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function Wc({slug:e,tab:t}){let n=M(`workflows.list`,{}),r=M(`runs.list`,{}),[i,a]=(0,v.useState)(``),o=(0,v.useMemo)(()=>n?.workflows??[],[n]),s=r?.runs??[],c=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?o.filter(t=>[t.name,t.slug,t.description].some(t=>t?.toLowerCase().includes(e))):o},[o,i]),l=(0,v.useMemo)(()=>{if(o.length!==0)return(o.map(e=>({w:e,last:Hc(s,e).last})).filter(e=>!!e.last).sort((e,t)=>(t.last.updatedAt??``).localeCompare(e.last.updatedAt??``))[0]?.w??o[0]).slug},[o,s]),u=!!r;return(0,v.useEffect)(()=>{!e&&l&&u&&z(`/workflows/${encodeURIComponent(l)}`,{replace:!0})},[e,l,u]),(0,P.jsxs)(`div`,{className:`runs-screen workflows-screen`,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`workflows`,count:n?o.length:void 0,action:(0,P.jsxs)(B,{size:`sm`,variant:`quiet`,icon:`history`,href:`/runs`,title:`every run of every workflow, newest first`,children:[`runs `,(0,P.jsx)(`span`,{className:`tabular-nums`,children:s.length})]})}),o.length>0&&(0,P.jsx)(Et,{icon:`search`,value:i,placeholder:`search workflows`,"aria-label":`search workflows`,onChange:e=>a(e.target.value)}),(0,P.jsxs)(Dt,{children:[c.map(t=>{let n=Hc(s,t);return(0,P.jsx)(J,{className:`wf-row`,href:`/workflows/${encodeURIComponent(t.slug)}`,active:t.slug===e,leading:(0,P.jsx)(H,{tone:qs(n.last?.status),title:n.last?.status??`no runs yet`}),title:t.name??t.slug,titleExtra:t.error&&(0,P.jsx)(U,{tone:`bad`,children:`broken`}),meta:n.last&&Ke(n.last.updatedAt),sub:(0,P.jsx)(`span`,{title:t.error??t.description??``,children:t.error??t.description??`${t.agents} agents · ${t.steps} steps`}),subTone:t.error?`bad`:`plain`,actionsAlways:!0,actions:n.last?(0,P.jsxs)(`button`,{type:`button`,className:`wf-runs inline-flex cursor-pointer items-center gap-1 rounded-control border-0 bg-transparent px-1.5 py-0.5 text-2xs tabular-nums text-fg-2 transition-colors hover:bg-surface-2 hover:text-fg`,title:`show the runs of this workflow`,onClick:()=>z(Uc(n.last,t)),children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,P.jsx)(Js,{status:n.last.status})]}):(0,P.jsx)(`span`,{className:`wf-runs px-1.5 text-2xs text-fg-2 opacity-80`,children:`no runs yet`})},t.slug)}),n&&o.length>0&&c.length===0&&(0,P.jsxs)(Ot,{className:`wf-nomatch`,children:[`no workflow matches “`,i,`”`]}),n&&o.length===0&&(0,P.jsx)(Ot,{children:`no workflows yet`})]})]}),(0,P.jsx)(`div`,{className:`runs-main`,children:e?(0,P.jsx)(Fc,{slug:e,tab:t},e):n&&o.length===0?(0,P.jsxs)(G,{icon:`account_tree`,children:[`No workflows found — expected `,(0,P.jsx)(`code`,{children:`src/workflows/`}),` or `,(0,P.jsx)(`code`,{children:`workflows/`}),` next to the output folder.`]}):(0,P.jsx)(G,{children:`loading…`})})]})}var Gc=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,Kc=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function qc(e){return e.scope.kind===`channel`?`/channels/${e.scope.slug}`:e.scope.kind===`project`?`/projects/${e.scope.slug}/chat/${e.id}`:e.scope.kind===`agent`?`/agents/${e.scope.slug}/chat/${e.id}`:`/agents/chats/${e.id}`}function Jc(e,t,n){switch(e.scope.kind){case`agent`:{let r=e.scope.slug,i=t.find(e=>e.slug===r),a=i?`${i.emoji||`🤖`} ${i.name}`:r;return e.project?`📁 ${n(e.project)} · ${a}`:a}case`project`:return`📁 ${n(e.scope.slug)}`;case`channel`:return e.project?`📁 ${n(e.project)} · #${e.scope.slug}`:`#${e.scope.slug}`;case`run`:return`⚙️ run ${e.scope.runId}`;case`knowledge`:return e.scope.bundle?`📚 ${e.scope.bundle}`:`📚 knowledge`;default:return`🎩 Ralv`}}function Yc(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function Xc(){let e=M(`runs.list`,{}),t=M(`chats.list`,{}),n=M(`knowledge.list`,{}),r=M(`agents.list`,{}),i=M(`workflows.list`,{}),a=M(`skills.list`,{}),[o,s]=(0,v.useState)(`all`),c=xe(),l=M(`projects.list`,{},{interval:3e4}),u=e=>l?.projects.find(t=>t.slug===e)?.title??e,d=e?.runs??[],f=t?.chats??[],p=n?.bundles??[],m=(a?.skills??[]).filter(e=>e.source===`workspace`),h=[[i?.workflows.length,`workflows`,`/workflows`],[e?d.length:void 0,`runs`,`/runs`],[n?p.length:void 0,`bundles`,`/knowledge`],[a?m.length:void 0,`skills`,`/skills`],[t?f.length:void 0,`chats`,`/agents/chats`]],g=d.filter(e=>e.status===`failed`&&Date.now()-Date.parse(e.updatedAt)<864e5);return(0,P.jsxs)(`div`,{className:`w-full px-7 pt-6 pb-10 max-[800px]:px-3 max-[800px]:pt-3`,children:[(0,P.jsx)(il,{runs:d,chats:f,bundles:p,agents:r?.agents??[],workflows:i?.workflows??[],projectTitle:u,loaded:!!e&&!!t}),c&&(0,P.jsx)(`div`,{className:`mx-0.5 mt-3.5 mb-3 flex flex-wrap justify-end gap-x-[18px] gap-y-1 text-xs text-fg-2 max-[800px]:justify-start max-[800px]:gap-x-3.5`,children:h.map(([e,t,n])=>(0,P.jsxs)(ge,{href:n,className:`group/mini text-inherit no-underline hover:text-accent hover:underline`,children:[(0,P.jsx)(`b`,{className:`font-semibold tabular-nums text-fg group-hover/mini:text-accent`,children:e??`…`}),` `,t]},t))}),c&&g.length>0&&o!==`failed`&&(0,P.jsxs)(`button`,{type:`button`,className:`mb-3.5 flex w-full cursor-pointer items-center gap-2 rounded-xl border border-bad/40 bg-bad-soft px-3.5 py-[9px] text-left text-[12.5px] text-on-bad-soft hover:brightness-104`,onClick:()=>s(`failed`),children:[`⚠ `,g.length,` run`,g.length===1?``:`s`,` failed in the last 24 h — review`]}),c&&(0,P.jsx)($c,{projectTitle:u,runs:d,chats:f,bundles:p,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function Zc(e){if(e.lamp===`running`)return`now`;let t=new Date(e.at),n=new Date;if(t.toDateString()===n.toDateString())return`today`;let r=new Date(n);return r.setDate(r.getDate()-1),t.toDateString()===r.toDateString()?`yesterday`:`earlier`}var Qc=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function $c({projectTitle:e,runs:t,chats:n,bundles:r,agents:i,workflows:a,filter:o,setFilter:s}){let c=xe(),l=(0,v.useMemo)(()=>{let s=[],l=e=>e?a.find(t=>t.slug===e)?.name??e:void 0;for(let e of t)s.push({at:e.updatedAt,kind:`run`,emoji:`⚙️`,title:l(e.workflow)??e.id,sub:e.request??``,href:`/runs/${e.id}`,lamp:Gc(e.status),status:Kc(e.status)});for(let t of n){let n=t.scope.kind===`agent`?i.find(e=>t.scope.kind===`agent`&&e.slug===t.scope.slug):void 0;s.push({at:t.updatedAt,kind:`session`,emoji:n?n.emoji||`🤖`:`💬`,title:n?n.name:t.title||`new chat`,sub:n?`${t.title||`new chat`}${c?` · ${t.agent}`:``}`:c?`${t.agent} · ${Jc(t,i,e)}`:Jc(t,i,e),href:qc(t),lamp:t.awaitingApproval?`blocked`:t.busy?`running`:`ok`,status:t.awaitingApproval?`needs approval`:t.busy?`working`:void 0})}for(let e of r)e.updatedAt&&s.push({at:e.updatedAt,kind:`knowledge`,emoji:`📚`,title:e.name,sub:`${e.concepts} concepts`,href:`/knowledge/${encodeURIComponent(e.name)}`,lamp:`ok`});return(o===`all`?s:o===`failed`?s.filter(e=>e.kind===`run`&&e.lamp===`failed`):s.filter(e=>e.kind===o)).sort((e,t)=>{let n=Number(t.lamp===`running`)-Number(e.lamp===`running`);return n===0?t.at.localeCompare(e.at):n}).slice(0,15)},[t,n,r,i,c,o]),u=``,d=(e,t)=>N(`inline-flex cursor-pointer items-center gap-0.5 rounded-lg border px-2.5 py-0.5 text-2xs transition-colors`,e?N(`border-transparent`,t?`bg-bad-soft text-on-bad-soft`:`bg-accent-soft text-on-accent-soft`):`border-line bg-transparent text-fg-2 hover:text-fg`);return(0,P.jsx)(q,{className:`animate-rise`,title:`all activity`,actions:(0,P.jsxs)(`span`,{className:`flex flex-wrap gap-1.5`,children:[Qc.map(([e,t])=>(0,P.jsx)(`button`,{type:`button`,className:d(o===e),"aria-pressed":o===e,onClick:()=>s(e),children:t},e)),o===`failed`&&(0,P.jsxs)(`button`,{type:`button`,className:d(!0,!0),onClick:()=>s(`all`),children:[`failed `,(0,P.jsx)(F,{name:`close`,className:`ms-sm`})]})]}),children:l.length===0?(0,P.jsx)(`div`,{className:`px-[18px] py-4 text-sm text-fg-2`,children:o===`all`?`nothing yet — run a workflow or start a chat`:`nothing here for this filter`}):(0,P.jsx)(`div`,{className:`flex flex-col p-1.5`,children:l.map(e=>{let t=Zc(e),n=t===u?null:t;return u=t,(0,P.jsxs)(`div`,{children:[n&&(0,P.jsx)(tt,{className:`block px-2.5 pt-3 pb-1`,children:n}),(0,P.jsx)(J,{href:e.href,leading:(0,P.jsxs)(`span`,{className:`relative text-[18px] leading-none`,children:[(0,P.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),e.lamp===`running`&&(0,P.jsx)(`span`,{className:`absolute -right-1 -bottom-1 grid rounded-full bg-surface p-px`,children:(0,P.jsx)(H,{tone:`working`})})]}),title:Yc(e.title),titleExtra:(0,P.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,P.jsx)(U,{tone:el[e.kind],children:e.kind===`session`?`chat`:e.kind})}),sub:e.sub&&Yc(e.sub),meta:(0,P.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.status&&(0,P.jsx)(U,{tone:tl[e.lamp]??`neutral`,children:e.status}),(0,P.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:Ke(e.at)}),(0,P.jsx)(F,{name:`chevron_right`,className:`ms-sm max-[800px]:hidden`})]})})]},`${e.kind}:${e.href}:${e.at}`)})})})}var el={run:`accent`,session:`ask`,knowledge:`ok`},tl={ok:`ok`,failed:`bad`,blocked:`bad`,running:`accent`,aborted:`neutral`};function nl(e){if(!e)return``;let t=Math.max(0,Math.round((Date.now()-Date.parse(e))/6e4));return t<1?`just started`:t<60?`${t} min`:`${Math.floor(t/60)} h ${t%60} min`}var rl=e=>new Date(e).toDateString()===new Date().toDateString();function il({runs:e,chats:t,bundles:n,agents:r,workflows:i,projectTitle:a,loaded:o}){let s=It()??[],c=I(),l=M(`agents.status`,{},{interval:5e3}),u=e=>e?i.find(t=>t.slug===e)?.name??e:`workflow`,d=new Map;for(let e of Object.values(l??{}))for(let t of e.working)t.since&&d.set(t.chatId,t.since);let f=[...t.filter(e=>e.busy&&!e.awaitingApproval).map(e=>({key:`c:${e.id}`,owner:Jc(e,r,a),title:Yc(e.title||`new chat`),meta:`working${d.get(e.id)?` · ${nl(d.get(e.id))}`:``}`,href:qc(e),tone:`working`})),...e.filter(e=>e.status===`running`).map(e=>({key:`r:${e.id}`,owner:`⚙️ ${u(e.workflow)}`,title:Yc(e.request??``),meta:`running`,href:`/runs/${e.id}`,tone:`working`}))],p=[...t.filter(e=>!e.busy&&!e.awaitingApproval&&rl(e.updatedAt)&&e.title).map(e=>({key:`c:${e.id}`,at:e.updatedAt,owner:Jc(e,r,a),title:Yc(e.title),meta:Ke(e.updatedAt),href:qc(e)})),...e.filter(e=>e.status!==`running`&&rl(e.updatedAt)).map(e=>({key:`r:${e.id}`,at:e.updatedAt,owner:`⚙️ ${u(e.workflow)}`,title:Yc(e.request??``),meta:`${e.status===`ok`?`done`:e.status===`aborted`?`stopped`:`failed`} · ${Ke(e.updatedAt)}`,href:`/runs/${e.id}`})),...n.filter(e=>e.updatedAt&&rl(e.updatedAt)).map(e=>({key:`k:${e.name}`,at:e.updatedAt,owner:`📚 ${e.name}`,title:`knowledge updated`,meta:Ke(e.updatedAt),href:`/knowledge/${encodeURIComponent(e.name)}`}))].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,12),m=Ut(s,c),h=o&&s.length===0&&f.length===0;return(0,P.jsxs)(`div`,{className:`today flex flex-col gap-3.5`,children:[(0,P.jsxs)(q,{className:`today-section`,title:`needs you`,count:s.length,actions:m&&(0,P.jsxs)(B,{variant:`primary`,size:`sm`,onClick:()=>Wt(m),className:`bg-bad text-on-bad hover:bg-bad`,children:[`start `,(0,P.jsx)(F,{name:`arrow_forward`,className:`ms-sm`})]}),children:[s.length===0?(0,P.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:h?`Nothing waiting, nothing running.`:`Nothing is waiting for you.`}):(0,P.jsx)(`div`,{className:`p-1.5`,children:s.map(e=>(0,P.jsx)(J,{className:`today-row waiting`,onClick:()=>Wt(e),over:Bt(e.owner),title:e.title,meta:(0,P.jsxs)(`span`,{className:`font-semibold text-bad`,children:[zt(e.kind),` · `,Ke(e.since)]})},e.id))}),h&&(0,P.jsx)(`div`,{className:`px-[18px] pb-4`,children:(0,P.jsx)(B,{variant:`primary`,icon:`chat`,href:`/agents/chats`,children:`chat with Ralv`})})]}),f.length>0&&(0,P.jsx)(q,{className:`today-section`,title:`in progress`,children:(0,P.jsx)(`div`,{className:`p-1.5`,children:f.map(e=>(0,P.jsx)(al,{r:e},e.key))})}),(0,P.jsx)(q,{className:`today-section`,title:`done today`,children:p.length===0?(0,P.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:`Nothing finished yet today.`}):(0,P.jsx)(`div`,{className:`p-1.5`,children:p.map(e=>(0,P.jsx)(al,{r:e},e.key))})})]})}function al({r:e}){return(0,P.jsx)(J,{className:`today-row`,href:e.href,over:e.owner,title:e.title,meta:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e.tone===`working`&&(0,P.jsx)(H,{tone:`working`}),e.meta]})})}var ol=`modulepreload`,sl=function(e){return`/`+e},cl={},ll=function(e){return e.pathname.endsWith(`.css`)},ul=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=sl(t,n);let r=s(t);if(r.href in cl)return;cl[r.href]=!0;let i=ll(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:ol,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},dl=(0,v.lazy)(()=>ul(()=>import(`./editor-DHAdW1g_.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),fl=()=>ul(()=>import(`./editor-DHAdW1g_.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function pl({bundle:e,conceptId:t}){let n=M(`knowledge.list`,{}),[r,i]=(0,v.useState)([]);(0,v.useEffect)(()=>{n&&i(e=>e.filter(e=>n.bundles.some(t=>t.name===e)))},[n]);let a=(n?.bundles??[]).filter(e=>!r.includes(e.name)),o=e===`new`,s=a.reduce((e,t)=>!e||(t.updatedAt??``)>(e.updatedAt??``)?t:e,void 0);return(0,v.useEffect)(()=>{!e&&s&&z(`/knowledge/${encodeURIComponent(s.name)}`,{replace:!0})},[e,s?.name]),(0,P.jsxs)(`div`,{className:`runs-screen`,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`bundles`,action:(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`add`,href:`/knowledge/new`,children:`new`})}),(0,P.jsxs)(Dt,{children:[a.map(t=>(0,P.jsx)(J,{href:`/knowledge/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,P.jsx)(H,{tone:`ok`}),title:t.name,meta:t.concepts,sub:`${t.okfVersion?`okf ${t.okfVersion}`:`okf`}${t.updatedAt?` · ${t.updatedAt.slice(0,10)}`:``}`},t.name)),n&&a.length===0&&(0,P.jsx)(Ot,{children:`no bundles yet`})]})]}),(0,P.jsx)(`div`,{className:`runs-main`,children:e&&!o?(0,P.jsx)(bl,{name:e,conceptId:t,onRemoved:()=>{i(t=>[...t,e]),z(`/knowledge`,{replace:!0})}},e):o||n&&!s?(0,P.jsx)(ml,{}):(0,P.jsx)(G,{children:`loading…`})})]})}function ml(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1);async function o(){let t=e.trim();if(!t)return;a(!0),r(``);let n=await A.request(`knowledge.create`,{body:{name:t}});a(!1),n.ok?z(`/knowledge/${encodeURIComponent(t)}`):r(j(n))}return(0,P.jsxs)(`div`,{className:`empty-action flex flex-col items-center gap-3 px-4 py-16`,children:[(0,P.jsxs)(`div`,{className:`flex w-full max-w-[520px] gap-2.5`,children:[(0,P.jsx)(Y,{className:`flex-1 font-mono text-sm`,value:e,placeholder:`bundle name, e.g. customer-support`,"aria-label":`bundle name`,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&void o(),autoFocus:!0}),(0,P.jsx)(B,{variant:`primary`,icon:`add`,busy:i,disabled:!e.trim(),onClick:o,children:i?`creating…`:`new bundle`})]}),n&&(0,P.jsx)(K,{tone:`bad`,children:n})]})}function hl({tier:e}){return(0,P.jsx)(U,{tone:e===`human-reviewed`?`ok`:e===`machine-confirmed`?`accent`:`neutral`,children:e})}var gl=e=>e===`deprecated`||e===`stale`?`bad`:e===`draft`?`accent`:`neutral`,_l=()=>(0,v.useContext)(he)!==null,vl=`m-0 max-h-[560px] overflow-auto px-[18px] py-3.5 font-mono text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,yl=`@activity`;function bl({name:e,conceptId:t,onRemoved:n}){let r=M(`knowledge.get`,{bundle:e}),i=_l(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``);async function l(){let t=await A.request(`knowledge.delete`,{bundle:e}).catch(()=>null);if(!t?.ok){c(t?.error??`delete failed`),o(!1);return}n?n():z(`/knowledge`,{replace:!0})}if(!r)return(0,P.jsx)(G,{children:`loading…`});if(`error`in r)return(0,P.jsx)(G,{icon:`menu_book`,children:`bundle not found`});let u=t===yl?`activity`:`pages`,d=r.concepts,f=u===`pages`?t&&d.some(e=>e.id===t)?t:d[0]?.id:void 0,p=`/knowledge/${encodeURIComponent(e)}`;return(0,P.jsxs)(`div`,{className:N(`agent-view @container flex flex-col`,i?`gap-2.5`:`gap-4`),children:[(0,P.jsxs)(`div`,{className:N(`flex flex-wrap items-center gap-x-4 gap-y-2`,i?`mb-0.5`:`mx-0.5 mt-1 mb-2`),children:[(0,P.jsx)(rt,{size:i?`md`:`lg`,children:e}),(0,P.jsxs)(`span`,{className:N(`text-fg-2`,i?`text-[12.5px]`:`text-base`),children:[d.length,` pages`]}),(0,P.jsx)(pt,{bare:!0,className:`self-end`,label:`bundle views`,value:u,items:[{id:`pages`,href:p,label:`pages`},{id:`activity`,href:`${p}/${yl}`,label:`activity`}]}),(0,P.jsx)(`span`,{className:`flex-1`}),!i&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void ls(e),children:`export PDF`}),a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void l(),children:`move to trash`}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,onClick:()=>o(!1),children:`cancel`})]}):(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`delete`,onClick:()=>o(!0),title:`Move the bundle to the trash`,children:`delete`}),(0,P.jsx)(B,{variant:`primary`,onClick:()=>void Lo(`claude`,{kind:`knowledge`,bundle:e}),children:`curate in chat`})]})]}),s&&(0,P.jsx)(K,{tone:`bad`,children:s}),u===`activity`?r.log?(0,P.jsx)(Cl,{name:e,log:r.log}):(0,P.jsx)(q,{children:(0,P.jsx)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:`no activity yet`})}):d.length===0?(0,P.jsx)(q,{children:(0,P.jsxs)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:[`No pages yet — start a chat to author some, or write one with`,` `,(0,P.jsxs)(`code`,{children:[`kraftwerk knowledge put `,e,`/<path>`]}),`.`]})}):(0,P.jsxs)(`div`,{className:N(`grid items-start`,i?`grid-cols-[170px_minmax(0,1fr)] gap-3.5 @max-[560px]:grid-cols-1`:`grid-cols-[260px_minmax(0,1fr)] gap-6 max-[1100px]:grid-cols-1`),children:[(0,P.jsx)(`aside`,{className:N(`flex flex-col gap-0.5 overflow-y-auto border-r border-line`,i?`sticky top-0 max-h-[calc(100vh-var(--topbar-h)-160px)] pr-2 pb-1.5 @max-[560px]:static @max-[560px]:max-h-[200px] @max-[560px]:border-r-0 @max-[560px]:pr-0`:`sticky top-[calc(var(--topbar-h)+18px)] max-h-[calc(100vh-var(--topbar-h)-36px)] py-1.5 pr-3 max-[1100px]:static max-[1100px]:max-h-none max-[1100px]:border-r-0 max-[1100px]:pr-0`),children:(0,P.jsx)(Tl,{concepts:d,base:p,selected:f})}),(0,P.jsx)(`div`,{className:`min-w-0`,children:f&&(0,P.jsx)(Dl,{bundle:e,conceptId:f},f)})]})]})}function xl(e){let t=[];for(let n of e.split(`
215
+ `).length+2)),value:l,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>u(e.target.value),spellCheck:!1}),O({system:l})]})]}),(0,P.jsx)(ct,{icon:`account_tree`,title:`workflows`,action:s!==`workflows`&&k(()=>(f(t.workflows),c(`workflows`))),children:s===`workflows`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(gs,{children:[(x?.workflows??[]).map(e=>(0,P.jsx)(xt,{checked:d.includes(e.slug),onChange:t=>E(e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),(x?.workflows??[]).length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),O({workflows:d})]}):t.workflows.length===0?(0,P.jsx)(`span`,{className:ms,children:`none connected — the agent can run any workflow you connect`}):(0,P.jsx)(hs,{children:t.workflows.map(e=>(0,P.jsx)(U,{href:`/workflows/${encodeURIComponent(e)}`,children:e},e))})}),(0,P.jsx)(ct,{icon:`menu_book`,title:`knowledge`,action:s!==`knowledge`&&k(()=>(f(t.knowledge),c(`knowledge`))),children:s===`knowledge`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(gs,{children:[(S?.bundles??[]).map(e=>(0,P.jsx)(xt,{checked:d.includes(e.name),onChange:t=>E(e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),(S?.bundles??[]).length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),O({knowledge:d})]}):t.knowledge.length===0?(0,P.jsx)(`span`,{className:ms,children:`none connected — connected bundles are read and kept current by the agent`}):(0,P.jsx)(hs,{children:t.knowledge.map(e=>(0,P.jsx)(U,{href:`/knowledge/${encodeURIComponent(e)}`,children:e},e))})}),(b.vibeables||(t.vibeables??[]).length>0)&&(0,P.jsx)(ct,{icon:`web`,title:`apps`,"data-link-kind":`vibeables`,action:s!==`vibeables`&&k(()=>(f(t.vibeables??[]),c(`vibeables`))),children:s===`vibeables`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(gs,{children:[(C?.vibeables??[]).map(e=>(0,P.jsx)(xt,{checked:d.includes(e.slug),onChange:t=>E(e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),d.filter(e=>!(C?.vibeables??[]).some(t=>t.slug===e)).map(e=>(0,P.jsx)(xt,{checked:!0,onChange:t=>E(e,t),hint:`not found in this workspace`,mono:!0,children:e},e)),!b.vibeables&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),b.vibeables&&(C?.vibeables??[]).length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no apps in this workspace yet — create one on the apps page`})]}),O({vibeables:d})]}):(t.vibeables??[]).length===0?(0,P.jsx)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:`none linked — linked apps are the agent's to build and maintain; it knows them from the first message`}):(0,P.jsx)(hs,{children:(t.vibeables??[]).map(e=>{let t=!b.vibeables||!C||C.vibeables.some(t=>t.slug===e);return(0,P.jsxs)(U,{href:`/vibeables/${encodeURIComponent(e)}`,tone:t?`neutral`:`bad`,title:t?void 0:`configured but not found in this workspace`,children:[e,!t&&` · not found`]},e)})})}),(0,P.jsx)(ct,{icon:`extension`,title:`shared skills`,action:s!==`skills`&&k(()=>{m(t.skills===void 0),f(t.skills??[]),c(`skills`)}),children:s===`skills`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(gs,{children:[(0,P.jsx)(xt,{checked:p,onChange:m,hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),!p&&(w?.skills??[]).map(e=>(0,P.jsx)(xt,{checked:d.includes(e.name),onChange:t=>E(e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),!p&&(w?.skills??[]).length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),O({skills:p?void 0:d})]}):t.skills===void 0?(0,P.jsx)(`span`,{className:ms,children:`all discovered skills (default) — invoke with /name in a session`}):t.skills.length===0?(0,P.jsx)(`span`,{className:ms,children:`none — this agent runs without skills`}):(0,P.jsx)(hs,{children:t.skills.map(e=>(0,P.jsxs)(U,{children:[`/`,e]},e))})})]}),_&&(0,P.jsx)(`div`,{className:`px-[18px] pb-3`,children:(0,P.jsx)(K,{tone:`bad`,children:_})})]}),(0,P.jsx)(js,{slug:e}),(0,P.jsx)(Ps,{slug:e})]})}var Is=[`🤖`,`🧑‍💻`,`🎧`,`🛠️`,`📊`,`✍️`,`🔍`,`🧹`,`📦`,`🚀`];function Ls({slug:e}){let[t,n]=(0,v.useState)(e?null:f()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=M(`workflows.list`,{})?.workflows??[],c=M(`knowledge.list`,{})?.bundles??[],l=Te(),u=M(`vibeables.list`,l.vibeables?{}:null)?.vibeables??[],d=M(`skills.list`,{})?.skills??[];(0,v.useEffect)(()=>{e&&A.call(`agents.get`,{slug:e}).then(e=>n({name:e.name,emoji:e.emoji,description:e.description??``,harness:e.harness,model:e.model??``,effort:e.effort??``,group:e.group??``,system:e.system,workflows:e.workflows,knowledge:e.knowledge??[],vibeables:e.vibeables??[],skillsAll:e.skills===void 0,skills:e.skills??[]})).catch(()=>i(`agent not found`))},[e]);function f(){return{name:``,emoji:`🤖`,description:``,harness:`claude`,model:``,effort:``,group:``,system:``,workflows:[],knowledge:[],vibeables:[],skillsAll:!0,skills:[]}}async function p(){if(!t)return;o(!0),i(``);let n={...t,skills:t.skillsAll?void 0:t.skills},r=e?await A.request(`agents.save`,{slug:e,body:n}):await A.request(`agents.create`,{body:n});o(!1),r.ok?z(`/agents/${encodeURIComponent(r.data.slug)}/info`):i(j(r))}async function m(){e&&window.confirm(`Move agent "${e}" to the trash?`)&&(await A.request(`agents.delete`,{slug:e}).catch(()=>{}),z(`/agents`))}if(!t)return(0,P.jsx)(G,{children:r||`loading…`});let h=e=>n({...t,...e}),g=(e,n,r)=>h({[e]:r?[...t[e],n]:t[e].filter(e=>e!==n)});return(0,P.jsxs)(at,{width:`narrow`,children:[(0,P.jsx)(rt,{children:e?`edit ${e}`:`new agent`}),(0,P.jsx)(q,{children:(0,P.jsxs)(yt,{className:`max-w-[680px]`,children:[(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`name`,className:`flex-1`,children:(0,P.jsx)(Y,{value:t.name,placeholder:`e.g. Max`,onChange:e=>h({name:e.target.value})})}),(0,P.jsx)(X,{label:`emoji`,className:`w-[90px] max-[900px]:w-auto`,children:(0,P.jsx)(Y,{value:t.emoji,onChange:e=>h({emoji:e.target.value})})})]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Is.map(e=>(0,P.jsx)(`button`,{type:`button`,"aria-pressed":t.emoji===e,className:N(`cursor-pointer rounded-xl border px-2.5 py-1.5 text-base transition-colors`,t.emoji===e?`border-transparent bg-accent-soft`:`border-line bg-transparent hover:bg-surface-2`),onClick:()=>h({emoji:e}),children:e},e))}),(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`description`,className:`flex-1`,children:(0,P.jsx)(Y,{value:t.description,placeholder:`one line: what this agent is for`,onChange:e=>h({description:e.target.value})})}),(0,P.jsx)(X,{label:`group`,className:`w-[180px] max-[900px]:w-auto`,children:(0,P.jsx)(Y,{value:t.group,placeholder:`none`,onChange:e=>h({group:e.target.value})})})]}),(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`harness`,className:`w-[140px] max-[900px]:w-auto`,children:(0,P.jsxs)(vt,{value:t.harness,onChange:e=>h({harness:e.target.value}),children:[(0,P.jsx)(`option`,{value:`claude`,children:`claude`}),(0,P.jsx)(`option`,{value:`codex`,children:`codex`}),(0,P.jsx)(`option`,{value:`pi`,children:`pi`})]})}),(0,P.jsx)(X,{label:`model`,className:`flex-1`,children:(0,P.jsx)(Y,{className:`font-mono`,value:t.model,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>h({model:e.target.value})})}),(0,P.jsx)(X,{label:`effort`,className:`w-[140px] max-[900px]:w-auto`,children:(0,P.jsx)(vt,{value:t.effort,onChange:e=>h({effort:e.target.value}),children:Je.map(e=>(0,P.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,P.jsx)(X,{label:`system prompt — the agent's role`,children:(0,P.jsx)(_t,{className:_s,rows:10,value:t.system,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>h({system:e.target.value})})}),(0,P.jsxs)(Rs,{label:`connected workflows — autoloaded into the agent's context; it can run them`,children:[s.map(e=>(0,P.jsx)(xt,{checked:t.workflows.includes(e.slug),onChange:t=>g(`workflows`,e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),s.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),(0,P.jsxs)(Rs,{label:`connected knowledge — OKF bundles the agent consults and maintains`,children:[c.map(e=>(0,P.jsx)(xt,{checked:t.knowledge.includes(e.name),onChange:t=>g(`knowledge`,e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),c.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),(l.vibeables||t.vibeables.length>0)&&(0,P.jsxs)(Rs,{label:`apps — small apps the agent builds and maintains`,linkKind:`vibeables`,children:[u.map(e=>(0,P.jsx)(xt,{checked:t.vibeables.includes(e.slug),onChange:t=>g(`vibeables`,e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),t.vibeables.filter(e=>!u.some(t=>t.slug===e)).map(e=>(0,P.jsx)(xt,{checked:!0,onChange:()=>g(`vibeables`,e,!1),hint:`not found in this workspace`,mono:!0,children:e},e)),!l.vibeables&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),l.vibeables&&u.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no vibeables in this workspace yet`})]}),(0,P.jsxs)(Rs,{label:`connected skills — workspace skill packages (see the skills tab); invoked with /name in sessions`,children:[(0,P.jsx)(xt,{checked:t.skillsAll,onChange:e=>h({skillsAll:e}),hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),!t.skillsAll&&d.map(e=>(0,P.jsx)(xt,{checked:t.skills.includes(e.name),onChange:t=>g(`skills`,e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),!t.skillsAll&&d.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),r&&(0,P.jsx)(K,{tone:`bad`,children:r}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,P.jsx)(B,{variant:`primary`,busy:a,disabled:!t.name.trim(),onClick:p,children:a?`saving…`:e?`save`:`create`}),(0,P.jsx)(`span`,{className:`flex-1`}),e&&(0,P.jsx)(B,{variant:`danger`,icon:`delete`,onClick:m,children:`delete agent`})]})]})})]})}function Rs({label:e,linkKind:t,children:n}){return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-link-kind":t,children:[(0,P.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e}),(0,P.jsx)(gs,{children:n})]})}var zs=`bg-accent/7 outline-[1.5px] -outline-offset-[1.5px] outline-accent outline-dashed`,Bs=`px-2.5 pt-1.5 pb-2 text-2xs text-fg-2`;function Vs({seg:e}){let t=e[0]&&e[0]!==`new`&&e[0]!==`chats`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[0]===`chats`?`chats`:e[1]===`edit`?`edit`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`agent`:`home`,r=n===`chats`&&e[1]===`new`,i=n===`chat`?e[2]:n===`chats`&&!r?e[1]:void 0,a=M(`agents.list`,{}),o=xe(),s=Ba(),[c,l]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`kw-agent-groups`)??`[]`);return Array.isArray(e)?e.map(String):[]}catch{return[]}}),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)({}),T=(a?.agents??[]).map(e=>C[e.slug]===void 0?e:{...e,group:C[e.slug]||void 0});(0,v.useEffect)(()=>{w(e=>{let t={...e},n=!1;for(let e of a?.agents??[])t[e.slug]!==void 0&&(e.group??``)===t[e.slug]&&(delete t[e.slug],n=!0);return n?t:e})},[a]);let E=T.filter(e=>!e.archived),D=T.filter(e=>e.archived),[O,k]=(0,v.useState)(!1),ee=[...new Set([...E.map(e=>e.group??``).filter(Boolean),...c])].sort((e,t)=>e.localeCompare(t)),te=E.filter(e=>!e.group);function j(e){l(e);try{localStorage.setItem(`kw-agent-groups`,JSON.stringify(e))}catch{}}function ne(){let e=f.trim();d(!1),p(``),e&&!ee.includes(e)&&j([...c,e])}function re(e,t){h(null);let n=t.trim();if(n&&n!==e){for(let t of T.filter(t=>t.group===e))I(t.slug,n);c.includes(e)&&j([...new Set(c.map(t=>t===e?n:t))])}}async function I(e,t){if((T.find(t=>t.slug===e)?.group??``)!==t){w(n=>({...n,[e]:t}));try{let n=await A.call(`agents.get`,{slug:e});await A.call(`agents.save`,{slug:e,body:{...n,group:t||void 0}})}catch{w(t=>{let n={...t};return delete n[e],n})}}}let ie=e=>o?{onDragOver:t=>{y!=null&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,x!==e&&S(e))},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||y;n&&I(n,e),b(null),S(null)}}:{},ae=e=>(0,P.jsx)(`div`,{className:y===e.slug?`opacity-40`:void 0,onDragStart:t=>{if(!o)return t.preventDefault();t.dataTransfer.setData(`text/plain`,e.slug),t.dataTransfer.effectAllowed=`move`,b(e.slug)},onDragEnd:()=>{b(null),S(null)},children:(0,P.jsx)(J,{href:`/agents/${encodeURIComponent(e.slug)}`,active:e.slug===t,leading:(0,P.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness})},e.slug),oe=e=>(0,P.jsx)(J,{href:`/agents/${encodeURIComponent(e.slug)}/info`,active:e.slug===t,dim:e.slug!==t,leading:(0,P.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness},e.slug),se;se=n===`new`?(0,P.jsx)(Ls,{},`new`):n===`edit`&&t?(0,P.jsx)(Ls,{slug:t},t):n===`chat`&&t&&i===`new`?(0,P.jsx)(Ss,{slug:t,name:T.find(e=>e.slug===t)?.name},t):n===`chat`&&t&&i?(0,P.jsx)(`div`,{className:`chat-main`,children:(0,P.jsx)(No,{id:i,agentName:T.find(e=>e.slug===t)?.name??t,agentDescription:T.find(e=>e.slug===t)?.description},i)}):n===`chats`?i?(0,P.jsx)(`div`,{className:`chat-main`,children:(0,P.jsx)(No,{id:i},i)}):r?(0,P.jsx)(Ro,{}):(0,P.jsx)(Cs,{}):n===`info`&&t?(0,P.jsx)(Fs,{slug:t},t):t?(0,P.jsx)(xs,{slug:t,name:T.find(e=>e.slug===t)?.name},t):a?E.length?(0,P.jsx)(Os,{agents:E}):(0,P.jsx)(ks,{}):(0,P.jsx)(G,{children:`loading…`});let ce=(n===`agent`||n===`info`||n===`chat`)&&t?T.find(e=>e.slug===t)?.knowledge??[]:[],[le,ue]=(0,v.useState)(()=>localStorage.getItem(`kw-kside`)!==`hidden`),[de,fe]=(0,v.useState)(()=>Number(localStorage.getItem(`kw-kside-w`))||460),L=ce.length>0&&le;function R(e){ue(e),localStorage.setItem(`kw-kside`,e?`open`:`hidden`)}function z(e){fe(e),localStorage.setItem(`kw-kside-w`,String(e))}return(0,P.jsxs)(`div`,{className:`runs-screen agents-screen ${t||n===`chats`?`has-tabs`:``} ${(t||n===`chats`)&&s?`has-sessions`:``} ${L?`has-knowledge`:``}`,style:L?{"--kside-w":`${de}px`}:void 0,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`agents`,action:o&&(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`add`,href:`/agents/new`,children:`new`})}),(0,P.jsxs)(Dt,{children:[(0,P.jsx)(`div`,{className:`mb-1.5 border-b border-line pb-1.5`,children:(0,P.jsx)(J,{href:`/agents/chats`,active:n===`chats`,leading:(0,P.jsx)(`span`,{"aria-hidden":!0,children:`🎩`}),title:`Ralv`,sub:`chief of staff of the workspace`})}),(0,P.jsxs)(`div`,{className:N(`rounded-xl`,y&&x===``&&zs),...ie(``),children:[te.map(ae),y!=null&&te.length===0&&(0,P.jsx)(`div`,{className:Bs,children:`no group — drop here`})]}),ee.map(e=>{let t=E.filter(t=>t.group===e);return(0,P.jsxs)(`div`,{className:N(`group/grp mt-3 rounded-xl`,y&&x===e&&zs),...ie(e),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pt-1.5 pb-0.5`,children:[m===e?(0,P.jsx)(Y,{className:`h-7 min-w-0 flex-1 text-2xs`,autoFocus:!0,"aria-label":`group name`,value:g,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Enter`&&re(e,g),t.key===`Escape`&&h(null)},onBlur:()=>re(e,g)}):(0,P.jsx)(tt,{children:e}),(0,P.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-2`,children:t.length}),(0,P.jsx)(`span`,{className:`flex-1`}),o&&m!==e&&(0,P.jsx)(V,{icon:`edit`,label:`Rename group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>{h(e),_(e)}}),o&&t.length===0&&c.includes(e)&&(0,P.jsx)(V,{icon:`close`,label:`Remove empty group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>j(c.filter(t=>t!==e))})]}),t.map(ae),t.length===0&&(0,P.jsx)(`div`,{className:Bs,children:o?`drag agents here`:`no agents`})]},e)}),D.length>0&&(0,P.jsxs)(`div`,{className:`mt-2.5 border-t border-line pt-1`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`group/arch flex w-full cursor-pointer items-center gap-1.5 border-0 bg-transparent px-2.5 pt-1.5 pb-0.5 text-left text-fg-2`,"aria-expanded":O,onClick:()=>k(e=>!e),children:[(0,P.jsx)(tt,{className:`group-hover/arch:text-fg`,children:`archived`}),(0,P.jsx)(`span`,{className:`text-[10px] tabular-nums`,children:D.length}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsx)(F,{name:O?`expand_less`:`expand_more`,className:`ms-sm`})]}),O&&D.map(oe)]}),a&&T.length===0&&(0,P.jsx)(W,{className:`py-1.5 px-2.5`,children:`no agents yet`}),o&&(u?(0,P.jsx)(`div`,{className:`px-2.5 pt-2.5 pb-1`,children:(0,P.jsx)(Y,{className:`h-8 text-sm`,autoFocus:!0,"aria-label":`new group`,value:f,placeholder:`group name, e.g. Team Content`,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ne(),e.key===`Escape`&&(d(!1),p(``))},onBlur:ne})}):(0,P.jsxs)(`button`,{type:`button`,className:`mx-2.5 mt-3 mb-1 flex cursor-pointer items-center gap-1 rounded-lg border border-dashed border-line bg-transparent px-2.5 py-1 text-2xs text-fg-2 hover:text-accent`,onClick:()=>d(!0),children:[(0,P.jsx)(F,{name:`add`,className:`ms-sm`}),` group`]}))]})]}),t&&(0,P.jsx)(ws,{slug:t,chatId:i===`new`?void 0:i}),n===`chats`&&(0,P.jsx)(Ds,{chatId:i}),(0,P.jsx)(`div`,{className:`runs-main`,children:se}),L&&(0,P.jsx)(vs,{bundles:ce,onHide:()=>R(!1),onResize:z}),ce.length>0&&!le&&(0,P.jsxs)(`button`,{type:`button`,className:`kside-reopen fixed top-[60px] right-3.5 z-5 inline-flex cursor-pointer items-center gap-1 rounded-full border border-line bg-surface-2 px-3 py-1 text-2xs text-fg-2 hover:text-fg`,onClick:()=>R(!0),title:`Show knowledge sidebar`,children:[(0,P.jsx)(F,{name:`menu_book`,className:`ms-sm`}),` knowledge`]})]})}function Hs(e){if(!R(e))return null;let t=e.split(`/`).filter(Boolean),n=decodeURIComponent(t[1]),r=t[0]===`agents`||t[0]===`team`;return n===`new`?t[0]===`projects`?(0,P.jsx)(Xo,{},`new-project`):r?(0,P.jsx)(Ls,{},`new-agent`):(0,P.jsx)(ka,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,P.jsx)(rs,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,P.jsx)(Fs,{slug:n},n):r&&t[2]===`edit`?(0,P.jsx)(Ls,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,P.jsx)(ka,{slug:n},n):null}function Us({back:e,children:t}){let n=()=>z(e);return(0,v.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`.palette-backdrop`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,P.jsx)(`div`,{className:`fixed inset-0 z-40 flex animate-fade items-start justify-center bg-black/38 px-4 pt-[6vh] pb-4 max-[800px]:p-0`,onMouseDown:n,children:(0,P.jsxs)(`div`,{className:`edit-modal relative max-h-[88dvh] w-[min(960px,100%)] animate-modal overflow-y-auto rounded-card border border-line bg-surface shadow-modal max-[800px]:max-h-dvh max-[800px]:rounded-none`,role:`dialog`,"aria-label":`edit`,onMouseDown:e=>e.stopPropagation(),children:[(0,P.jsx)(V,{icon:`close`,label:`close (esc)`,className:`absolute top-3 right-3 z-1 rounded-full`,onClick:n}),(0,P.jsx)(`div`,{className:`runs-main min-w-0 pt-[18px] pr-12 pb-10 pl-6`,children:t})]})})}function Ws({runId:e,decision:t}){let{request:n,answer:r}=t,[i,a]=(0,v.useState)(n.options.length===1?n.options[0].value:null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=e=>n.options.find(t=>t.value===e)?.label??e;if(r)return(0,P.jsx)(`section`,{className:N(Gs,`decision-panel is-decided`),"aria-label":`decision`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,P.jsx)(`div`,{className:Ks,children:n.title??`Decision`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-base`,children:[(0,P.jsx)(U,{tone:`ok`,children:f(r.decision)}),r.note&&(0,P.jsxs)(`span`,{className:`text-fg-2`,children:[`“`,r.note,`”`]}),r.decidedAt&&(0,P.jsx)(`span`,{className:`text-xs tabular-nums text-fg-2`,children:Ge(r.decidedAt)})]})]})});let p=!!i&&!c&&(n.note!==`required`||!!o.trim());async function m(){if(!p)return;l(!0),d(null);let t=await A.request(`runs.decide`,{id:e,body:{decision:i,note:o.trim()}}).catch(()=>null);t?.ok||(d(t?.error??`could not save the decision`),l(!1))}return(0,P.jsx)(`section`,{className:N(Gs,`decision-panel`),"aria-label":`decision needed`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,P.jsx)(H,{tone:`working`}),(0,P.jsx)(`div`,{className:Ks,children:n.title??`This run needs your decision`})]}),n.prompt&&(0,P.jsx)(`p`,{className:`m-0 max-w-[80ch] text-base text-fg-2`,children:n.prompt}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2 self-start`,role:`radiogroup`,"aria-label":`options`,children:n.options.map(e=>(0,P.jsx)(B,{role:`radio`,"aria-checked":i===e.value,variant:i===e.value?`primary`:`secondary`,onClick:()=>a(e.value),children:e.label??e.value},e.value))}),n.note!==!1&&(0,P.jsx)(Y,{value:o,placeholder:n.note===`required`?`Note (required)`:`Note`,"aria-label":`note`,className:`max-w-[60ch]`,onChange:e=>s(e.target.value),onKeyDown:e=>e.key===`Enter`&&m()}),u&&(0,P.jsx)(K,{tone:`bad`,children:u}),(0,P.jsx)(`div`,{className:`flex gap-2`,children:(0,P.jsx)(B,{variant:`primary`,onClick:m,disabled:!p,busy:c,children:c?`Saving…`:`Submit decision`})})]})})}var Gs=`mb-[18px] overflow-hidden rounded-card border border-line bg-surface`,Ks=`text-[16px] font-medium text-fg`;function qs(e){return e===`ok`?`ok`:e===`running`?`working`:e===`failed`||e===`blocked`?`bad`:`idle`}function Js({status:e}){return(0,P.jsx)(`span`,{"data-ui":`status`,"data-status":e,className:`inline-flex`,children:(0,P.jsx)(U,{tone:e===`ok`?`ok`:e===`failed`||e===`blocked`?`bad`:e===`running`?`accent`:`neutral`,children:e})})}function Ys(){return(0,P.jsx)(`span`,{"data-ui":`decision`,className:`inline-flex`,children:(0,P.jsx)(U,{tone:`accent`,children:`decision needed`})})}function Xs({label:e,children:t,className:n}){return(0,P.jsxs)(`div`,{className:n,children:[(0,P.jsx)(tt,{className:`mb-px block`,children:e}),(0,P.jsx)(`div`,{className:`font-mono text-md font-medium tabular-nums text-fg`,children:t})]})}var Zs=`mb-[22px] flex flex-wrap gap-[26px]`;function Qs({id:e,workflow:t}){let n=M(`runs.list`,{},{fast:!0}),r=n?.runs??[],[i,a]=(0,v.useState)(t??``),o=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?r.filter(t=>[t.workflow,t.request,t.id].some(t=>t?.toLowerCase().includes(e))):r},[r,i]);return(0,P.jsxs)(`div`,{className:`runs-screen`,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`runs`,back:{href:`/workflows`,label:`back to workflows`},count:i?`${o.length} / ${r.length}`:r.length}),(0,P.jsx)(Et,{icon:`filter_list`,value:i,placeholder:`filter by workflow or request`,"aria-label":`filter runs`,onChange:e=>a(e.target.value)}),(0,P.jsxs)(Dt,{label:`runs list`,children:[o.map(t=>(0,P.jsx)($s,{r:t,active:t.id===e},t.id)),n&&r.length===0&&(0,P.jsx)(Ot,{children:`no runs yet`}),r.length>0&&o.length===0&&(0,P.jsxs)(Ot,{children:[`no run matches “`,i,`”`]})]})]}),(0,P.jsx)(`div`,{className:`runs-main`,children:(0,P.jsx)(ec,{id:e},e)})]})}function $s({r:e,active:t}){return(0,P.jsx)(J,{href:`/runs/${e.id}`,active:t,size:`sm`,leading:(0,P.jsx)(H,{tone:qs(e.status),title:e.status}),title:e.workflow??`unknown`,meta:Ge(e.startedAt),sub:(0,P.jsxs)(`span`,{className:`flex gap-2`,children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.request,children:e.status===`running`&&e.currentPhase?`${e.currentPhase}`:e.request??``}),(0,P.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.status===`running`?(0,P.jsx)(qe,{since:e.startedAt}):Ve(e.durationMs)})]})})}function ec({id:e}){let t=M(`runs.get`,{id:e},{fast:!0}),n=t?.status===`running`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),l=xe();if(!t)return(0,P.jsx)(G,{children:`loading…`});let u=t.files.some(e=>e.name===`runner.json`),d=r??(n?`run`:`artifacts`),f=l?t.files.length:t.files.filter(e=>!sc(e.name)).length;async function p(){o(!0),c(null);let t=await A.request(`runs.stop`,{id:e}).catch(()=>null);t?.ok||(o(!1),c(t?.error??`stop failed`))}async function m(){if(!window.confirm(`Move run ${e} to the trash?`))return;c(null);let n=await A.request(`runs.delete`,{id:e}).catch(()=>null);if(n?.ok){z(t?.workflow?`/workflows/${encodeURIComponent(t.workflow)}`:`/workflows`);return}c(n?.error??`remove failed`)}return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5`,children:[(0,P.jsx)(H,{tone:qs(t.status),title:t.status}),(0,P.jsx)(rt,{size:`lg`,children:t.workflow?(0,P.jsx)(ge,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,className:`text-inherit no-underline hover:text-accent`,children:t.workflow}):`unknown workflow`}),(0,P.jsx)(Js,{status:t.status}),u&&(0,P.jsxs)(U,{children:[(0,P.jsx)(F,{name:`science`,className:`ms-sm mr-1`}),` sandbox`]}),(0,P.jsx)(`span`,{className:`font-mono text-xs text-fg-2`,children:e.replace(/^run-/,``)}),n?(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`stop`,busy:a,onClick:p,children:a?`stopping…`:`stop`}):(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`delete`,onClick:m,title:`delete this run's folder`,children:`remove`}),s&&(0,P.jsx)(`span`,{className:`text-xs text-bad`,children:s}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,title:`chat with an agent about this run`,onClick:()=>void Lo(`claude`,{kind:`run`,runId:e}),children:`⌬ discuss`}),(0,P.jsx)(pt,{className:`border-b-0 px-0`,label:`run sections`,value:d,onChange:i,items:[{id:`run`,label:`run`},{id:`artifacts`,label:`artifacts`,count:f}]})]}),t.request&&(0,P.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:t.request}),d===`run`?(0,P.jsx)(tc,{run:t,live:n}):(0,P.jsx)(lc,{id:e,files:t.files,live:n})]})}function tc({run:e,live:t}){return(0,P.jsxs)(`div`,{className:`max-w-[1080px]`,children:[e.decision&&(0,P.jsx)(Ws,{runId:e.id,decision:e.decision}),(0,P.jsxs)(`div`,{className:Zs,children:[(0,P.jsxs)(Xs,{label:`phases`,children:[e.phasesDone,e.phasesTotal==null?``:` / ${e.phasesTotal}`]}),(0,P.jsx)(Xs,{label:`duration`,children:t?(0,P.jsx)(qe,{since:e.startedAt}):Ve(e.durationMs)}),(0,P.jsx)(Xs,{label:`cost`,children:He(e.costUsd??rc(e.phases))}),(0,P.jsxs)(Xs,{label:`tokens in / out`,children:[Ue(nc(e.phases,`tokensIn`)),` / `,Ue(nc(e.phases,`tokensOut`))]})]}),(0,P.jsx)(q,{title:`phase timeline`,actions:t&&(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-[7px] text-2xs text-fg-2`,children:[(0,P.jsx)(H,{tone:`working`}),` live · polling`]}),children:(0,P.jsx)(`div`,{className:`py-1.5`,children:e.phases.map(e=>(0,P.jsx)(ac,{p:e},e.phase))})})]})}function nc(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function rc(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}var ic=`relative border-line/55 [&+&]:border-t before:absolute before:top-0 before:bottom-0 before:w-px before:bg-line last:before:bottom-auto`;function ac({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,P.jsxs)(`div`,{className:N(ic,`py-2.5 pr-[18px] pl-[42px] before:left-[23px] first:before:top-4 last:before:h-4`),children:[(0,P.jsx)(`span`,{className:`absolute top-4 left-[19px] z-1 grid`,children:(0,P.jsx)(H,{tone:qs(e.status),title:e.status})}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,P.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.phase}),e.kind===`agent`?(0,P.jsxs)(U,{tone:`accent`,children:[e.agent,e.model?` · ${e.model}`:``,e.protocol?` · ${e.protocol}`:``]}):(0,P.jsx)(U,{children:`script`}),e.status===`skipped`&&(0,P.jsx)(Js,{status:`skipped`}),(0,P.jsxs)(`span`,{className:`ml-auto flex gap-3.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[e.attempts>1&&(0,P.jsxs)(`span`,{children:[`att `,e.attempts]}),e.status===`running`?(0,P.jsx)(qe,{since:e.startedAt}):e.durationMs!=null&&(0,P.jsx)(`span`,{children:Ve(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,P.jsxs)(`span`,{children:[Ue(e.tokensIn),` / `,Ue(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,P.jsx)(`span`,{children:He(e.costUsd)})]})]}),e.status===`running`&&e.lastActivity&&(0,P.jsxs)(`div`,{className:`mt-[3px] font-mono text-[11.5px] text-accent`,children:[`▸ `,e.lastActivity]}),e.summary&&e.status!==`running`&&(0,P.jsx)(`div`,{className:`mt-[3px] max-w-[72ch] text-[12.5px] text-fg-2`,children:e.summary}),e.gates.length>0&&(0,P.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,P.jsxs)(`span`,{className:N(`inline-flex items-center gap-[5px] rounded-lg px-2.5 py-0.5 font-mono text-2xs`,e.passed?`bg-ok-soft text-ok`:`bg-bad-soft text-on-bad-soft`),title:e.failure??``,children:[(0,P.jsx)(F,{name:e.passed?`check`:`close`,className:`ms-sm`}),` `,e.gate]},e.gate))}),t.map(e=>(0,P.jsx)(`div`,{className:`mt-1 text-xs text-bad`,children:e.failure},e.gate))]})}var oc=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function sc(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function cc(e){let t=[`report.html`,`recommendation.md`].find(t=>e.some(e=>e.name===t));if(t)return t;let n=e=>{let t=e.split(`.`).pop()?.toLowerCase()??``;return[`html`,`md`,`markdown`,`pdf`].includes(t)||oc.has(t)?0:sc(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function lc({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=xe(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!sc(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&sc(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(cc(o))},[o,r]),(0,P.jsxs)(`div`,{className:`grid h-[calc(100vh-172px)] min-h-[420px] grid-cols-[280px_minmax(0,1fr)] gap-3.5 max-[940px]:h-auto max-[940px]:grid-cols-1`,children:[(0,P.jsx)(q,{title:(0,P.jsxs)(P.Fragment,{children:[`files `,(0,P.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,o.length,`)`]})]}),className:`flex min-h-0 flex-col`,children:(0,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto max-[940px]:max-h-60`,children:[o.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:N(`flex w-full cursor-pointer items-center gap-2.5 border-0 border-b border-line/55 px-[18px] py-2 text-left font-mono text-[12.5px] transition-colors last:border-b-0`,r===e.name?`bg-accent-soft text-on-accent-soft`:`bg-transparent text-fg-2 hover:bg-surface-2 hover:text-fg`),onClick:()=>i(e.name),children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,P.jsx)(`span`,{className:`text-2xs tabular-nums text-fg-2`,children:We(e.size)})]},e.name)),o.length===0&&(0,P.jsx)(W,{className:`px-[18px] py-3`,children:t.length>0?`no result files — raw run files live in expert mode`:`no files yet`})]})}),(0,P.jsx)(q,{title:r??`viewer`,className:`flex min-h-0 flex-col`,actions:r&&(0,P.jsx)(`a`,{className:uc,href:A.url(`runs.file`,{id:e,query:{name:r,raw:!0}}),target:`_blank`,children:`open raw ↗`}),children:r?(0,P.jsx)(hc,{id:e,name:r,live:n}):(0,P.jsx)(G,{className:`flex-1 justify-center`,children:`select a file`})})]})}var uc=`inline-flex h-7 items-center rounded-control px-2.5 text-sm font-medium text-fg-2 no-underline transition-colors hover:bg-surface-2 hover:text-fg`,dc=`flex min-h-0 flex-1 flex-col`,fc=`min-h-0 flex-1`,pc=`m-0 h-full overflow-auto px-[18px] py-3.5 text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,mc=`block h-full min-h-[560px] w-full border-0 bg-white`;function hc({id:e,name:t,live:n}){let r=t.split(`.`).pop()?.toLowerCase()??``,i=A.url(`runs.file`,{id:e,query:{name:t,raw:!0}});return r===`html`?(0,P.jsx)(`div`,{className:dc,children:(0,P.jsx)(`div`,{className:fc,children:(0,P.jsx)(`iframe`,{className:mc,src:i,sandbox:`allow-scripts`,allow:`clipboard-write`,title:t})})}):r===`pdf`?(0,P.jsx)(`div`,{className:dc,children:(0,P.jsx)(`div`,{className:fc,children:(0,P.jsx)(`iframe`,{className:mc,src:i,title:t})})}):oc.has(r)?(0,P.jsx)(`div`,{className:dc,children:(0,P.jsx)(`div`,{className:fc,children:(0,P.jsx)(`img`,{className:`block max-h-full max-w-full object-contain px-[18px] py-3.5`,src:i,alt:t})})}):r===`md`||r===`markdown`?(0,P.jsx)(_c,{id:e,name:t,live:n}):(0,P.jsx)(vc,{id:e,name:t,live:n})}var gc=`flex items-center gap-3 border-b border-line/55 px-[18px] py-1.5 text-2xs text-fg-2`;function _c({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=M(`runs.fileText`,{id:e,query:{name:t}},{fast:n}),o=(0,v.useMemo)(()=>a?pa.sanitize(Q.parse(a.content,{async:!1})):``,[a?.content]);return(0,P.jsxs)(`div`,{className:dc,children:[(0,P.jsxs)(`div`,{className:gc,children:[(0,P.jsx)(pt,{className:`border-b-0 px-0`,label:`markdown view`,value:r,onChange:i,items:[{id:`rendered`,label:`rendered`},{id:`source`,label:`source`}]}),a?.truncated&&(0,P.jsxs)(`span`,{children:[`large file — showing the last `,We(4e5)]})]}),(0,P.jsx)(`div`,{className:N(fc,`overflow-auto`),children:a?r===`rendered`?(0,P.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:{__html:o}}):(0,P.jsx)(`pre`,{className:pc,children:a.content||`(empty)`}):(0,P.jsx)(`pre`,{className:pc,children:`loading…`})})]})}function vc({id:e,name:t,live:n}){let r=M(`runs.fileText`,{id:e,query:{name:t}},{fast:n});return(0,P.jsxs)(`div`,{className:dc,children:[r?.truncated&&(0,P.jsxs)(`div`,{className:gc,children:[`large file — showing the last `,We(4e5)]}),(0,P.jsx)(`div`,{className:fc,children:(0,P.jsx)(`pre`,{className:pc,children:r?r.content||`(empty)`:`loading…`})})]})}function yc(){return M(`workflows.runner`,{slug:`any`},{interval:15e3})}var bc=e=>!!e?.available&&!!e?.image;function xc(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function Sc(e,t){return(await A.call(`workflows.run`,{slug:e,body:t})).runId}function Cc(e,t,n,r){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=yc();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]),(0,v.useEffect)(()=>{m&&!bc(m)&&s(!1)},[m]);let h=!u&&(!t||!!i.trim())&&(!o||bc(m));async function g(){if(h){d(!0),p(null);try{let t=await Sc(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):z(`/runs/${t}`)}catch(e){p(e.message),d(!1)}}}return{request:i,setRequest:a,sandbox:o,setSandbox:s,ssh:c,setSsh:l,busy:u,error:f,docker:m,canRun:h,launch:g}}function wc({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=Cc(e,t,n,r);return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 px-5 pt-4 pb-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-4 max-[700px]:flex-wrap`,children:[t?(0,P.jsx)(Y,{className:`h-11 min-w-0 flex-1 text-md`,value:i.request,placeholder:`Request`,"aria-label":`request`,onChange:e=>i.setRequest(e.target.value),onKeyDown:e=>e.key===`Enter`&&i.launch()}):(0,P.jsx)(`span`,{className:`flex-1 text-base text-fg-2`,children:`This workflow takes no request.`}),(0,P.jsx)(B,{variant:`primary`,icon:`play_arrow`,className:`h-11 px-5 max-[700px]:w-full`,busy:i.busy,onClick:i.launch,disabled:!i.canRun,children:i.busy?`Starting…`:`Run`})]}),(0,P.jsxs)(`div`,{className:`-mx-2 mt-1 flex flex-wrap gap-x-2`,children:[(0,P.jsx)(wt,{label:`Docker sandbox`,hint:xc(i.docker),checked:i.sandbox,onChange:i.setSandbox}),i.sandbox&&(0,P.jsx)(wt,{label:`Forward SSH agent`,hint:`keys and known hosts from this machine`,checked:i.ssh,onChange:i.setSsh})]}),i.error&&(0,P.jsx)(K,{tone:`bad`,children:i.error})]})}var Tc=`\0done`,Ec=5;function Dc(e,t){return e.status===`ok`?Tc:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??Tc}var Oc=[`var(--accent)`,`#4fb8a8`,`#a78bfa`,`#e5793b`];function kc(e){return e==null?`var(--text-2)`:Oc[e%Oc.length]}function Ac({colour:e,children:t,small:n}){return(0,P.jsx)(`span`,{style:{"--aid":e},className:N(`relative z-1 grid flex-none place-items-center rounded-full border font-mono font-bold tabular-nums`,`border-[color-mix(in_srgb,var(--aid)_55%,var(--line))] bg-[color-mix(in_srgb,var(--aid)_18%,var(--surface-1))] text-[var(--aid)]`,n?`size-[22px] text-2xs`:`mt-px size-[26px] text-[11.5px]`),children:t})}function jc({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,Tc].map(e=>[e,[]]));for(let e of t)a.get(Dc(e,i)).push(e);let o=a.get(Tc)??[];return(0,P.jsxs)(`div`,{className:`board flex items-start gap-3 overflow-x-auto px-[18px] pt-3.5 pb-[18px]`,children:[e.steps.map((e,t)=>{let i=a.get(e.name)??[];return(0,P.jsx)(Mc,{step:e.name,index:(0,P.jsx)(Ac,{small:!0,colour:kc(e.agent?n.get(e.agent)??0:null),children:t+1}),count:i.length,children:(0,P.jsx)(Nc,{cards:i,moreHref:r})},e.name)}),(0,P.jsx)(Mc,{step:`done`,name:`done`,done:!0,index:(0,P.jsx)(Ac,{small:!0,colour:`var(--ok)`,children:`✓`}),count:o.length,children:(0,P.jsx)(Nc,{cards:o,moreHref:r})})]})}function Mc({step:e,name:t,done:n,index:r,count:i,children:a}){return(0,P.jsxs)(`div`,{className:N(`board-col flex min-w-60 flex-[0_0_240px] flex-col gap-1.5`,n&&`is-done`),"data-step":e,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 px-0.5 pt-0.5 pb-1`,children:[r,(0,P.jsx)(`span`,{className:`board-col-name min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t??e,children:t??e}),(0,P.jsx)(`span`,{className:`board-col-count ml-auto font-mono text-[11.5px] tabular-nums text-fg-2`,children:i})]}),a]})}function Nc({cards:e,moreHref:t}){return(0,P.jsxs)(`div`,{className:`flex min-h-14 flex-col gap-2 rounded-xl bg-surface-2/60 p-2`,children:[e.slice(0,Ec).map(e=>(0,P.jsx)(Pc,{r:e},e.id)),e.length===0&&(0,P.jsx)(`div`,{className:`board-col-empty py-3.5 text-center text-xs text-fg-2`,children:`—`}),e.length>Ec&&(0,P.jsxs)(ge,{href:t,className:`board-more block p-1.5 text-center text-xs text-fg-2 no-underline hover:text-accent`,children:[`+ `,e.length-Ec,` more ↗`]})]})}function Pc({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,P.jsxs)(ge,{href:`/runs/${e.id}`,className:`board-card block rounded-xl border border-line bg-surface px-3 py-2.5 text-inherit no-underline transition-colors hover:bg-surface-2`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(H,{tone:qs(e.status),title:e.status}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t,children:t})]}),(0,P.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-2.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[(0,P.jsx)(`span`,{children:Ge(e.startedAt)}),(0,P.jsx)(`span`,{children:e.status===`running`?(0,P.jsx)(qe,{since:e.startedAt}):Ve(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,P.jsx)(`span`,{children:He(e.costUsd)})]}),(e.awaitingDecision||e.status===`failed`||e.status===`aborted`)&&(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[e.awaitingDecision&&(0,P.jsx)(Ys,{}),(e.status===`failed`||e.status===`aborted`)&&(0,P.jsx)(Js,{status:e.status})]})]})}function Fc({slug:e,tab:t}){let n=M(`workflows.get`,{slug:e}),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=M(`runs.list`,{},{fast:a>0||Date.now()-r<2e4});if(!n)return(0,P.jsx)(G,{children:`loading…`});if(n.error)return(0,P.jsxs)(G,{children:[(0,P.jsx)(U,{tone:`bad`,children:`broken workflow`}),(0,P.jsx)(`pre`,{className:`mt-3 text-left`,children:n.error}),(0,P.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,P.jsx)(Lc,{slug:n.slug})})]});let c=new Map(n.agents.map((e,t)=>[e.id,t%4])),l=(s?.runs??[]).filter(e=>e.workflow===n.name||e.workflow===n.slug),u=`/workflows/${encodeURIComponent(n.slug)}`,d=l.filter(e=>e.status===`running`).length;return d!==a&&o(d),(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5 in-[.ctx-embed]:mb-3 in-[.ctx-embed]:gap-y-2`,children:[(0,P.jsx)(rt,{size:`lg`,className:`in-[.ctx-embed]:text-xl`,children:n.name??n.slug}),(0,P.jsx)(`span`,{className:`min-w-0 font-mono text-xs [overflow-wrap:anywhere] text-fg-2 in-[.ctx-embed]:hidden`,children:n.dir}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsx)(pt,{bare:!0,label:`workflow sections`,value:t,items:[{id:`overview`,href:u,label:`overview`},{id:`details`,href:`${u}/details`,label:`details`},{id:`runs`,href:`${u}/runs`,label:(0,P.jsxs)(P.Fragment,{children:[`runs `,(0,P.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,`)`]})]})}]})]}),n.description&&(0,P.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:n.description}),t===`overview`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(q,{className:`run-panel mb-[18px]`,children:(0,P.jsx)(wc,{slug:n.slug,usesRequest:n.usesRequest,initialRequest:l[0]?.request,onLaunched:()=>i(Date.now())})}),(0,P.jsx)(q,{title:(0,P.jsxs)(P.Fragment,{children:[`board`,` `,(0,P.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,` runs`,d>0?`, ${d} live`:``,`)`]})]}),actions:l[0]&&(0,P.jsx)(B,{size:`sm`,variant:`quiet`,href:`${u}/runs`,className:`in-[.ctx-embed]:hidden`,children:`all runs ↗`}),children:(0,P.jsx)(jc,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})})]}),t===`details`&&(0,P.jsx)(Ic,{wf:n,agentIdx:c}),t===`runs`&&(0,P.jsx)(Rc,{runs:l})]})}function Ic({wf:e,agentIdx:t}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:Zs,children:[(0,P.jsx)(Xs,{label:`agents`,children:e.agents.length}),(0,P.jsxs)(Xs,{label:`steps`,children:[e.steps.length,` `,(0,P.jsxs)(`span`,{className:`font-normal text-fg-2`,children:[`(`,e.steps.filter(e=>e.kind===`agent`).length,` agent · `,e.steps.filter(e=>e.kind===`script`).length,` script)`]})]}),e.workspace&&(0,P.jsx)(Xs,{label:`workspace`,className:`max-w-[420px]`,children:(0,P.jsx)(`span`,{className:`text-[11.5px] font-normal whitespace-pre-wrap text-fg-2`,children:e.workspace})})]}),(0,P.jsx)(q,{title:`agents`,className:`mb-[18px]`,children:(0,P.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(280px,1fr))]`,children:[e.agents.map(e=>(0,P.jsx)(Bc,{a:e,idx:t.get(e.id)??0},e.id)),e.agents.length===0&&(0,P.jsx)(W,{className:`px-[18px] py-3`,children:`no agents — script-only workflow`})]})}),(0,P.jsxs)(`div`,{className:`grid items-start gap-[18px] grid-cols-[minmax(430px,5fr)_minmax(360px,4fr)] max-[1100px]:grid-cols-1 in-[.ctx-embed]:grid-cols-1`,children:[(0,P.jsx)(q,{title:`pipeline`,children:(0,P.jsx)(`div`,{className:`pipeline py-2`,children:e.steps.map((e,n)=>(0,P.jsx)(Vc,{s:e,i:n,idx:e.agent?t.get(e.agent)??0:null},e.name))})}),(0,P.jsx)(q,{title:(0,P.jsxs)(P.Fragment,{children:[`folder `,(0,P.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,e.files.length,` files)`]})]}),children:(0,P.jsx)(`div`,{className:`max-h-[300px] overflow-auto`,children:e.files.map(e=>(0,P.jsx)(`div`,{className:`truncate border-b border-line/55 px-[18px] py-2 font-mono text-[12.5px] text-fg-2 last:border-b-0`,children:e},e))})})]}),(0,P.jsx)(`div`,{className:`mt-[18px] in-[.ctx-embed]:hidden`,children:(0,P.jsx)(Lc,{slug:e.slug})})]})}function Lc({slug:e}){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=async()=>{i(!0),o(``);try{let t=await A.request(`workflows.delete`,{slug:e});if(!t.ok)throw Error(t.error||`failed`);z(`/workflows`,{replace:!0})}catch(e){o(e.message),n(!1)}finally{i(!1)}};return(0,P.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,P.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:t?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{variant:`danger`,icon:`delete`,busy:r,onClick:()=>void s(),children:`confirm delete`}),(0,P.jsx)(B,{variant:`quiet`,onClick:()=>n(!1),children:`cancel`}),(0,P.jsx)(W,{children:`its runs stay; the trash can put it back`})]}):(0,P.jsx)(B,{variant:`danger`,icon:`delete`,onClick:()=>n(!0),title:`Move the workflow's folder to the trash`,children:`delete workflow`})}),a&&(0,P.jsx)(K,{tone:`bad`,children:a})]})}function Rc({runs:e}){return e.length===0?(0,P.jsx)(G,{children:`no runs of this workflow yet`}):(0,P.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>{let t=e.phasesTotal??0,n=t>0?Math.round(e.phasesDone/t*100):e.status===`ok`?100:0;return(0,P.jsxs)(ge,{href:`/runs/${e.id}`,className:`run-card grid grid-cols-[12px_200px_1fr_auto] items-center gap-x-4 gap-y-2 rounded-card border border-line bg-surface px-5 py-3.5 text-inherit no-underline transition-colors hover:bg-surface-2 max-[900px]:grid-cols-[12px_1fr]`,children:[(0,P.jsx)(H,{tone:qs(e.status),title:e.status}),(0,P.jsx)(`span`,{className:`font-mono text-[12.5px] text-fg-2`,children:e.id.replace(/^run-/,``)}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-fg`,title:e.request,children:e.status===`running`&&e.currentPhase?e.currentPhase:e.request??``}),(0,P.jsxs)(`span`,{className:`flex items-center gap-3.5 font-mono text-xs tabular-nums text-fg-2 max-[900px]:col-span-2`,children:[e.awaitingDecision&&(0,P.jsx)(Ys,{}),(0,P.jsx)(Js,{status:e.status}),(0,P.jsx)(`span`,{className:`h-1 w-[90px] overflow-hidden rounded-full bg-surface-2`,title:`${e.phasesDone}${t?` / ${t}`:``} steps`,children:(0,P.jsx)(`i`,{className:N(`block h-full rounded-full`,e.status===`ok`?`bg-ok`:e.status===`failed`?`bg-bad`:`bg-accent`),style:{width:`${n}%`}})}),(0,P.jsx)(`span`,{children:e.status===`running`?(0,P.jsx)(qe,{since:e.startedAt}):Ve(e.durationMs)}),(0,P.jsx)(`span`,{children:He(e.costUsd)}),(0,P.jsx)(`span`,{children:Ge(e.startedAt)})]})]},e.id)})})}var zc=`border-line/55`;function Bc({a:e,idx:t}){return(0,P.jsxs)(`div`,{className:N(`agent-card border-r border-b px-[18px] py-3.5`,zc),children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`size-2.5 rounded-full`,style:{background:kc(t)}}),(0,P.jsx)(`b`,{className:`text-base font-medium text-fg`,children:e.name??e.id}),(0,P.jsxs)(`code`,{className:`text-2xs text-fg-2`,children:[`[`,e.id,`]`]}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsxs)(U,{children:[e.model??`default`,e.effort?` · ${e.effort}`:``,e.protocol===`acp`?` · acp`:``]})]}),e.tools.length>0&&(0,P.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-[5px]`,children:e.tools.map(e=>(0,P.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-px font-mono text-2xs text-fg-2`,children:e},e))}),e.persona&&(0,P.jsx)(`p`,{className:`mt-2 mb-0 text-xs leading-[1.55] whitespace-pre-wrap text-fg-2`,children:e.persona})]})}function Vc({s:e,i:t,idx:n}){let r=e.kind===`script`?e.script:e.prompt;return(0,P.jsxs)(`div`,{className:N(`step-node flex gap-3.5 px-[18px] py-3 first:before:top-[18px] last:before:h-[18px] before:left-[31px]`,ic),children:[(0,P.jsx)(Ac,{colour:kc(n),children:t+1}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,P.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.name}),e.kind===`agent`?(0,P.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded-full border px-2 text-2xs font-semibold`,style:{color:kc(n??0),borderColor:`color-mix(in srgb, ${kc(n??0)} 50%, var(--line))`},children:[`agent · `,e.agent]}):(0,P.jsxs)(U,{children:[`script`,e.sourceRef?` · ${e.sourceRef}`:``]})]}),r&&(0,P.jsxs)(`details`,{className:`mt-1.5`,children:[(0,P.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-2 select-none hover:text-accent`,children:e.kind===`agent`?`prompt`:`script`}),(0,P.jsx)(`pre`,{className:`mt-1.5 max-h-[360px] overflow-auto rounded-xl bg-surface-2 px-3 py-2.5 text-[11.5px] leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,children:r})]}),e.gates.length>0&&(0,P.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-[5px] rounded-lg bg-surface-2 px-2.5 py-0.5 font-mono text-2xs text-fg-2`,children:[`⛨ `,e]},e))})]})]})}function Hc(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function Uc(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function Wc({slug:e,tab:t}){let n=M(`workflows.list`,{}),r=M(`runs.list`,{}),[i,a]=(0,v.useState)(``),o=(0,v.useMemo)(()=>n?.workflows??[],[n]),s=r?.runs??[],c=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?o.filter(t=>[t.name,t.slug,t.description].some(t=>t?.toLowerCase().includes(e))):o},[o,i]),l=(0,v.useMemo)(()=>{if(o.length!==0)return(o.map(e=>({w:e,last:Hc(s,e).last})).filter(e=>!!e.last).sort((e,t)=>(t.last.updatedAt??``).localeCompare(e.last.updatedAt??``))[0]?.w??o[0]).slug},[o,s]),u=!!r;return(0,v.useEffect)(()=>{!e&&l&&u&&z(`/workflows/${encodeURIComponent(l)}`,{replace:!0})},[e,l,u]),(0,P.jsxs)(`div`,{className:`runs-screen workflows-screen`,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`workflows`,count:n?o.length:void 0,action:(0,P.jsxs)(B,{size:`sm`,variant:`quiet`,icon:`history`,href:`/runs`,title:`every run of every workflow, newest first`,children:[`runs `,(0,P.jsx)(`span`,{className:`tabular-nums`,children:s.length})]})}),o.length>0&&(0,P.jsx)(Et,{icon:`search`,value:i,placeholder:`search workflows`,"aria-label":`search workflows`,onChange:e=>a(e.target.value)}),(0,P.jsxs)(Dt,{children:[c.map(t=>{let n=Hc(s,t);return(0,P.jsx)(J,{className:`wf-row`,href:`/workflows/${encodeURIComponent(t.slug)}`,active:t.slug===e,leading:(0,P.jsx)(H,{tone:qs(n.last?.status),title:n.last?.status??`no runs yet`}),title:t.name??t.slug,titleExtra:t.error&&(0,P.jsx)(U,{tone:`bad`,children:`broken`}),meta:n.last&&Ke(n.last.updatedAt),sub:(0,P.jsx)(`span`,{title:t.error??t.description??``,children:t.error??t.description??`${t.agents} agents · ${t.steps} steps`}),subTone:t.error?`bad`:`plain`,actionsAlways:!0,actions:n.last?(0,P.jsxs)(`button`,{type:`button`,className:`wf-runs inline-flex cursor-pointer items-center gap-1 rounded-control border-0 bg-transparent px-1.5 py-0.5 text-2xs tabular-nums text-fg-2 transition-colors hover:bg-surface-2 hover:text-fg`,title:`show the runs of this workflow`,onClick:()=>z(Uc(n.last,t)),children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,P.jsx)(Js,{status:n.last.status})]}):(0,P.jsx)(`span`,{className:`wf-runs px-1.5 text-2xs text-fg-2 opacity-80`,children:`no runs yet`})},t.slug)}),n&&o.length>0&&c.length===0&&(0,P.jsxs)(Ot,{className:`wf-nomatch`,children:[`no workflow matches “`,i,`”`]}),n&&o.length===0&&(0,P.jsx)(Ot,{children:`no workflows yet`})]})]}),(0,P.jsx)(`div`,{className:`runs-main`,children:e?(0,P.jsx)(Fc,{slug:e,tab:t},e):n&&o.length===0?(0,P.jsxs)(G,{icon:`account_tree`,children:[`No workflows found — expected `,(0,P.jsx)(`code`,{children:`src/workflows/`}),` or `,(0,P.jsx)(`code`,{children:`workflows/`}),` next to the output folder.`]}):(0,P.jsx)(G,{children:`loading…`})})]})}var Gc=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,Kc=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function qc(e){return e.scope.kind===`channel`?`/channels/${e.scope.slug}`:e.scope.kind===`project`?`/projects/${e.scope.slug}/chat/${e.id}`:e.scope.kind===`agent`?`/agents/${e.scope.slug}/chat/${e.id}`:`/agents/chats/${e.id}`}function Jc(e,t,n){switch(e.scope.kind){case`agent`:{let r=e.scope.slug,i=t.find(e=>e.slug===r),a=i?`${i.emoji||`🤖`} ${i.name}`:r;return e.project?`📁 ${n(e.project)} · ${a}`:a}case`project`:return`📁 ${n(e.scope.slug)}`;case`channel`:return e.project?`📁 ${n(e.project)} · #${e.scope.slug}`:`#${e.scope.slug}`;case`run`:return`⚙️ run ${e.scope.runId}`;case`knowledge`:return e.scope.bundle?`📚 ${e.scope.bundle}`:`📚 knowledge`;default:return`🎩 Ralv`}}function Yc(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function Xc(){let e=M(`runs.list`,{}),t=M(`chats.list`,{}),n=M(`knowledge.list`,{}),r=M(`agents.list`,{}),i=M(`workflows.list`,{}),a=M(`skills.list`,{}),[o,s]=(0,v.useState)(`all`),c=xe(),l=M(`projects.list`,{},{interval:3e4}),u=e=>l?.projects.find(t=>t.slug===e)?.title??e,d=e?.runs??[],f=t?.chats??[],p=n?.bundles??[],m=(a?.skills??[]).filter(e=>e.source===`workspace`),h=[[i?.workflows.length,`workflows`,`/workflows`],[e?d.length:void 0,`runs`,`/runs`],[n?p.length:void 0,`bundles`,`/knowledge`],[a?m.length:void 0,`skills`,`/skills`],[t?f.length:void 0,`chats`,`/agents/chats`]],g=d.filter(e=>e.status===`failed`&&Date.now()-Date.parse(e.updatedAt)<864e5);return(0,P.jsxs)(`div`,{className:`w-full px-7 pt-6 pb-10 max-[800px]:px-3 max-[800px]:pt-3`,children:[(0,P.jsx)(il,{runs:d,chats:f,bundles:p,agents:r?.agents??[],workflows:i?.workflows??[],projectTitle:u,loaded:!!e&&!!t}),c&&(0,P.jsx)(`div`,{className:`mx-0.5 mt-3.5 mb-3 flex flex-wrap justify-end gap-x-[18px] gap-y-1 text-xs text-fg-2 max-[800px]:justify-start max-[800px]:gap-x-3.5`,children:h.map(([e,t,n])=>(0,P.jsxs)(ge,{href:n,className:`group/mini text-inherit no-underline hover:text-accent hover:underline`,children:[(0,P.jsx)(`b`,{className:`font-semibold tabular-nums text-fg group-hover/mini:text-accent`,children:e??`…`}),` `,t]},t))}),c&&g.length>0&&o!==`failed`&&(0,P.jsxs)(`button`,{type:`button`,className:`mb-3.5 flex w-full cursor-pointer items-center gap-2 rounded-xl border border-bad/40 bg-bad-soft px-3.5 py-[9px] text-left text-[12.5px] text-on-bad-soft hover:brightness-104`,onClick:()=>s(`failed`),children:[`⚠ `,g.length,` run`,g.length===1?``:`s`,` failed in the last 24 h — review`]}),c&&(0,P.jsx)($c,{projectTitle:u,runs:d,chats:f,bundles:p,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function Zc(e){if(e.lamp===`running`)return`now`;let t=new Date(e.at),n=new Date;if(t.toDateString()===n.toDateString())return`today`;let r=new Date(n);return r.setDate(r.getDate()-1),t.toDateString()===r.toDateString()?`yesterday`:`earlier`}var Qc=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function $c({projectTitle:e,runs:t,chats:n,bundles:r,agents:i,workflows:a,filter:o,setFilter:s}){let c=xe(),l=(0,v.useMemo)(()=>{let s=[],l=e=>e?a.find(t=>t.slug===e)?.name??e:void 0;for(let e of t)s.push({at:e.updatedAt,kind:`run`,emoji:`⚙️`,title:l(e.workflow)??e.id,sub:e.request??``,href:`/runs/${e.id}`,lamp:Gc(e.status),status:Kc(e.status)});for(let t of n){let n=t.scope.kind===`agent`?i.find(e=>t.scope.kind===`agent`&&e.slug===t.scope.slug):void 0;s.push({at:t.updatedAt,kind:`session`,emoji:n?n.emoji||`🤖`:`💬`,title:n?n.name:t.title||`new chat`,sub:n?`${t.title||`new chat`}${c?` · ${t.agent}`:``}`:c?`${t.agent} · ${Jc(t,i,e)}`:Jc(t,i,e),href:qc(t),lamp:t.awaitingApproval?`blocked`:t.busy?`running`:`ok`,status:t.awaitingApproval?`needs approval`:t.busy?`working`:void 0})}for(let e of r)e.updatedAt&&s.push({at:e.updatedAt,kind:`knowledge`,emoji:`📚`,title:e.name,sub:`${e.concepts} concepts`,href:`/knowledge/${encodeURIComponent(e.name)}`,lamp:`ok`});return(o===`all`?s:o===`failed`?s.filter(e=>e.kind===`run`&&e.lamp===`failed`):s.filter(e=>e.kind===o)).sort((e,t)=>{let n=Number(t.lamp===`running`)-Number(e.lamp===`running`);return n===0?t.at.localeCompare(e.at):n}).slice(0,15)},[t,n,r,i,c,o]),u=``,d=(e,t)=>N(`inline-flex cursor-pointer items-center gap-0.5 rounded-lg border px-2.5 py-0.5 text-2xs transition-colors`,e?N(`border-transparent`,t?`bg-bad-soft text-on-bad-soft`:`bg-accent-soft text-on-accent-soft`):`border-line bg-transparent text-fg-2 hover:text-fg`);return(0,P.jsx)(q,{className:`animate-rise`,title:`all activity`,actions:(0,P.jsxs)(`span`,{className:`flex flex-wrap gap-1.5`,children:[Qc.map(([e,t])=>(0,P.jsx)(`button`,{type:`button`,className:d(o===e),"aria-pressed":o===e,onClick:()=>s(e),children:t},e)),o===`failed`&&(0,P.jsxs)(`button`,{type:`button`,className:d(!0,!0),onClick:()=>s(`all`),children:[`failed `,(0,P.jsx)(F,{name:`close`,className:`ms-sm`})]})]}),children:l.length===0?(0,P.jsx)(`div`,{className:`px-[18px] py-4 text-sm text-fg-2`,children:o===`all`?`nothing yet — run a workflow or start a chat`:`nothing here for this filter`}):(0,P.jsx)(`div`,{className:`flex flex-col p-1.5`,children:l.map(e=>{let t=Zc(e),n=t===u?null:t;return u=t,(0,P.jsxs)(`div`,{children:[n&&(0,P.jsx)(tt,{className:`block px-2.5 pt-3 pb-1`,children:n}),(0,P.jsx)(J,{href:e.href,leading:(0,P.jsxs)(`span`,{className:`relative text-[18px] leading-none`,children:[(0,P.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),e.lamp===`running`&&(0,P.jsx)(`span`,{className:`absolute -right-1 -bottom-1 grid rounded-full bg-surface p-px`,children:(0,P.jsx)(H,{tone:`working`})})]}),title:Yc(e.title),titleExtra:(0,P.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,P.jsx)(U,{tone:el[e.kind],children:e.kind===`session`?`chat`:e.kind})}),sub:e.sub&&Yc(e.sub),meta:(0,P.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.status&&(0,P.jsx)(U,{tone:tl[e.lamp]??`neutral`,children:e.status}),(0,P.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:Ke(e.at)}),(0,P.jsx)(F,{name:`chevron_right`,className:`ms-sm max-[800px]:hidden`})]})})]},`${e.kind}:${e.href}:${e.at}`)})})})}var el={run:`accent`,session:`ask`,knowledge:`ok`},tl={ok:`ok`,failed:`bad`,blocked:`bad`,running:`accent`,aborted:`neutral`};function nl(e){if(!e)return``;let t=Math.max(0,Math.round((Date.now()-Date.parse(e))/6e4));return t<1?`just started`:t<60?`${t} min`:`${Math.floor(t/60)} h ${t%60} min`}var rl=e=>new Date(e).toDateString()===new Date().toDateString();function il({runs:e,chats:t,bundles:n,agents:r,workflows:i,projectTitle:a,loaded:o}){let s=It()??[],c=I(),l=M(`agents.status`,{},{interval:5e3}),u=e=>e?i.find(t=>t.slug===e)?.name??e:`workflow`,d=new Map;for(let e of Object.values(l??{}))for(let t of e.working)t.since&&d.set(t.chatId,t.since);let f=[...t.filter(e=>e.busy&&!e.awaitingApproval).map(e=>({key:`c:${e.id}`,owner:Jc(e,r,a),title:Yc(e.title||`new chat`),meta:`working${d.get(e.id)?` · ${nl(d.get(e.id))}`:``}`,href:qc(e),tone:`working`})),...e.filter(e=>e.status===`running`).map(e=>({key:`r:${e.id}`,owner:`⚙️ ${u(e.workflow)}`,title:Yc(e.request??``),meta:`running`,href:`/runs/${e.id}`,tone:`working`}))],p=[...t.filter(e=>!e.busy&&!e.awaitingApproval&&rl(e.updatedAt)&&e.title).map(e=>({key:`c:${e.id}`,at:e.updatedAt,owner:Jc(e,r,a),title:Yc(e.title),meta:Ke(e.updatedAt),href:qc(e)})),...e.filter(e=>e.status!==`running`&&rl(e.updatedAt)).map(e=>({key:`r:${e.id}`,at:e.updatedAt,owner:`⚙️ ${u(e.workflow)}`,title:Yc(e.request??``),meta:`${e.status===`ok`?`done`:e.status===`aborted`?`stopped`:`failed`} · ${Ke(e.updatedAt)}`,href:`/runs/${e.id}`})),...n.filter(e=>e.updatedAt&&rl(e.updatedAt)).map(e=>({key:`k:${e.name}`,at:e.updatedAt,owner:`📚 ${e.name}`,title:`knowledge updated`,meta:Ke(e.updatedAt),href:`/knowledge/${encodeURIComponent(e.name)}`}))].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,12),m=Ut(s,c),h=o&&s.length===0&&f.length===0;return(0,P.jsxs)(`div`,{className:`today flex flex-col gap-3.5`,children:[(0,P.jsxs)(q,{className:`today-section`,title:`needs you`,count:s.length,actions:m&&(0,P.jsxs)(B,{variant:`primary`,size:`sm`,onClick:()=>Wt(m),className:`bg-bad text-on-bad hover:bg-bad`,children:[`start `,(0,P.jsx)(F,{name:`arrow_forward`,className:`ms-sm`})]}),children:[s.length===0?(0,P.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:h?`Nothing waiting, nothing running.`:`Nothing is waiting for you.`}):(0,P.jsx)(`div`,{className:`p-1.5`,children:s.map(e=>(0,P.jsx)(J,{className:`today-row waiting`,onClick:()=>Wt(e),over:Bt(e.owner),title:e.title,meta:(0,P.jsxs)(`span`,{className:`font-semibold text-bad`,children:[zt(e.kind),` · `,Ke(e.since)]})},e.id))}),h&&(0,P.jsx)(`div`,{className:`px-[18px] pb-4`,children:(0,P.jsx)(B,{variant:`primary`,icon:`chat`,href:`/agents/chats`,children:`chat with Ralv`})})]}),f.length>0&&(0,P.jsx)(q,{className:`today-section`,title:`in progress`,children:(0,P.jsx)(`div`,{className:`p-1.5`,children:f.map(e=>(0,P.jsx)(al,{r:e},e.key))})}),(0,P.jsx)(q,{className:`today-section`,title:`done today`,children:p.length===0?(0,P.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:`Nothing finished yet today.`}):(0,P.jsx)(`div`,{className:`p-1.5`,children:p.map(e=>(0,P.jsx)(al,{r:e},e.key))})})]})}function al({r:e}){return(0,P.jsx)(J,{className:`today-row`,href:e.href,over:e.owner,title:e.title,meta:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e.tone===`working`&&(0,P.jsx)(H,{tone:`working`}),e.meta]})})}var ol=`modulepreload`,sl=function(e){return`/`+e},cl={},ll=function(e){return e.pathname.endsWith(`.css`)},ul=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=sl(t,n);let r=s(t);if(r.href in cl)return;cl[r.href]=!0;let i=ll(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:ol,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},dl=(0,v.lazy)(()=>ul(()=>import(`./editor-BQlHN7qT.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),fl=()=>ul(()=>import(`./editor-BQlHN7qT.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function pl({bundle:e,conceptId:t}){let n=M(`knowledge.list`,{}),[r,i]=(0,v.useState)([]);(0,v.useEffect)(()=>{n&&i(e=>e.filter(e=>n.bundles.some(t=>t.name===e)))},[n]);let a=(n?.bundles??[]).filter(e=>!r.includes(e.name)),o=e===`new`,s=a.reduce((e,t)=>!e||(t.updatedAt??``)>(e.updatedAt??``)?t:e,void 0);return(0,v.useEffect)(()=>{!e&&s&&z(`/knowledge/${encodeURIComponent(s.name)}`,{replace:!0})},[e,s?.name]),(0,P.jsxs)(`div`,{className:`runs-screen`,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`bundles`,action:(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`add`,href:`/knowledge/new`,children:`new`})}),(0,P.jsxs)(Dt,{children:[a.map(t=>(0,P.jsx)(J,{href:`/knowledge/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,P.jsx)(H,{tone:`ok`}),title:t.name,meta:t.concepts,sub:`${t.okfVersion?`okf ${t.okfVersion}`:`okf`}${t.updatedAt?` · ${t.updatedAt.slice(0,10)}`:``}`},t.name)),n&&a.length===0&&(0,P.jsx)(Ot,{children:`no bundles yet`})]})]}),(0,P.jsx)(`div`,{className:`runs-main`,children:e&&!o?(0,P.jsx)(bl,{name:e,conceptId:t,onRemoved:()=>{i(t=>[...t,e]),z(`/knowledge`,{replace:!0})}},e):o||n&&!s?(0,P.jsx)(ml,{}):(0,P.jsx)(G,{children:`loading…`})})]})}function ml(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1);async function o(){let t=e.trim();if(!t)return;a(!0),r(``);let n=await A.request(`knowledge.create`,{body:{name:t}});a(!1),n.ok?z(`/knowledge/${encodeURIComponent(t)}`):r(j(n))}return(0,P.jsxs)(`div`,{className:`empty-action flex flex-col items-center gap-3 px-4 py-16`,children:[(0,P.jsxs)(`div`,{className:`flex w-full max-w-[520px] gap-2.5`,children:[(0,P.jsx)(Y,{className:`flex-1 font-mono text-sm`,value:e,placeholder:`bundle name, e.g. customer-support`,"aria-label":`bundle name`,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&void o(),autoFocus:!0}),(0,P.jsx)(B,{variant:`primary`,icon:`add`,busy:i,disabled:!e.trim(),onClick:o,children:i?`creating…`:`new bundle`})]}),n&&(0,P.jsx)(K,{tone:`bad`,children:n})]})}function hl({tier:e}){return(0,P.jsx)(U,{tone:e===`human-reviewed`?`ok`:e===`machine-confirmed`?`accent`:`neutral`,children:e})}var gl=e=>e===`deprecated`||e===`stale`?`bad`:e===`draft`?`accent`:`neutral`,_l=()=>(0,v.useContext)(he)!==null,vl=`m-0 max-h-[560px] overflow-auto px-[18px] py-3.5 font-mono text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,yl=`@activity`;function bl({name:e,conceptId:t,onRemoved:n}){let r=M(`knowledge.get`,{bundle:e}),i=_l(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``);async function l(){let t=await A.request(`knowledge.delete`,{bundle:e}).catch(()=>null);if(!t?.ok){c(t?.error??`delete failed`),o(!1);return}n?n():z(`/knowledge`,{replace:!0})}if(!r)return(0,P.jsx)(G,{children:`loading…`});if(`error`in r)return(0,P.jsx)(G,{icon:`menu_book`,children:`bundle not found`});let u=t===yl?`activity`:`pages`,d=r.concepts,f=u===`pages`?t&&d.some(e=>e.id===t)?t:d[0]?.id:void 0,p=`/knowledge/${encodeURIComponent(e)}`;return(0,P.jsxs)(`div`,{className:N(`agent-view @container flex flex-col`,i?`gap-2.5`:`gap-4`),children:[(0,P.jsxs)(`div`,{className:N(`flex flex-wrap items-center gap-x-4 gap-y-2`,i?`mb-0.5`:`mx-0.5 mt-1 mb-2`),children:[(0,P.jsx)(rt,{size:i?`md`:`lg`,children:e}),(0,P.jsxs)(`span`,{className:N(`text-fg-2`,i?`text-[12.5px]`:`text-base`),children:[d.length,` pages`]}),(0,P.jsx)(pt,{bare:!0,className:`self-end`,label:`bundle views`,value:u,items:[{id:`pages`,href:p,label:`pages`},{id:`activity`,href:`${p}/${yl}`,label:`activity`}]}),(0,P.jsx)(`span`,{className:`flex-1`}),!i&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void ls(e),children:`export PDF`}),a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void l(),children:`move to trash`}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,onClick:()=>o(!1),children:`cancel`})]}):(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`delete`,onClick:()=>o(!0),title:`Move the bundle to the trash`,children:`delete`}),(0,P.jsx)(B,{variant:`primary`,onClick:()=>void Lo(`claude`,{kind:`knowledge`,bundle:e}),children:`curate in chat`})]})]}),s&&(0,P.jsx)(K,{tone:`bad`,children:s}),u===`activity`?r.log?(0,P.jsx)(Cl,{name:e,log:r.log}):(0,P.jsx)(q,{children:(0,P.jsx)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:`no activity yet`})}):d.length===0?(0,P.jsx)(q,{children:(0,P.jsxs)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:[`No pages yet — start a chat to author some, or write one with`,` `,(0,P.jsxs)(`code`,{children:[`kraftwerk knowledge put `,e,`/<path>`]}),`.`]})}):(0,P.jsxs)(`div`,{className:N(`grid items-start`,i?`grid-cols-[170px_minmax(0,1fr)] gap-3.5 @max-[560px]:grid-cols-1`:`grid-cols-[260px_minmax(0,1fr)] gap-6 max-[1100px]:grid-cols-1`),children:[(0,P.jsx)(`aside`,{className:N(`flex flex-col gap-0.5 overflow-y-auto border-r border-line`,i?`sticky top-0 max-h-[calc(100vh-var(--topbar-h)-160px)] pr-2 pb-1.5 @max-[560px]:static @max-[560px]:max-h-[200px] @max-[560px]:border-r-0 @max-[560px]:pr-0`:`sticky top-[calc(var(--topbar-h)+18px)] max-h-[calc(100vh-var(--topbar-h)-36px)] py-1.5 pr-3 max-[1100px]:static max-[1100px]:max-h-none max-[1100px]:border-r-0 max-[1100px]:pr-0`),children:(0,P.jsx)(Tl,{concepts:d,base:p,selected:f})}),(0,P.jsx)(`div`,{className:`min-w-0`,children:f&&(0,P.jsx)(Dl,{bundle:e,conceptId:f},f)})]})]})}function xl(e){let t=[];for(let n of e.split(`
216
216
  `)){let e=n.match(/^##\s+(\d{4}-\d{2}-\d{2})/);if(e){t.push({date:e[1],entries:[]});continue}let r=n.match(/^[*-]\s+\*\*([^*]+)\*\*:\s*(.*)$/);r&&t.length>0&&t[t.length-1].entries.push({kind:r[1].toLowerCase(),text:r[2]})}return t.filter(e=>e.entries.length>0)}function Sl(e,t){let n=[],r=/\[([^\]]+)\]\(\/?([^)]+?)\.md\)/g,i=0,a;for(;a=r.exec(t);)a.index>i&&n.push(t.slice(i,a.index)),n.push((0,P.jsx)(ge,{href:`/knowledge/${encodeURIComponent(e)}/${a[2].replace(/^\//,``)}`,children:a[1]},a.index)),i=a.index+a[0].length;return i<t.length&&n.push(t.slice(i)),n}function Cl({name:e,log:t}){let n=xl(t),[r,i]=(0,v.useState)(!1);return(0,P.jsx)(q,{title:`activity`,actions:(0,P.jsx)(B,{size:`sm`,variant:`quiet`,onClick:()=>i(!r),children:r?`timeline`:`raw log`}),children:r||n.length===0?(0,P.jsx)(`pre`,{className:vl,children:t}):(0,P.jsx)(`div`,{className:`pt-0.5 pb-2.5`,children:n.map((t,n)=>(0,P.jsxs)(v.Fragment,{children:[(0,P.jsx)(`div`,{className:N(`px-[18px] pt-3.5 pb-1 font-mono text-2xs tracking-[0.05em] text-fg-2 tabular-nums`,n>0&&`mt-1 border-t border-line`),children:t.date}),t.entries.map((t,n)=>(0,P.jsxs)(`div`,{className:`flex items-baseline gap-2.5 px-[18px] py-1`,children:[(0,P.jsx)(U,{tone:t.kind===`verification`?`ok`:t.kind===`creation`||t.kind===`initialization`?`accent`:`neutral`,children:t.kind}),(0,P.jsx)(`span`,{className:`min-w-0 text-[12.5px] leading-[1.55] break-words text-fg-2 [&_a]:text-accent`,children:Sl(e,t.text)})]},n))]},t.date))})})}function wl(e){let t={name:``,path:``,folders:[],pages:[],total:0};for(let n of e){let e=n.id.split(`/`),r=t;r.total++;for(let t of e.slice(0,-1)){let e=r.folders.find(e=>e.name===t);e||(e={name:t,path:r.path?`${r.path}/${t}`:t,folders:[],pages:[],total:0},r.folders.push(e)),r=e,r.total++}r.pages.push(n)}let n=e=>{e.folders.sort((e,t)=>e.name.localeCompare(t.name)),e.pages.sort((e,t)=>e.title.localeCompare(t.title)),e.folders.forEach(n)};return n(t),t}function Tl({concepts:e,base:t,selected:n}){let r=(0,v.useMemo)(()=>wl(e),[e]),[i,a]=(0,v.useState)(()=>new Set);(0,v.useEffect)(()=>{n&&n.includes(`/`)&&a(e=>{let t=new Set(e),r=n.split(`/`).slice(0,-1);for(let e=1;e<=r.length;e++)t.delete(r.slice(0,e).join(`/`));return t.size===e.size?e:t})},[n]);let o=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),s=_l();return(0,P.jsx)(El,{folder:r,base:t,selected:n,closed:i,toggle:o,embedded:s})}function El({folder:e,base:t,selected:n,closed:r,toggle:i,embedded:a}){return(0,P.jsxs)(P.Fragment,{children:[e.pages.map(e=>{let r=e.id===n;return(0,P.jsxs)(ge,{href:`${t}/${e.id}`,"aria-current":r?`page`:void 0,className:N(`wiki-page flex items-center gap-2 rounded-control px-2.5 py-1.5 leading-[1.35] no-underline transition-colors`,a?`text-[12.5px]`:`text-sm`,r?`active bg-accent-soft font-medium text-on-accent-soft`:`text-fg hover:bg-surface-2`),title:`${e.id}.md`,children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(e.stale||e.error)&&(0,P.jsx)(`span`,{className:`size-1.5 flex-none rounded-full bg-bad`,title:e.error??`stale`})]},e.id)}),e.folders.map(e=>{let o=!r.has(e.path),s=!!n&&n.startsWith(`${e.path}/`)&&!o;return(0,P.jsxs)(v.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,className:N(`wiki-folder mt-2.5 mb-0.5 flex w-full cursor-pointer items-center gap-1 rounded-control border-0 bg-transparent py-1 pr-2 pl-0.5 text-left`,`font-[inherit] text-2xs leading-[1.3] font-semibold tracking-[0.06em] uppercase transition-colors`,o&&`open`,s?`holds text-accent`:`text-fg-2 hover:text-fg`),onClick:()=>i(e.path),"aria-expanded":o,title:`${e.path}/`,children:[(0,P.jsx)(F,{name:`chevron_right`,className:N(`ms-sm flex-none text-[16px] transition-transform`,o&&`rotate-90`,!s&&`text-fg-2`)}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,P.jsx)(`span`,{className:`text-[10.5px] font-medium tracking-normal text-fg-2 tabular-nums opacity-70`,children:e.total})]}),o&&(0,P.jsx)(`div`,{className:`wiki-branch ml-[9px] flex flex-col gap-0.5 border-l border-line pl-1`,children:(0,P.jsx)(El,{folder:e,base:t,selected:n,closed:r,toggle:i,embedded:a})})]},e.path)})]})}function Dl({bundle:e,conceptId:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),c=_l(),[l,u]=(0,v.useState)(`document`),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(`saved`),[S,C]=(0,v.useState)(``),w=(0,v.useRef)(``),T=(0,v.useRef)(null),E=(0,v.useRef)(!1),D=(0,v.useRef)(null),O=(0,v.useRef)(null),k=(0,v.useRef)(null),ee=()=>{A.call(`knowledge.concept`,{bundle:e,query:{id:t}}).then(r,()=>a(!0))};(0,v.useEffect)(()=>{if(l===`markdown`)return;let n=!0,i,o=async()=>{try{let i=await A.request(`knowledge.concept`,{bundle:e,query:{id:t}});if(i.ok){let e=i.data;n&&(a(!1),r(t=>JSON.stringify(t)===JSON.stringify(e)?t:e))}else i.status===404&&n&&a(!0)}catch{}n&&(i=setTimeout(o,6e3))};return o(),()=>{n=!1,clearTimeout(i)}},[e,t,l]),(0,v.useEffect)(()=>{if(!n||n.raw===T.current||D.current!==null||k.current)return;let e=!0;return fl().then(({splitFrontmatter:t,unwrapParagraphs:r})=>{if(!e)return;let{head:i,body:a}=t(n.raw);w.current=i,T.current=n.raw,E.current=!1,y(e=>({key:(e?.key??0)+1,body:r(a)}))}),()=>{e=!1}},[n]);async function te(){k.current&&await k.current;let n=D.current;if(n===null)return;D.current=null,x(`saving`);let i=(async()=>{try{let i=w.current,a=i?`${i}${i.endsWith(`
217
217
  `)?``:`
218
218
  `}${n.replace(/^\n+/,`
219
219
  `)}`:n,o=await A.request(`knowledge.putConcept`,{bundle:e,body:{id:t,content:a},keepalive:!0});if(!o.ok)throw Error(j(o));let s=o.data;if(s.error)throw Error(s.error);w.current=(await fl()).splitFrontmatter(s.raw).head,T.current=s.raw,r(s),C(``),x(D.current===null?`saved`:`unsaved`)}catch(e){C(e.message),x(`error`),D.current===null&&(D.current=n)}})();k.current=i,await i,k.current=null}function M(e){E.current&&(D.current=e,x(`unsaved`),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>void te(),1e3))}(0,v.useEffect)(()=>{let e=()=>{D.current!==null&&te()};return window.addEventListener(`beforeunload`,e),window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`beforeunload`,e),window.removeEventListener(`pagehide`,e),O.current&&clearTimeout(O.current),D.current!==null&&te()}},[]);async function ne(){s(!0),await A.request(`knowledge.verify`,{bundle:e,body:{id:t}}).catch(()=>{}),s(!1),ee()}function re(){n&&(f(n.raw),g(``),u(`markdown`))}async function F(){m(!0),g(``);let n=await A.request(`knowledge.putConcept`,{bundle:e,body:{id:t,content:d}}).catch(()=>null);m(!1),!n?.ok||!n.data||typeof n.data!=`object`?g(n?.error??`save failed`):n.data.error?g(n.data.error):(T.current=null,r(n.data),u(`document`))}if(i)return(0,P.jsx)(G,{icon:`description`,children:`concept not found`});if(!n)return(0,P.jsx)(G,{children:`loading…`});let I=b===`saving`?`saving…`:b===`unsaved`?`unsaved changes`:b===`error`?`not saved — ${S}`:`all changes saved`;return(0,P.jsxs)(`div`,{className:N(`agent-view flex flex-col`,c?`gap-2.5`:`gap-4`),children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,P.jsx)(rt,{size:c?`md`:`lg`,children:n.title}),n.type&&(0,P.jsx)(U,{children:n.type}),(0,P.jsx)(hl,{tier:n.trustTier}),n.status!==`stable`&&(0,P.jsx)(U,{tone:gl(n.status),children:n.status}),n.stale&&(0,P.jsxs)(U,{tone:`bad`,children:[`stale since `,n.staleAfter?.slice(0,10)]}),(0,P.jsx)(`span`,{className:`flex-1`}),!c&&(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void ls(e,n.id),children:`export PDF`}),(0,P.jsx)(B,{variant:`primary`,size:c?`sm`:`md`,icon:`check`,busy:o,onClick:ne,children:o?`verifying…`:`verify (human)`})]}),n.error&&(0,P.jsx)(K,{tone:`bad`,children:n.error}),(0,P.jsxs)(`div`,{className:N(`grid items-start`,c?`grid-cols-1 gap-3`:`grid-cols-[minmax(0,1fr)_320px] gap-4 max-[1020px]:grid-cols-1`),children:[(0,P.jsxs)(q,{className:`min-w-0`,title:`content`,actions:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-[10.5px] text-fg-2`,children:[e,`/`,n.id,`.md`]}),l===`markdown`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{size:`sm`,variant:`quiet`,onClick:()=>{u(`document`),g(``)},children:`cancel`}),(0,P.jsx)(B,{size:`sm`,icon:`check`,busy:p,onClick:()=>void F(),children:p?`saving…`:`save`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:N(`text-xs whitespace-nowrap`,b===`error`?`text-bad`:b===`unsaved`||b===`saving`?`text-ask`:`text-fg-2`),children:I}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`code`,title:`The whole file as text, frontmatter included`,onClick:re,children:`edit markdown`})]})]}),children:[l===`markdown`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`textarea`,{className:`concept-edit block w-full resize-y border-0 border-b border-line bg-surface px-[18px] py-3.5 font-mono text-[12.5px] leading-[1.65] text-fg outline-none`,value:d,rows:Math.min(40,Math.max(18,d.split(`
220
220
  `).length+2)),onChange:e=>f(e.target.value),spellCheck:!1}),(0,P.jsxs)(W,{className:`border-b border-line px-[18px] py-1.5`,children:[`full file (frontmatter + markdown body) — saving stamps provenance as `,(0,P.jsx)(`code`,{children:`human:user`}),` and logs an update.`]})]}):(0,P.jsxs)(`div`,{className:N(`concept-doc`,c?`[&_.editor-content]:min-h-[220px]`:`[&_.editor-content]:min-h-[280px]`),onPointerDownCapture:()=>E.current=!0,onKeyDownCapture:()=>E.current=!0,onPasteCapture:()=>E.current=!0,onDropCapture:()=>E.current=!0,children:[_?(0,P.jsx)(v.Suspense,{fallback:(0,P.jsx)(W,{className:`border-b border-line px-[18px] py-1.5`,children:`loading the editor…`}),children:(0,P.jsx)(dl,{markdown:_.body,autoFocus:!1,onChange:M,onError:re},_.key)}):(0,P.jsx)(W,{className:`border-b border-line px-[18px] py-1.5`,children:`loading…`}),(0,P.jsxs)(W,{className:`border-b border-line px-[18px] py-1.5`,children:[`the page as a document, saved as you type; every save stamps provenance as `,(0,P.jsx)(`code`,{children:`human:user`}),` and logs an update.`]})]}),h&&(0,P.jsx)(`div`,{className:`px-3 py-1`,children:(0,P.jsx)(K,{tone:`bad`,children:h})})]}),(0,P.jsxs)(`aside`,{className:N(`flex min-w-0 flex-col`,c?`gap-2.5`:`gap-4`),children:[(0,P.jsx)(q,{title:`about`,children:(0,P.jsxs)(dt,{compact:c,children:[(0,P.jsx)(ft,{label:`trust`,children:(0,P.jsx)(hl,{tier:n.trustTier})}),(0,P.jsx)(ft,{label:`generated`,dim:!n.generated,children:n.generated?`${n.generated.by??`?`} · ${(n.generated.at??`?`).slice(0,10)}`:`not stamped`}),(0,P.jsx)(ft,{label:`verified`,dim:n.verified.length===0,children:n.verified.length===0?`never`:n.verified.map((e,t)=>(0,P.jsxs)(`span`,{className:`block`,children:[e.by??`?`,` · `,(e.at??`?`).slice(0,10)]},t))}),n.staleAfter&&(0,P.jsxs)(ft,{label:`stale after`,dim:!n.stale,children:[n.staleAfter.slice(0,10),n.stale&&(0,P.jsx)(U,{tone:`bad`,children:`stale`})]}),n.tags.length>0&&(0,P.jsx)(ft,{label:`tags`,children:n.tags.map(e=>(0,P.jsx)(U,{children:e},e))})]})}),n.sources.length>0&&(0,P.jsx)(q,{title:`sources`,children:(0,P.jsx)(dt,{compact:c,children:n.sources.map((e,t)=>(0,P.jsxs)(`div`,{className:N(`flex flex-col gap-[3px] break-words`,c?`px-3.5 py-1.5 text-xs`:`px-[18px] py-2.5 text-[12.5px]`),children:[(0,P.jsxs)(`span`,{className:`text-fg [&_a]:text-accent`,children:[e.resource?.startsWith(`http`)?(0,P.jsx)(`a`,{href:e.resource,target:`_blank`,rel:`noreferrer`,children:e.title??e.resource}):e.title??e.resource??`?`,e.id&&(0,P.jsxs)(`span`,{className:`ml-2 font-mono text-2xs text-fg-2`,children:[`[^`,e.id,`]`]})]}),(0,P.jsx)(`span`,{className:`text-fg-2`,children:[e.author,e.usage_count==null?null:`${e.usage_count} uses`,e.last_modified?`mod ${e.last_modified.slice(0,10)}`:null].filter(Boolean).join(` · `)})]},t))})})]})]})]})}var Ol={workspace:`workspace`,project:`.claude`,user:`global`,agent:`agent`};function kl(e){return(0,P.jsx)(U,{tone:e===`workspace`?`ok`:e===`agent`?`accent`:`neutral`,children:Ol[e]})}function Al({name:e}){let t=M(`skills.list`,{}),n=t?.skills??[],r=n.filter(e=>e.source===`workspace`),i=n.filter(e=>e.source!==`workspace`),a=r[0]??i[0];(0,v.useEffect)(()=>{!e&&a&&z(`/skills/${encodeURIComponent(a.name)}`,{replace:!0})},[e,a?.name]);let o=t=>(0,P.jsx)(J,{href:`/skills/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,P.jsx)(H,{tone:t.source===`workspace`?`ok`:`idle`}),title:`/${t.name}`,titleExtra:t.source!==`workspace`&&kl(t.source),sub:t.description||`no description`},`${t.source}:${t.name}`);return(0,P.jsxs)(`div`,{className:`runs-screen`,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`workspace skills`}),(0,P.jsxs)(Dt,{children:[r.map(o),t&&r.length===0&&(0,P.jsx)(Ot,{children:`no workspace skills yet`}),i.length>0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Tt,{title:`local (this machine / repo)`,divided:!0}),i.map(o)]})]})]}),(0,P.jsx)(`div`,{className:`runs-main`,children:e?(0,P.jsx)(Ml,{name:e},e):t&&!a?(0,P.jsx)(jl,{root:t.root}):(0,P.jsx)(G,{children:`loading…`})})]})}function jl({root:e}){return(0,P.jsx)(`div`,{className:`empty-action py-6`,children:(0,P.jsxs)(G,{icon:`extension`,children:[`Create `,(0,P.jsxs)(`code`,{children:[e,`/<name>/SKILL.md`]}),` and it appears here and in every session's `,(0,P.jsx)(`code`,{children:`/`}),` menu.`]})})}function Ml({name:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(`rendered`),s=(0,v.useMemo)(()=>t?t.content.replace(/^---\r?\n[\s\S]*?\r?\n---(\r?\n|$)/,``):``,[t?.content]),c=(0,v.useMemo)(()=>t?pa.sanitize(Q.parse(s,{async:!1})):``,[s]);return(0,v.useEffect)(()=>{A.call(`skills.get`,{name:e}).then(n,()=>i(!0))},[e]),r?(0,P.jsx)(G,{icon:`extension`,children:`skill not found`}):t?(0,P.jsxs)(`div`,{className:`agent-view flex flex-col gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,P.jsxs)(rt,{size:`lg`,children:[`/`,t.name]}),kl(t.source)]}),t.description&&(0,P.jsx)(`p`,{className:`-mt-2 mb-0 mx-0.5 text-sm leading-[1.6] text-fg-2`,children:t.description}),(0,P.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_320px] items-start gap-4 max-[1020px]:grid-cols-1`,children:[(0,P.jsx)(q,{className:`min-w-0`,title:`SKILL.md`,actions:(0,P.jsx)(pt,{bare:!0,label:`SKILL.md view`,value:a,onChange:o,items:[{id:`rendered`,label:`rendered`},{id:`source`,label:`source`}]}),children:a===`rendered`?(0,P.jsx)(`div`,{className:`md-body h-auto overflow-visible [&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2`,dangerouslySetInnerHTML:{__html:c}}):(0,P.jsx)(`pre`,{className:`m-0 max-h-[560px] overflow-auto px-[18px] py-3.5 font-mono text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,children:t.content.trim()||`(empty)`})}),(0,P.jsx)(`aside`,{className:`flex min-w-0 flex-col gap-4`,children:(0,P.jsx)(q,{title:`about`,children:(0,P.jsxs)(dt,{children:[(0,P.jsx)(ft,{label:`source`,children:t.source===`workspace`?`workspace — git-tracked, shared with the team`:t.source===`project`?`repo .claude/skills — tracked, but outside the workspace root`:`global ~/.claude/skills — only on this machine`}),(0,P.jsx)(ft,{label:`path`,mono:!0,children:(0,P.jsx)(`span`,{title:t.path,children:t.path})}),(0,P.jsx)(ft,{label:`invoke`,children:(0,P.jsxs)(`span`,{children:[(0,P.jsxs)(`code`,{children:[`/`,t.name]}),` in any session`]})}),t.files.length>0&&(0,P.jsx)(ft,{label:`bundled files`,mono:!0,children:t.files.map(e=>(0,P.jsx)(`span`,{className:`block w-full`,children:e},e))})]})})})]})]}):(0,P.jsx)(G,{children:`loading…`})}var Nl=function(e,t){let n=e,r=Fl[t],i=null,a=0,o=null,s=[],c={},l=function(e,t){a=n*4+17,i=function(e){let t=Array(e);for(let n=0;n<e;n+=1){t[n]=Array(e);for(let r=0;r<e;r+=1)t[n][r]=null}return t}(a),u(0,0),u(a-7,0),u(0,a-7),p(),f(),h(e,t),n>=7&&m(e),o??=v(n,r,s),g(o,t)},u=function(e,t){for(let n=-1;n<=7;n+=1)if(!(e+n<=-1||a<=e+n))for(let r=-1;r<=7;r+=1)t+r<=-1||a<=t+r||(0<=n&&n<=6&&(r==0||r==6)||0<=r&&r<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=r&&r<=4?i[e+n][t+r]=!0:i[e+n][t+r]=!1)},d=function(){let e=0,t=0;for(let n=0;n<8;n+=1){l(!0,n);let r=Ll.getLostPoint(c);(n==0||e>r)&&(e=r,t=n)}return t},f=function(){for(let e=8;e<a-8;e+=1)i[e][6]??(i[e][6]=e%2==0);for(let e=8;e<a-8;e+=1)i[6][e]??(i[6][e]=e%2==0)},p=function(){let e=Ll.getPatternPosition(n);for(let t=0;t<e.length;t+=1)for(let n=0;n<e.length;n+=1){let r=e[t],a=e[n];if(i[r][a]==null)for(let e=-2;e<=2;e+=1)for(let t=-2;t<=2;t+=1)e==-2||e==2||t==-2||t==2||e==0&&t==0?i[r+e][a+t]=!0:i[r+e][a+t]=!1}},m=function(e){let t=Ll.getBCHTypeNumber(n);for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[Math.floor(n/3)][n%3+a-8-3]=r}for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[n%3+a-8-3][Math.floor(n/3)]=r}},h=function(e,t){let n=r<<3|t,o=Ll.getBCHTypeInfo(n);for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<6?i[t][8]=n:t<8?i[t+1][8]=n:i[a-15+t][8]=n}for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<8?i[8][a-t-1]=n:t<9?i[8][15-t-1+1]=n:i[8][15-t-1]=n}i[a-8][8]=!e},g=function(e,t){let n=-1,r=a-1,o=7,s=0,c=Ll.getMaskFunction(t);for(let t=a-1;t>0;t-=2)for(t==6&&--t;;){for(let n=0;n<2;n+=1)if(i[r][t-n]==null){let a=!1;s<e.length&&(a=(e[s]>>>o&1)==1),c(r,t-n)&&(a=!a),i[r][t-n]=a,--o,o==-1&&(s+=1,o=7)}if(r+=n,r<0||a<=r){r-=n,n=-n;break}}},_=function(e,t){let n=0,r=0,i=0,a=Array(t.length),o=Array(t.length);for(let s=0;s<t.length;s+=1){let c=t[s].dataCount,l=t[s].totalCount-c;r=Math.max(r,c),i=Math.max(i,l),a[s]=Array(c);for(let t=0;t<a[s].length;t+=1)a[s][t]=255&e.getBuffer()[t+n];n+=c;let u=Ll.getErrorCorrectPolynomial(l),d=zl(a[s],u.getLength()-1).mod(u);o[s]=Array(u.getLength()-1);for(let e=0;e<o[s].length;e+=1){let t=e+d.getLength()-o[s].length;o[s][e]=t>=0?d.getAt(t):0}}let s=0;for(let e=0;e<t.length;e+=1)s+=t[e].totalCount;let c=Array(s),l=0;for(let e=0;e<r;e+=1)for(let n=0;n<t.length;n+=1)e<a[n].length&&(c[l]=a[n][e],l+=1);for(let e=0;e<i;e+=1)for(let n=0;n<t.length;n+=1)e<o[n].length&&(c[l]=o[n][e],l+=1);return c},v=function(e,t,n){let r=Bl.getRSBlocks(e,t),i=Vl();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),Ll.getLengthInBits(r.getMode(),e)),r.write(i)}let a=0;for(let e=0;e<r.length;e+=1)a+=r[e].dataCount;if(i.getLengthInBits()>a*8)throw`code length overflow. (`+i.getLengthInBits()+`>`+a*8+`)`;for(i.getLengthInBits()+4<=a*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=a*8||(i.put(236,8),i.getLengthInBits()>=a*8));)i.put(17,8);return _(i,r)};c.addData=function(e,t){t||=`Byte`;let n=null;switch(t){case`Numeric`:n=Hl(e);break;case`Alphanumeric`:n=Ul(e);break;case`Byte`:n=Wl(e);break;case`Kanji`:n=Gl(e);break;default:throw`mode:`+t}s.push(n),o=null},c.isDark=function(e,t){if(e<0||a<=e||t<0||a<=t)throw e+`,`+t;return i[e][t]},c.getModuleCount=function(){return a},c.make=function(){if(n<1){let e=1;for(;e<40;e++){let t=Bl.getRSBlocks(e,r),n=Vl();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),Ll.getLengthInBits(r.getMode(),e)),r.write(n)}let i=0;for(let e=0;e<t.length;e++)i+=t[e].dataCount;if(n.getLengthInBits()<=i*8)break}n=e}l(!1,d())},c.createTableTag=function(e,t){e||=2,t=t===void 0?e*4:t;let n=``;n+=`<table style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: `+t+`px;`,n+=`">`,n+=`<tbody>`;for(let t=0;t<c.getModuleCount();t+=1){n+=`<tr>`;for(let r=0;r<c.getModuleCount();r+=1)n+=`<td style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: 0px;`,n+=` width: `+e+`px;`,n+=` height: `+e+`px;`,n+=` background-color: `,n+=c.isDark(t,r)?`#000000`:`#ffffff`,n+=`;`,n+=`"/>`;n+=`</tr>`}return n+=`</tbody>`,n+=`</table>`,n},c.createSvgTag=function(e,t,n,r){let i={};typeof arguments[0]==`object`&&(i=arguments[0],e=i.cellSize,t=i.margin,n=i.alt,r=i.title),e||=2,t=t===void 0?e*4:t,n=typeof n==`string`?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||`qrcode-description`:null,r=typeof r==`string`?{text:r}:r||{},r.text=r.text||null,r.id=r.text?r.id||`qrcode-title`:null;let a=c.getModuleCount()*e+t*2,o,s,l,u,d=``,f;for(f=`l`+e+`,0 0,`+e+` -`+e+`,0 0,-`+e+`z `,d+=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"`,d+=i.scalable?``:` width="`+a+`px" height="`+a+`px"`,d+=` viewBox="0 0 `+a+` `+a+`" `,d+=` preserveAspectRatio="xMinYMin meet"`,d+=r.text||n.text?` role="img" aria-labelledby="`+y([r.id,n.id].join(` `).trim())+`"`:``,d+=`>`,d+=r.text?`<title id="`+y(r.id)+`">`+y(r.text)+`</title>`:``,d+=n.text?`<description id="`+y(n.id)+`">`+y(n.text)+`</description>`:``,d+=`<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>`,d+=`<path d="`,l=0;l<c.getModuleCount();l+=1)for(u=l*e+t,o=0;o<c.getModuleCount();o+=1)c.isDark(l,o)&&(s=o*e+t,d+=`M`+s+`,`+u+f);return d+=`" stroke="transparent" fill="black"/>`,d+=`</svg>`,d},c.createDataURL=function(e,t){e||=2,t=t===void 0?e*4:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t;return Xl(n,n,function(t,n){if(r<=t&&t<i&&r<=n&&n<i){let i=Math.floor((t-r)/e),a=Math.floor((n-r)/e);return+!c.isDark(a,i)}return 1})},c.createImgTag=function(e,t,n){e||=2,t=t===void 0?e*4:t;let r=c.getModuleCount()*e+t*2,i=``;return i+=`<img`,i+=` src="`,i+=c.createDataURL(e,t),i+=`"`,i+=` width="`,i+=r,i+=`"`,i+=` height="`,i+=r,i+=`"`,n&&(i+=` alt="`,i+=y(n),i+=`"`),i+=`/>`,i};let y=function(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e.charAt(n);switch(r){case`<`:t+=`&lt;`;break;case`>`:t+=`&gt;`;break;case`&`:t+=`&amp;`;break;case`"`:t+=`&quot;`;break;default:t+=r}}return t},b=function(e){e=e===void 0?2:e;let t=c.getModuleCount()*1+e*2,n=e,r=t-e,i,a,o,s,l,u={"██":`█`,"█ ":`▀`," █":`▄`," ":` `},d={"██":`▀`,"█ ":`▀`," █":` `," ":` `},f=``;for(i=0;i<t;i+=2){for(o=Math.floor((i-n)/1),s=Math.floor((i+1-n)/1),a=0;a<t;a+=1)l=`█`,n<=a&&a<r&&n<=i&&i<r&&c.isDark(o,Math.floor((a-n)/1))&&(l=` `),n<=a&&a<r&&n<=i+1&&i+1<r&&c.isDark(s,Math.floor((a-n)/1))?l+=` `:l+=`█`,f+=e<1&&i+1>=r?d[l]:u[l];f+=`
221
221
  `}return t%2&&e>0?f.substring(0,f.length-t-1)+Array(t+1).join(`▀`):f.substring(0,f.length-1)};return c.createASCII=function(e,t){if(e||=1,e<2)return b(t);--e,t=t===void 0?e*2:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t,a,o,s,l,u=Array(e+1).join(`██`),d=Array(e+1).join(` `),f=``,p=``;for(a=0;a<n;a+=1){for(s=Math.floor((a-r)/e),p=``,o=0;o<n;o+=1)l=1,r<=o&&o<i&&r<=a&&a<i&&c.isDark(s,Math.floor((o-r)/e))&&(l=0),p+=l?u:d;for(s=0;s<e;s+=1)f+=p+`
222
- `}return f.substring(0,f.length-1)},c.renderTo2dContext=function(e,t){t||=2;let n=c.getModuleCount();for(let r=0;r<n;r++)for(let i=0;i<n;i++)e.fillStyle=c.isDark(r,i)?`black`:`white`,e.fillRect(i*t,r*t,t,t)},c};Nl.stringToBytes=function(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t.push(r&255)}return t},Nl.createStringToBytes=function(e,t){let n=function(){let n=Jl(e),r=function(){let e=n.read();if(e==-1)throw`eof`;return e},i=0,a={};for(;;){let e=n.read();if(e==-1)break;let t=r(),o=r(),s=r(),c=String.fromCharCode(e<<8|t);a[c]=o<<8|s,i+=1}if(i!=t)throw i+` != `+t;return a}();return function(e){let t=[];for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i<128)t.push(i);else{let i=n[e.charAt(r)];typeof i==`number`?(i&255)==i?t.push(i):(t.push(i>>>8),t.push(i&255)):t.push(63)}}return t}};var Pl={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Fl={L:1,M:0,Q:3,H:2},Il={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Ll=function(){let e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r={},i=function(e){let t=0;for(;e!=0;)t+=1,e>>>=1;return t};return r.getBCHTypeInfo=function(e){let n=e<<10;for(;i(n)-i(t)>=0;)n^=t<<i(n)-i(t);return(e<<10|n)^21522},r.getBCHTypeNumber=function(e){let t=e<<12;for(;i(t)-i(n)>=0;)t^=n<<i(t)-i(n);return e<<12|t},r.getPatternPosition=function(t){return e[t-1]},r.getMaskFunction=function(e){switch(e){case Il.PATTERN000:return function(e,t){return(e+t)%2==0};case Il.PATTERN001:return function(e,t){return e%2==0};case Il.PATTERN010:return function(e,t){return t%3==0};case Il.PATTERN011:return function(e,t){return(e+t)%3==0};case Il.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case Il.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case Il.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case Il.PATTERN111:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw`bad maskPattern:`+e}},r.getErrorCorrectPolynomial=function(e){let t=zl([1],0);for(let n=0;n<e;n+=1)t=t.multiply(zl([1,Rl.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case Pl.MODE_NUMBER:return 10;case Pl.MODE_ALPHA_NUM:return 9;case Pl.MODE_8BIT_BYTE:return 8;case Pl.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case Pl.MODE_NUMBER:return 12;case Pl.MODE_ALPHA_NUM:return 11;case Pl.MODE_8BIT_BYTE:return 16;case Pl.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case Pl.MODE_NUMBER:return 14;case Pl.MODE_ALPHA_NUM:return 13;case Pl.MODE_8BIT_BYTE:return 16;case Pl.MODE_KANJI:return 12;default:throw`mode:`+e}else throw`type:`+t},r.getLostPoint=function(e){let t=e.getModuleCount(),n=0;for(let r=0;r<t;r+=1)for(let i=0;i<t;i+=1){let a=0,o=e.isDark(r,i);for(let n=-1;n<=1;n+=1)if(!(r+n<0||t<=r+n))for(let s=-1;s<=1;s+=1)i+s<0||t<=i+s||(n!=0||s!=0)&&o==e.isDark(r+n,i+s)&&(a+=1);a>5&&(n+=3+a-5)}for(let r=0;r<t-1;r+=1)for(let i=0;i<t-1;i+=1){let t=0;e.isDark(r,i)&&(t+=1),e.isDark(r+1,i)&&(t+=1),e.isDark(r,i+1)&&(t+=1),e.isDark(r+1,i+1)&&(t+=1),(t==0||t==4)&&(n+=3)}for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(n+=40);for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(n+=40);let r=0;for(let n=0;n<t;n+=1)for(let i=0;i<t;i+=1)e.isDark(i,n)&&(r+=1);let i=Math.abs(100*r/t/t-50)/5;return n+=i*10,n},r}(),Rl=function(){let e=Array(256),t=Array(256);for(let t=0;t<8;t+=1)e[t]=1<<t;for(let t=8;t<256;t+=1)e[t]=e[t-4]^e[t-5]^e[t-6]^e[t-8];for(let n=0;n<255;n+=1)t[e[n]]=n;let n={};return n.glog=function(e){if(e<1)throw`glog(`+e+`)`;return t[e]},n.gexp=function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]},n}(),zl=function(e,t){if(e.length===void 0)throw e.length+`/`+t;let n=function(){let n=0;for(;n<e.length&&e[n]==0;)n+=1;let r=Array(e.length-n+t);for(let t=0;t<e.length-n;t+=1)r[t]=e[t+n];return r}(),r={};return r.getAt=function(e){return n[e]},r.getLength=function(){return n.length},r.multiply=function(e){let t=Array(r.getLength()+e.getLength()-1);for(let n=0;n<r.getLength();n+=1)for(let i=0;i<e.getLength();i+=1)t[n+i]^=Rl.gexp(Rl.glog(r.getAt(n))+Rl.glog(e.getAt(i)));return zl(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=Rl.glog(r.getAt(0))-Rl.glog(e.getAt(0)),n=Array(r.getLength());for(let e=0;e<r.getLength();e+=1)n[e]=r.getAt(e);for(let r=0;r<e.getLength();r+=1)n[r]^=Rl.gexp(Rl.glog(e.getAt(r))+t);return zl(n,0).mod(e)},r},Bl=function(){let e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(e,t){let n={};return n.totalCount=e,n.dataCount=t,n},n={},r=function(t,n){switch(n){case Fl.L:return e[(t-1)*4+0];case Fl.M:return e[(t-1)*4+1];case Fl.Q:return e[(t-1)*4+2];case Fl.H:return e[(t-1)*4+3];default:return}};return n.getRSBlocks=function(e,n){let i=r(e,n);if(i===void 0)throw`bad rs block @ typeNumber:`+e+`/errorCorrectionLevel:`+n;let a=i.length/3,o=[];for(let e=0;e<a;e+=1){let n=i[e*3+0],r=i[e*3+1],a=i[e*3+2];for(let e=0;e<n;e+=1)o.push(t(r,a))}return o},n}(),Vl=function(){let e=[],t=0,n={};return n.getBuffer=function(){return e},n.getAt=function(t){let n=Math.floor(t/8);return(e[n]>>>7-t%8&1)==1},n.put=function(e,t){for(let r=0;r<t;r+=1)n.putBit((e>>>t-r-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(n){let r=Math.floor(t/8);e.length<=r&&e.push(0),n&&(e[r]|=128>>>t%8),t+=1},n},Hl=function(e){let t=Pl.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+2<t.length;)e.put(i(t.substring(r,r+3)),10),r+=3;r<t.length&&(t.length-r==1?e.put(i(t.substring(r,r+1)),4):t.length-r==2&&e.put(i(t.substring(r,r+2)),7))};let i=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*10+a(e.charAt(n));return t},a=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;throw`illegal char :`+e};return r},Ul=function(e){let t=Pl.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+1<t.length;)e.put(i(t.charAt(r))*45+i(t.charAt(r+1)),11),r+=2;r<t.length&&e.put(i(t.charAt(r)),6)};let i=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;if(`A`<=e&&e<=`Z`)return e.charCodeAt(0)-65+10;switch(e){case` `:return 36;case`$`:return 37;case`%`:return 38;case`*`:return 39;case`+`:return 40;case`-`:return 41;case`.`:return 42;case`/`:return 43;case`:`:return 44;default:throw`illegal char :`+e}};return r},Wl=function(e){let t=Pl.MODE_8BIT_BYTE,n=Nl.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){for(let t=0;t<n.length;t+=1)e.put(n[t],8)},r},Gl=function(e){let t=Pl.MODE_KANJI,n=Nl.stringToBytes;(function(e,t){let r=n(e);if(r.length!=2||(r[0]<<8|r[1])!=t)throw`sjis not supported.`})(`友`,38726);let r=n(e),i={};return i.getMode=function(){return t},i.getLength=function(e){return~~(r.length/2)},i.write=function(e){let t=r,n=0;for(;n+1<t.length;){let r=(255&t[n])<<8|255&t[n+1];if(33088<=r&&r<=40956)r-=33088;else if(57408<=r&&r<=60351)r-=49472;else throw`illegal char at `+(n+1)+`/`+r;r=(r>>>8&255)*192+(r&255),e.put(r,13),n+=2}if(n<t.length)throw`illegal char at `+(n+1)},i},Kl=function(){let e=[],t={};return t.writeByte=function(t){e.push(t&255)},t.writeShort=function(e){t.writeByte(e),t.writeByte(e>>>8)},t.writeBytes=function(e,n,r){n||=0,r||=e.length;for(let i=0;i<r;i+=1)t.writeByte(e[i+n])},t.writeString=function(e){for(let n=0;n<e.length;n+=1)t.writeByte(e.charCodeAt(n))},t.toByteArray=function(){return e},t.toString=function(){let t=``;t+=`[`;for(let n=0;n<e.length;n+=1)n>0&&(t+=`,`),t+=e[n];return t+=`]`,t},t},ql=function(){let e=0,t=0,n=0,r=``,i={},a=function(e){r+=String.fromCharCode(o(e&63))},o=function(e){if(e<0)throw`n:`+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw`n:`+e};return i.writeByte=function(r){for(e=e<<8|r&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){let e=3-n%3;for(let t=0;t<e;t+=1)r+=`=`}},i.toString=function(){return r},i},Jl=function(e){let t=e,n=0,r=0,i=0,a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw`unexpected end of file./`+i}let e=t.charAt(n);if(n+=1,e==`=`)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}let e=r>>>i-8&255;return i-=8,e};let o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw`c:`+e};return a},Yl=function(e,t){let n=e,r=t,i=Array(e*t),a={};a.setPixel=function(e,t,r){i[t*n+e]=r},a.write=function(e){e.writeString(`GIF87a`),e.writeShort(n),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(`,`),e.writeShort(0),e.writeShort(0),e.writeShort(n),e.writeShort(r),e.writeByte(0);let t=s(2);e.writeByte(2);let i=0;for(;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(`;`)};let o=function(e){let t=e,n=0,r=0,i={};return i.write=function(e,i){if(e>>>i)throw`length over`;for(;n+i>=8;)t.writeByte(255&(e<<n|r)),i-=8-n,e>>>=8-n,r=0,n=0;r=e<<n|r,n+=i},i.flush=function(){n>0&&t.writeByte(r)},i},s=function(e){let t=1<<e,n=(1<<e)+1,r=e+1,a=c();for(let e=0;e<t;e+=1)a.add(String.fromCharCode(e));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(n));let s=Kl(),l=o(s);l.write(t,r);let u=0,d=String.fromCharCode(i[u]);for(u+=1;u<i.length;){let e=String.fromCharCode(i[u]);u+=1,a.contains(d+e)?d+=e:(l.write(a.indexOf(d),r),a.size()<4095&&(a.size()==1<<r&&(r+=1),a.add(d+e)),d=e)}return l.write(a.indexOf(d),r),l.write(n,r),l.flush(),s.toByteArray()},c=function(){let e={},t=0,n={};return n.add=function(r){if(n.contains(r))throw`dup key:`+r;e[r]=t,t+=1},n.size=function(){return t},n.indexOf=function(t){return e[t]},n.contains=function(t){return e[t]!==void 0},n};return a},Xl=function(e,t,n){let r=Yl(e,t);for(let i=0;i<t;i+=1)for(let t=0;t<e;t+=1)r.setPixel(t,i,n(t,i));let i=Kl();r.write(i);let a=ql(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};Nl.stringToBytes;function Zl(){let e=navigator.userAgent,t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Mac/.test(e)?`Mac`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:`device`,n=/Edg\//.test(e)?`Edge`:/Firefox\//.test(e)?`Firefox`:/Chrome\//.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n?`${t} · ${n}`:t}function Ql(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(Zl),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=async()=>{a(!0),s(``);let t=await A.request(`devices.pair`,{body:{code:e,name:n}}).catch(()=>null);if(t?.ok)return location.reload();a(!1),s(t?j(t):`could not reach kraftwerk`)};return(0,P.jsxs)(`main`,{className:`mx-auto flex min-h-screen w-full max-w-[420px] flex-col justify-center gap-5 px-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,P.jsx)(F,{name:`phonelink_lock`,className:`text-[32px] text-fg-2`}),(0,P.jsx)(rt,{size:`lg`,children:`Pair this device`}),(0,P.jsxs)(`p`,{className:`m-0 text-sm leading-relaxed text-fg-2`,children:[`This kraftwerk runs on another machine. On that machine, run `,(0,P.jsx)(`code`,{children:`kraftwerk devices pair`}),` or open settings → devices, and enter the code here. You pair once; it stays paired until it is removed there.`]})]}),(0,P.jsxs)(`form`,{className:`flex flex-col gap-3.5`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,P.jsx)(X,{label:`pairing code`,children:(0,P.jsx)(Y,{value:e,onChange:e=>t(e.target.value.toUpperCase()),placeholder:`ABCD-EF23`,autoFocus:!0,autoComplete:`one-time-code`,autoCapitalize:`characters`,"aria-label":`pairing code`,className:`font-mono tracking-widest`})}),(0,P.jsx)(X,{label:`name of this device`,hint:`how it shows in the list of paired devices`,children:(0,P.jsx)(Y,{value:n,onChange:e=>r(e.target.value),"aria-label":`device name`})}),o&&(0,P.jsx)(K,{tone:`bad`,children:o}),(0,P.jsx)(B,{variant:`primary`,type:`submit`,busy:i,disabled:!e.trim(),children:`pair`})]})]})}function $l({children:e}){return O()?(0,P.jsx)(Ql,{}):(0,P.jsx)(P.Fragment,{children:e})}function eu({text:e,size:t=176}){let n=(0,v.useMemo)(()=>{let t=Nl(0,`M`);t.addData(e),t.make();let n=t.getModuleCount(),r=``;for(let e=0;e<n;e++)for(let i=0;i<n;i++)t.isDark(e,i)&&(r+=`M${i+4} ${e+4}h1v1h-1z`);return{d:r,n:n+8}},[e]);return(0,P.jsx)(`svg`,{viewBox:`0 0 ${n.n} ${n.n}`,width:t,height:t,role:`img`,"aria-label":`pairing QR code`,className:`rounded-lg bg-white text-black`,shapeRendering:`crispEdges`,children:(0,P.jsx)(`path`,{d:n.d,fill:`currentColor`})})}function tu({onError:e}){let t=M(`devices.relay`,{},{interval:1e4}),[n,r]=(0,v.useState)(!1);if(!t)return null;let i=async()=>{r(!0);let n=await A.request(`devices.setRelay`,{body:{enabled:!t.enabled}}).catch(()=>null);r(!1),n&&!n.ok&&e(j(n))},a=t.enabled?t.daemon?t.state===`connected`?`connected${t.clients?` · ${t.clients} device${t.clients===1?``:`s`} now`:``}`:t.state===`error`?`not connected: ${t.error??`unknown error`}`:`connecting…`:"on — the daemon connects it (this kraftwerk is not the daemon: `kraftwerk daemon`)":`off — devices reach this machine on your network only`;return(0,P.jsx)(lt,{children:(0,P.jsx)(ct,{icon:t.enabled?`public`:`public_off`,title:`reach this machine from anywhere`,"data-relay":t.enabled?t.state:`off`,action:(0,P.jsx)(B,{size:`sm`,busy:n,variant:t.enabled?void 0:`primary`,onClick:()=>void i(),children:t.enabled?`turn off`:`turn on`}),children:(0,P.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[a,t.enabled&&t.fingerprint&&(0,P.jsxs)(P.Fragment,{children:[` · machine key `,(0,P.jsx)(`code`,{children:t.fingerprint})]}),` — through the kraftwerk relay, end to end encrypted: it cannot read along`]})})})}function nu(){let e=M(`devices.self`,{},{interval:6e4}),t=e?.trust===`local`,n=M(`devices.list`,t?{}:null,{interval:15e3}),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``);if(!e)return null;if(!t)return(0,P.jsx)(q,{title:`devices`,children:(0,P.jsx)(lt,{children:(0,P.jsx)(ct,{icon:`phonelink_lock`,title:`this browser is paired as “${e.device?.name}”`,children:(0,P.jsx)(`span`,{className:`text-xs text-fg-2`,children:`devices are managed on the machine kraftwerk runs on`})})})});let s=async()=>{o(``);let e=await A.request(`devices.code`).catch(()=>null);e?.ok?i(e.data):o(e?j(e):`could not make a code`)},c=async(e,t)=>{if(!window.confirm(`Unpair “${t}”? It loses access at once.`))return;let n=await A.request(`devices.revoke`,{id:e}).catch(()=>null);n&&!n.ok&&o(j(n))};return(0,P.jsxs)(q,{title:`devices`,actions:(0,P.jsx)(B,{size:`sm`,icon:`add_link`,onClick:()=>void s(),children:`pair a device`}),children:[r&&(0,P.jsxs)(yt,{className:`border-b border-line`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-3`,children:[(0,P.jsx)(`span`,{className:`font-mono text-[22px] font-semibold tracking-widest text-fg`,"aria-label":`pairing code`,children:r.code}),(0,P.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`once, until `,new Date(r.expiresAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]})]}),r.remote&&(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,P.jsx)(eu,{text:r.remote}),(0,P.jsxs)(`span`,{className:`max-w-[28ch] text-sm text-fg-2`,children:[`From anywhere: scan this with the phone's camera, or open `,(0,P.jsx)(`a`,{href:r.remote,target:`_blank`,rel:`noreferrer`,children:`the pairing link`}),` on it. It carries the code — treat it like a password.`]})]}),r.urls.length?(0,P.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`On the device, open `,r.urls.map((e,t)=>(0,P.jsxs)(`span`,{children:[t>0&&` or `,(0,P.jsx)(`code`,{children:e})]},e)),` and enter the code.`]}):r.remote?null:(0,P.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`This kraftwerk only listens on this machine. Restart it with `,(0,P.jsx)(`code`,{children:`kraftwerk ui --lan`}),` to reach it from your network (or use a tunnel), then enter the code on the device — or turn on “reach this machine from anywhere”.`]})]}),(0,P.jsx)(tu,{onError:o}),a&&(0,P.jsx)(`div`,{className:`px-[18px] pt-3`,children:(0,P.jsx)(K,{tone:`bad`,children:a})}),n&&n.devices.length===0&&!r&&(0,P.jsx)(G,{icon:`devices`,children:`no paired devices — a phone or another computer can use this kraftwerk once paired`}),n&&n.devices.length>0&&(0,P.jsx)(lt,{children:n.devices.map(e=>(0,P.jsx)(ct,{icon:`devices`,title:e.name,"data-device":e.id,action:(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`link_off`,onClick:()=>void c(e.id,e.name),"aria-label":`unpair ${e.name}`,children:`unpair`}),children:(0,P.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`paired `,Ke(e.createdAt),` · `,e.lastSeenAt?`last seen ${Ke(e.lastSeenAt)}`:`not used yet`]})},e.id))})]})}var ru={enabled:!1,remote:`origin`,branch:``,interval:`300`,autosync:`pull`};function iu(e){let t=e.config.git;return t?{enabled:t.enabled!==!1,remote:t.remote??ru.remote,branch:t.branch??``,interval:String(t.interval??ru.interval),autosync:t.autosync??ru.autosync}:ru}var au={enabled:!1,root:``};function ou(e){let t=e.config.repos;return t?{enabled:t.enabled!==!1,root:t.root??``}:au}function su(e){let t=e.config.vibeables;return t?{enabled:t.enabled!==!1,root:t.root??``}:au}function cu(e){let t=e.config.projects;return t?{enabled:t.enabled!==!1,root:t.root??``}:au}function lu(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1);if((0,v.useEffect)(()=>{let e=!0,n=()=>A.call(`meta.get`).then(n=>e&&n.cloud&&t(n.cloud)).catch(()=>{});n();let r=setInterval(n,1e4);return()=>{e=!1,clearInterval(r)}},[]),!e)return null;let i=e.state===`connected`?e.account?`claimed`:`unclaimed`:e.state,a=e.state===`connected`&&e.account?`ok`:e.state===`error`?`bad`:`neutral`;return(0,P.jsx)(q,{title:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`cloud `,(0,P.jsx)(U,{tone:a,children:i})]}),actions:e.url&&(0,P.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,P.jsx)(F,{name:`cloud`,className:`ms-sm`}),` open the cloud`]}),children:(0,P.jsxs)(yt,{children:[e.state===`off`&&(0,P.jsxs)(W,{children:[`Off — `,e.reason??`turned off for this machine`,`. The daemon registers the machine with the kraftwerk cloud, so its owner sees its workspaces running from anywhere; `,(0,P.jsx)(`code`,{children:`kraftwerk cloud on`}),` and `,(0,P.jsx)(`code`,{children:`kraftwerk login`}),` in a terminal turn it on and claim it.`]}),e.state===`connecting`&&(0,P.jsxs)(W,{children:[`Registering with `,e.url,` …`]}),e.state===`error`&&(0,P.jsxs)(W,{children:[`Could not reach `,e.url,`: `,e.error,`. Retrying every `,e.interval??60,`s — the UI works as before meanwhile.`]}),e.state===`connected`&&e.account&&(0,P.jsxs)(W,{children:[`This machine`,e.machine?(0,P.jsxs)(P.Fragment,{children:[` (`,(0,P.jsx)(`code`,{children:e.machine}),`)`]}):null,` is registered at `,(0,P.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),` under `,(0,P.jsx)(`strong`,{children:e.account}),`. Last heartbeat `,e.lastSeen?new Date(e.lastSeen).toLocaleTimeString():`pending`,`.`]}),e.state===`connected`&&!e.account&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(W,{children:[`This machine is registered at `,(0,P.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),`, not yet under an account (no folder paths are sent until it is). Sign in there and enter this code — or open the link, or run `,(0,P.jsx)(`code`,{children:`kraftwerk login`}),`:`]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,P.jsx)(`code`,{className:`rounded-control border border-line bg-surface-2 px-3 py-1.5 font-mono text-lg tracking-[0.12em] text-fg`,children:e.claimCode??`…`}),e.claimCode&&(0,P.jsx)(B,{size:`sm`,icon:`content_copy`,onClick:()=>{navigator.clipboard.writeText(e.claimCode),r(!0),setTimeout(()=>r(!1),1500)},children:n?`copied`:`copy`}),e.claimUrl&&(0,P.jsxs)(`a`,{className:Qe(`primary`,`sm`),href:e.claimUrl,target:`_blank`,rel:`noreferrer`,children:[(0,P.jsx)(F,{name:`link`,className:`ms-sm`}),` claim in the cloud`]})]}),(0,P.jsxs)(W,{children:[`A claim made there reaches this machine with the next heartbeat (every `,e.interval??60,`s). To keep this workspace out of the cloud, set `,(0,P.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]}),e.state!==`off`&&e.included===!1&&(0,P.jsxs)(W,{children:[`This workspace is left out of the machine's record: `,(0,P.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]})})}function uu(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)(ru),[f,p]=(0,v.useState)(au),[m,h]=(0,v.useState)(au),[g,_]=(0,v.useState)(au),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(``),D=M(`identity.get`,{},{interval:6e4});(0,v.useEffect)(()=>{A.call(`settings.get`).then(e=>{t(e),r(e.config.name??``),a(e.config.icon??``),s(e.config.color??``),l(e.config.switcher??[]),d(iu(e)),p(ou(e)),h(su(e)),_(cu(e))}).catch(()=>E(`could not load settings`))},[]);let O=()=>{b(!0),w(!1),E(``)};async function k(){S(!0),E(``);try{let e=await A.request(`settings.save`,{body:{name:n,icon:i,color:o,switcher:c,git:{...u,interval:u.interval===``?void 0:Number(u.interval)},repos:f,vibeables:m,projects:g}});if(!e.ok)throw Error(e.error||`save failed`);let r=e.data;t(r),l(r.config.switcher??[]),d(iu(r)),p(ou(r)),h(su(r)),_(cu(r)),b(!1),w(!0)}catch(e){E(e.message)}finally{S(!1)}}let ee=(e,t)=>{l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),O()},te=e=>{d(t=>({...t,...e})),O()},j=e=>{p(t=>({...t,...e})),O()},N=e=>{h(t=>({...t,...e})),O()},ne=e=>{_(t=>({...t,...e})),O()};if(!e)return(0,P.jsx)(G,{children:T||`loading…`});let re=[[`identity`,D?.identity??`…`,`this machine — the runner routines name in runs_on (kraftwerk whoami to rename)`],[`port`,String(e.resolved.port),`kraftwerk ui listens here (CLI --port wins)`],[`workflows`,e.resolved.workflowsRoot??`— none found`,`workflow definitions`],[`output`,e.resolved.outputDir,`run artifacts`],[`knowledge`,e.config.knowledge??`knowledge`,`OKF knowledge bundles`],[`agents`,e.config.agents??`agents`,`agent definitions`],[`skills`,e.config.skills??`skills`,`workspace skills`]];return(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[860px] flex-col gap-4`,children:[(0,P.jsx)(it,{icon:(0,P.jsx)(F,{name:`settings`,className:`text-[28px] text-fg-2`}),title:`Settings`,actions:(0,P.jsxs)(P.Fragment,{children:[T&&(0,P.jsx)(K,{tone:`bad`,children:T}),C&&!y&&(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12.5px] text-ok`,children:[(0,P.jsx)(F,{name:`check`,className:`ms-sm`}),` saved`]}),(0,P.jsx)(B,{variant:`primary`,busy:x,disabled:!y,onClick:()=>void k(),children:x?`saving…`:`save changes`})]})}),(0,P.jsx)(q,{title:`workspace`,children:(0,P.jsxs)(yt,{children:[(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`icon`,className:`w-[90px]`,children:(0,P.jsx)(Y,{value:i,placeholder:`🤖`,onChange:e=>{a(e.target.value),O()}})}),(0,P.jsx)(X,{label:`name`,className:`min-w-40 flex-1`,children:(0,P.jsx)(Y,{value:n,placeholder:`my workspace`,onChange:e=>{r(e.target.value),O()}})}),(0,P.jsxs)(`label`,{className:`flex w-[130px] flex-col gap-1.5`,title:`Accent in the workspace switcher; empty = derived from the folder`,children:[(0,P.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:`color`}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`input`,{type:`color`,"aria-label":`pick a color`,className:`h-9 w-10 flex-none cursor-pointer rounded-control border border-line bg-surface p-0.5`,value:/^#[0-9a-f]{6}$/i.test(o)?o:`#888888`,onChange:e=>{s(e.target.value),O()}}),(0,P.jsx)(Y,{className:`min-w-0 px-2`,value:o,placeholder:`auto`,onChange:e=>{s(e.target.value),O()}})]})]})]}),(0,P.jsx)(W,{children:`Shown in the header, browser tab and to other workspaces discovering this one.`})]})}),(0,P.jsx)(q,{title:`workspace switcher`,actions:(0,P.jsx)(B,{size:`sm`,icon:`add`,onClick:()=>{l(e=>[...e,{name:``,url:`http://localhost:`}]),O()},children:`add entry`}),children:(0,P.jsxs)(yt,{children:[c.length===0&&(0,P.jsx)(W,{children:`No manual entries.`}),c.map((e,t)=>(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`icon`,className:`w-[70px]`,children:(0,P.jsx)(Y,{value:e.icon??``,placeholder:`•`,onChange:e=>ee(t,{icon:e.target.value})})}),(0,P.jsx)(X,{label:`name`,className:`min-w-32 flex-1`,children:(0,P.jsx)(Y,{value:e.name,placeholder:`other workspace`,onChange:e=>ee(t,{name:e.target.value})})}),(0,P.jsx)(X,{label:`url`,className:`min-w-40 flex-[1.4]`,children:(0,P.jsx)(Y,{value:e.url,placeholder:`http://localhost:1982`,onChange:e=>ee(t,{url:e.target.value})})}),(0,P.jsx)(V,{icon:`close`,label:`remove entry`,className:`mb-0.5`,onClick:()=>{l(e=>e.filter((e,n)=>n!==t)),O()}})]},t)),(0,P.jsx)(W,{children:`Running workspaces on this machine are discovered automatically — manual entries are for remote instances or extra links.`})]})}),(0,P.jsx)(q,{title:`git sync`,actions:(0,P.jsx)(B,{size:`sm`,icon:`account_tree`,href:`/git`,children:`open git`}),children:(0,P.jsxs)(yt,{children:[(0,P.jsx)(xt,{checked:u.enabled,onChange:e=>te({enabled:e}),children:`sync workflows, knowledge, agents and skills with a git remote`}),u.enabled&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`remote`,className:`min-w-32 flex-1`,children:(0,P.jsx)(Y,{value:u.remote,placeholder:`origin`,onChange:e=>te({remote:e.target.value})})}),(0,P.jsx)(X,{label:`branch`,className:`min-w-32 flex-1`,children:(0,P.jsx)(Y,{value:u.branch,placeholder:`checked-out branch`,onChange:e=>te({branch:e.target.value})})}),(0,P.jsx)(X,{label:`interval (s)`,className:`w-[120px]`,children:(0,P.jsx)(Y,{type:`number`,min:0,step:1,value:u.interval,placeholder:`300`,onChange:e=>te({interval:e.target.value})})}),(0,P.jsx)(X,{label:`autosync`,className:`w-[150px]`,children:(0,P.jsxs)(vt,{value:u.autosync,onChange:e=>te({autosync:e.target.value}),children:[(0,P.jsx)(`option`,{value:`pull`,children:`fetch and pull`}),(0,P.jsx)(`option`,{value:`off`,children:`fetch only`})]})})]}),(0,P.jsx)(W,{children:`The interval fetches in the background (0 turns the timer off); with autosync on it also fast-forwards when behind and nothing is modified locally. Commit and push stay manual on the git screen.`})]})]})}),(0,P.jsx)(q,{title:`repositories`,actions:(0,P.jsx)(B,{size:`sm`,icon:`source`,href:`/repos`,children:`open repositories`}),children:(0,P.jsxs)(yt,{children:[(0,P.jsx)(xt,{checked:f.enabled,onChange:e=>j({enabled:e}),children:`keep git repositories the agents work on under one folder`}),f.enabled&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(X,{label:`repos root`,children:(0,P.jsx)(Y,{value:f.root,placeholder:`repos`,onChange:e=>j({root:e.target.value})})}),(0,P.jsxs)(W,{children:[`Relative to the project root. Saving creates the folder and adds it to .gitignore; every agent gets the list of clones as context and can add more with `,(0,P.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})]})}),(0,P.jsx)(q,{title:`apps (vibeables)`,actions:(0,P.jsx)(B,{size:`sm`,icon:`web`,href:`/vibeables`,children:`open apps`}),children:(0,P.jsxs)(yt,{children:[(0,P.jsx)(xt,{checked:m.enabled,onChange:e=>N({enabled:e}),children:`build small apps live in a chat, with a preview pane next to the thread`}),m.enabled&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(X,{label:`vibeables root`,children:(0,P.jsx)(Y,{value:m.root,placeholder:`kraftwerk-data/vibeables`,onChange:e=>N({root:e.target.value})})}),(0,P.jsxs)(W,{children:[`Relative to the project root, one folder per app. Part of the workspace: versioned with it on the git screen, not git-ignored. Every chat gets a `,(0,P.jsx)(`b`,{children:`vibeable`}),` button; the agent then works inside the app folder.`]})]})]})}),(0,P.jsx)(q,{title:`projects`,actions:(0,P.jsx)(B,{size:`sm`,icon:`folder_special`,href:`/projects`,children:`open projects`}),children:(0,P.jsxs)(yt,{children:[(0,P.jsx)(xt,{checked:g.enabled,onChange:e=>ne({enabled:e}),children:`gather a goal, its brief, systems of record and links in one folder, and chat inside it`}),g.enabled&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(X,{label:`projects root`,children:(0,P.jsx)(Y,{value:g.root,placeholder:`kraftwerk-data/projects`,onChange:e=>ne({root:e.target.value})})}),(0,P.jsx)(W,{children:`Relative to the project root, one folder per project (project.yml, brief.md, state.md, log.md). Part of the workspace: versioned with it on the git screen. A chat opened in a project starts with all of it as context.`})]})]})}),(0,P.jsx)(lu,{}),(0,P.jsx)(nu,{}),(0,P.jsxs)(q,{title:`paths & port`,actions:(0,P.jsx)(`code`,{className:`max-w-[60%] truncate text-2xs text-fg-2`,title:e.configPath,children:e.exists?e.configPath:`${e.configPath} (not created yet)`}),children:[(0,P.jsx)(`div`,{className:`flex flex-col pt-1.5 pb-2.5`,children:re.map(([e,t,n])=>(0,P.jsxs)(`div`,{className:`grid grid-cols-[110px_1fr] items-baseline gap-x-3.5 gap-y-px border-line/55 px-[18px] py-2 [&+&]:border-t`,children:[(0,P.jsx)(tt,{children:e}),(0,P.jsx)(`code`,{className:`text-xs break-all`,children:t}),(0,P.jsx)(`span`,{className:`col-start-2 text-2xs text-fg-2`,children:n})]},e))}),(0,P.jsxs)(W,{className:`px-[18px] pb-3.5`,children:[`Read-only here — edit `,(0,P.jsx)(`code`,{children:`kraftwerk.yml`}),` directly to change these.`]})]})]})}var du={agents:{label:`agents`,icon:`smart_toy`},"agent-skills":{label:`agent skills`,icon:`extension`},projects:{label:`projects`,icon:`folder`},workflows:{label:`workflows`,icon:`account_tree`},knowledge:{label:`knowledge bundles`,icon:`menu_book`},vibeables:{label:`apps`,icon:`web`},channels:{label:`channels`,icon:`forum`},repos:{label:`repositories`,icon:`source`},chats:{label:`chats`,icon:`chat`},runs:{label:`runs`,icon:`play_circle`}};function fu(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=(0,v.useCallback)(async()=>{let e=await A.request(`trash.list`).catch(()=>null);e?.ok?t(e.data):r(e?.status===404?`this server has no trash yet — restart it after updating`:`could not load the trash`)},[]);(0,v.useEffect)(()=>{c()},[c]);let l=async(e,t)=>{a(t),r(``),s(null);try{let n=e===`empty`?(await A.request(`trash.empty`)).error:j(await A.request(`trash.${e}`,{body:{id:t}}));if(n)throw Error(n)}catch(e){r(e.message)}finally{a(null),c()}},u=e?.entries??[],d=[...new Set(u.map(e=>e.kind))].sort((e,t)=>Object.keys(du).indexOf(e)-Object.keys(du).indexOf(t));return(0,P.jsxs)(at,{className:`px-6 py-6`,children:[(0,P.jsx)(it,{icon:(0,P.jsx)(F,{name:`delete`,className:`text-[28px] text-fg-2`}),title:`Trash`,sub:e?`${u.length} item${u.length===1?``:`s`}`:void 0,actions:u.length>0&&(o===`*`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(B,{variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`empty`,`*`),children:[`delete all `,u.length,` for good`]}),(0,P.jsx)(B,{variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,P.jsx)(B,{variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(`*`),children:`empty trash`}))}),n&&(0,P.jsx)(K,{tone:`bad`,children:n}),!e&&!n&&(0,P.jsx)(q,{children:(0,P.jsx)(G,{children:`loading…`})}),e&&u.length===0&&(0,P.jsx)(q,{children:(0,P.jsx)(G,{icon:`delete`,children:`The trash is empty. What you delete lands here first.`})}),d.map(e=>(0,P.jsx)(q,{title:du[e]?.label??e,actions:(0,P.jsxs)(`code`,{className:`text-xs text-fg-2`,children:[`trash/`,e,`/`]}),children:(0,P.jsx)(`div`,{className:`p-1.5`,children:u.filter(t=>t.kind===e).map(t=>(0,P.jsx)(J,{className:`trash-row`,leading:(0,P.jsx)(F,{name:du[e]?.icon??`draft`,className:`ms-sm`}),title:t.name,sub:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`font-mono`,children:t.from}),` · `,(0,P.jsxs)(`span`,{title:t.trashedAt,children:[`deleted `,Ke(t.trashedAt)]})]}),meta:(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(B,{size:`sm`,variant:`secondary`,icon:`restore_from_trash`,busy:i===t.id,disabled:!!i,onClick:()=>void l(`restore`,t.id),title:`Put it back at ${t.from}`,children:`restore`}),o===t.id?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`purge`,t.id),children:`delete for good`}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(t.id),children:`delete`})]})},t.id))})},e)),e&&(0,P.jsxs)(`p`,{className:`m-0 text-sm text-fg-2`,children:[`The trash lives in `,(0,P.jsx)(`code`,{children:e.root}),`, kept out of the workspace git. From the terminal:`,` `,(0,P.jsx)(`code`,{children:`kraftwerk trash`}),`, `,(0,P.jsx)(`code`,{children:`kraftwerk trash restore <id>`}),`, `,(0,P.jsx)(`code`,{children:`kraftwerk trash empty`}),`.`]})]})}var pu=(e,t,n=!1)=>A.url(`files.raw`,{query:{scope:e,path:t,download:n}}),mu=(e,t=``,n)=>`/files/${encodeURIComponent(e)}${t?`/${t.split(`/`).map(encodeURIComponent).join(`/`)}`:``}${n?`?file=${encodeURIComponent(n)}`:``}`,hu=`inline-grid size-7 shrink-0 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,gu=`whitespace-nowrap border-b border-line px-2.5 py-1.5 text-left`;function _u({here:e,onClick:t,children:n}){return(0,P.jsx)(`button`,{type:`button`,onClick:t,className:N(`cursor-pointer rounded-md border-0 bg-transparent px-1 py-0.5 font-[inherit] hover:bg-surface-2 hover:text-fg`,e?`font-semibold text-fg`:`text-fg-2`),children:n})}function vu(e){if(e.type===`dir`)return`folder`;let t=e.mime??``;return t.startsWith(`image/`)?`image`:t===`application/pdf`?`picture_as_pdf`:t.startsWith(`video/`)?`movie`:t.startsWith(`audio/`)?`music_note`:/csv|tab-separated|spreadsheet/.test(t)?`table`:/zip/.test(t)?`folder_zip`:/presentation/.test(t)?`slideshow`:t.startsWith(`text/`)||/json|yaml|xml|wordprocessing/.test(t)?`description`:`draft`}function yu({scope:e,dir:t,file:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(0);(0,v.useEffect)(()=>{A.call(`files.scopes`).then(e=>i(e.scopes),()=>i([]))},[a]);let s=(r??[]).filter(e=>e.scope!==`workspace`);return(0,P.jsxs)(`div`,{className:`runs-screen files-screen`,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`files`}),(0,P.jsxs)(Dt,{children:[(r??[]).filter(e=>e.scope===`workspace`).map(t=>(0,P.jsx)(bu,{s:t,active:e===t.scope,icon:`home_storage`},t.scope)),s.length>0&&(0,P.jsx)(Tt,{title:`projects`,divided:!0}),s.map(t=>(0,P.jsx)(bu,{s:t,active:e===t.scope,icon:`folder_special`},t.scope))]})]}),(0,P.jsx)(`div`,{className:`runs-main min-w-0`,children:(0,P.jsx)(xu,{scope:e,dir:t,file:n,onOpen:(t,n)=>z(mu(e,t,n)),onChanged:()=>o(e=>e+1)},e)})]})}function bu({s:e,active:t,icon:n}){return(0,P.jsx)(J,{href:mu(e.scope),active:t,size:`sm`,leading:(0,P.jsx)(F,{name:n,className:`ms-sm`}),title:e.label,sub:(0,P.jsxs)(`span`,{className:`font-mono`,children:[e.root,`/`]}),meta:e.count})}function xu({scope:e,dir:t,file:n,onOpen:r,onChanged:i,compact:a=!1}){let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),x=(0,v.useRef)(null),S=(0,v.useCallback)(async()=>{let n=await A.request(`files.list`,{query:{scope:e,path:t}}).catch(()=>null);if(!n?.ok||!n.data||typeof n.data!=`object`){l(n?.error??`could not load the folder`),s(null);return}l(``),s(n.data)},[e,t]);(0,v.useEffect)(()=>{S();let e=setInterval(()=>void S(),1e4);return()=>clearInterval(e)},[S]);let C=async()=>{await S(),i?.()};async function w(n){let r=[...n];if(r.length){l(``);for(let[n,i]of r.entries()){d(r.length>1?`uploading ${n+1} of ${r.length}…`:`uploading ${i.name}…`);let a=await A.request(`files.upload`,{query:{scope:e,path:t},headers:{"x-file-name":encodeURIComponent(i.name),"content-type":i.type||`application/octet-stream`},body:i}).catch(()=>null);a?.ok||l(a?.error??`could not upload ${i.name}`)}d(``),await C()}}async function T(n){let r=n.trim();if(h(null),!r)return;let i=j(await A.request(`files.mkdir`,{body:{scope:e,path:t?`${t}/${r}`:r}}));i&&l(i),await C()}async function E(i,a){_(null);let o=a.trim();if(!o||o===i.split(`/`).pop())return;let s=i.includes(`/`)?`${i.slice(0,i.lastIndexOf(`/`))}/${o}`:o,c=j(await A.request(`files.move`,{body:{scope:e,from:i,to:s}}));c?l(c):n===i&&r(t,s),await C()}async function D(i){b(null);let a=await A.request(`files.delete`,{query:{scope:e,path:i}}).catch(()=>null);a?.ok||l(a?.error??`could not delete`),n===i&&r(t),await C()}let O=t?t.split(`/`):[],k=n?o?.entries.find(e=>e.path===n):void 0,ee=!(a&&n);return(0,P.jsxs)(`div`,{className:N(`files-browser h-full min-h-0`,a?`flex flex-col gap-2 px-1.5 py-1`:N(`grid gap-4`,n?`grid-cols-1 min-[900px]:grid-cols-[minmax(280px,1fr)_minmax(0,1.3fr)]`:`grid-cols-1`)),children:[ee&&(0,P.jsxs)(`div`,{className:N(`flex min-h-0 flex-col rounded-card outline-2 -outline-offset-2 outline-dashed transition-colors`,f?`bg-accent/5 outline-accent`:`outline-transparent`),onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),p(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||p(!1)},onDrop:e=>{e.preventDefault(),p(!1),w(e.dataTransfer.files)},children:[(0,P.jsxs)(`div`,{className:N(`flex items-center gap-1`,a?`px-1 pb-1.5 pt-0.5`:`px-0.5 pb-2.5 pt-1`),children:[(0,P.jsxs)(`nav`,{className:N(`flex min-w-0 flex-wrap items-center`,a?`text-sm`:`text-md`),"aria-label":`Folder`,children:[(0,P.jsx)(_u,{here:!O.length,onClick:()=>r(``),children:o?.label??(e===`workspace`?`Workspace`:e.replace(/^project:/,``))}),O.map((e,t)=>(0,P.jsxs)(`span`,{className:`inline-flex items-center text-fg-2`,children:[(0,P.jsx)(F,{name:`chevron_right`,className:`ms-sm`}),(0,P.jsx)(_u,{here:t===O.length-1,onClick:()=>r(O.slice(0,t+1).join(`/`)),children:e})]},t))]}),(0,P.jsx)(`span`,{className:`flex-1`}),a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(V,{icon:`create_new_folder`,label:`New folder`,size:`sm`,onClick:()=>h(``)}),(0,P.jsx)(V,{icon:`upload`,label:`Upload files`,size:`sm`,onClick:()=>x.current?.click()})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{variant:`quiet`,size:`sm`,icon:`create_new_folder`,onClick:()=>h(``),title:`New folder`,children:`folder`}),(0,P.jsx)(B,{variant:`quiet`,size:`sm`,icon:`upload`,onClick:()=>x.current?.click(),title:`Upload files`,children:`upload`})]}),(0,P.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`Upload files`,onChange:e=>e.target.files&&void w(e.target.files)})]}),u&&(0,P.jsx)(K,{children:u}),c&&(0,P.jsx)(K,{tone:`bad`,children:c}),(0,P.jsxs)(`div`,{className:`files-list flex min-h-0 flex-1 flex-col gap-px overflow-y-auto`,role:`list`,children:[m!==null&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,P.jsx)(F,{name:`create_new_folder`,className:`text-[20px] text-fg-2`}),(0,P.jsx)(Y,{className:`h-8`,autoFocus:!0,value:m,placeholder:`folder name`,"aria-label":`Folder name`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(m),e.key===`Escape`&&h(null)},onBlur:()=>void T(m)})]}),o?.entries.map(i=>g?.path===i.path?(0,P.jsxs)(`div`,{role:`listitem`,className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,P.jsx)(F,{name:vu(i),className:`text-[20px] text-fg-2`}),(0,P.jsx)(Y,{className:`h-8`,autoFocus:!0,value:g.name,"aria-label":`New name`,onChange:e=>_({path:i.path,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&E(i.path,g.name),e.key===`Escape`&&_(null)},onBlur:()=>void E(i.path,g.name)})]},i.path):(0,P.jsx)(`div`,{role:`listitem`,children:(0,P.jsx)(J,{className:`files-row`,active:i.path===n,onClick:()=>i.type===`dir`?r(i.path):r(t,i.path),label:i.name,leading:(0,P.jsx)(F,{name:vu(i),className:`text-[20px] text-fg-2`}),title:(0,P.jsx)(`span`,{className:`font-normal`,children:i.name}),titleExtra:i.local?(0,P.jsx)(`span`,{className:`text-xs font-normal text-fg-2`,title:`Over 25 MB: kept out of git, stays on this machine`,children:`local only`}):void 0,meta:(0,P.jsxs)(P.Fragment,{children:[i.type===`dir`?`${i.count??0} file${i.count===1?``:`s`}`:We(i.size??0),!a&&` · ${Ke(i.modifiedAt)}`]}),actions:(0,P.jsxs)(P.Fragment,{children:[i.type===`file`&&(0,P.jsx)(`a`,{className:`inline-grid size-7 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,href:pu(e,i.path,!0),title:`Download`,"aria-label":`Download ${i.name}`,children:(0,P.jsx)(F,{name:`download`,className:`ms-sm`})}),(0,P.jsx)(V,{icon:`edit`,size:`sm`,label:`Rename ${i.name}`,onClick:()=>_({path:i.path,name:i.name})}),y===i.path?(0,P.jsx)(B,{variant:`danger`,size:`sm`,autoFocus:!0,onClick:()=>void D(i.path),onBlur:()=>b(null),children:`move to trash`}):(0,P.jsx)(V,{icon:`delete`,size:`sm`,label:`Delete ${i.name}`,onClick:()=>b(i.path)})]})})},i.path)),o&&o.entries.length===0&&m===null&&(0,P.jsxs)(G,{icon:`upload_file`,action:(0,P.jsxs)(`span`,{className:`font-mono text-2xs opacity-80`,children:[o.root,`/`,t?`${t}/`:``]}),children:[`Drop files here, or`,` `,(0,P.jsx)(`button`,{type:`button`,className:`cursor-pointer border-0 bg-transparent p-0 font-[inherit] text-accent underline`,onClick:()=>x.current?.click(),children:`choose some`}),`.`]}),!o&&!c&&(0,P.jsx)(G,{children:`loading…`})]})]}),n&&(0,P.jsx)(Su,{scope:e,path:n,entry:k,onClose:()=>r(t),compact:a})]})}function Su({scope:e,path:t,entry:n,onClose:r,compact:i}){let a=n?.mime??``,o=t.split(`/`).pop()??t,s=pu(e,t),c=/^text\/|json|yaml|xml/.test(a)&&!/html/.test(a),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(u(null),!c||(n?.size??0)>2e6)return;let e=!0;return fetch(s,{cache:`no-store`}).then(e=>e.text()).then(t=>e&&u(t)).catch(()=>{}),()=>{e=!1}},[s,c,n?.size]);let d;return d=n?a.startsWith(`image/`)?(0,P.jsx)(`img`,{className:`m-auto max-h-full max-w-full flex-none object-contain p-4`,src:s,alt:o}):a===`application/pdf`?(0,P.jsx)(`iframe`,{className:N(`w-full border-0 bg-white`,i?`min-h-[60vh]`:`min-h-[70vh]`),src:s,title:o}):a.startsWith(`video/`)?(0,P.jsx)(`video`,{className:`m-auto max-h-full w-full p-4`,src:s,controls:!0}):a.startsWith(`audio/`)?(0,P.jsx)(`audio`,{className:`m-auto w-full p-4`,src:s,controls:!0}):c&&l!==null?/markdown/.test(a)?(0,P.jsx)(`div`,{className:`md-body files-md px-5 py-4`,dangerouslySetInnerHTML:{__html:pa.sanitize(Q.parse(l,{async:!1}))}}):/csv|tab-separated/.test(a)?(0,P.jsx)(Cu,{text:l,tab:/tab-separated/.test(a)}):(0,P.jsx)(`pre`,{className:`files-text m-0 whitespace-pre-wrap p-4 font-mono text-[12.5px] leading-relaxed [overflow-wrap:anywhere]`,children:l}):c&&(n.size??0)<=2e6?(0,P.jsx)(G,{children:`loading…`}):(0,P.jsx)(G,{icon:vu(n),action:(0,P.jsx)(B,{variant:`primary`,size:`sm`,icon:`download`,href:void 0,onClick:()=>window.location.href=pu(e,t,!0),children:`download`}),children:`No preview for this kind of file.`}):(0,P.jsx)(G,{children:`loading…`}),(0,P.jsxs)(`section`,{className:N(`files-preview flex min-h-0 flex-col overflow-hidden rounded-card border border-line bg-surface`,i&&`min-h-[60vh]`),"aria-label":`Preview of ${o}`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-3 py-2`,children:[i&&(0,P.jsx)(V,{icon:`arrow_back`,label:`Back to the folder`,size:`sm`,onClick:r}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold`,title:t,children:o}),n?.size!==void 0&&(0,P.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-2`,children:We(n.size)}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsx)(`a`,{className:hu,href:s,target:`_blank`,rel:`noopener`,title:`Open in a new tab`,"aria-label":`Open in a new tab`,children:(0,P.jsx)(F,{name:`open_in_new`,className:`ms-sm`})}),(0,P.jsx)(`a`,{className:hu,href:pu(e,t,!0),title:`Download`,"aria-label":`Download`,children:(0,P.jsx)(F,{name:`download`,className:`ms-sm`})}),!i&&(0,P.jsx)(V,{icon:`close`,label:`Close the preview`,size:`sm`,onClick:r})]}),(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-auto [&>*]:flex-1`,children:d})]})}function Cu({text:e,tab:t}){let n=t?` `:e.split(`
222
+ `}return f.substring(0,f.length-1)},c.renderTo2dContext=function(e,t){t||=2;let n=c.getModuleCount();for(let r=0;r<n;r++)for(let i=0;i<n;i++)e.fillStyle=c.isDark(r,i)?`black`:`white`,e.fillRect(i*t,r*t,t,t)},c};Nl.stringToBytes=function(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t.push(r&255)}return t},Nl.createStringToBytes=function(e,t){let n=function(){let n=Jl(e),r=function(){let e=n.read();if(e==-1)throw`eof`;return e},i=0,a={};for(;;){let e=n.read();if(e==-1)break;let t=r(),o=r(),s=r(),c=String.fromCharCode(e<<8|t);a[c]=o<<8|s,i+=1}if(i!=t)throw i+` != `+t;return a}();return function(e){let t=[];for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i<128)t.push(i);else{let i=n[e.charAt(r)];typeof i==`number`?(i&255)==i?t.push(i):(t.push(i>>>8),t.push(i&255)):t.push(63)}}return t}};var Pl={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Fl={L:1,M:0,Q:3,H:2},Il={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Ll=function(){let e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r={},i=function(e){let t=0;for(;e!=0;)t+=1,e>>>=1;return t};return r.getBCHTypeInfo=function(e){let n=e<<10;for(;i(n)-i(t)>=0;)n^=t<<i(n)-i(t);return(e<<10|n)^21522},r.getBCHTypeNumber=function(e){let t=e<<12;for(;i(t)-i(n)>=0;)t^=n<<i(t)-i(n);return e<<12|t},r.getPatternPosition=function(t){return e[t-1]},r.getMaskFunction=function(e){switch(e){case Il.PATTERN000:return function(e,t){return(e+t)%2==0};case Il.PATTERN001:return function(e,t){return e%2==0};case Il.PATTERN010:return function(e,t){return t%3==0};case Il.PATTERN011:return function(e,t){return(e+t)%3==0};case Il.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case Il.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case Il.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case Il.PATTERN111:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw`bad maskPattern:`+e}},r.getErrorCorrectPolynomial=function(e){let t=zl([1],0);for(let n=0;n<e;n+=1)t=t.multiply(zl([1,Rl.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case Pl.MODE_NUMBER:return 10;case Pl.MODE_ALPHA_NUM:return 9;case Pl.MODE_8BIT_BYTE:return 8;case Pl.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case Pl.MODE_NUMBER:return 12;case Pl.MODE_ALPHA_NUM:return 11;case Pl.MODE_8BIT_BYTE:return 16;case Pl.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case Pl.MODE_NUMBER:return 14;case Pl.MODE_ALPHA_NUM:return 13;case Pl.MODE_8BIT_BYTE:return 16;case Pl.MODE_KANJI:return 12;default:throw`mode:`+e}else throw`type:`+t},r.getLostPoint=function(e){let t=e.getModuleCount(),n=0;for(let r=0;r<t;r+=1)for(let i=0;i<t;i+=1){let a=0,o=e.isDark(r,i);for(let n=-1;n<=1;n+=1)if(!(r+n<0||t<=r+n))for(let s=-1;s<=1;s+=1)i+s<0||t<=i+s||(n!=0||s!=0)&&o==e.isDark(r+n,i+s)&&(a+=1);a>5&&(n+=3+a-5)}for(let r=0;r<t-1;r+=1)for(let i=0;i<t-1;i+=1){let t=0;e.isDark(r,i)&&(t+=1),e.isDark(r+1,i)&&(t+=1),e.isDark(r,i+1)&&(t+=1),e.isDark(r+1,i+1)&&(t+=1),(t==0||t==4)&&(n+=3)}for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(n+=40);for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(n+=40);let r=0;for(let n=0;n<t;n+=1)for(let i=0;i<t;i+=1)e.isDark(i,n)&&(r+=1);let i=Math.abs(100*r/t/t-50)/5;return n+=i*10,n},r}(),Rl=function(){let e=Array(256),t=Array(256);for(let t=0;t<8;t+=1)e[t]=1<<t;for(let t=8;t<256;t+=1)e[t]=e[t-4]^e[t-5]^e[t-6]^e[t-8];for(let n=0;n<255;n+=1)t[e[n]]=n;let n={};return n.glog=function(e){if(e<1)throw`glog(`+e+`)`;return t[e]},n.gexp=function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]},n}(),zl=function(e,t){if(e.length===void 0)throw e.length+`/`+t;let n=function(){let n=0;for(;n<e.length&&e[n]==0;)n+=1;let r=Array(e.length-n+t);for(let t=0;t<e.length-n;t+=1)r[t]=e[t+n];return r}(),r={};return r.getAt=function(e){return n[e]},r.getLength=function(){return n.length},r.multiply=function(e){let t=Array(r.getLength()+e.getLength()-1);for(let n=0;n<r.getLength();n+=1)for(let i=0;i<e.getLength();i+=1)t[n+i]^=Rl.gexp(Rl.glog(r.getAt(n))+Rl.glog(e.getAt(i)));return zl(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=Rl.glog(r.getAt(0))-Rl.glog(e.getAt(0)),n=Array(r.getLength());for(let e=0;e<r.getLength();e+=1)n[e]=r.getAt(e);for(let r=0;r<e.getLength();r+=1)n[r]^=Rl.gexp(Rl.glog(e.getAt(r))+t);return zl(n,0).mod(e)},r},Bl=function(){let e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(e,t){let n={};return n.totalCount=e,n.dataCount=t,n},n={},r=function(t,n){switch(n){case Fl.L:return e[(t-1)*4+0];case Fl.M:return e[(t-1)*4+1];case Fl.Q:return e[(t-1)*4+2];case Fl.H:return e[(t-1)*4+3];default:return}};return n.getRSBlocks=function(e,n){let i=r(e,n);if(i===void 0)throw`bad rs block @ typeNumber:`+e+`/errorCorrectionLevel:`+n;let a=i.length/3,o=[];for(let e=0;e<a;e+=1){let n=i[e*3+0],r=i[e*3+1],a=i[e*3+2];for(let e=0;e<n;e+=1)o.push(t(r,a))}return o},n}(),Vl=function(){let e=[],t=0,n={};return n.getBuffer=function(){return e},n.getAt=function(t){let n=Math.floor(t/8);return(e[n]>>>7-t%8&1)==1},n.put=function(e,t){for(let r=0;r<t;r+=1)n.putBit((e>>>t-r-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(n){let r=Math.floor(t/8);e.length<=r&&e.push(0),n&&(e[r]|=128>>>t%8),t+=1},n},Hl=function(e){let t=Pl.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+2<t.length;)e.put(i(t.substring(r,r+3)),10),r+=3;r<t.length&&(t.length-r==1?e.put(i(t.substring(r,r+1)),4):t.length-r==2&&e.put(i(t.substring(r,r+2)),7))};let i=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*10+a(e.charAt(n));return t},a=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;throw`illegal char :`+e};return r},Ul=function(e){let t=Pl.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+1<t.length;)e.put(i(t.charAt(r))*45+i(t.charAt(r+1)),11),r+=2;r<t.length&&e.put(i(t.charAt(r)),6)};let i=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;if(`A`<=e&&e<=`Z`)return e.charCodeAt(0)-65+10;switch(e){case` `:return 36;case`$`:return 37;case`%`:return 38;case`*`:return 39;case`+`:return 40;case`-`:return 41;case`.`:return 42;case`/`:return 43;case`:`:return 44;default:throw`illegal char :`+e}};return r},Wl=function(e){let t=Pl.MODE_8BIT_BYTE,n=Nl.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){for(let t=0;t<n.length;t+=1)e.put(n[t],8)},r},Gl=function(e){let t=Pl.MODE_KANJI,n=Nl.stringToBytes;(function(e,t){let r=n(e);if(r.length!=2||(r[0]<<8|r[1])!=t)throw`sjis not supported.`})(`友`,38726);let r=n(e),i={};return i.getMode=function(){return t},i.getLength=function(e){return~~(r.length/2)},i.write=function(e){let t=r,n=0;for(;n+1<t.length;){let r=(255&t[n])<<8|255&t[n+1];if(33088<=r&&r<=40956)r-=33088;else if(57408<=r&&r<=60351)r-=49472;else throw`illegal char at `+(n+1)+`/`+r;r=(r>>>8&255)*192+(r&255),e.put(r,13),n+=2}if(n<t.length)throw`illegal char at `+(n+1)},i},Kl=function(){let e=[],t={};return t.writeByte=function(t){e.push(t&255)},t.writeShort=function(e){t.writeByte(e),t.writeByte(e>>>8)},t.writeBytes=function(e,n,r){n||=0,r||=e.length;for(let i=0;i<r;i+=1)t.writeByte(e[i+n])},t.writeString=function(e){for(let n=0;n<e.length;n+=1)t.writeByte(e.charCodeAt(n))},t.toByteArray=function(){return e},t.toString=function(){let t=``;t+=`[`;for(let n=0;n<e.length;n+=1)n>0&&(t+=`,`),t+=e[n];return t+=`]`,t},t},ql=function(){let e=0,t=0,n=0,r=``,i={},a=function(e){r+=String.fromCharCode(o(e&63))},o=function(e){if(e<0)throw`n:`+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw`n:`+e};return i.writeByte=function(r){for(e=e<<8|r&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){let e=3-n%3;for(let t=0;t<e;t+=1)r+=`=`}},i.toString=function(){return r},i},Jl=function(e){let t=e,n=0,r=0,i=0,a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw`unexpected end of file./`+i}let e=t.charAt(n);if(n+=1,e==`=`)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}let e=r>>>i-8&255;return i-=8,e};let o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw`c:`+e};return a},Yl=function(e,t){let n=e,r=t,i=Array(e*t),a={};a.setPixel=function(e,t,r){i[t*n+e]=r},a.write=function(e){e.writeString(`GIF87a`),e.writeShort(n),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(`,`),e.writeShort(0),e.writeShort(0),e.writeShort(n),e.writeShort(r),e.writeByte(0);let t=s(2);e.writeByte(2);let i=0;for(;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(`;`)};let o=function(e){let t=e,n=0,r=0,i={};return i.write=function(e,i){if(e>>>i)throw`length over`;for(;n+i>=8;)t.writeByte(255&(e<<n|r)),i-=8-n,e>>>=8-n,r=0,n=0;r=e<<n|r,n+=i},i.flush=function(){n>0&&t.writeByte(r)},i},s=function(e){let t=1<<e,n=(1<<e)+1,r=e+1,a=c();for(let e=0;e<t;e+=1)a.add(String.fromCharCode(e));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(n));let s=Kl(),l=o(s);l.write(t,r);let u=0,d=String.fromCharCode(i[u]);for(u+=1;u<i.length;){let e=String.fromCharCode(i[u]);u+=1,a.contains(d+e)?d+=e:(l.write(a.indexOf(d),r),a.size()<4095&&(a.size()==1<<r&&(r+=1),a.add(d+e)),d=e)}return l.write(a.indexOf(d),r),l.write(n,r),l.flush(),s.toByteArray()},c=function(){let e={},t=0,n={};return n.add=function(r){if(n.contains(r))throw`dup key:`+r;e[r]=t,t+=1},n.size=function(){return t},n.indexOf=function(t){return e[t]},n.contains=function(t){return e[t]!==void 0},n};return a},Xl=function(e,t,n){let r=Yl(e,t);for(let i=0;i<t;i+=1)for(let t=0;t<e;t+=1)r.setPixel(t,i,n(t,i));let i=Kl();r.write(i);let a=ql(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};Nl.stringToBytes;function Zl(){let e=navigator.userAgent,t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Mac/.test(e)?`Mac`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:`device`,n=/Edg\//.test(e)?`Edge`:/Firefox\//.test(e)?`Firefox`:/Chrome\//.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n?`${t} · ${n}`:t}function Ql(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(Zl),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=async()=>{a(!0),s(``);let t=await A.request(`devices.pair`,{body:{code:e,name:n}}).catch(()=>null);if(t?.ok)return location.reload();a(!1),s(t?j(t):`could not reach kraftwerk`)};return(0,P.jsxs)(`main`,{className:`mx-auto flex min-h-screen w-full max-w-[420px] flex-col justify-center gap-5 px-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,P.jsx)(F,{name:`phonelink_lock`,className:`text-[32px] text-fg-2`}),(0,P.jsx)(rt,{size:`lg`,children:`Pair this device`}),(0,P.jsxs)(`p`,{className:`m-0 text-sm leading-relaxed text-fg-2`,children:[`This kraftwerk runs on another machine. On that machine, run `,(0,P.jsx)(`code`,{children:`kraftwerk devices pair`}),` or open settings → devices, and enter the code here. You pair once; it stays paired until it is removed there.`]})]}),(0,P.jsxs)(`form`,{className:`flex flex-col gap-3.5`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,P.jsx)(X,{label:`pairing code`,children:(0,P.jsx)(Y,{value:e,onChange:e=>t(e.target.value.toUpperCase()),placeholder:`ABCD-EF23`,autoFocus:!0,autoComplete:`one-time-code`,autoCapitalize:`characters`,"aria-label":`pairing code`,className:`font-mono tracking-widest`})}),(0,P.jsx)(X,{label:`name of this device`,hint:`how it shows in the list of paired devices`,children:(0,P.jsx)(Y,{value:n,onChange:e=>r(e.target.value),"aria-label":`device name`})}),o&&(0,P.jsx)(K,{tone:`bad`,children:o}),(0,P.jsx)(B,{variant:`primary`,type:`submit`,busy:i,disabled:!e.trim(),children:`pair`})]})]})}function $l({children:e}){return O()?(0,P.jsx)(Ql,{}):(0,P.jsx)(P.Fragment,{children:e})}function eu({text:e,size:t=176}){let n=(0,v.useMemo)(()=>{let t=Nl(0,`M`);t.addData(e),t.make();let n=t.getModuleCount(),r=``;for(let e=0;e<n;e++)for(let i=0;i<n;i++)t.isDark(e,i)&&(r+=`M${i+4} ${e+4}h1v1h-1z`);return{d:r,n:n+8}},[e]);return(0,P.jsx)(`svg`,{viewBox:`0 0 ${n.n} ${n.n}`,width:t,height:t,role:`img`,"aria-label":`pairing QR code`,className:`rounded-lg bg-white text-black`,shapeRendering:`crispEdges`,children:(0,P.jsx)(`path`,{d:n.d,fill:`currentColor`})})}function tu({onError:e}){let t=M(`devices.relay`,{},{interval:1e4}),[n,r]=(0,v.useState)(!1);if(!t)return null;let i=async()=>{r(!0);let n=await A.request(`devices.setRelay`,{body:{enabled:!t.enabled}}).catch(()=>null);r(!1),n&&!n.ok&&e(j(n))},a=t.enabled?t.daemon?t.state===`connected`?`connected${t.clients?` · ${t.clients} device${t.clients===1?``:`s`} now`:``}`:t.state===`error`?`not connected: ${t.error??`unknown error`}`:`connecting…`:"on — the daemon connects it (this kraftwerk is not the daemon: `kraftwerk daemon`)":`off — devices reach this machine on your network only`;return(0,P.jsx)(lt,{children:(0,P.jsx)(ct,{icon:t.enabled?`public`:`public_off`,title:`reach this machine from anywhere`,"data-relay":t.enabled?t.state:`off`,action:(0,P.jsx)(B,{size:`sm`,busy:n,variant:t.enabled?void 0:`primary`,onClick:()=>void i(),children:t.enabled?`turn off`:`turn on`}),children:(0,P.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[a,t.enabled&&t.fingerprint&&(0,P.jsxs)(P.Fragment,{children:[` · machine key `,(0,P.jsx)(`code`,{children:t.fingerprint})]}),` — through the kraftwerk relay, end to end encrypted: it cannot read along`]})})})}function nu(){let e=M(`devices.self`,{},{interval:6e4}),t=e?.trust===`local`,n=M(`devices.list`,t?{}:null,{interval:15e3}),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``);if(!e)return null;if(!t)return(0,P.jsx)(q,{title:`devices`,children:(0,P.jsx)(lt,{children:(0,P.jsx)(ct,{icon:`phonelink_lock`,title:`this browser is paired as “${e.device?.name}”`,children:(0,P.jsx)(`span`,{className:`text-xs text-fg-2`,children:`devices are managed on the machine kraftwerk runs on`})})})});let s=async()=>{o(``);let e=await A.request(`devices.code`).catch(()=>null);e?.ok?i(e.data):o(e?j(e):`could not make a code`)},c=async(e,t)=>{if(!window.confirm(`Unpair “${t}”? It loses access at once.`))return;let n=await A.request(`devices.revoke`,{id:e}).catch(()=>null);n&&!n.ok&&o(j(n))};return(0,P.jsxs)(q,{title:`devices`,actions:(0,P.jsx)(B,{size:`sm`,icon:`add_link`,onClick:()=>void s(),children:`pair a device`}),children:[r&&(0,P.jsxs)(yt,{className:`border-b border-line`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-3`,children:[(0,P.jsx)(`span`,{className:`font-mono text-[22px] font-semibold tracking-widest text-fg`,"aria-label":`pairing code`,children:r.code}),(0,P.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`once, until `,new Date(r.expiresAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]})]}),r.remote&&(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,P.jsx)(eu,{text:r.remote}),(0,P.jsxs)(`span`,{className:`max-w-[28ch] text-sm text-fg-2`,children:[`From anywhere: scan this with the phone's camera, or open `,(0,P.jsx)(`a`,{href:r.remote,target:`_blank`,rel:`noreferrer`,children:`the pairing link`}),` on it. It carries the code — treat it like a password.`]})]}),r.urls.length?(0,P.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`On the device, open `,r.urls.map((e,t)=>(0,P.jsxs)(`span`,{children:[t>0&&` or `,(0,P.jsx)(`code`,{children:e})]},e)),` and enter the code.`]}):r.remote?null:(0,P.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`This kraftwerk only listens on this machine. Restart it with `,(0,P.jsx)(`code`,{children:`kraftwerk ui --lan`}),` to reach it from your network (or use a tunnel), then enter the code on the device — or turn on “reach this machine from anywhere”.`]})]}),(0,P.jsx)(tu,{onError:o}),a&&(0,P.jsx)(`div`,{className:`px-[18px] pt-3`,children:(0,P.jsx)(K,{tone:`bad`,children:a})}),n&&n.devices.length===0&&!r&&(0,P.jsx)(G,{icon:`devices`,children:`no paired devices — a phone or another computer can use this kraftwerk once paired`}),n&&n.devices.length>0&&(0,P.jsx)(lt,{children:n.devices.map(e=>(0,P.jsx)(ct,{icon:`devices`,title:e.name,"data-device":e.id,action:(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`link_off`,onClick:()=>void c(e.id,e.name),"aria-label":`unpair ${e.name}`,children:`unpair`}),children:(0,P.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`paired `,Ke(e.createdAt),` · `,e.lastSeenAt?`last seen ${Ke(e.lastSeenAt)}`:`not used yet`]})},e.id))})]})}var ru={enabled:!1,remote:`origin`,branch:``,interval:`300`,autosync:`pull`};function iu(e){let t=e.config.git;return t?{enabled:t.enabled!==!1,remote:t.remote??ru.remote,branch:t.branch??``,interval:String(t.interval??ru.interval),autosync:t.autosync??ru.autosync}:ru}var au={enabled:!1,root:``};function ou(e){let t=e.config.repos;return t?{enabled:t.enabled!==!1,root:t.root??``}:au}function su(e){let t=e.config.vibeables;return t?{enabled:t.enabled!==!1,root:t.root??``}:au}function cu(e){let t=e.config.projects;return t?{enabled:t.enabled!==!1,root:t.root??``}:au}function lu(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(!1);if((0,v.useEffect)(()=>{let e=!0,n=()=>A.call(`meta.get`).then(n=>e&&n.cloud&&t(n.cloud)).catch(()=>{});n();let r=setInterval(n,1e4);return()=>{e=!1,clearInterval(r)}},[]),(0,v.useEffect)(()=>{if(!i)return;if(e?.account)return void a(!1);let n=setInterval(()=>{A.call(`cloud.sync`).then(e=>{t(t=>t&&{...t,...e}),e.account&&a(!1)}).catch(()=>{})},2e3),r=setTimeout(()=>a(!1),6e5);return()=>{clearInterval(n),clearTimeout(r)}},[i,e?.account]),!e)return null;let o=e.state===`connected`?e.account?`claimed`:`unclaimed`:e.state,s=e.state===`connected`&&e.account?`ok`:e.state===`error`?`bad`:`neutral`;return(0,P.jsx)(q,{title:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`cloud `,(0,P.jsx)(U,{tone:s,children:o})]}),actions:e.url&&(0,P.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,P.jsx)(F,{name:`cloud`,className:`ms-sm`}),` open the cloud`]}),children:(0,P.jsxs)(yt,{children:[e.state===`off`&&(0,P.jsxs)(W,{children:[`Off — `,e.reason??`turned off for this machine`,`. The daemon registers the machine with the kraftwerk cloud, so its owner sees its workspaces running from anywhere; `,(0,P.jsx)(`code`,{children:`kraftwerk cloud on`}),` and `,(0,P.jsx)(`code`,{children:`kraftwerk login`}),` in a terminal turn it on and claim it.`]}),e.state===`connecting`&&(0,P.jsxs)(W,{children:[`Registering with `,e.url,` …`]}),e.state===`error`&&(0,P.jsxs)(W,{children:[`Could not reach `,e.url,`: `,e.error,`. Retrying every `,e.interval??60,`s — the UI works as before meanwhile.`]}),e.state===`connected`&&e.account&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(W,{children:[`This machine`,e.machine?(0,P.jsxs)(P.Fragment,{children:[` (`,(0,P.jsx)(`code`,{children:e.machine}),`)`]}):null,` is registered at `,(0,P.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),` under `,(0,P.jsx)(`strong`,{children:e.account}),`. Last heartbeat `,e.lastSeen?new Date(e.lastSeen).toLocaleTimeString():`pending`,`.`]}),(0,P.jsx)(`div`,{children:(0,P.jsx)(B,{size:`sm`,variant:`secondary`,icon:`logout`,onClick:()=>{confirm(`Sign this machine out of ${e.account}? It stays registered, unclaimed, and sends no folder paths until claimed again.`)&&A.call(`cloud.unlink`).then(e=>t(t=>t&&{...t,...e,account:null})).catch(()=>{})},children:`sign out`})})]}),e.state===`connected`&&!e.account&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(W,{children:[`This machine is registered at `,(0,P.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),`, not yet under an account (no folder paths are sent until it is). Sign in there and enter this code — or open the link, or run `,(0,P.jsx)(`code`,{children:`kraftwerk login`}),`:`]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,P.jsx)(`code`,{className:`rounded-control border border-line bg-surface-2 px-3 py-1.5 font-mono text-lg tracking-[0.12em] text-fg`,children:e.claimCode??`…`}),e.claimCode&&(0,P.jsx)(B,{size:`sm`,icon:`content_copy`,onClick:()=>{navigator.clipboard.writeText(e.claimCode),r(!0),setTimeout(()=>r(!1),1500)},children:n?`copied`:`copy`}),e.claimUrl&&(0,P.jsxs)(`a`,{className:Qe(`primary`,`sm`),href:e.claimUrl,target:`_blank`,rel:`noreferrer`,onClick:()=>a(!0),children:[(0,P.jsx)(F,{name:`link`,className:`ms-sm`}),` sign in & claim`]}),i&&(0,P.jsx)(`span`,{className:`text-fg-dim text-sm`,children:`waiting for the claim …`})]}),(0,P.jsxs)(W,{children:[`A claim made there reaches this machine with the next heartbeat (every `,e.interval??60,`s). To keep this workspace out of the cloud, set `,(0,P.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]}),e.state!==`off`&&e.included===!1&&(0,P.jsxs)(W,{children:[`This workspace is left out of the machine's record: `,(0,P.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]})})}function uu(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)(ru),[f,p]=(0,v.useState)(au),[m,h]=(0,v.useState)(au),[g,_]=(0,v.useState)(au),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(``),D=M(`identity.get`,{},{interval:6e4});(0,v.useEffect)(()=>{A.call(`settings.get`).then(e=>{t(e),r(e.config.name??``),a(e.config.icon??``),s(e.config.color??``),l(e.config.switcher??[]),d(iu(e)),p(ou(e)),h(su(e)),_(cu(e))}).catch(()=>E(`could not load settings`))},[]);let O=()=>{b(!0),w(!1),E(``)};async function k(){S(!0),E(``);try{let e=await A.request(`settings.save`,{body:{name:n,icon:i,color:o,switcher:c,git:{...u,interval:u.interval===``?void 0:Number(u.interval)},repos:f,vibeables:m,projects:g}});if(!e.ok)throw Error(e.error||`save failed`);let r=e.data;t(r),l(r.config.switcher??[]),d(iu(r)),p(ou(r)),h(su(r)),_(cu(r)),b(!1),w(!0)}catch(e){E(e.message)}finally{S(!1)}}let ee=(e,t)=>{l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),O()},te=e=>{d(t=>({...t,...e})),O()},j=e=>{p(t=>({...t,...e})),O()},N=e=>{h(t=>({...t,...e})),O()},ne=e=>{_(t=>({...t,...e})),O()};if(!e)return(0,P.jsx)(G,{children:T||`loading…`});let re=[[`identity`,D?.identity??`…`,`this machine — the runner routines name in runs_on (kraftwerk whoami to rename)`],[`port`,String(e.resolved.port),`kraftwerk ui listens here (CLI --port wins)`],[`workflows`,e.resolved.workflowsRoot??`— none found`,`workflow definitions`],[`output`,e.resolved.outputDir,`run artifacts`],[`knowledge`,e.config.knowledge??`knowledge`,`OKF knowledge bundles`],[`agents`,e.config.agents??`agents`,`agent definitions`],[`skills`,e.config.skills??`skills`,`workspace skills`]];return(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[860px] flex-col gap-4`,children:[(0,P.jsx)(it,{icon:(0,P.jsx)(F,{name:`settings`,className:`text-[28px] text-fg-2`}),title:`Settings`,actions:(0,P.jsxs)(P.Fragment,{children:[T&&(0,P.jsx)(K,{tone:`bad`,children:T}),C&&!y&&(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12.5px] text-ok`,children:[(0,P.jsx)(F,{name:`check`,className:`ms-sm`}),` saved`]}),(0,P.jsx)(B,{variant:`primary`,busy:x,disabled:!y,onClick:()=>void k(),children:x?`saving…`:`save changes`})]})}),(0,P.jsx)(q,{title:`workspace`,children:(0,P.jsxs)(yt,{children:[(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`icon`,className:`w-[90px]`,children:(0,P.jsx)(Y,{value:i,placeholder:`🤖`,onChange:e=>{a(e.target.value),O()}})}),(0,P.jsx)(X,{label:`name`,className:`min-w-40 flex-1`,children:(0,P.jsx)(Y,{value:n,placeholder:`my workspace`,onChange:e=>{r(e.target.value),O()}})}),(0,P.jsxs)(`label`,{className:`flex w-[130px] flex-col gap-1.5`,title:`Accent in the workspace switcher; empty = derived from the folder`,children:[(0,P.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:`color`}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`input`,{type:`color`,"aria-label":`pick a color`,className:`h-9 w-10 flex-none cursor-pointer rounded-control border border-line bg-surface p-0.5`,value:/^#[0-9a-f]{6}$/i.test(o)?o:`#888888`,onChange:e=>{s(e.target.value),O()}}),(0,P.jsx)(Y,{className:`min-w-0 px-2`,value:o,placeholder:`auto`,onChange:e=>{s(e.target.value),O()}})]})]})]}),(0,P.jsx)(W,{children:`Shown in the header, browser tab and to other workspaces discovering this one.`})]})}),(0,P.jsx)(q,{title:`workspace switcher`,actions:(0,P.jsx)(B,{size:`sm`,icon:`add`,onClick:()=>{l(e=>[...e,{name:``,url:`http://localhost:`}]),O()},children:`add entry`}),children:(0,P.jsxs)(yt,{children:[c.length===0&&(0,P.jsx)(W,{children:`No manual entries.`}),c.map((e,t)=>(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`icon`,className:`w-[70px]`,children:(0,P.jsx)(Y,{value:e.icon??``,placeholder:`•`,onChange:e=>ee(t,{icon:e.target.value})})}),(0,P.jsx)(X,{label:`name`,className:`min-w-32 flex-1`,children:(0,P.jsx)(Y,{value:e.name,placeholder:`other workspace`,onChange:e=>ee(t,{name:e.target.value})})}),(0,P.jsx)(X,{label:`url`,className:`min-w-40 flex-[1.4]`,children:(0,P.jsx)(Y,{value:e.url,placeholder:`http://localhost:1982`,onChange:e=>ee(t,{url:e.target.value})})}),(0,P.jsx)(V,{icon:`close`,label:`remove entry`,className:`mb-0.5`,onClick:()=>{l(e=>e.filter((e,n)=>n!==t)),O()}})]},t)),(0,P.jsx)(W,{children:`Running workspaces on this machine are discovered automatically — manual entries are for remote instances or extra links.`})]})}),(0,P.jsx)(q,{title:`git sync`,actions:(0,P.jsx)(B,{size:`sm`,icon:`account_tree`,href:`/git`,children:`open git`}),children:(0,P.jsxs)(yt,{children:[(0,P.jsx)(xt,{checked:u.enabled,onChange:e=>te({enabled:e}),children:`sync workflows, knowledge, agents and skills with a git remote`}),u.enabled&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(bt,{children:[(0,P.jsx)(X,{label:`remote`,className:`min-w-32 flex-1`,children:(0,P.jsx)(Y,{value:u.remote,placeholder:`origin`,onChange:e=>te({remote:e.target.value})})}),(0,P.jsx)(X,{label:`branch`,className:`min-w-32 flex-1`,children:(0,P.jsx)(Y,{value:u.branch,placeholder:`checked-out branch`,onChange:e=>te({branch:e.target.value})})}),(0,P.jsx)(X,{label:`interval (s)`,className:`w-[120px]`,children:(0,P.jsx)(Y,{type:`number`,min:0,step:1,value:u.interval,placeholder:`300`,onChange:e=>te({interval:e.target.value})})}),(0,P.jsx)(X,{label:`autosync`,className:`w-[150px]`,children:(0,P.jsxs)(vt,{value:u.autosync,onChange:e=>te({autosync:e.target.value}),children:[(0,P.jsx)(`option`,{value:`pull`,children:`fetch and pull`}),(0,P.jsx)(`option`,{value:`off`,children:`fetch only`})]})})]}),(0,P.jsx)(W,{children:`The interval fetches in the background (0 turns the timer off); with autosync on it also fast-forwards when behind and nothing is modified locally. Commit and push stay manual on the git screen.`})]})]})}),(0,P.jsx)(q,{title:`repositories`,actions:(0,P.jsx)(B,{size:`sm`,icon:`source`,href:`/repos`,children:`open repositories`}),children:(0,P.jsxs)(yt,{children:[(0,P.jsx)(xt,{checked:f.enabled,onChange:e=>j({enabled:e}),children:`keep git repositories the agents work on under one folder`}),f.enabled&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(X,{label:`repos root`,children:(0,P.jsx)(Y,{value:f.root,placeholder:`repos`,onChange:e=>j({root:e.target.value})})}),(0,P.jsxs)(W,{children:[`Relative to the project root. Saving creates the folder and adds it to .gitignore; every agent gets the list of clones as context and can add more with `,(0,P.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})]})}),(0,P.jsx)(q,{title:`apps (vibeables)`,actions:(0,P.jsx)(B,{size:`sm`,icon:`web`,href:`/vibeables`,children:`open apps`}),children:(0,P.jsxs)(yt,{children:[(0,P.jsx)(xt,{checked:m.enabled,onChange:e=>N({enabled:e}),children:`build small apps live in a chat, with a preview pane next to the thread`}),m.enabled&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(X,{label:`vibeables root`,children:(0,P.jsx)(Y,{value:m.root,placeholder:`kraftwerk-data/vibeables`,onChange:e=>N({root:e.target.value})})}),(0,P.jsxs)(W,{children:[`Relative to the project root, one folder per app. Part of the workspace: versioned with it on the git screen, not git-ignored. Every chat gets a `,(0,P.jsx)(`b`,{children:`vibeable`}),` button; the agent then works inside the app folder.`]})]})]})}),(0,P.jsx)(q,{title:`projects`,actions:(0,P.jsx)(B,{size:`sm`,icon:`folder_special`,href:`/projects`,children:`open projects`}),children:(0,P.jsxs)(yt,{children:[(0,P.jsx)(xt,{checked:g.enabled,onChange:e=>ne({enabled:e}),children:`gather a goal, its brief, systems of record and links in one folder, and chat inside it`}),g.enabled&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(X,{label:`projects root`,children:(0,P.jsx)(Y,{value:g.root,placeholder:`kraftwerk-data/projects`,onChange:e=>ne({root:e.target.value})})}),(0,P.jsx)(W,{children:`Relative to the project root, one folder per project (project.yml, brief.md, state.md, log.md). Part of the workspace: versioned with it on the git screen. A chat opened in a project starts with all of it as context.`})]})]})}),(0,P.jsx)(lu,{}),(0,P.jsx)(nu,{}),(0,P.jsxs)(q,{title:`paths & port`,actions:(0,P.jsx)(`code`,{className:`max-w-[60%] truncate text-2xs text-fg-2`,title:e.configPath,children:e.exists?e.configPath:`${e.configPath} (not created yet)`}),children:[(0,P.jsx)(`div`,{className:`flex flex-col pt-1.5 pb-2.5`,children:re.map(([e,t,n])=>(0,P.jsxs)(`div`,{className:`grid grid-cols-[110px_1fr] items-baseline gap-x-3.5 gap-y-px border-line/55 px-[18px] py-2 [&+&]:border-t`,children:[(0,P.jsx)(tt,{children:e}),(0,P.jsx)(`code`,{className:`text-xs break-all`,children:t}),(0,P.jsx)(`span`,{className:`col-start-2 text-2xs text-fg-2`,children:n})]},e))}),(0,P.jsxs)(W,{className:`px-[18px] pb-3.5`,children:[`Read-only here — edit `,(0,P.jsx)(`code`,{children:`kraftwerk.yml`}),` directly to change these.`]})]})]})}var du={agents:{label:`agents`,icon:`smart_toy`},"agent-skills":{label:`agent skills`,icon:`extension`},projects:{label:`projects`,icon:`folder`},workflows:{label:`workflows`,icon:`account_tree`},knowledge:{label:`knowledge bundles`,icon:`menu_book`},vibeables:{label:`apps`,icon:`web`},channels:{label:`channels`,icon:`forum`},repos:{label:`repositories`,icon:`source`},chats:{label:`chats`,icon:`chat`},runs:{label:`runs`,icon:`play_circle`}};function fu(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=(0,v.useCallback)(async()=>{let e=await A.request(`trash.list`).catch(()=>null);e?.ok?t(e.data):r(e?.status===404?`this server has no trash yet — restart it after updating`:`could not load the trash`)},[]);(0,v.useEffect)(()=>{c()},[c]);let l=async(e,t)=>{a(t),r(``),s(null);try{let n=e===`empty`?(await A.request(`trash.empty`)).error:j(await A.request(`trash.${e}`,{body:{id:t}}));if(n)throw Error(n)}catch(e){r(e.message)}finally{a(null),c()}},u=e?.entries??[],d=[...new Set(u.map(e=>e.kind))].sort((e,t)=>Object.keys(du).indexOf(e)-Object.keys(du).indexOf(t));return(0,P.jsxs)(at,{className:`px-6 py-6`,children:[(0,P.jsx)(it,{icon:(0,P.jsx)(F,{name:`delete`,className:`text-[28px] text-fg-2`}),title:`Trash`,sub:e?`${u.length} item${u.length===1?``:`s`}`:void 0,actions:u.length>0&&(o===`*`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(B,{variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`empty`,`*`),children:[`delete all `,u.length,` for good`]}),(0,P.jsx)(B,{variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,P.jsx)(B,{variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(`*`),children:`empty trash`}))}),n&&(0,P.jsx)(K,{tone:`bad`,children:n}),!e&&!n&&(0,P.jsx)(q,{children:(0,P.jsx)(G,{children:`loading…`})}),e&&u.length===0&&(0,P.jsx)(q,{children:(0,P.jsx)(G,{icon:`delete`,children:`The trash is empty. What you delete lands here first.`})}),d.map(e=>(0,P.jsx)(q,{title:du[e]?.label??e,actions:(0,P.jsxs)(`code`,{className:`text-xs text-fg-2`,children:[`trash/`,e,`/`]}),children:(0,P.jsx)(`div`,{className:`p-1.5`,children:u.filter(t=>t.kind===e).map(t=>(0,P.jsx)(J,{className:`trash-row`,leading:(0,P.jsx)(F,{name:du[e]?.icon??`draft`,className:`ms-sm`}),title:t.name,sub:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`font-mono`,children:t.from}),` · `,(0,P.jsxs)(`span`,{title:t.trashedAt,children:[`deleted `,Ke(t.trashedAt)]})]}),meta:(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(B,{size:`sm`,variant:`secondary`,icon:`restore_from_trash`,busy:i===t.id,disabled:!!i,onClick:()=>void l(`restore`,t.id),title:`Put it back at ${t.from}`,children:`restore`}),o===t.id?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`purge`,t.id),children:`delete for good`}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(t.id),children:`delete`})]})},t.id))})},e)),e&&(0,P.jsxs)(`p`,{className:`m-0 text-sm text-fg-2`,children:[`The trash lives in `,(0,P.jsx)(`code`,{children:e.root}),`, kept out of the workspace git. From the terminal:`,` `,(0,P.jsx)(`code`,{children:`kraftwerk trash`}),`, `,(0,P.jsx)(`code`,{children:`kraftwerk trash restore <id>`}),`, `,(0,P.jsx)(`code`,{children:`kraftwerk trash empty`}),`.`]})]})}var pu=(e,t,n=!1)=>A.url(`files.raw`,{query:{scope:e,path:t,download:n}}),mu=(e,t=``,n)=>`/files/${encodeURIComponent(e)}${t?`/${t.split(`/`).map(encodeURIComponent).join(`/`)}`:``}${n?`?file=${encodeURIComponent(n)}`:``}`,hu=`inline-grid size-7 shrink-0 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,gu=`whitespace-nowrap border-b border-line px-2.5 py-1.5 text-left`;function _u({here:e,onClick:t,children:n}){return(0,P.jsx)(`button`,{type:`button`,onClick:t,className:N(`cursor-pointer rounded-md border-0 bg-transparent px-1 py-0.5 font-[inherit] hover:bg-surface-2 hover:text-fg`,e?`font-semibold text-fg`:`text-fg-2`),children:n})}function vu(e){if(e.type===`dir`)return`folder`;let t=e.mime??``;return t.startsWith(`image/`)?`image`:t===`application/pdf`?`picture_as_pdf`:t.startsWith(`video/`)?`movie`:t.startsWith(`audio/`)?`music_note`:/csv|tab-separated|spreadsheet/.test(t)?`table`:/zip/.test(t)?`folder_zip`:/presentation/.test(t)?`slideshow`:t.startsWith(`text/`)||/json|yaml|xml|wordprocessing/.test(t)?`description`:`draft`}function yu({scope:e,dir:t,file:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(0);(0,v.useEffect)(()=>{A.call(`files.scopes`).then(e=>i(e.scopes),()=>i([]))},[a]);let s=(r??[]).filter(e=>e.scope!==`workspace`);return(0,P.jsxs)(`div`,{className:`runs-screen files-screen`,children:[(0,P.jsxs)(`aside`,{className:`runs-side`,children:[(0,P.jsx)(Tt,{title:`files`}),(0,P.jsxs)(Dt,{children:[(r??[]).filter(e=>e.scope===`workspace`).map(t=>(0,P.jsx)(bu,{s:t,active:e===t.scope,icon:`home_storage`},t.scope)),s.length>0&&(0,P.jsx)(Tt,{title:`projects`,divided:!0}),s.map(t=>(0,P.jsx)(bu,{s:t,active:e===t.scope,icon:`folder_special`},t.scope))]})]}),(0,P.jsx)(`div`,{className:`runs-main min-w-0`,children:(0,P.jsx)(xu,{scope:e,dir:t,file:n,onOpen:(t,n)=>z(mu(e,t,n)),onChanged:()=>o(e=>e+1)},e)})]})}function bu({s:e,active:t,icon:n}){return(0,P.jsx)(J,{href:mu(e.scope),active:t,size:`sm`,leading:(0,P.jsx)(F,{name:n,className:`ms-sm`}),title:e.label,sub:(0,P.jsxs)(`span`,{className:`font-mono`,children:[e.root,`/`]}),meta:e.count})}function xu({scope:e,dir:t,file:n,onOpen:r,onChanged:i,compact:a=!1}){let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),x=(0,v.useRef)(null),S=(0,v.useCallback)(async()=>{let n=await A.request(`files.list`,{query:{scope:e,path:t}}).catch(()=>null);if(!n?.ok||!n.data||typeof n.data!=`object`){l(n?.error??`could not load the folder`),s(null);return}l(``),s(n.data)},[e,t]);(0,v.useEffect)(()=>{S();let e=setInterval(()=>void S(),1e4);return()=>clearInterval(e)},[S]);let C=async()=>{await S(),i?.()};async function w(n){let r=[...n];if(r.length){l(``);for(let[n,i]of r.entries()){d(r.length>1?`uploading ${n+1} of ${r.length}…`:`uploading ${i.name}…`);let a=await A.request(`files.upload`,{query:{scope:e,path:t},headers:{"x-file-name":encodeURIComponent(i.name),"content-type":i.type||`application/octet-stream`},body:i}).catch(()=>null);a?.ok||l(a?.error??`could not upload ${i.name}`)}d(``),await C()}}async function T(n){let r=n.trim();if(h(null),!r)return;let i=j(await A.request(`files.mkdir`,{body:{scope:e,path:t?`${t}/${r}`:r}}));i&&l(i),await C()}async function E(i,a){_(null);let o=a.trim();if(!o||o===i.split(`/`).pop())return;let s=i.includes(`/`)?`${i.slice(0,i.lastIndexOf(`/`))}/${o}`:o,c=j(await A.request(`files.move`,{body:{scope:e,from:i,to:s}}));c?l(c):n===i&&r(t,s),await C()}async function D(i){b(null);let a=await A.request(`files.delete`,{query:{scope:e,path:i}}).catch(()=>null);a?.ok||l(a?.error??`could not delete`),n===i&&r(t),await C()}let O=t?t.split(`/`):[],k=n?o?.entries.find(e=>e.path===n):void 0,ee=!(a&&n);return(0,P.jsxs)(`div`,{className:N(`files-browser h-full min-h-0`,a?`flex flex-col gap-2 px-1.5 py-1`:N(`grid gap-4`,n?`grid-cols-1 min-[900px]:grid-cols-[minmax(280px,1fr)_minmax(0,1.3fr)]`:`grid-cols-1`)),children:[ee&&(0,P.jsxs)(`div`,{className:N(`flex min-h-0 flex-col rounded-card outline-2 -outline-offset-2 outline-dashed transition-colors`,f?`bg-accent/5 outline-accent`:`outline-transparent`),onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),p(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||p(!1)},onDrop:e=>{e.preventDefault(),p(!1),w(e.dataTransfer.files)},children:[(0,P.jsxs)(`div`,{className:N(`flex items-center gap-1`,a?`px-1 pb-1.5 pt-0.5`:`px-0.5 pb-2.5 pt-1`),children:[(0,P.jsxs)(`nav`,{className:N(`flex min-w-0 flex-wrap items-center`,a?`text-sm`:`text-md`),"aria-label":`Folder`,children:[(0,P.jsx)(_u,{here:!O.length,onClick:()=>r(``),children:o?.label??(e===`workspace`?`Workspace`:e.replace(/^project:/,``))}),O.map((e,t)=>(0,P.jsxs)(`span`,{className:`inline-flex items-center text-fg-2`,children:[(0,P.jsx)(F,{name:`chevron_right`,className:`ms-sm`}),(0,P.jsx)(_u,{here:t===O.length-1,onClick:()=>r(O.slice(0,t+1).join(`/`)),children:e})]},t))]}),(0,P.jsx)(`span`,{className:`flex-1`}),a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(V,{icon:`create_new_folder`,label:`New folder`,size:`sm`,onClick:()=>h(``)}),(0,P.jsx)(V,{icon:`upload`,label:`Upload files`,size:`sm`,onClick:()=>x.current?.click()})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{variant:`quiet`,size:`sm`,icon:`create_new_folder`,onClick:()=>h(``),title:`New folder`,children:`folder`}),(0,P.jsx)(B,{variant:`quiet`,size:`sm`,icon:`upload`,onClick:()=>x.current?.click(),title:`Upload files`,children:`upload`})]}),(0,P.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`Upload files`,onChange:e=>e.target.files&&void w(e.target.files)})]}),u&&(0,P.jsx)(K,{children:u}),c&&(0,P.jsx)(K,{tone:`bad`,children:c}),(0,P.jsxs)(`div`,{className:`files-list flex min-h-0 flex-1 flex-col gap-px overflow-y-auto`,role:`list`,children:[m!==null&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,P.jsx)(F,{name:`create_new_folder`,className:`text-[20px] text-fg-2`}),(0,P.jsx)(Y,{className:`h-8`,autoFocus:!0,value:m,placeholder:`folder name`,"aria-label":`Folder name`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(m),e.key===`Escape`&&h(null)},onBlur:()=>void T(m)})]}),o?.entries.map(i=>g?.path===i.path?(0,P.jsxs)(`div`,{role:`listitem`,className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,P.jsx)(F,{name:vu(i),className:`text-[20px] text-fg-2`}),(0,P.jsx)(Y,{className:`h-8`,autoFocus:!0,value:g.name,"aria-label":`New name`,onChange:e=>_({path:i.path,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&E(i.path,g.name),e.key===`Escape`&&_(null)},onBlur:()=>void E(i.path,g.name)})]},i.path):(0,P.jsx)(`div`,{role:`listitem`,children:(0,P.jsx)(J,{className:`files-row`,active:i.path===n,onClick:()=>i.type===`dir`?r(i.path):r(t,i.path),label:i.name,leading:(0,P.jsx)(F,{name:vu(i),className:`text-[20px] text-fg-2`}),title:(0,P.jsx)(`span`,{className:`font-normal`,children:i.name}),titleExtra:i.local?(0,P.jsx)(`span`,{className:`text-xs font-normal text-fg-2`,title:`Over 25 MB: kept out of git, stays on this machine`,children:`local only`}):void 0,meta:(0,P.jsxs)(P.Fragment,{children:[i.type===`dir`?`${i.count??0} file${i.count===1?``:`s`}`:We(i.size??0),!a&&` · ${Ke(i.modifiedAt)}`]}),actions:(0,P.jsxs)(P.Fragment,{children:[i.type===`file`&&(0,P.jsx)(`a`,{className:`inline-grid size-7 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,href:pu(e,i.path,!0),title:`Download`,"aria-label":`Download ${i.name}`,children:(0,P.jsx)(F,{name:`download`,className:`ms-sm`})}),(0,P.jsx)(V,{icon:`edit`,size:`sm`,label:`Rename ${i.name}`,onClick:()=>_({path:i.path,name:i.name})}),y===i.path?(0,P.jsx)(B,{variant:`danger`,size:`sm`,autoFocus:!0,onClick:()=>void D(i.path),onBlur:()=>b(null),children:`move to trash`}):(0,P.jsx)(V,{icon:`delete`,size:`sm`,label:`Delete ${i.name}`,onClick:()=>b(i.path)})]})})},i.path)),o&&o.entries.length===0&&m===null&&(0,P.jsxs)(G,{icon:`upload_file`,action:(0,P.jsxs)(`span`,{className:`font-mono text-2xs opacity-80`,children:[o.root,`/`,t?`${t}/`:``]}),children:[`Drop files here, or`,` `,(0,P.jsx)(`button`,{type:`button`,className:`cursor-pointer border-0 bg-transparent p-0 font-[inherit] text-accent underline`,onClick:()=>x.current?.click(),children:`choose some`}),`.`]}),!o&&!c&&(0,P.jsx)(G,{children:`loading…`})]})]}),n&&(0,P.jsx)(Su,{scope:e,path:n,entry:k,onClose:()=>r(t),compact:a})]})}function Su({scope:e,path:t,entry:n,onClose:r,compact:i}){let a=n?.mime??``,o=t.split(`/`).pop()??t,s=pu(e,t),c=/^text\/|json|yaml|xml/.test(a)&&!/html/.test(a),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(u(null),!c||(n?.size??0)>2e6)return;let e=!0;return fetch(s,{cache:`no-store`}).then(e=>e.text()).then(t=>e&&u(t)).catch(()=>{}),()=>{e=!1}},[s,c,n?.size]);let d;return d=n?a.startsWith(`image/`)?(0,P.jsx)(`img`,{className:`m-auto max-h-full max-w-full flex-none object-contain p-4`,src:s,alt:o}):a===`application/pdf`?(0,P.jsx)(`iframe`,{className:N(`w-full border-0 bg-white`,i?`min-h-[60vh]`:`min-h-[70vh]`),src:s,title:o}):a.startsWith(`video/`)?(0,P.jsx)(`video`,{className:`m-auto max-h-full w-full p-4`,src:s,controls:!0}):a.startsWith(`audio/`)?(0,P.jsx)(`audio`,{className:`m-auto w-full p-4`,src:s,controls:!0}):c&&l!==null?/markdown/.test(a)?(0,P.jsx)(`div`,{className:`md-body files-md px-5 py-4`,dangerouslySetInnerHTML:{__html:pa.sanitize(Q.parse(l,{async:!1}))}}):/csv|tab-separated/.test(a)?(0,P.jsx)(Cu,{text:l,tab:/tab-separated/.test(a)}):(0,P.jsx)(`pre`,{className:`files-text m-0 whitespace-pre-wrap p-4 font-mono text-[12.5px] leading-relaxed [overflow-wrap:anywhere]`,children:l}):c&&(n.size??0)<=2e6?(0,P.jsx)(G,{children:`loading…`}):(0,P.jsx)(G,{icon:vu(n),action:(0,P.jsx)(B,{variant:`primary`,size:`sm`,icon:`download`,href:void 0,onClick:()=>window.location.href=pu(e,t,!0),children:`download`}),children:`No preview for this kind of file.`}):(0,P.jsx)(G,{children:`loading…`}),(0,P.jsxs)(`section`,{className:N(`files-preview flex min-h-0 flex-col overflow-hidden rounded-card border border-line bg-surface`,i&&`min-h-[60vh]`),"aria-label":`Preview of ${o}`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-3 py-2`,children:[i&&(0,P.jsx)(V,{icon:`arrow_back`,label:`Back to the folder`,size:`sm`,onClick:r}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold`,title:t,children:o}),n?.size!==void 0&&(0,P.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-2`,children:We(n.size)}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsx)(`a`,{className:hu,href:s,target:`_blank`,rel:`noopener`,title:`Open in a new tab`,"aria-label":`Open in a new tab`,children:(0,P.jsx)(F,{name:`open_in_new`,className:`ms-sm`})}),(0,P.jsx)(`a`,{className:hu,href:pu(e,t,!0),title:`Download`,"aria-label":`Download`,children:(0,P.jsx)(F,{name:`download`,className:`ms-sm`})}),!i&&(0,P.jsx)(V,{icon:`close`,label:`Close the preview`,size:`sm`,onClick:r})]}),(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-auto [&>*]:flex-1`,children:d})]})}function Cu({text:e,tab:t}){let n=t?` `:e.split(`
223
223
  `)[0].includes(`;`)&&!e.split(`
224
224
  `)[0].includes(`,`)?`;`:`,`,r=[];for(let t of e.split(/\r?\n/).slice(0,501)){if(!t)continue;let e=[],i=``,a=!1;for(let r=0;r<t.length;r++){let o=t[r];a&&o===`"`&&t[r+1]===`"`?(i+=`"`,r++):o===`"`?a=!a:o===n&&!a?(e.push(i),i=``):i+=o}e.push(i),r.push(e)}let[i,...a]=r;return(0,P.jsx)(`div`,{className:`overflow-auto`,children:(0,P.jsxs)(`table`,{className:`border-collapse text-[12.5px]`,children:[i&&(0,P.jsx)(`thead`,{children:(0,P.jsx)(`tr`,{children:i.map((e,t)=>(0,P.jsx)(`th`,{className:N(gu,`sticky top-0 bg-surface font-semibold`),children:e},t))})}),(0,P.jsx)(`tbody`,{children:a.map((e,t)=>(0,P.jsx)(`tr`,{children:e.map((e,t)=>(0,P.jsx)(`td`,{className:gu,children:e},t))},t))})]})})}function wu(){let[e,t]=(0,v.useState)(`overview`),[n,r]=(0,v.useState)(!0);return(0,P.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4 p-6`,children:[(0,P.jsx)(it,{title:`Components`,sub:`src/ui — what every screen is built from`,actions:(0,P.jsx)(B,{variant:`primary`,icon:`add`,children:`primary`})}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(q,{title:`Buttons`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 p-4`,children:[(0,P.jsx)(B,{variant:`primary`,icon:`play_arrow`,children:`Run`}),(0,P.jsx)(B,{variant:`secondary`,icon:`upload`,children:`Upload`}),(0,P.jsx)(B,{variant:`quiet`,icon:`create_new_folder`,children:`Folder`}),(0,P.jsx)(B,{variant:`danger`,icon:`delete`,children:`Move to trash`}),(0,P.jsx)(B,{variant:`primary`,busy:!0,children:`Saving`}),(0,P.jsx)(B,{variant:`secondary`,disabled:!0,children:`Disabled`})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 pb-4`,children:[(0,P.jsx)(B,{size:`sm`,variant:`primary`,children:`small`}),(0,P.jsx)(B,{size:`sm`,variant:`secondary`,children:`small`}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,children:`small`}),(0,P.jsx)(V,{icon:`edit`,label:`Rename`}),(0,P.jsx)(V,{icon:`download`,label:`Download`}),(0,P.jsx)(V,{icon:`delete`,label:`Delete`,variant:`danger`}),(0,P.jsx)(V,{icon:`close`,label:`Close`,size:`sm`})]})]}),(0,P.jsxs)(q,{title:`Status`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,P.jsx)($e,{n:3}),` `,(0,P.jsx)($e,{n:12,tone:`neutral`}),(0,P.jsx)(H,{tone:`ok`}),` `,(0,P.jsx)(H,{tone:`bad`}),` `,(0,P.jsx)(H,{tone:`ask`}),` `,(0,P.jsx)(H,{tone:`live`}),` `,(0,P.jsx)(H,{tone:`working`}),` `,(0,P.jsx)(H,{tone:`idle`}),(0,P.jsx)(U,{children:`static`}),` `,(0,P.jsx)(U,{tone:`ok`,children:`done`}),` `,(0,P.jsx)(U,{tone:`bad`,children:`failed`}),` `,(0,P.jsx)(U,{tone:`ask`,children:`needs approval`}),` `,(0,P.jsx)(U,{tone:`accent`,children:`running`})]}),(0,P.jsx)(K,{tone:`bad`,children:`Could not upload brief.pdf`}),(0,P.jsx)(K,{children:`uploading 2 of 3…`})]}),(0,P.jsx)(q,{title:`Rows`,count:1,actions:(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`arrow_forward`,children:`all`}),children:(0,P.jsxs)(`div`,{className:`p-1.5`,children:[(0,P.jsx)(J,{leading:`🐻`,title:`Max`,sub:`waiting for you · Set up the build`,subTone:`bad`,titleExtra:(0,P.jsx)($e,{n:1}),href:`/ui`}),(0,P.jsx)(J,{leading:`🦊`,title:`Lisa`,sub:`last active 2h ago`,href:`/ui`,active:!0}),(0,P.jsx)(J,{leading:(0,P.jsx)(`span`,{className:`ms material-symbols-rounded ms-sm`,children:`folder`}),title:`briefing`,meta:`3 files`,onClick:()=>{},actions:(0,P.jsx)(V,{icon:`edit`,label:`Rename`,size:`sm`})}),(0,P.jsx)(J,{leading:(0,P.jsx)(H,{tone:`working`}),title:`website-check`,sub:`https://netnode.ch`,meta:`running`,size:`sm`}),(0,P.jsx)(J,{leading:`📁`,title:`Gone project`,sub:`not in this workspace`,dim:!0})]})}),(0,P.jsxs)(q,{title:`Tabs and sections`,children:[(0,P.jsx)(pt,{items:[{id:`overview`,label:`overview`},{id:`files`,label:`files`,count:4},{id:`knowledge`,label:`knowledge`,count:0}],value:e,onChange:t}),(0,P.jsxs)(`div`,{className:`p-2`,children:[(0,P.jsx)(nt,{size:`lg`,title:`needs you`,count:2,action:(0,P.jsx)(B,{size:`sm`,variant:`quiet`,children:`all`}),children:(0,P.jsx)(J,{leading:`✋`,title:`Run npm install`,sub:`🐻 Max · needs approval · 4m ago`,onClick:()=>{}})}),(0,P.jsx)(nt,{title:`team`,children:(0,P.jsx)(J,{leading:`🦊`,title:`Lisa`,sub:`Research`})})]})]}),(0,P.jsx)(q,{title:`Fields`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,P.jsx)(X,{label:`Name`,hint:`Shown in the rail.`,children:(0,P.jsx)(Y,{placeholder:`e.g. Max`})}),(0,P.jsx)(X,{label:`Harness`,children:(0,P.jsxs)(vt,{defaultValue:`claude`,children:[(0,P.jsx)(`option`,{children:`claude`}),(0,P.jsx)(`option`,{children:`codex`}),(0,P.jsx)(`option`,{children:`pi`})]})}),(0,P.jsx)(X,{label:`Role`,children:(0,P.jsx)(_t,{rows:3,placeholder:`What this agent does`})})]})}),(0,P.jsxs)(q,{title:`Empty and menus`,children:[(0,P.jsx)(G,{icon:`upload_file`,action:(0,P.jsx)(B,{variant:`secondary`,size:`sm`,icon:`upload`,children:`choose files`}),children:`Drop files here.`}),(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(kt,{trigger:({toggle:e})=>(0,P.jsx)(B,{onClick:e,icon:`expand_more`,children:`menu`}),children:e=>(0,P.jsxs)(`div`,{className:`flex flex-col`,children:[(0,P.jsx)(J,{leading:`⚙️`,title:`Settings`,onClick:e,size:`sm`}),(0,P.jsx)(J,{leading:`🗑`,title:`Trash`,onClick:e,size:`sm`})]})})})]}),(0,P.jsx)(q,{title:`Sidebar parts`,children:(0,P.jsxs)(`div`,{className:`w-[300px] border-r border-line`,children:[(0,P.jsx)(Tt,{title:`workflows`,count:3,action:(0,P.jsx)(B,{size:`sm`,variant:`quiet`,icon:`add`,children:`new`})}),(0,P.jsx)(Et,{placeholder:`search workflows`,"aria-label":`search workflows`}),(0,P.jsxs)(Dt,{children:[(0,P.jsx)(J,{leading:(0,P.jsx)(H,{tone:`ok`}),title:`triage`,sub:`checks, drafts, publishes`,size:`sm`,active:!0}),(0,P.jsx)(Ot,{children:`no workflow matches “x”`})]})]})}),(0,P.jsx)(q,{title:`Choices`,children:(0,P.jsxs)(yt,{children:[(0,P.jsx)(xt,{checked:n,onChange:r,hint:`every discovered skill`,children:`all skills`}),(0,P.jsx)(xt,{checked:!n,onChange:e=>r(!e),hint:`0 concepts`,mono:!0,children:`brand-guide`}),(0,P.jsxs)(bt,{children:[(0,P.jsx)(Ct,{checked:n,onChange:r,label:`routine enabled`}),(0,P.jsxs)(W,{children:[`Hint: a small explaining line. Keys look like `,(0,P.jsx)(et,{children:`⌘K`}),`.`]})]}),(0,P.jsx)(wt,{label:`Docker sandbox`,hint:`Docker is not running`,checked:n,onChange:r})]})}),(0,P.jsxs)(q,{title:`Page parts`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(ot,{children:`🐻`}),(0,P.jsx)(rt,{size:`lg`,children:`Max`}),(0,P.jsx)(U,{href:`#/ui`,children:`linked tag`})]}),(0,P.jsx)(pt,{bare:!0,label:`link tabs`,value:`pages`,items:[{id:`pages`,label:`pages`,href:`/ui`},{id:`activity`,label:`activity`,href:`/ui`}]})]}),(0,P.jsxs)(lt,{children:[(0,P.jsx)(ct,{icon:`account_tree`,title:`workflows`,action:(0,P.jsx)(B,{size:`sm`,children:`edit`}),children:(0,P.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none connected`})}),(0,P.jsx)(ct,{icon:`menu_book`,title:`knowledge`})]}),(0,P.jsxs)(dt,{children:[(0,P.jsx)(ft,{label:`source`,children:`workspace`}),(0,P.jsx)(ft,{label:`path`,mono:!0,children:`skills/release-notes/SKILL.md`})]})]})]})]})}var Tu={running:{label:`running`},stopped:{label:`stopped`},died:{label:`died`,note:`was killed or crashed`},missing:{label:`missing`,note:`folder is gone`},orphaned:{label:`orphaned`,note:`no kraftwerk.yml any more`}},Eu={running:`text-ok`,stopped:`text-fg-2`,died:`text-ask`,missing:`text-bad`,orphaned:`text-bad`},Du={running:``,stopped:`opacity-65 grayscale-50`,died:`opacity-80`,missing:`opacity-45 grayscale-80`,orphaned:`opacity-45 grayscale-80`};function Ou(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(null),u=(0,v.useCallback)(async()=>{try{let e=await A.request(`workspaces.list`);if(e.ok){t(e.data),r(``);return}r(e.status===404?`This workspace runs a kraftwerk without the workspaces API. Update it and restart its UI.`:`Could not load the workspace registry (HTTP ${e.status}).`)}catch(e){r(e.message||`Could not reach this workspace's server.`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await u(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[u]);let d=e=>e.root??e.url,f=async(e,t)=>{let n=d(e);a(e=>({...e,[n]:t})),s(e=>({...e,[n]:``})),l(null);try{let n=t===`stop`?{root:e.root,url:e.url}:{root:e.root},r=await A.request(`workspaces.${t}`,{body:n});if(!r.ok)throw Error(j(r));if(!r.data.ok)throw Error(`failed`)}catch(e){s(t=>({...t,[n]:e.message}))}finally{a(e=>{let t={...e};return delete t[n],t}),u()}},p=e?.filter(e=>e.live).length??0,m=new Map;for(let t of e??[])t.icon&&m.set(t.icon,(m.get(t.icon)??0)+1);let h=e=>!!e&&(m.get(e)??0)>1;return(0,P.jsxs)(at,{children:[(0,P.jsx)(it,{icon:(0,P.jsx)(F,{name:`hub`,className:`text-[28px] text-fg-2`}),title:`Workspaces`,actions:(0,P.jsxs)(P.Fragment,{children:[e&&(0,P.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[e.length,` known · `,p,` running`]}),e&&n&&(0,P.jsx)(K,{tone:`bad`,children:n})]})}),(0,P.jsxs)(q,{title:`workspaces on this machine`,actions:(0,P.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`registry: `,(0,P.jsx)(`code`,{className:`text-2xs`,children:`~/.kraftwerk/workspaces`})]}),children:[!e&&!n&&(0,P.jsx)(G,{className:`py-6`,children:`loading…`}),!e&&n&&(0,P.jsx)(`div`,{className:`px-[18px] py-4`,children:(0,P.jsx)(K,{tone:`bad`,children:n})}),e&&e.length===0&&(0,P.jsx)(G,{className:`py-6`,children:`No workspaces known yet.`}),e?.map(e=>{let t=d(e),n=i[t],r=!e.live&&!!e.root&&(e.exists===!1||e.hasConfig===!1),a=N(`text-md font-semibold text-fg`,e.named===!1&&`italic text-fg-2`);return(0,P.jsxs)(`div`,{className:N(`grid grid-cols-[40px_minmax(0,1fr)_auto] items-start gap-3.5 px-[18px] py-3.5 [&+&]:border-t [&+&]:border-line/55`,e.state===`died`&&`bg-ask-soft/30`),children:[(0,P.jsx)(ze,{className:N(`size-10`,Du[e.state]),icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:h(e.icon)}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[e.live&&!e.current?(0,P.jsx)(`a`,{href:pe(e),className:N(a,`no-underline hover:underline`),children:e.name}):(0,P.jsx)(`span`,{className:a,children:e.name}),e.current&&(0,P.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.4px] text-fg-2 uppercase`,children:`current`}),(0,P.jsxs)(`span`,{className:N(`inline-flex items-center gap-1.5 text-2xs font-semibold tracking-[0.4px] uppercase`,Eu[e.state]),children:[e.live&&(0,P.jsx)(`span`,{className:`inline-block size-2 rounded-full bg-ok`}),Tu[e.state].label]}),Tu[e.state].note&&(0,P.jsx)(`span`,{className:`text-xs text-fg-2`,children:Tu[e.state].note})]}),(0,P.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.root,children:e.rootLabel??(0,P.jsx)(`span`,{className:`font-sans opacity-70`,children:`no root recorded (started by an older version)`})}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-x-3.5 gap-y-1 text-xs text-fg-2`,children:[e.state!==`missing`&&e.state!==`orphaned`&&(0,P.jsx)(`span`,{children:e.url.replace(/^https?:\/\//,``)}),e.counts&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{children:[e.counts.agents,` agents`]}),(0,P.jsxs)(`span`,{children:[e.counts.workflows,` workflows`]}),(0,P.jsxs)(`span`,{children:[e.counts.runs,` runs`]}),(0,P.jsxs)(`span`,{children:[e.counts.chats,` chats`]})]}),e.lastStarted&&(0,P.jsxs)(`span`,{title:e.lastStarted,children:[`started `,Ke(e.lastStarted)]}),!e.live&&e.lastStopped&&(0,P.jsxs)(`span`,{title:e.lastStopped,children:[`stopped `,Ke(e.lastStopped)]}),e.startCount!=null&&(0,P.jsxs)(`span`,{children:[e.startCount,`× launched`]}),e.firstSeen&&(0,P.jsxs)(`span`,{title:e.firstSeen,children:[`first seen `,Ke(e.firstSeen)]})]}),o[t]&&(0,P.jsx)(K,{tone:`bad`,children:o[t]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[e.live&&!e.current&&(0,P.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:pe(e),title:`Open this workspace`,children:[(0,P.jsx)(F,{name:`open_in_new`,className:`ms-sm`}),` open`]}),!e.live&&e.root&&e.exists!==!1&&!e.dirGone&&(0,P.jsx)(B,{size:`sm`,variant:`primary`,icon:`play_arrow`,busy:n===`start`,disabled:!!n,onClick:()=>void f(e,`start`),children:n===`start`?`starting…`:`start`}),e.live&&!e.current&&(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`stop`,busy:n===`stop`,disabled:!!n,onClick:()=>void f(e,`stop`),children:n===`stop`?`stopping…`:`stop`}),r&&c!==t&&(0,P.jsx)(B,{size:`sm`,icon:`delete`,disabled:!!n,title:`Drop this project from the registry (files untouched)`,onClick:()=>l(t),children:`remove`}),r&&c===t&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(B,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void f(e,`forget`),children:`confirm remove`}),(0,P.jsx)(B,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},t)})]}),(0,P.jsxs)(`p`,{className:`m-0 text-xs text-fg-2 [&_code]:text-2xs`,children:[`Start launches `,(0,P.jsx)(`code`,{children:`kraftwerk ui`}),` detached in the project root (log in `,(0,P.jsx)(`code`,{children:`~/.kraftwerk/logs`}),`). Stop sends SIGTERM to the running server. Remove is offered only for records whose root no longer holds a `,(0,P.jsx)(`code`,{children:`kraftwerk.yml`}),` — the same from the terminal:`,` `,(0,P.jsx)(`code`,{children:`kraftwerk workspaces`}),`.`]})]})}function ku(e){if(e<60)return`${e}s`;let t=Math.round(e/60);if(t<60)return`${t} min`;let n=Math.floor(t/60),r=t%60;return r?`${n} h ${r} min`:`${n} h`}var Au=[[/^(\+\+\+|---|diff |index )/,`text-fg-2 opacity-80`],[/^@@/,`text-accent`],[/^\+/,`text-ok`],[/^-/,`text-bad`]],ju=e=>Au.find(([t])=>t.test(e))?.[1]??``;function Mu({file:e}){return(0,P.jsx)(Pu,{source:{route:`git.diff`,input:{query:{path:e}}}})}var Nu=e=>(e.route===`git.diff`||e.route,A.request(e.route,e.input));function Pu({source:e,refresh:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=JSON.stringify(e);return(0,v.useEffect)(()=>{let t=!0;return r(null),s(``),Nu(e).then(e=>{if(t){if(!e.data||typeof e.data!=`object`)throw Error(`not json`);if(!e.ok){r(``),a(!1),s(e.error??``);return}r(e.data.diff??``),a(!!e.data.truncated),s(e.data.error??``)}}).catch(()=>t&&s(`could not load the diff`)),()=>{t=!1}},[c,t]),o?(0,P.jsx)(`div`,{className:N(Fu,`text-bad`),children:o}):n===null?(0,P.jsx)(`div`,{className:Fu,children:`loading…`}):n.trim()?(0,P.jsxs)(`pre`,{className:Fu,children:[n.split(`
225
225
  `).map((e,t)=>(0,P.jsxs)(`span`,{className:ju(e),children:[e||` `,`