@netnodeag/kraftwerk 0.106.0 → 0.107.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-A9_YWc5F.js","assets/dist-BUzdcj0Z.js","assets/dist-BxtR6jpW.js","assets/dist-B31Tw4i_.js","assets/dist-DdOmexTd.js","assets/dist-xJA0yP5A.js","assets/editor-C0_Snnzk.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-TtOHfgtL.js","assets/dist-BUzdcj0Z.js","assets/dist-BxtR6jpW.js","assets/dist-R4d_8TYT.js","assets/dist-BcAObTTF.js","assets/dist-cAilu-a-.js","assets/editor-C0_Snnzk.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,t.exports),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 ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function M(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 N(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,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(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(A,`$&/`)+`/`)+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+j(a,u),c+=N(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+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(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 P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(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 I=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 te(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,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function R(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 te(R.bind(null,e))}var z={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(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=z,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=R,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:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=te,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.1`})),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&&A(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&&A(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,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function A(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,A(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.1`})),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`),ee=Symbol.for(`react.portal`),A=Symbol.for(`react.fragment`),j=Symbol.for(`react.strict_mode`),M=Symbol.for(`react.profiler`),N=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),F=Symbol.for(`react.forward_ref`),I=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),R=Symbol.for(`react.memo`),z=Symbol.for(`react.lazy`),B=Symbol.for(`react.activity`),ne=Symbol.for(`react.legacy_hidden`),re=Symbol.for(`react.memo_cache_sentinel`),ie=Symbol.for(`react.view_transition`),ae=Symbol.for(`react.recoverable`),oe=Symbol.iterator;function se(e){return typeof e!=`object`||!e?null:(e=oe&&e[oe]||e[`@@iterator`],typeof e==`function`?e:null)}var ce=Symbol.for(`react.client.reference`);function le(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case A:return`Fragment`;case M:return`Profiler`;case j:return`StrictMode`;case I:return`Suspense`;case te:return`SuspenseList`;case B:return`Activity`;case ie:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case ee:return`Portal`;case P:return e.displayName||`Context`;case N:return(e._context.displayName||`Context`)+`.Consumer`;case F:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case R:return t=e.displayName||null,t===null?le(e.type)||`Memo`:t;case z:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}var ue=Array.isArray,de=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},pe=[],me=-1;function H(e){return{current:e}}function he(e){0>me||(e.current=pe[me],pe[me]=null,me--)}function ge(e,t){me++,pe[me]=e.current,e.current=t}var _e=H(null),U=H(null),ve=H(null),ye=H(null);function be(e,t){switch(ge(ve,t),ge(U,e),ge(_e,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?dp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=dp(t),e=fp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}he(_e),ge(_e,e)}function xe(){he(_e),he(U),he(ve)}function Se(e){var t=e.memoizedState;t!==null&&(ch._currentValue=t.memoizedState,ge(ye,e)),t=_e.current;var n=fp(t,e.type);t!==n&&(ge(U,e),ge(_e,n))}function Ce(e){U.current===e&&(he(_e),he(U)),ye.current===e&&(he(ye),ch._currentValue=fe)}var we,Te;function Ee(e){if(we===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);we=t&&t[1]||``,Te=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+we+e+Te}var De=!1;function Oe(e,t){if(!e||De)return``;De=!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(`
@@ -85,7 +85,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
85
85
  `),(!e.complete||e.note)&&(0,z.jsxs)(`span`,{className:`opacity-70`,children:[` · `,e.note??`list may be incomplete`]})]});case`question`:return(0,z.jsx)(Oo,{b:e,chatId:t});case`permission`:return(0,z.jsx)(jo,{b:e,chatId:t});case`error`:return(0,z.jsxs)(`div`,{className:`flex items-center gap-1 self-start text-[12.5px] text-bad`,children:[(0,z.jsx)(B,{name:`error`,className:`ms-sm`}),` `,e.text]});case`failure`:return(0,z.jsx)(Vo,{b:e,chatId:t})}}var Bo={retry:`try again`,login:`sign in again`,new_session:`start a fresh session`};function Vo({b:e,chatId:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(null),o=e.failure,s=!e.resolved&&!i;async function c(n){if(n===`login`)a(`Sign in again in a terminal (claude login, codex login, or agy acp --login), then send your message again.`);else{r(!0);try{if(n===`retry`){if(!e.retryText)return a(`nothing to retry — send a message`);await A.request(`chats.message`,{id:t,body:{text:e.retryText}})}else{let e=await A.request(`chats.resetSession`,{id:t});e.ok||a(e.error??`reset failed (${e.status})`)}}catch{}finally{r(!1)}}}return(0,z.jsxs)(`div`,{className:I(`max-w-[76ch] self-start rounded-2xl px-4 py-3`,o.severity===`warning`?`bg-ask-soft text-on-ask-soft`:`bg-bad-soft text-on-bad-soft`,!s&&`opacity-70`),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13.5px]`,children:[(0,z.jsx)(B,{name:o.severity===`warning`?`warning`:`error`,className:`ms-sm`}),(0,z.jsx)(it,{className:`mr-1 font-bold text-inherit`,children:o.category}),` `,o.title]}),o.details&&(0,z.jsx)(`div`,{className:`mt-1.5 text-xs break-words whitespace-pre-wrap`,children:o.details}),i&&(0,z.jsx)(`div`,{className:`mt-1.5 text-xs break-words whitespace-pre-wrap`,children:i}),s&&o.actions.length>0&&(0,z.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:o.actions.map(e=>(0,z.jsx)(K,{size:`sm`,disabled:n,className:`border-current text-inherit`,onClick:()=>c(e),children:Bo[e]},e))})]})}function Ho(e,t){let n=e=>e>=1e4?`${Math.round(e/1e3)}k`:String(e),r=[t===`completed`?`context compacted`:t===`failed`?`compaction failed`:`compacting context`];return e.preTokens!=null&&e.postTokens!=null?r.push(`${n(e.preTokens)} → ${n(e.postTokens)} tokens`):e.preTokens!=null&&r.push(`${n(e.preTokens)} tokens`),e.trigger&&r.push(e.trigger),e.error&&r.push(e.error),r.join(` · `)}function Uo({id:e,busy:t,scope:n,channel:r,agentMap:i,commands:a=[],canSteer:o,account:s,footer:c}){let[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(null),p=jn()().replace(/^\S+\s(?=\S)/u,e=>/\p{Extended_Pictographic}/u.test(e)?``:e).replace(/^The /,`the `),[m,h]=(0,v.useState)([]),[g,_]=(0,v.useState)(0),[y,b]=(0,v.useState)(!1);async function x(t){for(let n of Array.from(t)){_(e=>e+1);try{let t=await A.request(`chats.attach`,{id:e,headers:{"content-type":n.type||`application/octet-stream`,"x-file-name":encodeURIComponent(n.name||`pasted.png`)},body:n});if(typeof t.data!=`object`||!t.data)throw Error(`not json`);t.ok?h(e=>[...e,{...t.data,...n.type.startsWith(`image/`)?{preview:URL.createObjectURL(n)}:{}}]):f(t.error??`upload failed (${t.status})`)}catch{f(`upload failed`)}finally{_(e=>e-1)}}}let[S,C]=(0,v.useState)([]),[w,T]=(0,v.useState)(0),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(wn),[ee,j]=(0,v.useState)(!1),M=(0,v.useRef)(null),N=(0,v.useRef)(null),P=t&&!r&&!!o,te=t&&!r&&!o;(0,v.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await A.request(`skills.list`),r=(t.ok?t.data.skills:void 0)??[];if(n?.kind===`agent`){let[e,t]=await Promise.all([A.call(`agents.get`,{slug:n.slug}).catch(()=>null),A.call(`agents.skills`,{slug:n.slug}).catch(()=>null)]);if(e&&Array.isArray(e.skills)){let t=new Set(e.skills.map(e=>e.toLowerCase()));r=r.filter(e=>t.has(e.name.toLowerCase()))}let i=t?.skills??[],a=new Set(i.map(e=>e.name.toLowerCase()));r=[...i,...r.filter(e=>!a.has(e.name.toLowerCase()))]}e&&C(r)}catch{}})(),()=>{e=!1}},[e]);let R=/^\/([\w-]*)$/.exec(l)?.[1],ne=R!==void 0&&!E?S.filter(e=>e.name.toLowerCase().startsWith(R.toLowerCase())):[],re=new Set(S.map(e=>e.name.toLowerCase())),ie=R!==void 0&&!E?a.filter(e=>e.name.toLowerCase().startsWith(R.toLowerCase())&&!re.has(e.name.toLowerCase())):[],ae=M.current?.selectionStart??l.length,oe=r&&!E?/(^|\s)@([a-z0-9-]*)$/i.exec(l.slice(0,ae)):null,se=oe&&r?r.members.filter(e=>e.startsWith(oe[2].toLowerCase())||(i?.get(e)?.name??``).toLowerCase().startsWith(oe[2].toLowerCase())):[],ce=De(),le=!E&&ce.presentations?/(^|\s)presentation:([a-z0-9-]*)$/.exec(l.slice(0,ae)):null,ue=F(`presentations.list`,le?{query:{all:`1`}}:null,{interval:6e4}),de=le?(ue?.presentations??[]).filter(e=>e.name.startsWith(le[2])||e.title.toLowerCase().includes(le[2])):[],V=[...ne.map(e=>({id:`/${e.name}`,label:`/${e.name}`,hint:e.description,src:e.source,pick:()=>{u(`/${e.name} `),T(0)}})),...ie.map(e=>({id:`/${e.name}`,label:`/${e.name}${e.hint?` ${e.hint}`:``}`,hint:e.description,src:`agent`,pick:()=>{u(`/${e.name} `),T(0)}})),...se.map(e=>({id:`@${e}`,label:`${i?.get(e)?.emoji??`🤖`} @${e}`,hint:i?.get(e)?.name,pick:()=>{let t=l.slice(0,ae).replace(/@[a-z0-9-]*$/i,`@${e} `);u(t+l.slice(ae)),T(0),requestAnimationFrame(()=>{let e=M.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}})),...de.map(e=>({id:`presentation:${e.project??``}/${e.name}`,label:`▶ presentation:${e.name}`,hint:`${e.title}${e.project?` · ${e.project}`:``} · ${e.slides} slides`,pick:()=>{let t=l.slice(0,ae).replace(/presentation:[a-z0-9-]*$/,`presentation:${e.name} `);u(t+l.slice(ae)),T(0),requestAnimationFrame(()=>{let e=M.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}}))].slice(0,15),fe=V.length>0,pe=Math.min(w,V.length-1);async function me(){let t=l.trim();if(!t&&m.length===0||te||g>0)return;let n=m.map(({preview:e,...t})=>t);u(``),h([]),f(null);let i={text:t,...n.length?{attachments:n}:{},...r?{from:O||`you`}:{}},a=await(P?A.request(`chats.steer`,{id:e,body:i}):A.request(`chats.message`,{id:e,body:i})).catch(()=>null);a&&!a.ok&&(f(a.error??`not sent (${a.status})`),u(t),h(m))}return(0,z.jsxs)(`div`,{className:`composer relative flex flex-none flex-wrap items-end border-t border-line pt-2.5 pb-1`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),b(!0))},onDragLeave:()=>b(!1),onDrop:e=>{e.dataTransfer.files.length&&(e.preventDefault(),b(!1),x(e.dataTransfer.files))},children:[m.length>0&&(0,z.jsxs)(`div`,{className:`flex basis-full flex-wrap gap-1.5 px-1 pb-1.5`,children:[m.map(e=>(0,z.jsxs)(`span`,{className:Wo,title:`${e.name} · ${Math.round(e.size/1024)} KB`,children:[e.preview?(0,z.jsx)(`img`,{src:e.preview,alt:e.name,className:`h-7 rounded`}):(0,z.jsx)(B,{name:`attach_file`,className:`ms-sm`}),e.name.replace(/^\d{8}-\d{6}-/,``),(0,z.jsx)(`button`,{type:`button`,className:`inline-flex cursor-pointer border-0 bg-transparent p-0 text-inherit hover:text-fg`,title:`remove`,"aria-label":`remove ${e.name}`,onClick:()=>h(t=>t.filter(t=>t.name!==e.name)),children:(0,z.jsx)(B,{name:`close`,className:`ms-sm`})})]},e.name)),g>0&&(0,z.jsx)(`span`,{className:Wo,children:`uploading…`})]}),r&&(0,z.jsxs)(`div`,{className:`composer-me flex basis-full items-center gap-1.5 px-1 pb-1 text-xs text-fg-2`,children:[`posting as`,` `,ee?(0,z.jsx)(Z,{autoFocus:!0,className:`h-7 w-48 text-xs`,value:O,placeholder:`your name`,"aria-label":`your name`,onChange:e=>k(e.target.value),onBlur:()=>{Tn(O.trim()),j(!1)},onKeyDown:e=>{(e.key===`Enter`||e.key===`Escape`)&&e.target.blur()}}):(0,z.jsxs)(`button`,{type:`button`,className:`me-name inline-flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 font-[inherit] font-semibold text-fg`,onClick:()=>j(!0),title:`change your name`,children:[O||`you`,` `,(0,z.jsx)(B,{name:`edit`,className:`ms-sm`})]})]}),fe&&(0,z.jsx)(`div`,{className:`skill-menu absolute inset-x-0 bottom-full z-5 mb-1.5 flex max-h-[46vh] flex-col overflow-y-auto rounded-card border border-line bg-surface py-1 shadow-pop`,children:V.map((e,t)=>(0,z.jsxs)(`button`,{type:`button`,className:I(`flex cursor-pointer items-center gap-1.5 border-0 px-3.5 py-2 text-left text-sm whitespace-nowrap text-fg`,t===pe?`bg-surface-2`:`bg-transparent hover:bg-surface-2`),onMouseDown:t=>{t.preventDefault(),e.pick()},children:[(0,z.jsx)(`b`,{className:`max-w-[42%] flex-none truncate font-mono text-[12.5px] font-medium`,children:e.label}),e.hint&&(0,z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-2`,children:[`— `,e.hint]}),e.src&&(0,z.jsx)(`span`,{className:`ml-auto flex-none text-[10.5px] tracking-[0.04em] text-fg-2 uppercase`,children:e.src})]},e.id))}),d&&(0,z.jsx)(`div`,{className:`basis-full`,children:(0,z.jsx)(rt,{tone:`bad`,children:d})}),(0,z.jsxs)(`div`,{className:I(`flex min-w-0 flex-1 flex-col rounded-[18px] border bg-surface px-2.5 pt-1.5 pb-2 shadow-[0_1px_2px_rgb(0_0_0/0.04),0_4px_16px_rgb(0_0_0/0.04)] transition-[border-color,box-shadow]`,`focus-within:border-accent focus-within:shadow-[0_0_0_3px_color-mix(in_srgb,var(--accent)_16%,transparent)]`,y?`border-dashed border-accent`:`border-line`),children:[(0,z.jsx)(`textarea`,{ref:M,value:l,className:`max-h-[40vh] min-h-[44px] w-full min-w-0 flex-none resize-none overflow-y-auto rounded-none border-0 bg-transparent px-1.5 py-2 font-sans text-md leading-[1.5] text-fg shadow-none outline-none [field-sizing:content] placeholder:text-fg-2`,placeholder:r?te?`the agents are working…`:`Message the channel…`:te?`${p} is working…`:P?`Add to what ${p} is doing…`:`Message ${p}…`,title:`${r?`Enter to send · Shift+Enter for a newline · @ mentions an agent · / for skills · drop or paste files`:`Enter to send · Shift+Enter for a newline · / for skills · drop or paste files`}${s?`\nruns as ${s}`:``}`,rows:Math.min(6,Math.max(1,l.split(`
86
86
  `).length)),onChange:e=>{u(e.target.value),T(0),D(!1)},onPaste:e=>{let t=Array.from(e.clipboardData.items).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),x(t))},onKeyDown:e=>{if(fe){if(e.key===`ArrowDown`)return e.preventDefault(),T((pe+1)%V.length);if(e.key===`ArrowUp`)return e.preventDefault(),T((pe-1+V.length)%V.length);if(e.key===`Tab`||e.key===`Enter`)return e.preventDefault(),V[pe].pick();if(e.key===`Escape`)return e.preventDefault(),D(!0)}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),me())}}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-end gap-0.5`,children:[(0,z.jsx)(`div`,{className:`composer-details flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-1 self-center`,children:c}),t&&(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`stop`,className:`mr-1 self-center`,onClick:()=>A.request(`chats.cancel`,{id:e}).catch(()=>{}),children:`stop`}),!te&&(0,z.jsx)(q,{icon:`attach_file`,label:`attach files (or drop / paste them)`,className:`size-8 rounded-full [&_.ms]:text-[19px]`,onClick:()=>N.current?.click()}),(0,z.jsx)(`input`,{ref:N,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&x(e.target.files),e.target.value=``}}),!te&&(0,z.jsx)(`button`,{type:`button`,className:`inline-grid size-8 flex-none cursor-pointer place-items-center rounded-full border-0 bg-accent p-0 text-on-accent transition-[filter,opacity] hover:enabled:brightness-110 active:enabled:scale-95 disabled:cursor-default disabled:opacity-30`,disabled:!l.trim()&&m.length===0||g>0,onClick:me,"aria-label":P?`steer`:`send`,title:P?`steer: hand this into the running turn (Enter)`:`send (Enter)`,children:(0,z.jsx)(B,{name:P?`alt_route`:`arrow_upward`,className:`text-[19px]`})})]})]})]})}var Wo=`inline-flex items-center gap-1.5 rounded-full border border-line bg-surface-2 px-2 py-0.5 text-2xs text-fg-2`;function Go({id:e,live:t}){let n=Se(),[r,i]=(0,v.useState)(null),a=t.config.filter(e=>e.category===`model`||e.category===`thought_level`);async function o(t,n){i(t.id);let r=await A.request(`chats.config`,{id:e,body:{configId:t.id,value:n}}).catch(()=>null);i(null),r&&!r.ok&&alert(r.error??`setting refused (${r.status})`)}return(0,z.jsxs)(z.Fragment,{children:[t.auth?.kind===`none`&&(0,z.jsx)(`span`,{title:[t.auth.detail,t.auth.email,t.auth.organization,t.auth.plan,`set what it signs in with: settings → harnesses`].filter(Boolean).join(` · `),children:(0,z.jsxs)(J,{tone:t.auth.kind===`none`?`bad`:`neutral`,href:`/settings/harnesses`,children:[(0,z.jsx)(B,{name:t.auth.kind===`none`?`person_off`:`person`,className:`ms-sm mr-1`}),` `,t.auth.email??t.auth.label]})}),n&&t.usage&&t.usage.size>0&&(0,z.jsx)(`span`,{className:`font-mono`,title:`${t.usage.used.toLocaleString()} of ${t.usage.size.toLocaleString()} context tokens${t.usage.costUsd==null?``:` · $${t.usage.costUsd.toFixed(2)} so far`}`,children:(0,z.jsxs)(J,{children:[Math.round(100*t.usage.used/t.usage.size),`% ctx`,t.usage.costUsd!=null&&` · $${t.usage.costUsd.toFixed(2)}`]})}),n&&a.map(e=>e.type===`select`?(0,z.jsx)(St,{className:`h-7 w-auto max-w-[22ch] rounded-full border-transparent bg-transparent px-2 pr-6 text-xs text-fg-2 shadow-none hover:bg-surface-2`,value:e.value,disabled:r===e.id,title:e.description??e.name,"aria-label":e.name,onChange:t=>o(e,t.target.value),children:e.choices.map(e=>(0,z.jsxs)(`option`,{value:e.value,title:e.description,children:[e.group?`${e.group} · `:``,e.name]},e.value))},e.id):(0,z.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-fg-2`,title:e.description??e.name,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:e.value,disabled:r===e.id,onChange:t=>o(e,t.target.checked)}),` `,e.name]},e.id))]})}function Ko({id:e,agentName:t,agentDescription:n,channel:r,agents:i,onConverted:a}){let[o,s]=(0,v.useState)(null),c=F(`chats.list`,{})?.chats.find(t=>t.id===e)?.title;(0,v.useEffect)(()=>{c!==void 0&&s(e=>e&&e.title!==c?{...e,title:c}:e)},[c]);let[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),C=De(),w=Se(),T=F(`agents.list`,r?null:{},{interval:3e4})?.agents??[],E=o?.vibeable&&C.vibeables?o.vibeable:null,[D,O]=(0,v.useState)(null);(0,v.useEffect)(()=>E?(Qt({chatId:e,slug:E}),O(document.getElementById(Zt)),()=>Qt(null)):O(null),[e,E]);let k=(0,v.useMemo)(()=>kn(l),[l]);(0,v.useEffect)(()=>{let t=!0,n;return A.call(`chats.get`,{id:e}).then(r=>{if(!t)return;s(r.meta),u(r.events);let i=r.events[r.events.length-1]?.seq??0;n=N.subscribe(`chat.${e}`,{after:i},e=>{let t=e;u(e=>e.some(e=>e.seq===t.seq)?e:[...e,t])})}).catch(()=>t&&f(!0)),()=>{t=!1,n?.()}},[e]);let ee=(0,v.useMemo)(()=>{if(!r)return[];let e=new Set;for(let t of l)t.from?.kind===`agent`&&(t.type===`turn_start`&&e.add(t.from.slug),(t.type===`turn_end`||t.type===`error`)&&e.delete(t.from.slug));return[...e]},[l,r]),j=(0,v.useMemo)(()=>{if(r)return ee.length>0;for(let e=l.length-1;e>=0;e--){let t=l[e].type;if(t===`user_message`)return!0;if(t===`turn_end`||t===`error`)return!1}return!1},[l,r,ee]),M=(0,v.useMemo)(()=>{if(o?.title)return o.title;let e=l.find(e=>e.type===`user_message`);return e&&e.type===`user_message`?e.text.replace(/\s+/g,` `).trim().slice(0,80):``},[o,l]);if((0,v.useEffect)(()=>o?r?(le(`#${r.slug} · ${r.name}`),()=>le(``)):(le([t??(o.scope.kind===`agent`?o.scope.slug:o.agent),n,M||`new chat`].filter(Boolean).join(` · `)),()=>le(``)):void 0,[o,M,t,n,r]),d)return(0,z.jsx)(Y,{icon:`chat_error`,children:`chat not found`});if(!o)return(0,z.jsx)(Y,{children:`loading…`});let P=new Map((i??[]).map(e=>[e.slug,e]));if(r)return(0,z.jsxs)(`div`,{className:`chat-thread flex min-h-0 w-full flex-1 animate-rise flex-col`,children:[(0,z.jsxs)(`div`,{className:`channel-head flex flex-none flex-wrap items-center gap-x-3 gap-y-2 pb-1.5`,children:[(0,z.jsx)(et,{tone:j?`working`:`ok`}),(0,z.jsxs)(ot,{children:[`#`,r.slug]}),(0,z.jsx)(`span`,{className:`text-md text-fg-2`,children:r.name}),(0,z.jsx)(`span`,{className:`flex-1`}),ee.length>0&&(0,z.jsxs)(K,{size:`sm`,variant:`danger`,icon:`stop`,title:`interrupt every agent working in this channel`,onClick:()=>En(e),children:[`stop all (`,ee.length,`)`]}),(0,z.jsx)(K,{size:`sm`,icon:`tune`,href:`/channels/${encodeURIComponent(r.slug)}/edit`,title:`members, purpose, responder`,children:`members`})]}),(0,z.jsxs)(`div`,{className:`channel-members flex flex-none flex-wrap items-center gap-x-2.5 gap-y-2 pb-3`,children:[r.purpose&&(0,z.jsx)(`span`,{className:`channel-purpose w-full text-sm text-fg-2`,children:r.purpose}),r.members.map(t=>{let n=P.get(t),i=ee.includes(t),a=On(l,t);return(0,z.jsxs)(`div`,{className:I(`member-chip inline-flex items-center gap-1 rounded-full py-[3px] pr-1.5 pl-[3px] text-sm transition-colors`,i?`bg-accent-soft`:`bg-surface-2`,x===t&&`outline-2 outline-accent`),title:n?.description,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 cursor-pointer items-center gap-2 border-0 bg-transparent p-0 text-left font-[inherit] text-inherit`,onClick:()=>S(x===t?null:t),title:x===t?`back to the channel`:`look at @${t}'s session`,children:[(0,z.jsxs)(`span`,{className:`relative grid size-7 flex-none place-items-center rounded-full bg-surface text-[15px]`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:n?.emoji??`🤖`}),(0,z.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 grid rounded-full bg-surface p-px`,children:(0,z.jsx)(et,{tone:i?`working`:`idle`})})]}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`font-medium text-fg`,children:n?.name??t}),(0,z.jsxs)(`span`,{className:`member-handle font-mono text-2xs text-fg-2`,children:[`@`,t]}),r.responder===t&&(0,z.jsx)(J,{children:`responder`})]}),(a.task||a.now)&&(0,z.jsx)(`span`,{className:`max-w-[44ch] truncate text-2xs text-fg-2`,children:i?a.now?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(it,{className:`mr-1`,children:`now`}),` `,a.now]}):(0,z.jsxs)(z.Fragment,{children:[`working on: `,a.task]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(it,{className:`mr-1`,children:`last`}),` `,a.task]})})]})]}),i&&(0,z.jsx)(q,{icon:`stop`,label:`interrupt @${t}`,variant:`danger`,size:`sm`,className:`size-6`,onClick:()=>En(e,t)}),(0,z.jsx)(q,{icon:`info`,label:`agent definition`,size:`sm`,className:`size-6`,href:`/agents/${encodeURIComponent(t)}/info`})]},t)})]}),x&&(0,z.jsxs)(`div`,{className:`flex flex-none items-center gap-2.5 border-b border-line py-1.5 text-sm`,children:[(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`arrow_back`,onClick:()=>S(null),children:`channel`}),(0,z.jsxs)(`span`,{className:`min-w-0 truncate text-fg-2`,children:[P.get(x)?.emoji??`🤖`,` @`,x,`'s session — everything this agent did, tools included`]}),(0,z.jsx)(`span`,{className:`flex-1`}),ee.includes(x)&&(0,z.jsxs)(K,{size:`sm`,variant:`danger`,icon:`stop`,onClick:()=>En(e,x),children:[`stop @`,x]})]}),(0,z.jsxs)(An.Provider,{value:e=>{let t=e?.kind===`agent`?P.get(e.slug):void 0;return e?.kind===`agent`?`${t?.emoji??`🤖`} ${t?.name??e.slug}`:`The agent`},children:[(0,z.jsx)(Po,{id:e,events:l,busy:j,channel:r,agentMap:P,working:ee,focus:x??void 0}),(0,z.jsx)(Uo,{id:e,busy:j,scope:o.scope,channel:r,agentMap:P})]})]});let te=(o.scope.kind===`agent`||o.scope.kind===`project`)&&!o.scope.routine,R=k.auth?.kind===`none`,B=o.agent===`codex`||o.agent===`antigravity`,ne=(w||R)&&(0,z.jsxs)(z.Fragment,{children:[w&&o.agent!==`pi`&&o.sessions?.main&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`call_split`,busy:h,className:B?`opacity-50`:void 0,disabled:j,"aria-disabled":B,title:B?`not supported: ${o.agent} has no session fork`:`Branch this conversation: a new chat with the same history, the original stays as it is`,onClick:async()=>{if(B)return y(`fork is not supported by ${o.agent}`);g(!0);let t=await A.request(`chats.fork`,{id:e});if(g(!1),!t.ok||!t.data?.id)return alert(t.error??`fork failed (${t.status})`);let n=t.data;H(n.scope?.kind===`agent`?`/agents/${encodeURIComponent(n.scope.slug)}/chat/${n.id}`:`/agents/chats/${n.id}`)},children:h?`forking…`:`fork`}),w&&_&&(0,z.jsx)(`span`,{className:`text-2xs text-fg-2`,children:_}),w&&(0,z.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,z.jsx)(J,{children:o.agent})}),(0,z.jsx)(Go,{id:e,live:k}),w&&o.scope.kind===`run`&&(0,z.jsx)(qo,{href:`/runs/${o.scope.runId}`,children:o.scope.runId}),w&&o.scope.kind===`kraftwerk`&&(0,z.jsx)(J,{children:`kraftwerk-aware`}),w&&o.scope.kind===`knowledge`&&(0,z.jsxs)(qo,{href:o.scope.bundle?`/knowledge/${encodeURIComponent(o.scope.bundle)}`:`/knowledge`,children:[`knowledge`,o.scope.bundle?`:${o.scope.bundle}`:``]}),w&&o.scope.kind===`agent`&&(0,z.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,z.jsxs)(qo,{href:`/agents/${encodeURIComponent(o.scope.slug)}/info`,children:[`agent:`,o.scope.slug]})}),w&&(0,z.jsx)(`span`,{className:`rid max-w-[26ch] min-w-0 truncate font-mono text-2xs text-fg-2 [direction:rtl] max-[800px]:hidden`,title:o.cwd,children:o.cwd})]});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`chat-thread flex min-h-0 w-full flex-1 animate-rise flex-col`,children:[o.scope.kind===`agent`&&!o.scope.routine&&(0,z.jsx)(vn,{children:(0,z.jsx)(Jo,{id:e,project:o.project,onFiled:e=>s(t=>t&&{...t,project:e})})}),te&&(0,z.jsx)(vn,{children:(0,z.jsx)(q,{size:`sm`,icon:`group_add`,label:`add coworker`,title:o.scope.kind===`project`?`add coworker: turn this chat into a channel of the project and invite agents`:`add coworker: turn this chat into a channel and invite more agents`,onClick:()=>m(!0),disabled:j})}),o.vibeable&&!C.vibeables&&(0,z.jsx)(sn,{chatId:e,slug:o.vibeable,onClosed:s}),(0,z.jsxs)(An.Provider,{value:()=>Nn(o.scope,T,t),children:[(0,z.jsx)(Po,{id:e,events:l,busy:j}),(0,z.jsx)(Uo,{id:e,busy:j,scope:o.scope,footer:ne||void 0,commands:k.commands,canSteer:o.agent!==`pi`,account:k.auth&&k.auth.kind!==`none`?k.auth.email??k.auth.label:void 0})]})]}),E&&D&&(0,b.createPortal)((0,z.jsx)(en,{chatId:e,slug:E,agentBusy:j,onClosed:s},E),D),p&&o.scope.kind===`agent`&&(0,z.jsx)(gn,{chatId:e,agentSlug:o.scope.slug,title:M,onClose:()=>m(!1)}),p&&o.scope.kind===`project`&&(0,z.jsx)(gn,{chatId:e,project:o.scope.slug,title:M||t||``,onClose:()=>m(!1),onCreated:a})]})}function qo({href:e,children:t}){return(0,z.jsx)(U,{href:e,className:`no-underline hover:opacity-80`,children:(0,z.jsx)(J,{children:t})})}function Jo({id:e,project:t,onFiled:n}){let r=F(`projects.list`,{},{interval:6e4}),[i,a]=(0,v.useState)(!1),o=r?.enabled===!1?[]:r?.projects??[];return!o.length&&!t?null:(0,z.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-fg-2`,title:`file this chat under a project: the agent works in its context`,children:[(0,z.jsx)(B,{name:`folder`,className:`ms-sm`}),(0,z.jsxs)(St,{"aria-label":`project`,className:`h-7 w-auto max-w-[180px] py-0 pl-2 text-sm`,value:t??``,disabled:i,onChange:async t=>{let r=t.target.value||null;a(!0);let i=await A.request(`chats.setProject`,{id:e,body:{project:r}}).catch(()=>null);a(!1),i?.ok&&n(r??void 0)},children:[(0,z.jsx)(`option`,{value:``,children:`no project`}),o.map(e=>(0,z.jsx)(`option`,{value:e.slug,children:e.title},e.slug))]})]})}async function Yo(e,t,n,r){let i=await A.request(`chats.create`,{body:{agent:e,scope:t,...n?{resume:n}:{},...r?{project:r}:{}}}),a=i.ok?i.data:null;a?.id&&H(a.project?`/projects/${encodeURIComponent(a.project)}/chat/${a.id}`:a.scope?.kind===`agent`?`/agents/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`:a.scope?.kind===`project`?`/projects/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`:`/agents/chats/${a.id}`)}function Xo({children:e}){let[t,n]=(0,v.useState)(null),r=ne().split(`?`)[0];return(0,v.useEffect)(()=>n(null),[r]),(0,v.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&!(e.target instanceof HTMLTextAreaElement&&e.target.value)&&n(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,z.jsxs)(Jt.Provider,{value:e=>{let t=Gt(e);return t?(n({id:t,href:e}),!0):!1},children:[e,t&&(0,z.jsxs)(`aside`,{className:`chat-aside fixed top-[var(--topbar-h)] right-0 bottom-0 z-20 flex w-[min(560px,100vw)] animate-rise flex-col border-l border-line bg-bg shadow-[-8px_0_32px_rgb(0_0_0/0.08)]`,"aria-label":`Chat started here`,"data-chat":t.id,children:[(0,z.jsxs)(`div`,{className:`flex flex-none items-center gap-2 border-b border-line px-3 py-2`,children:[(0,z.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:`Chat`}),(0,z.jsx)(U,{href:t.href,className:`text-sm text-fg-2 no-underline hover:text-fg`,title:`open the chat in its own place`,children:`open`}),(0,z.jsx)(q,{icon:`close`,size:`sm`,label:`close the chat panel`,onClick:()=>n(null)})]}),(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-5 pb-3`,children:(0,z.jsx)(Ko,{id:t.id},t.id)})]})]})}var Zo=null,Qo=new Set,$o;async function es(){try{let e=await A.request(`attention.list`);if(e.ok){Zo=e.data.items;for(let e of Qo)e()}}catch{}$o=setTimeout(()=>void es(),3e3)}function ts(e){return Qo.add(e),Qo.size===1&&es(),()=>{Qo.delete(e),Qo.size===0&&$o&&clearTimeout($o)}}function ns(){$o&&clearTimeout($o),es()}function rs(){return(0,v.useSyncExternalStore)(ts,()=>Zo)}var is={agent:(e,t)=>e.filter(e=>e.owner.agent?.slug===t),project:(e,t,n=[])=>e.filter(e=>e.owner.project?.slug===t||!!e.owner.agent&&n.includes(e.owner.agent.slug)),channel:(e,t)=>e.filter(e=>e.owner.channel===t),general:e=>e.filter(e=>e.owner.general)},as=e=>e===`approval`?`front_hand`:e===`question`?`help`:e===`runner`?`event_busy`:e===`review`?`rate_review`:`error`,os=e=>e===`approval`?`needs approval`:e===`question`?`asks you`:e===`runner`?`no runner`:e===`review`?`for review`:`failed`;function ss(e){let t=e.agent?`${e.agent.emoji?`${e.agent.emoji} `:``}${e.agent.name}`:``;return[e.project?`📁 ${e.project.title}`:e.channel?`#${e.channel}`:e.general?`Ralv`:e.workflow?`${e.workflow} run`:``,t].filter(Boolean).join(` · `)||`workspace`}var cs=e=>new URLSearchParams(e.split(`?`)[1]??``).get(`focus`),ls=e=>e.split(`?`)[0];function us(e,t){if(e.length!==0)return e[(e.findIndex(e=>e.href===t||cs(t)===null&&ls(e.href)===t)+1)%e.length]}function ds(e){e.notificationId&&A.request(`notifications.read`,{body:{ids:[e.notificationId]}}).then(()=>ns()).catch(()=>{}),(window.location.hash.slice(1)||`/`)===e.href?window.dispatchEvent(new Event(fs)):H(e.href)}var fs=`kw-refocus`;function ps(){let e=rs()??[],t=us(e,ne());return(0,v.useEffect)(()=>{let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.code!==`KeyN`)return;let t=us(Zo??[],window.location.hash.slice(1)||`/`);t&&(e.preventDefault(),ds(t))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),t?(0,z.jsxs)(`button`,{type:`button`,className:`next-btn inline-flex h-8 cursor-pointer items-center gap-2 rounded-control border-0 bg-bad/12 px-1.5 font-[inherit] text-sm text-fg hover:bg-bad/18`,onClick:()=>ds(t),title:`next: ${ss(t.owner)} — ${t.title} (⌥N)`,children:[(0,z.jsx)(`span`,{className:`next-n inline-grid h-5 min-w-5 place-items-center rounded-full bg-bad px-1.5 text-2xs font-bold tabular-nums text-on-bad`,children:e.length}),(0,z.jsx)(`span`,{className:`text-fg-2 max-[640px]:hidden`,children:`waiting`}),(0,z.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-0.5 rounded-md bg-bad pl-2.5 pr-2 font-semibold text-on-bad`,children:[`next `,(0,z.jsx)(B,{name:`arrow_forward`,className:`ms-sm`})]}),(0,z.jsx)(tt,{className:`mr-1 max-[800px]:hidden`,"aria-hidden":!0,children:`⌥N`})]}):null}function ms(){let e=ne(),t=cs(e),[n,r]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>r(e=>e+1);return window.addEventListener(fs,e),()=>window.removeEventListener(fs,e)},[]),(0,v.useEffect)(()=>{if(!t)return;let e=0,n=setInterval(()=>{let r=document.querySelector(`[data-request="${CSS.escape(t)}"]`);r?(clearInterval(n),r.scrollIntoView({block:`center`,behavior:`smooth`}),r.classList.remove(`focus-flash`),r.offsetWidth,r.classList.add(`focus-flash`)):++e>40&&clearInterval(n)},150);return()=>clearInterval(n)},[t,e,n])}var hs=l(o(((e,t,n)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n.leaflet={}))})(n,(function(e){var t=`1.9.4`;function n(e){for(var t,n=1,r=arguments.length,i;n<r;n++)for(t in i=arguments[n],i)e[t]=i[t];return e}var r=Object.create||(function(){function e(){}return function(t){return e.prototype=t,new e}})();function i(e,t){var n=Array.prototype.slice;if(e.bind)return e.bind.apply(e,n.call(arguments,1));var r=n.call(arguments,2);return function(){return e.apply(t,r.length?r.concat(n.call(arguments)):arguments)}}var a=0;function o(e){return`_leaflet_id`in e||(e._leaflet_id=++a),e._leaflet_id}function s(e,t,n){var r,i,a,o=function(){r=!1,i&&=(a.apply(n,i),!1)};return a=function(){r?i=arguments:(e.apply(n,arguments),setTimeout(o,t),r=!0)},a}function c(e,t,n){var r=t[1],i=t[0],a=r-i;return e===r&&n?e:((e-i)%a+a)%a+i}function l(){return!1}function u(e,t){if(t===!1)return e;var n=10**(t===void 0?6:t);return Math.round(e*n)/n}function d(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,``)}function f(e){return d(e).split(/\s+/)}function p(e,t){for(var n in Object.prototype.hasOwnProperty.call(e,`options`)||(e.options=e.options?r(e.options):{}),t)e.options[n]=t[n];return e.options}function m(e,t,n){var r=[];for(var i in e)r.push(encodeURIComponent(n?i.toUpperCase():i)+`=`+encodeURIComponent(e[i]));return(!t||t.indexOf(`?`)===-1?`?`:`&`)+r.join(`&`)}var h=/\{ *([\w_ -]+) *\}/g;function g(e,t){return e.replace(h,function(e,n){var r=t[n];if(r===void 0)throw Error(`No value provided for variable `+e);return typeof r==`function`&&(r=r(t)),r})}var _=Array.isArray||function(e){return Object.prototype.toString.call(e)===`[object Array]`};function v(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1}var y=`data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=`;function b(e){return window[`webkit`+e]||window[`moz`+e]||window[`ms`+e]}var x=0;function S(e){var t=+new Date,n=Math.max(0,16-(t-x));return x=t+n,window.setTimeout(e,n)}var C=window.requestAnimationFrame||b(`RequestAnimationFrame`)||S,w=window.cancelAnimationFrame||b(`CancelAnimationFrame`)||b(`CancelRequestAnimationFrame`)||function(e){window.clearTimeout(e)};function T(e,t,n){if(n&&C===S)e.call(t);else return C.call(window,i(e,t))}function E(e){e&&w.call(window,e)}var D={__proto__:null,extend:n,create:r,bind:i,get lastId(){return a},stamp:o,throttle:s,wrapNum:c,falseFn:l,formatNum:u,trim:d,splitWords:f,setOptions:p,getParamString:m,template:g,isArray:_,indexOf:v,emptyImageUrl:y,requestFn:C,cancelFn:w,requestAnimFrame:T,cancelAnimFrame:E};function O(){}O.extend=function(e){var t=function(){p(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},i=t.__super__=this.prototype,a=r(i);for(var o in a.constructor=t,t.prototype=a,this)Object.prototype.hasOwnProperty.call(this,o)&&o!==`prototype`&&o!==`__super__`&&(t[o]=this[o]);return e.statics&&n(t,e.statics),e.includes&&(k(e.includes),n.apply(null,[a].concat(e.includes))),n(a,e),delete a.statics,delete a.includes,a.options&&(a.options=i.options?r(i.options):{},n(a.options,e.options)),a._initHooks=[],a.callInitHooks=function(){if(!this._initHooksCalled){i.callInitHooks&&i.callInitHooks.call(this),this._initHooksCalled=!0;for(var e=0,t=a._initHooks.length;e<t;e++)a._initHooks[e].call(this)}},t},O.include=function(e){var t=this.prototype.options;return n(this.prototype,e),e.options&&(this.prototype.options=t,this.mergeOptions(e.options)),this},O.mergeOptions=function(e){return n(this.prototype.options,e),this},O.addInitHook=function(e){var t=Array.prototype.slice.call(arguments,1),n=typeof e==`function`?e:function(){this[e].apply(this,t)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(n),this};function k(e){if(typeof L<`u`&&L&&L.Mixin){e=_(e)?e:[e];for(var t=0;t<e.length;t++)e[t]===L.Mixin.Events&&console.warn(`Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.`,Error().stack)}}var ee={on:function(e,t,n){if(typeof e==`object`)for(var r in e)this._on(r,e[r],t);else{e=f(e);for(var i=0,a=e.length;i<a;i++)this._on(e[i],t,n)}return this},off:function(e,t,n){if(!arguments.length)delete this._events;else if(typeof e==`object`)for(var r in e)this._off(r,e[r],t);else{e=f(e);for(var i=arguments.length===1,a=0,o=e.length;a<o;a++)i?this._off(e[a]):this._off(e[a],t,n)}return this},_on:function(e,t,n,r){if(typeof t!=`function`)console.warn(`wrong listener type: `+typeof t);else if(this._listens(e,t,n)===!1){n===this&&(n=void 0);var i={fn:t,ctx:n};r&&(i.once=!0),this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(i)}},_off:function(e,t,n){var r,i,a;if(this._events&&(r=this._events[e],r)){if(arguments.length===1){if(this._firingCount)for(i=0,a=r.length;i<a;i++)r[i].fn=l;delete this._events[e]}else if(typeof t!=`function`)console.warn(`wrong listener type: `+typeof t);else{var o=this._listens(e,t,n);if(o!==!1){var s=r[o];this._firingCount&&(s.fn=l,this._events[e]=r=r.slice()),r.splice(o,1)}}}},fire:function(e,t,r){if(!this.listens(e,r))return this;var i=n({},t,{type:e,target:this,sourceTarget:t&&t.sourceTarget||this});if(this._events){var a=this._events[e];if(a){this._firingCount=this._firingCount+1||1;for(var o=0,s=a.length;o<s;o++){var c=a[o],l=c.fn;c.once&&this.off(e,l,c.ctx),l.call(c.ctx||this,i)}this._firingCount--}}return r&&this._propagateEvent(i),this},listens:function(e,t,n,r){typeof e!=`string`&&console.warn(`"string" type argument expected`);var i=t;typeof t!=`function`&&(r=!!t,i=void 0,n=void 0);var a=this._events&&this._events[e];if(a&&a.length&&this._listens(e,i,n)!==!1)return!0;if(r){for(var o in this._eventParents)if(this._eventParents[o].listens(e,t,n,r))return!0}return!1},_listens:function(e,t,n){if(!this._events)return!1;var r=this._events[e]||[];if(!t)return!!r.length;n===this&&(n=void 0);for(var i=0,a=r.length;i<a;i++)if(r[i].fn===t&&r[i].ctx===n)return i;return!1},once:function(e,t,n){if(typeof e==`object`)for(var r in e)this._on(r,e[r],t,!0);else{e=f(e);for(var i=0,a=e.length;i<a;i++)this._on(e[i],t,n,!0)}return this},addEventParent:function(e){return this._eventParents=this._eventParents||{},this._eventParents[o(e)]=e,this},removeEventParent:function(e){return this._eventParents&&delete this._eventParents[o(e)],this},_propagateEvent:function(e){for(var t in this._eventParents)this._eventParents[t].fire(e.type,n({layer:e.target,propagatedFrom:e.target},e),!0)}};ee.addEventListener=ee.on,ee.removeEventListener=ee.clearAllEventListeners=ee.off,ee.addOneTimeEventListener=ee.once,ee.fireEvent=ee.fire,ee.hasEventListeners=ee.listens;var A=O.extend(ee);function j(e,t,n){this.x=n?Math.round(e):e,this.y=n?Math.round(t):t}var M=Math.trunc||function(e){return e>0?Math.floor(e):Math.ceil(e)};j.prototype={clone:function(){return new j(this.x,this.y)},add:function(e){return this.clone()._add(N(e))},_add:function(e){return this.x+=e.x,this.y+=e.y,this},subtract:function(e){return this.clone()._subtract(N(e))},_subtract:function(e){return this.x-=e.x,this.y-=e.y,this},divideBy:function(e){return this.clone()._divideBy(e)},_divideBy:function(e){return this.x/=e,this.y/=e,this},multiplyBy:function(e){return this.clone()._multiplyBy(e)},_multiplyBy:function(e){return this.x*=e,this.y*=e,this},scaleBy:function(e){return new j(this.x*e.x,this.y*e.y)},unscaleBy:function(e){return new j(this.x/e.x,this.y/e.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=M(this.x),this.y=M(this.y),this},distanceTo:function(e){e=N(e);var t=e.x-this.x,n=e.y-this.y;return Math.sqrt(t*t+n*n)},equals:function(e){return e=N(e),e.x===this.x&&e.y===this.y},contains:function(e){return e=N(e),Math.abs(e.x)<=Math.abs(this.x)&&Math.abs(e.y)<=Math.abs(this.y)},toString:function(){return`Point(`+u(this.x)+`, `+u(this.y)+`)`}};function N(e,t,n){return e instanceof j?e:_(e)?new j(e[0],e[1]):e==null?e:typeof e==`object`&&`x`in e&&`y`in e?new j(e.x,e.y):new j(e,t,n)}function P(e,t){if(e)for(var n=t?[e,t]:e,r=0,i=n.length;r<i;r++)this.extend(n[r])}P.prototype={extend:function(e){var t,n;if(!e)return this;if(e instanceof j||typeof e[0]==`number`||`x`in e)t=n=N(e);else if(e=F(e),t=e.min,n=e.max,!t||!n)return this;return!this.min&&!this.max?(this.min=t.clone(),this.max=n.clone()):(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(n.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(n.y,this.max.y)),this},getCenter:function(e){return N((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,e)},getBottomLeft:function(){return N(this.min.x,this.max.y)},getTopRight:function(){return N(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(e){var t,n;return e=typeof e[0]==`number`||e instanceof j?N(e):F(e),e instanceof P?(t=e.min,n=e.max):t=n=e,t.x>=this.min.x&&n.x<=this.max.x&&t.y>=this.min.y&&n.y<=this.max.y},intersects:function(e){e=F(e);var t=this.min,n=this.max,r=e.min,i=e.max,a=i.x>=t.x&&r.x<=n.x,o=i.y>=t.y&&r.y<=n.y;return a&&o},overlaps:function(e){e=F(e);var t=this.min,n=this.max,r=e.min,i=e.max,a=i.x>t.x&&r.x<n.x,o=i.y>t.y&&r.y<n.y;return a&&o},isValid:function(){return!!(this.min&&this.max)},pad:function(e){var t=this.min,n=this.max,r=Math.abs(t.x-n.x)*e,i=Math.abs(t.y-n.y)*e;return F(N(t.x-r,t.y-i),N(n.x+r,n.y+i))},equals:function(e){return e?(e=F(e),this.min.equals(e.getTopLeft())&&this.max.equals(e.getBottomRight())):!1}};function F(e,t){return!e||e instanceof P?e:new P(e,t)}function I(e,t){if(e)for(var n=t?[e,t]:e,r=0,i=n.length;r<i;r++)this.extend(n[r])}I.prototype={extend:function(e){var t=this._southWest,n=this._northEast,r,i;if(e instanceof R)r=e,i=e;else if(e instanceof I){if(r=e._southWest,i=e._northEast,!r||!i)return this}else return e?this.extend(z(e)||te(e)):this;return!t&&!n?(this._southWest=new R(r.lat,r.lng),this._northEast=new R(i.lat,i.lng)):(t.lat=Math.min(r.lat,t.lat),t.lng=Math.min(r.lng,t.lng),n.lat=Math.max(i.lat,n.lat),n.lng=Math.max(i.lng,n.lng)),this},pad:function(e){var t=this._southWest,n=this._northEast,r=Math.abs(t.lat-n.lat)*e,i=Math.abs(t.lng-n.lng)*e;return new I(new R(t.lat-r,t.lng-i),new R(n.lat+r,n.lng+i))},getCenter:function(){return new R((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new R(this.getNorth(),this.getWest())},getSouthEast:function(){return new R(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(e){e=typeof e[0]==`number`||e instanceof R||`lat`in e?z(e):te(e);var t=this._southWest,n=this._northEast,r,i;return e instanceof I?(r=e.getSouthWest(),i=e.getNorthEast()):r=i=e,r.lat>=t.lat&&i.lat<=n.lat&&r.lng>=t.lng&&i.lng<=n.lng},intersects:function(e){e=te(e);var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),a=i.lat>=t.lat&&r.lat<=n.lat,o=i.lng>=t.lng&&r.lng<=n.lng;return a&&o},overlaps:function(e){e=te(e);var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),a=i.lat>t.lat&&r.lat<n.lat,o=i.lng>t.lng&&r.lng<n.lng;return a&&o},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(`,`)},equals:function(e,t){return e?(e=te(e),this._southWest.equals(e.getSouthWest(),t)&&this._northEast.equals(e.getNorthEast(),t)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function te(e,t){return e instanceof I?e:new I(e,t)}function R(e,t,n){if(isNaN(e)||isNaN(t))throw Error(`Invalid LatLng object: (`+e+`, `+t+`)`);this.lat=+e,this.lng=+t,n!==void 0&&(this.alt=+n)}R.prototype={equals:function(e,t){return e?(e=z(e),Math.max(Math.abs(this.lat-e.lat),Math.abs(this.lng-e.lng))<=(t===void 0?1e-9:t)):!1},toString:function(e){return`LatLng(`+u(this.lat,e)+`, `+u(this.lng,e)+`)`},distanceTo:function(e){return ne.distance(this,z(e))},wrap:function(){return ne.wrapLatLng(this)},toBounds:function(e){var t=180*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return te([this.lat-t,this.lng-n],[this.lat+t,this.lng+n])},clone:function(){return new R(this.lat,this.lng,this.alt)}};function z(e,t,n){return e instanceof R?e:_(e)&&typeof e[0]!=`object`?e.length===3?new R(e[0],e[1],e[2]):e.length===2?new R(e[0],e[1]):null:e==null?e:typeof e==`object`&&`lat`in e?new R(e.lat,`lng`in e?e.lng:e.lon,e.alt):t===void 0?null:new R(e,t,n)}var B={latLngToPoint:function(e,t){var n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)},pointToLatLng:function(e,t){var n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)},project:function(e){return this.projection.project(e)},unproject:function(e){return this.projection.unproject(e)},scale:function(e){return 256*2**e},zoom:function(e){return Math.log(e/256)/Math.LN2},getProjectedBounds:function(e){if(this.infinite)return null;var t=this.projection.bounds,n=this.scale(e);return new P(this.transformation.transform(t.min,n),this.transformation.transform(t.max,n))},infinite:!1,wrapLatLng:function(e){var t=this.wrapLng?c(e.lng,this.wrapLng,!0):e.lng,n=this.wrapLat?c(e.lat,this.wrapLat,!0):e.lat,r=e.alt;return new R(n,t,r)},wrapLatLngBounds:function(e){var t=e.getCenter(),n=this.wrapLatLng(t),r=t.lat-n.lat,i=t.lng-n.lng;if(r===0&&i===0)return e;var a=e.getSouthWest(),o=e.getNorthEast();return new I(new R(a.lat-r,a.lng-i),new R(o.lat-r,o.lng-i))}},ne=n({},B,{wrapLng:[-180,180],R:6371e3,distance:function(e,t){var n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=Math.sin((t.lat-e.lat)*n/2),o=Math.sin((t.lng-e.lng)*n/2),s=a*a+Math.cos(r)*Math.cos(i)*o*o,c=2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s));return this.R*c}}),re=6378137,ie={R:re,MAX_LATITUDE:85.0511287798,project:function(e){var t=Math.PI/180,n=this.MAX_LATITUDE,r=Math.max(Math.min(n,e.lat),-n),i=Math.sin(r*t);return new j(this.R*e.lng*t,this.R*Math.log((1+i)/(1-i))/2)},unproject:function(e){var t=180/Math.PI;return new R((2*Math.atan(Math.exp(e.y/this.R))-Math.PI/2)*t,e.x*t/this.R)},bounds:(function(){var e=re*Math.PI;return new P([-e,-e],[e,e])})()};function ae(e,t,n,r){_(e)?(this._a=e[0],this._b=e[1],this._c=e[2],this._d=e[3]):(this._a=e,this._b=t,this._c=n,this._d=r)}ae.prototype={transform:function(e,t){return this._transform(e.clone(),t)},_transform:function(e,t){return t||=1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e},untransform:function(e,t){return t||=1,new j((e.x/t-this._b)/this._a,(e.y/t-this._d)/this._c)}};function oe(e,t,n,r){return new ae(e,t,n,r)}var se=n({},ne,{code:`EPSG:3857`,projection:ie,transformation:function(){var e=.5/(Math.PI*ie.R);return oe(e,.5,-e,.5)}()}),ce=n({},se,{code:`EPSG:900913`});function le(e){return document.createElementNS(`http://www.w3.org/2000/svg`,e)}function ue(e,t){for(var n=``,r=0,i,a=e.length,o,s,c;r<a;r++){for(s=e[r],i=0,o=s.length;i<o;i++)c=s[i],n+=(i?`L`:`M`)+c.x+` `+c.y;n+=t?W.svg?`z`:`x`:``}return n||`M0 0`}var de=document.documentElement.style,V=`ActiveXObject`in window,fe=V&&!document.addEventListener,pe=`msLaunchUri`in navigator&&!(`documentMode`in document),me=Ge(`webkit`),H=Ge(`android`),he=Ge(`android 2`)||Ge(`android 3`),ge=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),_e=H&&Ge(`Google`)&&ge<537&&!(`AudioNode`in window),U=!!window.opera,ve=!pe&&Ge(`chrome`),ye=Ge(`gecko`)&&!me&&!U&&!V,be=!ve&&Ge(`safari`),xe=Ge(`phantom`),Se=`OTransition`in de,Ce=navigator.platform.indexOf(`Win`)===0,we=V&&`transition`in de,Te=`WebKitCSSMatrix`in window&&`m11`in new window.WebKitCSSMatrix&&!he,Ee=`MozPerspective`in de,De=!window.L_DISABLE_3D&&(we||Te||Ee)&&!Se&&!xe,Oe=typeof orientation<`u`||Ge(`mobile`),ke=Oe&&me,Ae=Oe&&Te,je=!window.PointerEvent&&window.MSPointerEvent,Me=!!(window.PointerEvent||je),Ne=`ontouchstart`in window||!!window.TouchEvent,Pe=!window.L_NO_TOUCH&&(Ne||Me),Fe=Oe&&U,Ie=Oe&&ye,Le=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,Re=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener(`testPassiveEventSupport`,l,t),window.removeEventListener(`testPassiveEventSupport`,l,t)}catch{}return e}(),ze=function(){return!!document.createElement(`canvas`).getContext}(),Be=!!(document.createElementNS&&le(`svg`).createSVGRect),Ve=!!Be&&(function(){var e=document.createElement(`div`);return e.innerHTML=`<svg/>`,(e.firstChild&&e.firstChild.namespaceURI)===`http://www.w3.org/2000/svg`})(),He=!Be&&function(){try{var e=document.createElement(`div`);e.innerHTML=`<v:shape adj="1"/>`;var t=e.firstChild;return t.style.behavior=`url(#default#VML)`,t&&typeof t.adj==`object`}catch{return!1}}(),Ue=navigator.platform.indexOf(`Mac`)===0,We=navigator.platform.indexOf(`Linux`)===0;function Ge(e){return navigator.userAgent.toLowerCase().indexOf(e)>=0}var W={ie:V,ielt9:fe,edge:pe,webkit:me,android:H,android23:he,androidStock:_e,opera:U,chrome:ve,gecko:ye,safari:be,phantom:xe,opera12:Se,win:Ce,ie3d:we,webkit3d:Te,gecko3d:Ee,any3d:De,mobile:Oe,mobileWebkit:ke,mobileWebkit3d:Ae,msPointer:je,pointer:Me,touch:Pe,touchNative:Ne,mobileOpera:Fe,mobileGecko:Ie,retina:Le,passiveEvents:Re,canvas:ze,svg:Be,vml:He,inlineSvg:Ve,mac:Ue,linux:We},Ke=W.msPointer?`MSPointerDown`:`pointerdown`,G=W.msPointer?`MSPointerMove`:`pointermove`,qe=W.msPointer?`MSPointerUp`:`pointerup`,Je=W.msPointer?`MSPointerCancel`:`pointercancel`,Ye={touchstart:Ke,touchmove:G,touchend:qe,touchcancel:Je},Xe={touchstart:Y,touchmove:nt,touchend:nt,touchcancel:nt},Ze={},Qe=!1;function K(e,t,n){return t===`touchstart`&&tt(),Xe[t]?(n=Xe[t].bind(this,n),e.addEventListener(Ye[t],n,!1),n):(console.warn(`wrong event specified:`,t),l)}function q(e,t,n){Ye[t]?e.removeEventListener(Ye[t],n,!1):console.warn(`wrong event specified:`,t)}function $e(e){Ze[e.pointerId]=e}function et(e){Ze[e.pointerId]&&(Ze[e.pointerId]=e)}function J(e){delete Ze[e.pointerId]}function tt(){Qe||=(document.addEventListener(Ke,$e,!0),document.addEventListener(G,et,!0),document.addEventListener(qe,J,!0),document.addEventListener(Je,J,!0),!0)}function nt(e,t){if(t.pointerType!==(t.MSPOINTER_TYPE_MOUSE||`mouse`)){for(var n in t.touches=[],Ze)t.touches.push(Ze[n]);t.changedTouches=[t],e(t)}}function Y(e,t){t.MSPOINTER_TYPE_TOUCH&&t.pointerType===t.MSPOINTER_TYPE_TOUCH&&Jt(t),nt(e,t)}function rt(e){var t={},n,r;for(r in e)n=e[r],t[r]=n&&n.bind?n.bind(e):n;return e=t,t.type=`dblclick`,t.detail=2,t.isTrusted=!1,t._simulated=!0,t}var it=200;function at(e,t){e.addEventListener(`dblclick`,t);var n=0,r;function i(e){if(e.detail!==1)r=e.detail;else if(!(e.pointerType===`mouse`||e.sourceCapabilities&&!e.sourceCapabilities.firesTouchEvents)){var i=Xt(e);if(!i.some(function(e){return e instanceof HTMLLabelElement&&e.attributes.for})||i.some(function(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement})){var a=Date.now();a-n<=it?(r++,r===2&&t(rt(e))):r=1,n=a}}}return e.addEventListener(`click`,i),{dblclick:t,simDblclick:i}}function X(e,t){e.removeEventListener(`dblclick`,t.dblclick),e.removeEventListener(`click`,t.simDblclick)}var ot=St([`transform`,`webkitTransform`,`OTransform`,`MozTransform`,`msTransform`]),st=St([`webkitTransition`,`transition`,`OTransition`,`MozTransition`,`msTransition`]),ct=st===`webkitTransition`||st===`OTransition`?st+`End`:`transitionend`;function lt(e){return typeof e==`string`?document.getElementById(e):e}function ut(e,t){var n=e.style[t]||e.currentStyle&&e.currentStyle[t];if((!n||n===`auto`)&&document.defaultView){var r=document.defaultView.getComputedStyle(e,null);n=r?r[t]:null}return n===`auto`?null:n}function dt(e,t,n){var r=document.createElement(e);return r.className=t||``,n&&n.appendChild(r),r}function ft(e){var t=e.parentNode;t&&t.removeChild(e)}function pt(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function mt(e){var t=e.parentNode;t&&t.lastChild!==e&&t.appendChild(e)}function ht(e){var t=e.parentNode;t&&t.firstChild!==e&&t.insertBefore(e,t.firstChild)}function gt(e,t){if(e.classList!==void 0)return e.classList.contains(t);var n=bt(e);return n.length>0&&RegExp(`(^|\\s)`+t+`(\\s|$)`).test(n)}function _t(e,t){if(e.classList!==void 0)for(var n=f(t),r=0,i=n.length;r<i;r++)e.classList.add(n[r]);else if(!gt(e,t)){var a=bt(e);yt(e,(a?a+` `:``)+t)}}function vt(e,t){e.classList===void 0?yt(e,d((` `+bt(e)+` `).replace(` `+t+` `,` `))):e.classList.remove(t)}function yt(e,t){e.className.baseVal===void 0?e.className=t:e.className.baseVal=t}function bt(e){return e.correspondingElement&&(e=e.correspondingElement),e.className.baseVal===void 0?e.className:e.className.baseVal}function Z(e,t){`opacity`in e.style?e.style.opacity=t:`filter`in e.style&&xt(e,t)}function xt(e,t){var n=!1,r=`DXImageTransform.Microsoft.Alpha`;try{n=e.filters.item(r)}catch{if(t===1)return}t=Math.round(t*100),n?(n.Enabled=t!==100,n.Opacity=t):e.style.filter+=` progid:`+r+`(opacity=`+t+`)`}function St(e){for(var t=document.documentElement.style,n=0;n<e.length;n++)if(e[n]in t)return e[n];return!1}function Q(e,t,n){var r=t||new j(0,0);e.style[ot]=(W.ie3d?`translate(`+r.x+`px,`+r.y+`px)`:`translate3d(`+r.x+`px,`+r.y+`px,0)`)+(n?` scale(`+n+`)`:``)}function Ct(e,t){e._leaflet_pos=t,W.any3d?Q(e,t):(e.style.left=t.x+`px`,e.style.top=t.y+`px`)}function wt(e){return e._leaflet_pos||new j(0,0)}var Tt,Et,Dt;if(`onselectstart`in document)Tt=function(){Rt(window,`selectstart`,Jt)},Et=function(){Bt(window,`selectstart`,Jt)};else{var Ot=St([`userSelect`,`WebkitUserSelect`,`OUserSelect`,`MozUserSelect`,`msUserSelect`]);Tt=function(){if(Ot){var e=document.documentElement.style;Dt=e[Ot],e[Ot]=`none`}},Et=function(){Ot&&(document.documentElement.style[Ot]=Dt,Dt=void 0)}}function kt(){Rt(window,`dragstart`,Jt)}function At(){Bt(window,`dragstart`,Jt)}var jt,Mt;function Nt(e){for(;e.tabIndex===-1;)e=e.parentNode;e.style&&(Pt(),jt=e,Mt=e.style.outlineStyle,e.style.outlineStyle=`none`,Rt(window,`keydown`,Pt))}function Pt(){jt&&(jt.style.outlineStyle=Mt,jt=void 0,Mt=void 0,Bt(window,`keydown`,Pt))}function Ft(e){do e=e.parentNode;while((!e.offsetWidth||!e.offsetHeight)&&e!==document.body);return e}function It(e){var t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}var Lt={__proto__:null,TRANSFORM:ot,TRANSITION:st,TRANSITION_END:ct,get:lt,getStyle:ut,create:dt,remove:ft,empty:pt,toFront:mt,toBack:ht,hasClass:gt,addClass:_t,removeClass:vt,setClass:yt,getClass:bt,setOpacity:Z,testProp:St,setTransform:Q,setPosition:Ct,getPosition:wt,get disableTextSelection(){return Tt},get enableTextSelection(){return Et},disableImageDrag:kt,enableImageDrag:At,preventOutline:Nt,restoreOutline:Pt,getSizedParentNode:Ft,getScale:It};function Rt(e,t,n,r){if(t&&typeof t==`object`)for(var i in t)Ut(e,i,t[i],n);else{t=f(t);for(var a=0,o=t.length;a<o;a++)Ut(e,t[a],n,r)}return this}var zt=`_leaflet_events`;function Bt(e,t,n,r){if(arguments.length===1)Vt(e),delete e[zt];else if(t&&typeof t==`object`)for(var i in t)Wt(e,i,t[i],n);else if(t=f(t),arguments.length===2)Vt(e,function(e){return v(t,e)!==-1});else for(var a=0,o=t.length;a<o;a++)Wt(e,t[a],n,r);return this}function Vt(e,t){for(var n in e[zt]){var r=n.split(/\d/)[0];(!t||t(r))&&Wt(e,r,null,null,n)}}var Ht={mouseenter:`mouseover`,mouseleave:`mouseout`,wheel:!(`onwheel`in window)&&`mousewheel`};function Ut(e,t,n,r){var i=t+o(n)+(r?`_`+o(r):``);if(e[zt]&&e[zt][i])return this;var a=function(t){return n.call(r||e,t||window.event)},s=a;!W.touchNative&&W.pointer&&t.indexOf(`touch`)===0?a=K(e,t,a):W.touch&&t===`dblclick`?a=at(e,a):`addEventListener`in e?t===`touchstart`||t===`touchmove`||t===`wheel`||t===`mousewheel`?e.addEventListener(Ht[t]||t,a,W.passiveEvents?{passive:!1}:!1):t===`mouseenter`||t===`mouseleave`?(a=function(t){t||=window.event,en(e,t)&&s(t)},e.addEventListener(Ht[t],a,!1)):e.addEventListener(t,s,!1):e.attachEvent(`on`+t,a),e[zt]=e[zt]||{},e[zt][i]=a}function Wt(e,t,n,r,i){i||=t+o(n)+(r?`_`+o(r):``);var a=e[zt]&&e[zt][i];if(!a)return this;!W.touchNative&&W.pointer&&t.indexOf(`touch`)===0?q(e,t,a):W.touch&&t===`dblclick`?X(e,a):`removeEventListener`in e?e.removeEventListener(Ht[t]||t,a,!1):e.detachEvent(`on`+t,a),e[zt][i]=null}function Gt(e){return e.stopPropagation?e.stopPropagation():e.originalEvent?e.originalEvent._stopped=!0:e.cancelBubble=!0,this}function Kt(e){return Ut(e,`wheel`,Gt),this}function qt(e){return Rt(e,`mousedown touchstart dblclick contextmenu`,Gt),e._leaflet_disable_click=!0,this}function Jt(e){return e.preventDefault?e.preventDefault():e.returnValue=!1,this}function Yt(e){return Jt(e),Gt(e),this}function Xt(e){if(e.composedPath)return e.composedPath();for(var t=[],n=e.target;n;)t.push(n),n=n.parentNode;return t}function Zt(e,t){if(!t)return new j(e.clientX,e.clientY);var n=It(t),r=n.boundingClientRect;return new j((e.clientX-r.left)/n.x-t.clientLeft,(e.clientY-r.top)/n.y-t.clientTop)}var Qt=W.linux&&W.chrome?window.devicePixelRatio:W.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function $t(e){return W.edge?e.wheelDeltaY/2:e.deltaY&&e.deltaMode===0?-e.deltaY/Qt:e.deltaY&&e.deltaMode===1?-e.deltaY*20:e.deltaY&&e.deltaMode===2?-e.deltaY*60:e.deltaX||e.deltaZ?0:e.wheelDelta?(e.wheelDeltaY||e.wheelDelta)/2:e.detail&&Math.abs(e.detail)<32765?-e.detail*20:e.detail?e.detail/-32765*60:0}function en(e,t){var n=t.relatedTarget;if(!n)return!0;try{for(;n&&n!==e;)n=n.parentNode}catch{return!1}return n!==e}var tn={__proto__:null,on:Rt,off:Bt,stopPropagation:Gt,disableScrollPropagation:Kt,disableClickPropagation:qt,preventDefault:Jt,stop:Yt,getPropagationPath:Xt,getMousePosition:Zt,getWheelDelta:$t,isExternalTarget:en,addListener:Rt,removeListener:Bt},nn=A.extend({run:function(e,t,n,r){this.stop(),this._el=e,this._inProgress=!0,this._duration=n||.25,this._easeOutPower=1/Math.max(r||.5,.2),this._startPos=wt(e),this._offset=t.subtract(this._startPos),this._startTime=+new Date,this.fire(`start`),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=T(this._animate,this),this._step()},_step:function(e){var t=+new Date-this._startTime,n=this._duration*1e3;t<n?this._runFrame(this._easeOut(t/n),e):(this._runFrame(1),this._complete())},_runFrame:function(e,t){var n=this._startPos.add(this._offset.multiplyBy(e));t&&n._round(),Ct(this._el,n),this.fire(`step`)},_complete:function(){E(this._animId),this._inProgress=!1,this.fire(`end`)},_easeOut:function(e){return 1-(1-e)**this._easeOutPower}}),rn=A.extend({options:{crs:se,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(e,t){t=p(this,t),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(e),this._initLayout(),this._onResize=i(this._onResize,this),this._initEvents(),t.maxBounds&&this.setMaxBounds(t.maxBounds),t.zoom!==void 0&&(this._zoom=this._limitZoom(t.zoom)),t.center&&t.zoom!==void 0&&this.setView(z(t.center),t.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=st&&W.any3d&&!W.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),Rt(this._proxy,ct,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(e,t,r){return t=t===void 0?this._zoom:this._limitZoom(t),e=this._limitCenter(z(e),t,this.options.maxBounds),r||={},this._stop(),this._loaded&&!r.reset&&r!==!0&&(r.animate!==void 0&&(r.zoom=n({animate:r.animate},r.zoom),r.pan=n({animate:r.animate,duration:r.duration},r.pan)),this._zoom===t?this._tryAnimatedPan(e,r.pan):this._tryAnimatedZoom&&this._tryAnimatedZoom(e,t,r.zoom))?(clearTimeout(this._sizeTimer),this):(this._resetView(e,t,r.pan&&r.pan.noMoveStart),this)},setZoom:function(e,t){return this._loaded?this.setView(this.getCenter(),e,{zoom:t}):(this._zoom=e,this)},zoomIn:function(e,t){return e||=W.any3d?this.options.zoomDelta:1,this.setZoom(this._zoom+e,t)},zoomOut:function(e,t){return e||=W.any3d?this.options.zoomDelta:1,this.setZoom(this._zoom-e,t)},setZoomAround:function(e,t,n){var r=this.getZoomScale(t),i=this.getSize().divideBy(2),a=(e instanceof j?e:this.latLngToContainerPoint(e)).subtract(i).multiplyBy(1-1/r),o=this.containerPointToLatLng(i.add(a));return this.setView(o,t,{zoom:n})},_getBoundsCenterZoom:function(e,t){t||={},e=e.getBounds?e.getBounds():te(e);var n=N(t.paddingTopLeft||t.padding||[0,0]),r=N(t.paddingBottomRight||t.padding||[0,0]),i=this.getBoundsZoom(e,!1,n.add(r));if(i=typeof t.maxZoom==`number`?Math.min(t.maxZoom,i):i,i===1/0)return{center:e.getCenter(),zoom:i};var a=r.subtract(n).divideBy(2),o=this.project(e.getSouthWest(),i),s=this.project(e.getNorthEast(),i);return{center:this.unproject(o.add(s).divideBy(2).add(a),i),zoom:i}},fitBounds:function(e,t){if(e=te(e),!e.isValid())throw Error(`Bounds are not valid.`);var n=this._getBoundsCenterZoom(e,t);return this.setView(n.center,n.zoom,t)},fitWorld:function(e){return this.fitBounds([[-90,-180],[90,180]],e)},panTo:function(e,t){return this.setView(e,this._zoom,{pan:t})},panBy:function(e,t){if(e=N(e).round(),t||={},!e.x&&!e.y)return this.fire(`moveend`);if(t.animate!==!0&&!this.getSize().contains(e))return this._resetView(this.unproject(this.project(this.getCenter()).add(e)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new nn,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),t.noMoveStart||this.fire(`movestart`),t.animate!==!1){_t(this._mapPane,`leaflet-pan-anim`);var n=this._getMapPanePos().subtract(e).round();this._panAnim.run(this._mapPane,n,t.duration||.25,t.easeLinearity)}else this._rawPanBy(e),this.fire(`move`).fire(`moveend`);return this},flyTo:function(e,t,n){if(n||={},n.animate===!1||!W.any3d)return this.setView(e,t,n);this._stop();var r=this.project(this.getCenter()),i=this.project(e),a=this.getSize(),o=this._zoom;e=z(e),t=t===void 0?o:t;var s=Math.max(a.x,a.y),c=s*this.getZoomScale(o,t),l=i.distanceTo(r)||1,u=1.42,d=u*u;function f(e){var t=e?-1:1,n=e?c:s,r=(c*c-s*s+t*d*d*l*l)/(2*n*d*l),i=Math.sqrt(r*r+1)-r;return i<1e-9?-18:Math.log(i)}function p(e){return(Math.exp(e)-Math.exp(-e))/2}function m(e){return(Math.exp(e)+Math.exp(-e))/2}function h(e){return p(e)/m(e)}var g=f(0);function _(e){return s*(m(g)/m(g+u*e))}function v(e){return s*(m(g)*h(g+u*e)-p(g))/d}function y(e){return 1-(1-e)**1.5}var b=Date.now(),x=(f(1)-g)/u,S=n.duration?1e3*n.duration:1e3*x*.8;function C(){var n=(Date.now()-b)/S,a=y(n)*x;n<=1?(this._flyToFrame=T(C,this),this._move(this.unproject(r.add(i.subtract(r).multiplyBy(v(a)/l)),o),this.getScaleZoom(s/_(a),o),{flyTo:!0})):this._move(e,t)._moveEnd(!0)}return this._moveStart(!0,n.noMoveStart),C.call(this),this},flyToBounds:function(e,t){var n=this._getBoundsCenterZoom(e,t);return this.flyTo(n.center,n.zoom,t)},setMaxBounds:function(e){return e=te(e),this.listens(`moveend`,this._panInsideMaxBounds)&&this.off(`moveend`,this._panInsideMaxBounds),e.isValid()?(this.options.maxBounds=e,this._loaded&&this._panInsideMaxBounds(),this.on(`moveend`,this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(e){var t=this.options.minZoom;return this.options.minZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()<this.options.minZoom)?this.setZoom(e):this},setMaxZoom:function(e){var t=this.options.maxZoom;return this.options.maxZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()>this.options.maxZoom)?this.setZoom(e):this},panInsideBounds:function(e,t){this._enforcingBounds=!0;var n=this.getCenter(),r=this._limitCenter(n,this._zoom,te(e));return n.equals(r)||this.panTo(r,t),this._enforcingBounds=!1,this},panInside:function(e,t){t||={};var n=N(t.paddingTopLeft||t.padding||[0,0]),r=N(t.paddingBottomRight||t.padding||[0,0]),i=this.project(this.getCenter()),a=this.project(e),o=this.getPixelBounds(),s=F([o.min.add(n),o.max.subtract(r)]),c=s.getSize();if(!s.contains(a)){this._enforcingBounds=!0;var l=a.subtract(s.getCenter()),u=s.extend(a).getSize().subtract(c);i.x+=l.x<0?-u.x:u.x,i.y+=l.y<0?-u.y:u.y,this.panTo(this.unproject(i),t),this._enforcingBounds=!1}return this},invalidateSize:function(e){if(!this._loaded)return this;e=n({animate:!1,pan:!0},e===!0?{animate:!0}:e);var t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var r=this.getSize(),a=t.divideBy(2).round(),o=r.divideBy(2).round(),s=a.subtract(o);return!s.x&&!s.y?this:(e.animate&&e.pan?this.panBy(s):(e.pan&&this._rawPanBy(s),this.fire(`move`),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(i(this.fire,this,`moveend`),200)):this.fire(`moveend`)),this.fire(`resize`,{oldSize:t,newSize:r}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire(`viewreset`),this._stop()},locate:function(e){if(e=this._locateOptions=n({timeout:1e4,watch:!1},e),!(`geolocation`in navigator))return this._handleGeolocationError({code:0,message:`Geolocation not supported.`}),this;var t=i(this._handleGeolocationResponse,this),r=i(this._handleGeolocationError,this);return e.watch?this._locationWatchId=navigator.geolocation.watchPosition(t,r,e):navigator.geolocation.getCurrentPosition(t,r,e),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(e){if(this._container._leaflet_id){var t=e.code,n=e.message||(t===1?`permission denied`:t===2?`position unavailable`:`timeout`);this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire(`locationerror`,{code:t,message:`Geolocation error: `+n+`.`})}},_handleGeolocationResponse:function(e){if(this._container._leaflet_id){var t=e.coords.latitude,n=e.coords.longitude,r=new R(t,n),i=r.toBounds(e.coords.accuracy*2),a=this._locateOptions;if(a.setView){var o=this.getBoundsZoom(i);this.setView(r,a.maxZoom?Math.min(o,a.maxZoom):o)}var s={latlng:r,bounds:i,timestamp:e.timestamp};for(var c in e.coords)typeof e.coords[c]==`number`&&(s[c]=e.coords[c]);this.fire(`locationfound`,s)}},addHandler:function(e,t){if(!t)return this;var n=this[e]=new t(this);return this._handlers.push(n),this.options[e]&&n.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off(`moveend`,this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw Error(`Map container is being reused by another instance`);try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}for(var e in this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),ft(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&=(E(this._resizeRequest),null),this._clearHandlers(),this._loaded&&this.fire(`unload`),this._layers)this._layers[e].remove();for(e in this._panes)ft(this._panes[e]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(e,t){var n=dt(`div`,`leaflet-pane`+(e?` leaflet-`+e.replace(`Pane`,``)+`-pane`:``),t||this._mapPane);return e&&(this._panes[e]=n),n},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var e=this.getPixelBounds();return new I(this.unproject(e.getBottomLeft()),this.unproject(e.getTopRight()))},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(e,t,n){e=te(e),n=N(n||[0,0]);var r=this.getZoom()||0,i=this.getMinZoom(),a=this.getMaxZoom(),o=e.getNorthWest(),s=e.getSouthEast(),c=this.getSize().subtract(n),l=F(this.project(s,r),this.project(o,r)).getSize(),u=W.any3d?this.options.zoomSnap:1,d=c.x/l.x,f=c.y/l.y,p=t?Math.max(d,f):Math.min(d,f);return r=this.getScaleZoom(p,r),u&&(r=Math.round(r/(u/100))*(u/100),r=t?Math.ceil(r/u)*u:Math.floor(r/u)*u),Math.max(i,Math.min(a,r))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new j(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(e,t){var n=this._getTopLeftPoint(e,t);return new P(n,n.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(e){return this.options.crs.getProjectedBounds(e===void 0?this.getZoom():e)},getPane:function(e){return typeof e==`string`?this._panes[e]:e},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(e,t){var n=this.options.crs;return t=t===void 0?this._zoom:t,n.scale(e)/n.scale(t)},getScaleZoom:function(e,t){var n=this.options.crs;t=t===void 0?this._zoom:t;var r=n.zoom(e*n.scale(t));return isNaN(r)?1/0:r},project:function(e,t){return t=t===void 0?this._zoom:t,this.options.crs.latLngToPoint(z(e),t)},unproject:function(e,t){return t=t===void 0?this._zoom:t,this.options.crs.pointToLatLng(N(e),t)},layerPointToLatLng:function(e){var t=N(e).add(this.getPixelOrigin());return this.unproject(t)},latLngToLayerPoint:function(e){return this.project(z(e))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(e){return this.options.crs.wrapLatLng(z(e))},wrapLatLngBounds:function(e){return this.options.crs.wrapLatLngBounds(te(e))},distance:function(e,t){return this.options.crs.distance(z(e),z(t))},containerPointToLayerPoint:function(e){return N(e).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(e){return N(e).add(this._getMapPanePos())},containerPointToLatLng:function(e){var t=this.containerPointToLayerPoint(N(e));return this.layerPointToLatLng(t)},latLngToContainerPoint:function(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(z(e)))},mouseEventToContainerPoint:function(e){return Zt(e,this._container)},mouseEventToLayerPoint:function(e){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e))},mouseEventToLatLng:function(e){return this.layerPointToLatLng(this.mouseEventToLayerPoint(e))},_initContainer:function(e){var t=this._container=lt(e);if(!t)throw Error(`Map container not found.`);if(t._leaflet_id)throw Error(`Map container is already initialized.`);Rt(t,`scroll`,this._onScroll,this),this._containerId=o(t)},_initLayout:function(){var e=this._container;this._fadeAnimated=this.options.fadeAnimation&&W.any3d,_t(e,`leaflet-container`+(W.touch?` leaflet-touch`:``)+(W.retina?` leaflet-retina`:``)+(W.ielt9?` leaflet-oldie`:``)+(W.safari?` leaflet-safari`:``)+(this._fadeAnimated?` leaflet-fade-anim`:``));var t=ut(e,`position`);t!==`absolute`&&t!==`relative`&&t!==`fixed`&&t!==`sticky`&&(e.style.position=`relative`),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var e=this._panes={};this._paneRenderers={},this._mapPane=this.createPane(`mapPane`,this._container),Ct(this._mapPane,new j(0,0)),this.createPane(`tilePane`),this.createPane(`overlayPane`),this.createPane(`shadowPane`),this.createPane(`markerPane`),this.createPane(`tooltipPane`),this.createPane(`popupPane`),this.options.markerZoomAnimation||(_t(e.markerPane,`leaflet-zoom-hide`),_t(e.shadowPane,`leaflet-zoom-hide`))},_resetView:function(e,t,n){Ct(this._mapPane,new j(0,0));var r=!this._loaded;this._loaded=!0,t=this._limitZoom(t),this.fire(`viewprereset`);var i=this._zoom!==t;this._moveStart(i,n)._move(e,t)._moveEnd(i),this.fire(`viewreset`),r&&this.fire(`load`)},_moveStart:function(e,t){return e&&this.fire(`zoomstart`),t||this.fire(`movestart`),this},_move:function(e,t,n,r){t===void 0&&(t=this._zoom);var i=this._zoom!==t;return this._zoom=t,this._lastCenter=e,this._pixelOrigin=this._getNewPixelOrigin(e),r?n&&n.pinch&&this.fire(`zoom`,n):((i||n&&n.pinch)&&this.fire(`zoom`,n),this.fire(`move`,n)),this},_moveEnd:function(e){return e&&this.fire(`zoomend`),this.fire(`moveend`)},_stop:function(){return E(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(e){Ct(this._mapPane,this._getMapPanePos().subtract(e))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw Error(`Set map center and zoom first.`)},_initEvents:function(e){this._targets={},this._targets[o(this._container)]=this;var t=e?Bt:Rt;t(this._container,`click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup`,this._handleDOMEvent,this),this.options.trackResize&&t(window,`resize`,this._onResize,this),W.any3d&&this.options.transform3DLimit&&(e?this.off:this.on).call(this,`moveend`,this._onMoveEnd)},_onResize:function(){E(this._resizeRequest),this._resizeRequest=T(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var e=this._getMapPanePos();Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(e,t){for(var n=[],r,i=t===`mouseout`||t===`mouseover`,a=e.target||e.srcElement,s=!1;a;){if(r=this._targets[o(a)],r&&(t===`click`||t===`preclick`)&&this._draggableMoved(r)){s=!0;break}if(r&&r.listens(t,!0)&&(i&&!en(a,e)||(n.push(r),i))||a===this._container)break;a=a.parentNode}return!n.length&&!s&&!i&&this.listens(t,!0)&&(n=[this]),n},_isClickDisabled:function(e){for(;e&&e!==this._container;){if(e._leaflet_disable_click)return!0;e=e.parentNode}},_handleDOMEvent:function(e){var t=e.target||e.srcElement;if(!(!this._loaded||t._leaflet_disable_events||e.type===`click`&&this._isClickDisabled(t))){var n=e.type;n===`mousedown`&&Nt(t),this._fireDOMEvent(e,n)}},_mouseEvents:[`click`,`dblclick`,`mouseover`,`mouseout`,`contextmenu`],_fireDOMEvent:function(e,t,r){if(e.type===`click`){var i=n({},e);i.type=`preclick`,this._fireDOMEvent(i,i.type,r)}var a=this._findEventTargets(e,t);if(r){for(var o=[],s=0;s<r.length;s++)r[s].listens(t,!0)&&o.push(r[s]);a=o.concat(a)}if(a.length){t===`contextmenu`&&Jt(e);var c=a[0],l={originalEvent:e};if(e.type!==`keypress`&&e.type!==`keydown`&&e.type!==`keyup`){var u=c.getLatLng&&(!c._radius||c._radius<=10);l.containerPoint=u?this.latLngToContainerPoint(c.getLatLng()):this.mouseEventToContainerPoint(e),l.layerPoint=this.containerPointToLayerPoint(l.containerPoint),l.latlng=u?c.getLatLng():this.layerPointToLatLng(l.layerPoint)}for(s=0;s<a.length;s++)if(a[s].fire(t,l,!0),l.originalEvent._stopped||a[s].options.bubblingMouseEvents===!1&&v(this._mouseEvents,t)!==-1)return}},_draggableMoved:function(e){return e=e.dragging&&e.dragging.enabled()?e:this,e.dragging&&e.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var e=0,t=this._handlers.length;e<t;e++)this._handlers[e].disable()},whenReady:function(e,t){return this._loaded?e.call(t||this,{target:this}):this.on(`load`,e,t),this},_getMapPanePos:function(){return wt(this._mapPane)||new j(0,0)},_moved:function(){var e=this._getMapPanePos();return e&&!e.equals([0,0])},_getTopLeftPoint:function(e,t){return(e&&t!==void 0?this._getNewPixelOrigin(e,t):this.getPixelOrigin()).subtract(this._getMapPanePos())},_getNewPixelOrigin:function(e,t){var n=this.getSize()._divideBy(2);return this.project(e,t)._subtract(n)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(e,t,n){var r=this._getNewPixelOrigin(n,t);return this.project(e,t)._subtract(r)},_latLngBoundsToNewLayerBounds:function(e,t,n){var r=this._getNewPixelOrigin(n,t);return F([this.project(e.getSouthWest(),t)._subtract(r),this.project(e.getNorthWest(),t)._subtract(r),this.project(e.getSouthEast(),t)._subtract(r),this.project(e.getNorthEast(),t)._subtract(r)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(e){return this.latLngToLayerPoint(e).subtract(this._getCenterLayerPoint())},_limitCenter:function(e,t,n){if(!n)return e;var r=this.project(e,t),i=this.getSize().divideBy(2),a=new P(r.subtract(i),r.add(i)),o=this._getBoundsOffset(a,n,t);return Math.abs(o.x)<=1&&Math.abs(o.y)<=1?e:this.unproject(r.add(o),t)},_limitOffset:function(e,t){if(!t)return e;var n=this.getPixelBounds(),r=new P(n.min.add(e),n.max.add(e));return e.add(this._getBoundsOffset(r,t))},_getBoundsOffset:function(e,t,n){var r=F(this.project(t.getNorthEast(),n),this.project(t.getSouthWest(),n)),i=r.min.subtract(e.min),a=r.max.subtract(e.max);return new j(this._rebound(i.x,-a.x),this._rebound(i.y,-a.y))},_rebound:function(e,t){return e+t>0?Math.round(e-t)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(t))},_limitZoom:function(e){var t=this.getMinZoom(),n=this.getMaxZoom(),r=W.any3d?this.options.zoomSnap:1;return r&&(e=Math.round(e/r)*r),Math.max(t,Math.min(n,e))},_onPanTransitionStep:function(){this.fire(`move`)},_onPanTransitionEnd:function(){vt(this._mapPane,`leaflet-pan-anim`),this.fire(`moveend`)},_tryAnimatedPan:function(e,t){var n=this._getCenterOffset(e)._trunc();return(t&&t.animate)!==!0&&!this.getSize().contains(n)?!1:(this.panBy(n,t),!0)},_createAnimProxy:function(){var e=this._proxy=dt(`div`,`leaflet-proxy leaflet-zoom-animated`);this._panes.mapPane.appendChild(e),this.on(`zoomanim`,function(e){var t=ot,n=this._proxy.style[t];Q(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),n===this._proxy.style[t]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on(`load moveend`,this._animMoveEnd,this),this._on(`unload`,this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ft(this._proxy),this.off(`load moveend`,this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var e=this.getCenter(),t=this.getZoom();Q(this._proxy,this.project(e,t),this.getZoomScale(t,1))},_catchTransitionEnd:function(e){this._animatingZoom&&e.propertyName.indexOf(`transform`)>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName(`leaflet-zoom-animated`).length},_tryAnimatedZoom:function(e,t,n){if(this._animatingZoom)return!0;if(n||={},!this._zoomAnimated||n.animate===!1||this._nothingToAnimate()||Math.abs(t-this._zoom)>this.options.zoomAnimationThreshold)return!1;var r=this.getZoomScale(t),i=this._getCenterOffset(e)._divideBy(1-1/r);return n.animate!==!0&&!this.getSize().contains(i)?!1:(T(function(){this._moveStart(!0,n.noMoveStart||!1)._animateZoom(e,t,!0)},this),!0)},_animateZoom:function(e,t,n,r){this._mapPane&&(n&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=t,_t(this._mapPane,`leaflet-zoom-anim`)),this.fire(`zoomanim`,{center:e,zoom:t,noUpdate:r}),this._tempFireZoomEvent||=this._zoom!==this._animateToZoom,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(i(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&vt(this._mapPane,`leaflet-zoom-anim`),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire(`zoom`),delete this._tempFireZoomEvent,this.fire(`move`),this._moveEnd(!0))}});function an(e,t){return new rn(e,t)}var on=O.extend({options:{position:`topright`},initialize:function(e){p(this,e)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;return t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this),this},getContainer:function(){return this._container},addTo:function(e){this.remove(),this._map=e;var t=this._container=this.onAdd(e),n=this.getPosition(),r=e._controlCorners[n];return _t(t,`leaflet-control`),n.indexOf(`bottom`)===-1?r.appendChild(t):r.insertBefore(t,r.firstChild),this._map.on(`unload`,this.remove,this),this},remove:function(){return this._map&&=(ft(this._container),this.onRemove&&this.onRemove(this._map),this._map.off(`unload`,this.remove,this),null),this},_refocusOnMap:function(e){this._map&&e&&e.screenX>0&&e.screenY>0&&this._map.getContainer().focus()}}),sn=function(e){return new on(e)};rn.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.remove(),this},_initControlPos:function(){var e=this._controlCorners={},t=`leaflet-`,n=this._controlContainer=dt(`div`,t+`control-container`,this._container);function r(r,i){var a=t+r+` `+t+i;e[r+i]=dt(`div`,a,n)}r(`top`,`left`),r(`top`,`right`),r(`bottom`,`left`),r(`bottom`,`right`)},_clearControlPos:function(){for(var e in this._controlCorners)ft(this._controlCorners[e]);ft(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var cn=on.extend({options:{collapsed:!0,position:`topright`,autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(e,t,n,r){return n<r?-1:+(r<n)}},initialize:function(e,t,n){for(var r in p(this,n),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1,e)this._addLayer(e[r],r);for(r in t)this._addLayer(t[r],r,!0)},onAdd:function(e){this._initLayout(),this._update(),this._map=e,e.on(`zoomend`,this._checkDisabledLayers,this);for(var t=0;t<this._layers.length;t++)this._layers[t].layer.on(`add remove`,this._onLayerChange,this);return this._container},addTo:function(e){return on.prototype.addTo.call(this,e),this._expandIfNotCollapsed()},onRemove:function(){this._map.off(`zoomend`,this._checkDisabledLayers,this);for(var e=0;e<this._layers.length;e++)this._layers[e].layer.off(`add remove`,this._onLayerChange,this)},addBaseLayer:function(e,t){return this._addLayer(e,t),this._map?this._update():this},addOverlay:function(e,t){return this._addLayer(e,t,!0),this._map?this._update():this},removeLayer:function(e){e.off(`add remove`,this._onLayerChange,this);var t=this._getLayer(o(e));return t&&this._layers.splice(this._layers.indexOf(t),1),this._map?this._update():this},expand:function(){_t(this._container,`leaflet-control-layers-expanded`),this._section.style.height=null;var e=this._map.getSize().y-(this._container.offsetTop+50);return e<this._section.clientHeight?(_t(this._section,`leaflet-control-layers-scrollbar`),this._section.style.height=e+`px`):vt(this._section,`leaflet-control-layers-scrollbar`),this._checkDisabledLayers(),this},collapse:function(){return vt(this._container,`leaflet-control-layers-expanded`),this},_initLayout:function(){var e=`leaflet-control-layers`,t=this._container=dt(`div`,e),n=this.options.collapsed;t.setAttribute(`aria-haspopup`,!0),qt(t),Kt(t);var r=this._section=dt(`section`,e+`-list`);n&&(this._map.on(`click`,this.collapse,this),Rt(t,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var i=this._layersLink=dt(`a`,e+`-toggle`,t);i.href=`#`,i.title=`Layers`,i.setAttribute(`role`,`button`),Rt(i,{keydown:function(e){e.keyCode===13&&this._expandSafely()},click:function(e){Jt(e),this._expandSafely()}},this),n||this.expand(),this._baseLayersList=dt(`div`,e+`-base`,r),this._separator=dt(`div`,e+`-separator`,r),this._overlaysList=dt(`div`,e+`-overlays`,r),t.appendChild(r)},_getLayer:function(e){for(var t=0;t<this._layers.length;t++)if(this._layers[t]&&o(this._layers[t].layer)===e)return this._layers[t]},_addLayer:function(e,t,n){this._map&&e.on(`add remove`,this._onLayerChange,this),this._layers.push({layer:e,name:t,overlay:n}),this.options.sortLayers&&this._layers.sort(i(function(e,t){return this.options.sortFunction(e.layer,t.layer,e.name,t.name)},this)),this.options.autoZIndex&&e.setZIndex&&(this._lastZIndex++,e.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;pt(this._baseLayersList),pt(this._overlaysList),this._layerControlInputs=[];var e,t,n,r,i=0;for(n=0;n<this._layers.length;n++)r=this._layers[n],this._addItem(r),t||=r.overlay,e||=!r.overlay,i+=+!r.overlay;return this.options.hideSingleBase&&(e&&=i>1,this._baseLayersList.style.display=e?``:`none`),this._separator.style.display=t&&e?``:`none`,this},_onLayerChange:function(e){this._handlingClick||this._update();var t=this._getLayer(o(e.target)),n=t.overlay?e.type===`add`?`overlayadd`:`overlayremove`:e.type===`add`?`baselayerchange`:null;n&&this._map.fire(n,t)},_createRadioElement:function(e,t){var n=`<input type="radio" class="leaflet-control-layers-selector" name="`+e+`"`+(t?` checked="checked"`:``)+`/>`,r=document.createElement(`div`);return r.innerHTML=n,r.firstChild},_addItem:function(e){var t=document.createElement(`label`),n=this._map.hasLayer(e.layer),r;e.overlay?(r=document.createElement(`input`),r.type=`checkbox`,r.className=`leaflet-control-layers-selector`,r.defaultChecked=n):r=this._createRadioElement(`leaflet-base-layers_`+o(this),n),this._layerControlInputs.push(r),r.layerId=o(e.layer),Rt(r,`click`,this._onInputClick,this);var i=document.createElement(`span`);i.innerHTML=` `+e.name;var a=document.createElement(`span`);return t.appendChild(a),a.appendChild(r),a.appendChild(i),(e.overlay?this._overlaysList:this._baseLayersList).appendChild(t),this._checkDisabledLayers(),t},_onInputClick:function(){if(!this._preventClick){var e=this._layerControlInputs,t,n,r=[],i=[];this._handlingClick=!0;for(var a=e.length-1;a>=0;a--)t=e[a],n=this._getLayer(t.layerId).layer,t.checked?r.push(n):t.checked||i.push(n);for(a=0;a<i.length;a++)this._map.hasLayer(i[a])&&this._map.removeLayer(i[a]);for(a=0;a<r.length;a++)this._map.hasLayer(r[a])||this._map.addLayer(r[a]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var e=this._layerControlInputs,t,n,r=this._map.getZoom(),i=e.length-1;i>=0;i--)t=e[i],n=this._getLayer(t.layerId).layer,t.disabled=n.options.minZoom!==void 0&&r<n.options.minZoom||n.options.maxZoom!==void 0&&r>n.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var e=this._section;this._preventClick=!0,Rt(e,`click`,Jt),this.expand();var t=this;setTimeout(function(){Bt(e,`click`,Jt),t._preventClick=!1})}}),ln=function(e,t,n){return new cn(e,t,n)},un=on.extend({options:{position:`topleft`,zoomInText:`<span aria-hidden="true">+</span>`,zoomInTitle:`Zoom in`,zoomOutText:`<span aria-hidden="true">&#x2212;</span>`,zoomOutTitle:`Zoom out`},onAdd:function(e){var t=`leaflet-control-zoom`,n=dt(`div`,t+` leaflet-bar`),r=this.options;return this._zoomInButton=this._createButton(r.zoomInText,r.zoomInTitle,t+`-in`,n,this._zoomIn),this._zoomOutButton=this._createButton(r.zoomOutText,r.zoomOutTitle,t+`-out`,n,this._zoomOut),this._updateDisabled(),e.on(`zoomend zoomlevelschange`,this._updateDisabled,this),n},onRemove:function(e){e.off(`zoomend zoomlevelschange`,this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(e){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(e.shiftKey?3:1))},_zoomOut:function(e){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(e.shiftKey?3:1))},_createButton:function(e,t,n,r,i){var a=dt(`a`,n,r);return a.innerHTML=e,a.href=`#`,a.title=t,a.setAttribute(`role`,`button`),a.setAttribute(`aria-label`,t),qt(a),Rt(a,`click`,Yt),Rt(a,`click`,i,this),Rt(a,`click`,this._refocusOnMap,this),a},_updateDisabled:function(){var e=this._map,t=`leaflet-disabled`;vt(this._zoomInButton,t),vt(this._zoomOutButton,t),this._zoomInButton.setAttribute(`aria-disabled`,`false`),this._zoomOutButton.setAttribute(`aria-disabled`,`false`),(this._disabled||e._zoom===e.getMinZoom())&&(_t(this._zoomOutButton,t),this._zoomOutButton.setAttribute(`aria-disabled`,`true`)),(this._disabled||e._zoom===e.getMaxZoom())&&(_t(this._zoomInButton,t),this._zoomInButton.setAttribute(`aria-disabled`,`true`))}});rn.mergeOptions({zoomControl:!0}),rn.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new un,this.addControl(this.zoomControl))});var dn=function(e){return new un(e)},fn=on.extend({options:{position:`bottomleft`,maxWidth:100,metric:!0,imperial:!0},onAdd:function(e){var t=`leaflet-control-scale`,n=dt(`div`,t),r=this.options;return this._addScales(r,t+`-line`,n),e.on(r.updateWhenIdle?`moveend`:`move`,this._update,this),e.whenReady(this._update,this),n},onRemove:function(e){e.off(this.options.updateWhenIdle?`moveend`:`move`,this._update,this)},_addScales:function(e,t,n){e.metric&&(this._mScale=dt(`div`,t,n)),e.imperial&&(this._iScale=dt(`div`,t,n))},_update:function(){var e=this._map,t=e.getSize().y/2,n=e.distance(e.containerPointToLatLng([0,t]),e.containerPointToLatLng([this.options.maxWidth,t]));this._updateScales(n)},_updateScales:function(e){this.options.metric&&e&&this._updateMetric(e),this.options.imperial&&e&&this._updateImperial(e)},_updateMetric:function(e){var t=this._getRoundNum(e),n=t<1e3?t+` m`:t/1e3+` km`;this._updateScale(this._mScale,n,t/e)},_updateImperial:function(e){var t=e*3.2808399,n,r,i;t>5280?(n=t/5280,r=this._getRoundNum(n),this._updateScale(this._iScale,r+` mi`,r/n)):(i=this._getRoundNum(t),this._updateScale(this._iScale,i+` ft`,i/t))},_updateScale:function(e,t,n){e.style.width=Math.round(this.options.maxWidth*n)+`px`,e.innerHTML=t},_getRoundNum:function(e){var t=10**((Math.floor(e)+``).length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}}),pn=function(e){return new fn(e)},mn=on.extend({options:{position:`bottomright`,prefix:`<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">`+(W.inlineSvg?`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg> `:``)+`Leaflet</a>`},initialize:function(e){p(this,e),this._attributions={}},onAdd:function(e){for(var t in e.attributionControl=this,this._container=dt(`div`,`leaflet-control-attribution`),qt(this._container),e._layers)e._layers[t].getAttribution&&this.addAttribution(e._layers[t].getAttribution());return this._update(),e.on(`layeradd`,this._addAttribution,this),this._container},onRemove:function(e){e.off(`layeradd`,this._addAttribution,this)},_addAttribution:function(e){e.layer.getAttribution&&(this.addAttribution(e.layer.getAttribution()),e.layer.once(`remove`,function(){this.removeAttribution(e.layer.getAttribution())},this))},setPrefix:function(e){return this.options.prefix=e,this._update(),this},addAttribution:function(e){return e&&(this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update()),this},removeAttribution:function(e){return e&&this._attributions[e]&&(this._attributions[e]--,this._update()),this},_update:function(){if(this._map){var e=[];for(var t in this._attributions)this._attributions[t]&&e.push(t);var n=[];this.options.prefix&&n.push(this.options.prefix),e.length&&n.push(e.join(`, `)),this._container.innerHTML=n.join(` <span aria-hidden="true">|</span> `)}}});rn.mergeOptions({attributionControl:!0}),rn.addInitHook(function(){this.options.attributionControl&&new mn().addTo(this)}),on.Layers=cn,on.Zoom=un,on.Scale=fn,on.Attribution=mn,sn.layers=ln,sn.zoom=dn,sn.scale=pn,sn.attribution=function(e){return new mn(e)};var hn=O.extend({initialize:function(e){this._map=e},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});hn.addTo=function(e,t){return e.addHandler(t,this),this};var gn={Events:ee},_n=W.touch?`touchstart mousedown`:`mousedown`,vn=A.extend({options:{clickTolerance:3},initialize:function(e,t,n,r){p(this,r),this._element=e,this._dragStartTarget=t||e,this._preventOutline=n},enable:function(){this._enabled||=(Rt(this._dragStartTarget,_n,this._onDown,this),!0)},disable:function(){this._enabled&&(vn._dragging===this&&this.finishDrag(!0),Bt(this._dragStartTarget,_n,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(e){if(this._enabled&&(this._moved=!1,!gt(this._element,`leaflet-zoom-anim`))){if(e.touches&&e.touches.length!==1)vn._dragging===this&&this.finishDrag();else if(!(vn._dragging||e.shiftKey||e.which!==1&&e.button!==1&&!e.touches)&&(vn._dragging=this,this._preventOutline&&Nt(this._element),kt(),Tt(),!this._moving)){this.fire(`down`);var t=e.touches?e.touches[0]:e,n=Ft(this._element);this._startPoint=new j(t.clientX,t.clientY),this._startPos=wt(this._element),this._parentScale=It(n);var r=e.type===`mousedown`;Rt(document,r?`mousemove`:`touchmove`,this._onMove,this),Rt(document,r?`mouseup`:`touchend touchcancel`,this._onUp,this)}}},_onMove:function(e){if(this._enabled){if(e.touches&&e.touches.length>1)this._moved=!0;else{var t=e.touches&&e.touches.length===1?e.touches[0]:e,n=new j(t.clientX,t.clientY)._subtract(this._startPoint);(n.x||n.y)&&(Math.abs(n.x)+Math.abs(n.y)<this.options.clickTolerance||(n.x/=this._parentScale.x,n.y/=this._parentScale.y,Jt(e),this._moved||(this.fire(`dragstart`),this._moved=!0,_t(document.body,`leaflet-dragging`),this._lastTarget=e.target||e.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),_t(this._lastTarget,`leaflet-drag-target`)),this._newPos=this._startPos.add(n),this._moving=!0,this._lastEvent=e,this._updatePosition()))}}},_updatePosition:function(){var e={originalEvent:this._lastEvent};this.fire(`predrag`,e),Ct(this._element,this._newPos),this.fire(`drag`,e)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(e){vt(document.body,`leaflet-dragging`),this._lastTarget&&=(vt(this._lastTarget,`leaflet-drag-target`),null),Bt(document,`mousemove touchmove`,this._onMove,this),Bt(document,`mouseup touchend touchcancel`,this._onUp,this),At(),Et();var t=this._moved&&this._moving;this._moving=!1,vn._dragging=!1,t&&this.fire(`dragend`,{noInertia:e,distance:this._newPos.distanceTo(this._startPos)})}});function yn(e,t,n){for(var r,i=[1,4,2,8],a=0,o,s,c,l,u=e.length,d,f;a<u;a++)e[a]._code=Mn(e[a],t);for(s=0;s<4;s++){for(d=i[s],r=[],a=0,u=e.length,o=u-1;a<u;o=a++)c=e[a],l=e[o],c._code&d?l._code&d||(f=jn(l,c,d,t,n),f._code=Mn(f,t),r.push(f)):(l._code&d&&(f=jn(l,c,d,t,n),f._code=Mn(f,t),r.push(f)),r.push(c));e=r}return e}function bn(e,t){var n,r,i,a,o,s,c,l,u;if(!e||e.length===0)throw Error(`latlngs not passed`);Fn(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]);var d=z([0,0]),f=te(e);f.getNorthWest().distanceTo(f.getSouthWest())*f.getNorthEast().distanceTo(f.getNorthWest())<1700&&(d=xn(e));var p=e.length,m=[];for(n=0;n<p;n++){var h=z(e[n]);m.push(t.project(z([h.lat-d.lat,h.lng-d.lng])))}for(s=c=l=0,n=0,r=p-1;n<p;r=n++)i=m[n],a=m[r],o=i.y*a.x-a.y*i.x,c+=(i.x+a.x)*o,l+=(i.y+a.y)*o,s+=o*3;u=s===0?m[0]:[c/s,l/s];var g=t.unproject(N(u));return z([g.lat+d.lat,g.lng+d.lng])}function xn(e){for(var t=0,n=0,r=0,i=0;i<e.length;i++){var a=z(e[i]);t+=a.lat,n+=a.lng,r++}return z([t/r,n/r])}var Sn={__proto__:null,clipPolygon:yn,polygonCenter:bn,centroid:xn};function Cn(e,t){if(!t||!e.length)return e.slice();var n=t*t;return e=On(e,n),e=En(e,n),e}function wn(e,t,n){return Math.sqrt(Pn(e,t,n,!0))}function Tn(e,t,n){return Pn(e,t,n)}function En(e,t){var n=e.length,r=new(typeof Uint8Array<`u`?Uint8Array:Array)(n);r[0]=r[n-1]=1,Dn(e,r,t,0,n-1);var i,a=[];for(i=0;i<n;i++)r[i]&&a.push(e[i]);return a}function Dn(e,t,n,r,i){for(var a=0,o,s=r+1,c;s<=i-1;s++)c=Pn(e[s],e[r],e[i],!0),c>a&&(o=s,a=c);a>n&&(t[o]=1,Dn(e,t,n,r,o),Dn(e,t,n,o,i))}function On(e,t){for(var n=[e[0]],r=1,i=0,a=e.length;r<a;r++)Nn(e[r],e[i])>t&&(n.push(e[r]),i=r);return i<a-1&&n.push(e[a-1]),n}var kn;function An(e,t,n,r,i){var a=r?kn:Mn(e,n),o=Mn(t,n),s,c,l;for(kn=o;;){if(!(a|o))return[e,t];if(a&o)return!1;s=a||o,c=jn(e,t,s,n,i),l=Mn(c,n),s===a?(e=c,a=l):(t=c,o=l)}}function jn(e,t,n,r,i){var a=t.x-e.x,o=t.y-e.y,s=r.min,c=r.max,l,u;return n&8?(l=e.x+a*(c.y-e.y)/o,u=c.y):n&4?(l=e.x+a*(s.y-e.y)/o,u=s.y):n&2?(l=c.x,u=e.y+o*(c.x-e.x)/a):n&1&&(l=s.x,u=e.y+o*(s.x-e.x)/a),new j(l,u,i)}function Mn(e,t){var n=0;return e.x<t.min.x?n|=1:e.x>t.max.x&&(n|=2),e.y<t.min.y?n|=4:e.y>t.max.y&&(n|=8),n}function Nn(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function Pn(e,t,n,r){var i=t.x,a=t.y,o=n.x-i,s=n.y-a,c=o*o+s*s,l;return c>0&&(l=((e.x-i)*o+(e.y-a)*s)/c,l>1?(i=n.x,a=n.y):l>0&&(i+=o*l,a+=s*l)),o=e.x-i,s=e.y-a,r?o*o+s*s:new j(i,a)}function Fn(e){return!_(e[0])||typeof e[0][0]!=`object`&&e[0][0]!==void 0}function In(e){return console.warn(`Deprecated use of _flat, please use L.LineUtil.isFlat instead.`),Fn(e)}function Ln(e,t){var n,r,i,a,o,s,c,l;if(!e||e.length===0)throw Error(`latlngs not passed`);Fn(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]);var u=z([0,0]),d=te(e);d.getNorthWest().distanceTo(d.getSouthWest())*d.getNorthEast().distanceTo(d.getNorthWest())<1700&&(u=xn(e));var f=e.length,p=[];for(n=0;n<f;n++){var m=z(e[n]);p.push(t.project(z([m.lat-u.lat,m.lng-u.lng])))}for(n=0,r=0;n<f-1;n++)r+=p[n].distanceTo(p[n+1])/2;if(r===0)l=p[0];else for(n=0,a=0;n<f-1;n++)if(o=p[n],s=p[n+1],i=o.distanceTo(s),a+=i,a>r){c=(a-r)/i,l=[s.x-c*(s.x-o.x),s.y-c*(s.y-o.y)];break}var h=t.unproject(N(l));return z([h.lat+u.lat,h.lng+u.lng])}var Rn={__proto__:null,simplify:Cn,pointToSegmentDistance:wn,closestPointOnSegment:Tn,clipSegment:An,_getEdgeIntersection:jn,_getBitCode:Mn,_sqClosestPointOnSegment:Pn,isFlat:Fn,_flat:In,polylineCenter:Ln},zn={project:function(e){return new j(e.lng,e.lat)},unproject:function(e){return new R(e.y,e.x)},bounds:new P([-180,-90],[180,90])},Bn={R:6378137,R_MINOR:6356752.314245179,bounds:new P([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(e){var t=Math.PI/180,n=this.R,r=e.lat*t,i=this.R_MINOR/n,a=Math.sqrt(1-i*i),o=a*Math.sin(r),s=Math.tan(Math.PI/4-r/2)/((1-o)/(1+o))**(a/2);return r=-n*Math.log(Math.max(s,1e-10)),new j(e.lng*t*n,r)},unproject:function(e){for(var t=180/Math.PI,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=Math.exp(-e.y/n),o=Math.PI/2-2*Math.atan(a),s=0,c=.1,l;s<15&&Math.abs(c)>1e-7;s++)l=i*Math.sin(o),l=((1-l)/(1+l))**(i/2),c=Math.PI/2-2*Math.atan(a*l)-o,o+=c;return new R(o*t,e.x*t/n)}},Vn={__proto__:null,LonLat:zn,Mercator:Bn,SphericalMercator:ie},Hn=n({},ne,{code:`EPSG:3395`,projection:Bn,transformation:function(){var e=.5/(Math.PI*Bn.R);return oe(e,.5,-e,.5)}()}),Un=n({},ne,{code:`EPSG:4326`,projection:zn,transformation:oe(1/180,1,-1/180,.5)}),Wn=n({},B,{projection:zn,transformation:oe(1,0,-1,0),scale:function(e){return 2**e},zoom:function(e){return Math.log(e)/Math.LN2},distance:function(e,t){var n=t.lng-e.lng,r=t.lat-e.lat;return Math.sqrt(n*n+r*r)},infinite:!0});B.Earth=ne,B.EPSG3395=Hn,B.EPSG3857=se,B.EPSG900913=ce,B.EPSG4326=Un,B.Simple=Wn;var Gn=A.extend({options:{pane:`overlayPane`,attribution:null,bubblingMouseEvents:!0},addTo:function(e){return e.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(e){return e&&e.removeLayer(this),this},getPane:function(e){return this._map.getPane(e?this.options[e]||e:this.options.pane)},addInteractiveTarget:function(e){return this._map._targets[o(e)]=this,this},removeInteractiveTarget:function(e){return delete this._map._targets[o(e)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(e){var t=e.target;if(t.hasLayer(this)){if(this._map=t,this._zoomAnimated=t._zoomAnimated,this.getEvents){var n=this.getEvents();t.on(n,this),this.once(`remove`,function(){t.off(n,this)},this)}this.onAdd(t),this.fire(`add`),t.fire(`layeradd`,{layer:this})}}});rn.include({addLayer:function(e){if(!e._layerAdd)throw Error(`The provided object is not a Layer.`);var t=o(e);return this._layers[t]||(this._layers[t]=e,e._mapToAdd=this,e.beforeAdd&&e.beforeAdd(this),this.whenReady(e._layerAdd,e)),this},removeLayer:function(e){var t=o(e);return this._layers[t]&&(this._loaded&&e.onRemove(this),delete this._layers[t],this._loaded&&(this.fire(`layerremove`,{layer:e}),e.fire(`remove`)),e._map=e._mapToAdd=null),this},hasLayer:function(e){return o(e)in this._layers},eachLayer:function(e,t){for(var n in this._layers)e.call(t,this._layers[n]);return this},_addLayers:function(e){e=e?_(e)?e:[e]:[];for(var t=0,n=e.length;t<n;t++)this.addLayer(e[t])},_addZoomLimit:function(e){isNaN(e.options.maxZoom)&&isNaN(e.options.minZoom)||(this._zoomBoundLayers[o(e)]=e,this._updateZoomLevels())},_removeZoomLimit:function(e){var t=o(e);this._zoomBoundLayers[t]&&(delete this._zoomBoundLayers[t],this._updateZoomLevels())},_updateZoomLevels:function(){var e=1/0,t=-1/0,n=this._getZoomSpan();for(var r in this._zoomBoundLayers){var i=this._zoomBoundLayers[r].options;e=i.minZoom===void 0?e:Math.min(e,i.minZoom),t=i.maxZoom===void 0?t:Math.max(t,i.maxZoom)}this._layersMaxZoom=t===-1/0?void 0:t,this._layersMinZoom=e===1/0?void 0:e,n!==this._getZoomSpan()&&this.fire(`zoomlevelschange`),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var Kn=Gn.extend({initialize:function(e,t){p(this,t),this._layers={};var n,r;if(e)for(n=0,r=e.length;n<r;n++)this.addLayer(e[n])},addLayer:function(e){var t=this.getLayerId(e);return this._layers[t]=e,this._map&&this._map.addLayer(e),this},removeLayer:function(e){var t=e in this._layers?e:this.getLayerId(e);return this._map&&this._layers[t]&&this._map.removeLayer(this._layers[t]),delete this._layers[t],this},hasLayer:function(e){return(typeof e==`number`?e:this.getLayerId(e))in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(e){var t=Array.prototype.slice.call(arguments,1),n,r;for(n in this._layers)r=this._layers[n],r[e]&&r[e].apply(r,t);return this},onAdd:function(e){this.eachLayer(e.addLayer,e)},onRemove:function(e){this.eachLayer(e.removeLayer,e)},eachLayer:function(e,t){for(var n in this._layers)e.call(t,this._layers[n]);return this},getLayer:function(e){return this._layers[e]},getLayers:function(){var e=[];return this.eachLayer(e.push,e),e},setZIndex:function(e){return this.invoke(`setZIndex`,e)},getLayerId:function(e){return o(e)}}),qn=function(e,t){return new Kn(e,t)},Jn=Kn.extend({addLayer:function(e){return this.hasLayer(e)?this:(e.addEventParent(this),Kn.prototype.addLayer.call(this,e),this.fire(`layeradd`,{layer:e}))},removeLayer:function(e){return this.hasLayer(e)?(e in this._layers&&(e=this._layers[e]),e.removeEventParent(this),Kn.prototype.removeLayer.call(this,e),this.fire(`layerremove`,{layer:e})):this},setStyle:function(e){return this.invoke(`setStyle`,e)},bringToFront:function(){return this.invoke(`bringToFront`)},bringToBack:function(){return this.invoke(`bringToBack`)},getBounds:function(){var e=new I;for(var t in this._layers){var n=this._layers[t];e.extend(n.getBounds?n.getBounds():n.getLatLng())}return e}}),Yn=function(e,t){return new Jn(e,t)},Xn=O.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(e){p(this,e)},createIcon:function(e){return this._createIcon(`icon`,e)},createShadow:function(e){return this._createIcon(`shadow`,e)},_createIcon:function(e,t){var n=this._getIconUrl(e);if(!n){if(e===`icon`)throw Error(`iconUrl not set in Icon options (see the docs).`);return null}var r=this._createImg(n,t&&t.tagName===`IMG`?t:null);return this._setIconStyles(r,e),(this.options.crossOrigin||this.options.crossOrigin===``)&&(r.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),r},_setIconStyles:function(e,t){var n=this.options,r=n[t+`Size`];typeof r==`number`&&(r=[r,r]);var i=N(r),a=N(t===`shadow`&&n.shadowAnchor||n.iconAnchor||i&&i.divideBy(2,!0));e.className=`leaflet-marker-`+t+` `+(n.className||``),a&&(e.style.marginLeft=-a.x+`px`,e.style.marginTop=-a.y+`px`),i&&(e.style.width=i.x+`px`,e.style.height=i.y+`px`)},_createImg:function(e,t){return t||=document.createElement(`img`),t.src=e,t},_getIconUrl:function(e){return W.retina&&this.options[e+`RetinaUrl`]||this.options[e+`Url`]}});function Zn(e){return new Xn(e)}var Qn=Xn.extend({options:{iconUrl:`marker-icon.png`,iconRetinaUrl:`marker-icon-2x.png`,shadowUrl:`marker-shadow.png`,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(e){return typeof Qn.imagePath!=`string`&&(Qn.imagePath=this._detectIconPath()),(this.options.imagePath||Qn.imagePath)+Xn.prototype._getIconUrl.call(this,e)},_stripUrl:function(e){var t=function(e,t,n){var r=t.exec(e);return r&&r[n]};return e=t(e,/^url\((['"])?(.+)\1\)$/,2),e&&t(e,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var e=dt(`div`,`leaflet-default-icon-path`,document.body),t=ut(e,`background-image`)||ut(e,`backgroundImage`);if(document.body.removeChild(e),t=this._stripUrl(t),t)return t;var n=document.querySelector(`link[href$="leaflet.css"]`);return n?n.href.substring(0,n.href.length-11-1):``}}),$n=hn.extend({initialize:function(e){this._marker=e},addHooks:function(){var e=this._marker._icon;this._draggable||=new vn(e,e,!0),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),_t(e,`leaflet-marker-draggable`)},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&vt(this._marker._icon,`leaflet-marker-draggable`)},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(e){var t=this._marker,n=t._map,r=this._marker.options.autoPanSpeed,i=this._marker.options.autoPanPadding,a=wt(t._icon),o=n.getPixelBounds(),s=n.getPixelOrigin(),c=F(o.min._subtract(s).add(i),o.max._subtract(s).subtract(i));if(!c.contains(a)){var l=N((Math.max(c.max.x,a.x)-c.max.x)/(o.max.x-c.max.x)-(Math.min(c.min.x,a.x)-c.min.x)/(o.min.x-c.min.x),(Math.max(c.max.y,a.y)-c.max.y)/(o.max.y-c.max.y)-(Math.min(c.min.y,a.y)-c.min.y)/(o.min.y-c.min.y)).multiplyBy(r);n.panBy(l,{animate:!1}),this._draggable._newPos._add(l),this._draggable._startPos._add(l),Ct(t._icon,this._draggable._newPos),this._onDrag(e),this._panRequest=T(this._adjustPan.bind(this,e))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire(`movestart`).fire(`dragstart`)},_onPreDrag:function(e){this._marker.options.autoPan&&(E(this._panRequest),this._panRequest=T(this._adjustPan.bind(this,e)))},_onDrag:function(e){var t=this._marker,n=t._shadow,r=wt(t._icon),i=t._map.layerPointToLatLng(r);n&&Ct(n,r),t._latlng=i,e.latlng=i,e.oldLatLng=this._oldLatLng,t.fire(`move`,e).fire(`drag`,e)},_onDragEnd:function(e){E(this._panRequest),delete this._oldLatLng,this._marker.fire(`moveend`).fire(`dragend`,e)}}),er=Gn.extend({options:{icon:new Qn,interactive:!0,keyboard:!0,title:``,alt:`Marker`,zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:`markerPane`,shadowPane:`shadowPane`,bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(e,t){p(this,t),this._latlng=z(e)},onAdd:function(e){this._zoomAnimated=this._zoomAnimated&&e.options.markerZoomAnimation,this._zoomAnimated&&e.on(`zoomanim`,this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(e){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&e.off(`zoomanim`,this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(e){var t=this._latlng;return this._latlng=z(e),this.update(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})},setZIndexOffset:function(e){return this.options.zIndexOffset=e,this.update()},getIcon:function(){return this.options.icon},setIcon:function(e){return this.options.icon=e,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var e=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(e)}return this},_initIcon:function(){var e=this.options,t=`leaflet-zoom-`+(this._zoomAnimated?`animated`:`hide`),n=e.icon.createIcon(this._icon),r=!1;n!==this._icon&&(this._icon&&this._removeIcon(),r=!0,e.title&&(n.title=e.title),n.tagName===`IMG`&&(n.alt=e.alt||``)),_t(n,t),e.keyboard&&(n.tabIndex=`0`,n.setAttribute(`role`,`button`)),this._icon=n,e.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Rt(n,`focus`,this._panOnFocus,this);var i=e.icon.createShadow(this._shadow),a=!1;i!==this._shadow&&(this._removeShadow(),a=!0),i&&(_t(i,t),i.alt=``),this._shadow=i,e.opacity<1&&this._updateOpacity(),r&&this.getPane().appendChild(this._icon),this._initInteraction(),i&&a&&this.getPane(e.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Bt(this._icon,`focus`,this._panOnFocus,this),ft(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&ft(this._shadow),this._shadow=null},_setPos:function(e){this._icon&&Ct(this._icon,e),this._shadow&&Ct(this._shadow,e),this._zIndex=e.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(e){this._icon&&(this._icon.style.zIndex=this._zIndex+e)},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center).round();this._setPos(t)},_initInteraction:function(){if(this.options.interactive&&(_t(this._icon,`leaflet-interactive`),this.addInteractiveTarget(this._icon),$n)){var e=this.options.draggable;this.dragging&&(e=this.dragging.enabled(),this.dragging.disable()),this.dragging=new $n(this),e&&this.dragging.enable()}},setOpacity:function(e){return this.options.opacity=e,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var e=this.options.opacity;this._icon&&Z(this._icon,e),this._shadow&&Z(this._shadow,e)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var e=this._map;if(e){var t=this.options.icon.options,n=t.iconSize?N(t.iconSize):N(0,0),r=t.iconAnchor?N(t.iconAnchor):N(0,0);e.panInside(this._latlng,{paddingTopLeft:r,paddingBottomRight:n.subtract(r)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function tr(e,t){return new er(e,t)}var nr=Gn.extend({options:{stroke:!0,color:`#3388ff`,weight:3,opacity:1,lineCap:`round`,lineJoin:`round`,dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:`evenodd`,interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(e){this._renderer=e.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(e){return p(this,e),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&e&&Object.prototype.hasOwnProperty.call(e,`weight`)&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),rr=nr.extend({options:{fill:!0,radius:10},initialize:function(e,t){p(this,t),this._latlng=z(e),this._radius=this.options.radius},setLatLng:function(e){var t=this._latlng;return this._latlng=z(e),this.redraw(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(e){return this.options.radius=this._radius=e,this.redraw()},getRadius:function(){return this._radius},setStyle:function(e){var t=e&&e.radius||this._radius;return nr.prototype.setStyle.call(this,e),this.setRadius(t),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var e=this._radius,t=this._radiusY||e,n=this._clickTolerance(),r=[e+n,t+n];this._pxBounds=new P(this._point.subtract(r),this._point.add(r))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(e){return e.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function ir(e,t){return new rr(e,t)}var ar=rr.extend({initialize:function(e,t,r){if(typeof t==`number`&&(t=n({},r,{radius:t})),p(this,t),this._latlng=z(e),isNaN(this.options.radius))throw Error(`Circle radius cannot be NaN`);this._mRadius=this.options.radius},setRadius:function(e){return this._mRadius=e,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var e=[this._radius,this._radiusY||this._radius];return new I(this._map.layerPointToLatLng(this._point.subtract(e)),this._map.layerPointToLatLng(this._point.add(e)))},setStyle:nr.prototype.setStyle,_project:function(){var e=this._latlng.lng,t=this._latlng.lat,n=this._map,r=n.options.crs;if(r.distance===ne.distance){var i=Math.PI/180,a=this._mRadius/ne.R/i,o=n.project([t+a,e]),s=n.project([t-a,e]),c=o.add(s).divideBy(2),l=n.unproject(c).lat,u=Math.acos((Math.cos(a*i)-Math.sin(t*i)*Math.sin(l*i))/(Math.cos(t*i)*Math.cos(l*i)))/i;(isNaN(u)||u===0)&&(u=a/Math.cos(Math.PI/180*t)),this._point=c.subtract(n.getPixelOrigin()),this._radius=isNaN(u)?0:c.x-n.project([l,e-u]).x,this._radiusY=c.y-o.y}else{var d=r.unproject(r.project(this._latlng).subtract([this._mRadius,0]));this._point=n.latLngToLayerPoint(this._latlng),this._radius=this._point.x-n.latLngToLayerPoint(d).x}this._updateBounds()}});function or(e,t,n){return new ar(e,t,n)}var sr=nr.extend({options:{smoothFactor:1,noClip:!1},initialize:function(e,t){p(this,t),this._setLatLngs(e)},getLatLngs:function(){return this._latlngs},setLatLngs:function(e){return this._setLatLngs(e),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(e){for(var t=1/0,n=null,r=Pn,i,a,o=0,s=this._parts.length;o<s;o++)for(var c=this._parts[o],l=1,u=c.length;l<u;l++){i=c[l-1],a=c[l];var d=r(e,i,a,!0);d<t&&(t=d,n=r(e,i,a))}return n&&(n.distance=Math.sqrt(t)),n},getCenter:function(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return Ln(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(e,t){return t||=this._defaultShape(),e=z(e),t.push(e),this._bounds.extend(e),this.redraw()},_setLatLngs:function(e){this._bounds=new I,this._latlngs=this._convertLatLngs(e)},_defaultShape:function(){return Fn(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(e){for(var t=[],n=Fn(e),r=0,i=e.length;r<i;r++)n?(t[r]=z(e[r]),this._bounds.extend(t[r])):t[r]=this._convertLatLngs(e[r]);return t},_project:function(){var e=new P;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,e),this._bounds.isValid()&&e.isValid()&&(this._rawPxBounds=e,this._updateBounds())},_updateBounds:function(){var e=this._clickTolerance(),t=new j(e,e);this._rawPxBounds&&(this._pxBounds=new P([this._rawPxBounds.min.subtract(t),this._rawPxBounds.max.add(t)]))},_projectLatlngs:function(e,t,n){var r=e[0]instanceof R,i=e.length,a,o;if(r){for(o=[],a=0;a<i;a++)o[a]=this._map.latLngToLayerPoint(e[a]),n.extend(o[a]);t.push(o)}else for(a=0;a<i;a++)this._projectLatlngs(e[a],t,n)},_clipPoints:function(){var e=this._renderer._bounds;if(this._parts=[],this._pxBounds&&this._pxBounds.intersects(e)){if(this.options.noClip)this._parts=this._rings;else for(var t=this._parts,n=0,r,i=0,a=this._rings.length,o,s,c;n<a;n++)for(c=this._rings[n],r=0,o=c.length;r<o-1;r++)s=An(c[r],c[r+1],e,r,!0),s&&(t[i]=t[i]||[],t[i].push(s[0]),(s[1]!==c[r+1]||r===o-2)&&(t[i].push(s[1]),i++))}},_simplifyPoints:function(){for(var e=this._parts,t=this.options.smoothFactor,n=0,r=e.length;n<r;n++)e[n]=Cn(e[n],t)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(e,t){var n,r,i,a,o,s,c=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(n=0,a=this._parts.length;n<a;n++)for(s=this._parts[n],r=0,o=s.length,i=o-1;r<o;i=r++)if((t||r!==0)&&wn(e,s[i],s[r])<=c)return!0;return!1}});function cr(e,t){return new sr(e,t)}sr._flat=In;var lr=sr.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return bn(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(e){var t=sr.prototype._convertLatLngs.call(this,e),n=t.length;return n>=2&&t[0]instanceof R&&t[0].equals(t[n-1])&&t.pop(),t},_setLatLngs:function(e){sr.prototype._setLatLngs.call(this,e),Fn(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Fn(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var e=this._renderer._bounds,t=this.options.weight,n=new j(t,t);if(e=new P(e.min.subtract(n),e.max.add(n)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(e)){if(this.options.noClip)this._parts=this._rings;else for(var r=0,i=this._rings.length,a;r<i;r++)a=yn(this._rings[r],e,!0),a.length&&this._parts.push(a)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(e){var t=!1,n,r,i,a,o,s,c,l;if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(a=0,c=this._parts.length;a<c;a++)for(n=this._parts[a],o=0,l=n.length,s=l-1;o<l;s=o++)r=n[o],i=n[s],r.y>e.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(t=!t);return t||sr.prototype._containsPoint.call(this,e,!0)}});function ur(e,t){return new lr(e,t)}var dr=Jn.extend({initialize:function(e,t){p(this,t),this._layers={},e&&this.addData(e)},addData:function(e){var t=_(e)?e:e.features,n,r,i;if(t){for(n=0,r=t.length;n<r;n++)i=t[n],(i.geometries||i.geometry||i.features||i.coordinates)&&this.addData(i);return this}var a=this.options;if(a.filter&&!a.filter(e))return this;var o=fr(e,a);return o?(o.feature=yr(e),o.defaultOptions=o.options,this.resetStyle(o),a.onEachFeature&&a.onEachFeature(e,o),this.addLayer(o)):this},resetStyle:function(e){return e===void 0?this.eachLayer(this.resetStyle,this):(e.options=n({},e.defaultOptions),this._setLayerStyle(e,this.options.style),this)},setStyle:function(e){return this.eachLayer(function(t){this._setLayerStyle(t,e)},this)},_setLayerStyle:function(e,t){e.setStyle&&(typeof t==`function`&&(t=t(e.feature)),e.setStyle(t))}});function fr(e,t){var n=e.type===`Feature`?e.geometry:e,r=n?n.coordinates:null,i=[],a=t&&t.pointToLayer,o=t&&t.coordsToLatLng||mr,s,c,l,u;if(!r&&!n)return null;switch(n.type){case`Point`:return s=o(r),pr(a,e,s,t);case`MultiPoint`:for(l=0,u=r.length;l<u;l++)s=o(r[l]),i.push(pr(a,e,s,t));return new Jn(i);case`LineString`:case`MultiLineString`:return c=hr(r,n.type===`LineString`?0:1,o),new sr(c,t);case`Polygon`:case`MultiPolygon`:return c=hr(r,n.type===`Polygon`?1:2,o),new lr(c,t);case`GeometryCollection`:for(l=0,u=n.geometries.length;l<u;l++){var d=fr({geometry:n.geometries[l],type:`Feature`,properties:e.properties},t);d&&i.push(d)}return new Jn(i);case`FeatureCollection`:for(l=0,u=n.features.length;l<u;l++){var f=fr(n.features[l],t);f&&i.push(f)}return new Jn(i);default:throw Error(`Invalid GeoJSON object.`)}}function pr(e,t,n,r){return e?e(t,n):new er(n,r&&r.markersInheritOptions&&r)}function mr(e){return new R(e[1],e[0],e[2])}function hr(e,t,n){for(var r=[],i=0,a=e.length,o;i<a;i++)o=t?hr(e[i],t-1,n):(n||mr)(e[i]),r.push(o);return r}function gr(e,t){return e=z(e),e.alt===void 0?[u(e.lng,t),u(e.lat,t)]:[u(e.lng,t),u(e.lat,t),u(e.alt,t)]}function _r(e,t,n,r){for(var i=[],a=0,o=e.length;a<o;a++)i.push(t?_r(e[a],Fn(e[a])?0:t-1,n,r):gr(e[a],r));return!t&&n&&i.length>0&&i.push(i[0].slice()),i}function vr(e,t){return e.feature?n({},e.feature,{geometry:t}):yr(t)}function yr(e){return e.type===`Feature`||e.type===`FeatureCollection`?e:{type:`Feature`,properties:{},geometry:e}}var br={toGeoJSON:function(e){return vr(this,{type:`Point`,coordinates:gr(this.getLatLng(),e)})}};er.include(br),ar.include(br),rr.include(br),sr.include({toGeoJSON:function(e){var t=!Fn(this._latlngs),n=_r(this._latlngs,+!!t,!1,e);return vr(this,{type:(t?`Multi`:``)+`LineString`,coordinates:n})}}),lr.include({toGeoJSON:function(e){var t=!Fn(this._latlngs),n=t&&!Fn(this._latlngs[0]),r=_r(this._latlngs,n?2:+!!t,!0,e);return t||(r=[r]),vr(this,{type:(n?`Multi`:``)+`Polygon`,coordinates:r})}}),Kn.include({toMultiPoint:function(e){var t=[];return this.eachLayer(function(n){t.push(n.toGeoJSON(e).geometry.coordinates)}),vr(this,{type:`MultiPoint`,coordinates:t})},toGeoJSON:function(e){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(t===`MultiPoint`)return this.toMultiPoint(e);var n=t===`GeometryCollection`,r=[];return this.eachLayer(function(t){if(t.toGeoJSON){var i=t.toGeoJSON(e);if(n)r.push(i.geometry);else{var a=yr(i);a.type===`FeatureCollection`?r.push.apply(r,a.features):r.push(a)}}}),n?vr(this,{geometries:r,type:`GeometryCollection`}):{type:`FeatureCollection`,features:r}}});function xr(e,t){return new dr(e,t)}var Sr=xr,Cr=Gn.extend({options:{opacity:1,alt:``,interactive:!1,crossOrigin:!1,errorOverlayUrl:``,zIndex:1,className:``},initialize:function(e,t,n){this._url=e,this._bounds=te(t),p(this,n)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(_t(this._image,`leaflet-interactive`),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){ft(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(e){return this.options.opacity=e,this._image&&this._updateOpacity(),this},setStyle:function(e){return e.opacity&&this.setOpacity(e.opacity),this},bringToFront:function(){return this._map&&mt(this._image),this},bringToBack:function(){return this._map&&ht(this._image),this},setUrl:function(e){return this._url=e,this._image&&(this._image.src=e),this},setBounds:function(e){return this._bounds=te(e),this._map&&this._reset(),this},getEvents:function(){var e={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var e=this._url.tagName===`IMG`,t=this._image=e?this._url:dt(`img`);_t(t,`leaflet-image-layer`),this._zoomAnimated&&_t(t,`leaflet-zoom-animated`),this.options.className&&_t(t,this.options.className),t.onselectstart=l,t.onmousemove=l,t.onload=i(this.fire,this,`load`),t.onerror=i(this._overlayOnError,this,`error`),(this.options.crossOrigin||this.options.crossOrigin===``)&&(t.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),e?this._url=t.src:(t.src=this._url,t.alt=this.options.alt)},_animateZoom:function(e){var t=this._map.getZoomScale(e.zoom),n=this._map._latLngBoundsToNewLayerBounds(this._bounds,e.zoom,e.center).min;Q(this._image,n,t)},_reset:function(){var e=this._image,t=new P(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),n=t.getSize();Ct(e,t.min),e.style.width=n.x+`px`,e.style.height=n.y+`px`},_updateOpacity:function(){Z(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire(`error`);var e=this.options.errorOverlayUrl;e&&this._url!==e&&(this._url=e,this._image.src=e)},getCenter:function(){return this._bounds.getCenter()}}),wr=function(e,t,n){return new Cr(e,t,n)},Tr=Cr.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var e=this._url.tagName===`VIDEO`,t=this._image=e?this._url:dt(`video`);if(_t(t,`leaflet-image-layer`),this._zoomAnimated&&_t(t,`leaflet-zoom-animated`),this.options.className&&_t(t,this.options.className),t.onselectstart=l,t.onmousemove=l,t.onloadeddata=i(this.fire,this,`load`),e){for(var n=t.getElementsByTagName(`source`),r=[],a=0;a<n.length;a++)r.push(n[a].src);this._url=n.length>0?r:[t.src]}else{_(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(t.style,`objectFit`)&&(t.style.objectFit=`fill`),t.autoplay=!!this.options.autoplay,t.loop=!!this.options.loop,t.muted=!!this.options.muted,t.playsInline=!!this.options.playsInline;for(var o=0;o<this._url.length;o++){var s=dt(`source`);s.src=this._url[o],t.appendChild(s)}}}});function Er(e,t,n){return new Tr(e,t,n)}var Dr=Cr.extend({_initImage:function(){var e=this._image=this._url;_t(e,`leaflet-image-layer`),this._zoomAnimated&&_t(e,`leaflet-zoom-animated`),this.options.className&&_t(e,this.options.className),e.onselectstart=l,e.onmousemove=l}});function Or(e,t,n){return new Dr(e,t,n)}var kr=Gn.extend({options:{interactive:!1,offset:[0,0],className:``,pane:void 0,content:``},initialize:function(e,t){e&&(e instanceof R||_(e))?(this._latlng=z(e),p(this,t)):(p(this,e),this._source=t),this.options.content&&(this._content=this.options.content)},openOn:function(e){return e=arguments.length?e:this._source._map,e.hasLayer(this)||e.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(e){return this._map?this.close():(arguments.length?this._source=e:e=this._source,this._prepareOpen(),this.openOn(e._map)),this},onAdd:function(e){this._zoomAnimated=e._zoomAnimated,this._container||this._initLayout(),e._fadeAnimated&&Z(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),e._fadeAnimated&&Z(this._container,1),this.bringToFront(),this.options.interactive&&(_t(this._container,`leaflet-interactive`),this.addInteractiveTarget(this._container))},onRemove:function(e){e._fadeAnimated?(Z(this._container,0),this._removeTimeout=setTimeout(i(ft,void 0,this._container),200)):ft(this._container),this.options.interactive&&(vt(this._container,`leaflet-interactive`),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(e){return this._latlng=z(e),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(e){return this._content=e,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility=`hidden`,this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility=``,this._adjustPan())},getEvents:function(){var e={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&mt(this._container),this},bringToBack:function(){return this._map&&ht(this._container),this},_prepareOpen:function(e){var t=this._source;if(!t._map)return!1;if(t instanceof Jn){t=null;var n=this._source._layers;for(var r in n)if(n[r]._map){t=n[r];break}if(!t)return!1;this._source=t}if(!e){if(t.getCenter)e=t.getCenter();else if(t.getLatLng)e=t.getLatLng();else if(t.getBounds)e=t.getBounds().getCenter();else throw Error(`Unable to get source layer LatLng.`)}return this.setLatLng(e),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var e=this._contentNode,t=typeof this._content==`function`?this._content(this._source||this):this._content;if(typeof t==`string`)e.innerHTML=t;else{for(;e.hasChildNodes();)e.removeChild(e.firstChild);e.appendChild(t)}this.fire(`contentupdate`)}},_updatePosition:function(){if(this._map){var e=this._map.latLngToLayerPoint(this._latlng),t=N(this.options.offset),n=this._getAnchor();this._zoomAnimated?Ct(this._container,e.add(n)):t=t.add(e).add(n);var r=this._containerBottom=-t.y,i=this._containerLeft=-Math.round(this._containerWidth/2)+t.x;this._container.style.bottom=r+`px`,this._container.style.left=i+`px`}},_getAnchor:function(){return[0,0]}});rn.include({_initOverlay:function(e,t,n,r){var i=t;return i instanceof e||(i=new e(r).setContent(t)),n&&i.setLatLng(n),i}}),Gn.include({_initOverlay:function(e,t,n,r){var i=n;return i instanceof e?(p(i,r),i._source=this):(i=t&&!r?t:new e(r,this),i.setContent(n)),i}});var Ar=kr.extend({options:{pane:`popupPane`,offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:``},openOn:function(e){return e=arguments.length?e:this._source._map,!e.hasLayer(this)&&e._popup&&e._popup.options.autoClose&&e.removeLayer(e._popup),e._popup=this,kr.prototype.openOn.call(this,e)},onAdd:function(e){kr.prototype.onAdd.call(this,e),e.fire(`popupopen`,{popup:this}),this._source&&(this._source.fire(`popupopen`,{popup:this},!0),this._source instanceof nr||this._source.on(`preclick`,Gt))},onRemove:function(e){kr.prototype.onRemove.call(this,e),e.fire(`popupclose`,{popup:this}),this._source&&(this._source.fire(`popupclose`,{popup:this},!0),this._source instanceof nr||this._source.off(`preclick`,Gt))},getEvents:function(){var e=kr.prototype.getEvents.call(this);return(this.options.closeOnClick===void 0?this._map.options.closePopupOnClick:this.options.closeOnClick)&&(e.preclick=this.close),this.options.keepInView&&(e.moveend=this._adjustPan),e},_initLayout:function(){var e=`leaflet-popup`,t=this._container=dt(`div`,e+` `+(this.options.className||``)+` leaflet-zoom-animated`),n=this._wrapper=dt(`div`,e+`-content-wrapper`,t);if(this._contentNode=dt(`div`,e+`-content`,n),qt(t),Kt(this._contentNode),Rt(t,`contextmenu`,Gt),this._tipContainer=dt(`div`,e+`-tip-container`,t),this._tip=dt(`div`,e+`-tip`,this._tipContainer),this.options.closeButton){var r=this._closeButton=dt(`a`,e+`-close-button`,t);r.setAttribute(`role`,`button`),r.setAttribute(`aria-label`,`Close popup`),r.href=`#close`,r.innerHTML=`<span aria-hidden="true">&#215;</span>`,Rt(r,`click`,function(e){Jt(e),this.close()},this)}},_updateLayout:function(){var e=this._contentNode,t=e.style;t.width=``,t.whiteSpace=`nowrap`;var n=e.offsetWidth;n=Math.min(n,this.options.maxWidth),n=Math.max(n,this.options.minWidth),t.width=n+1+`px`,t.whiteSpace=``,t.height=``;var r=e.offsetHeight,i=this.options.maxHeight,a=`leaflet-popup-scrolled`;i&&r>i?(t.height=i+`px`,_t(e,a)):vt(e,a),this._containerWidth=this._container.offsetWidth},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),n=this._getAnchor();Ct(this._container,t.add(n))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning)this._autopanning=!1;else{var e=this._map,t=parseInt(ut(this._container,`marginBottom`),10)||0,n=this._container.offsetHeight+t,r=this._containerWidth,i=new j(this._containerLeft,-n-this._containerBottom);i._add(wt(this._container));var a=e.layerPointToContainerPoint(i),o=N(this.options.autoPanPadding),s=N(this.options.autoPanPaddingTopLeft||o),c=N(this.options.autoPanPaddingBottomRight||o),l=e.getSize(),u=0,d=0;a.x+r+c.x>l.x&&(u=a.x+r-l.x+c.x),a.x-u-s.x<0&&(u=a.x-s.x),a.y+n+c.y>l.y&&(d=a.y+n-l.y+c.y),a.y-d-s.y<0&&(d=a.y-s.y),(u||d)&&(this.options.keepInView&&(this._autopanning=!0),e.fire(`autopanstart`).panBy([u,d]))}}},_getAnchor:function(){return N(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),jr=function(e,t){return new Ar(e,t)};rn.mergeOptions({closePopupOnClick:!0}),rn.include({openPopup:function(e,t,n){return this._initOverlay(Ar,e,t,n).openOn(this),this},closePopup:function(e){return e=arguments.length?e:this._popup,e&&e.close(),this}}),Gn.include({bindPopup:function(e,t){return this._popup=this._initOverlay(Ar,this._popup,e,t),this._popupHandlersAdded||=(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),!0),this},unbindPopup:function(){return this._popup&&=(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,null),this},openPopup:function(e){return this._popup&&(this instanceof Jn||(this._popup._source=this),this._popup._prepareOpen(e||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(e){return this._popup&&this._popup.setContent(e),this},getPopup:function(){return this._popup},_openPopup:function(e){if(this._popup&&this._map){Yt(e);var t=e.layer||e.target;this._popup._source===t&&!(t instanceof nr)?this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(e.latlng):(this._popup._source=t,this.openPopup(e.latlng))}},_movePopup:function(e){this._popup.setLatLng(e.latlng)},_onKeyPress:function(e){e.originalEvent.keyCode===13&&this._openPopup(e)}});var Mr=kr.extend({options:{pane:`tooltipPane`,offset:[0,0],direction:`auto`,permanent:!1,sticky:!1,opacity:.9},onAdd:function(e){kr.prototype.onAdd.call(this,e),this.setOpacity(this.options.opacity),e.fire(`tooltipopen`,{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire(`tooltipopen`,{tooltip:this},!0))},onRemove:function(e){kr.prototype.onRemove.call(this,e),e.fire(`tooltipclose`,{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire(`tooltipclose`,{tooltip:this},!0))},getEvents:function(){var e=kr.prototype.getEvents.call(this);return this.options.permanent||(e.preclick=this.close),e},_initLayout:function(){var e=`leaflet-tooltip `+(this.options.className||``)+` leaflet-zoom-`+(this._zoomAnimated?`animated`:`hide`);this._contentNode=this._container=dt(`div`,e),this._container.setAttribute(`role`,`tooltip`),this._container.setAttribute(`id`,`leaflet-tooltip-`+o(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(e){var t,n,r=this._map,i=this._container,a=r.latLngToContainerPoint(r.getCenter()),o=r.layerPointToContainerPoint(e),s=this.options.direction,c=i.offsetWidth,l=i.offsetHeight,u=N(this.options.offset),d=this._getAnchor();s===`top`?(t=c/2,n=l):s===`bottom`?(t=c/2,n=0):s===`center`?(t=c/2,n=l/2):s===`right`?(t=0,n=l/2):s===`left`?(t=c,n=l/2):o.x<a.x?(s=`right`,t=0,n=l/2):(s=`left`,t=c+(u.x+d.x)*2,n=l/2),e=e.subtract(N(t,n,!0)).add(u).add(d),vt(i,`leaflet-tooltip-right`),vt(i,`leaflet-tooltip-left`),vt(i,`leaflet-tooltip-top`),vt(i,`leaflet-tooltip-bottom`),_t(i,`leaflet-tooltip-`+s),Ct(i,e)},_updatePosition:function(){var e=this._map.latLngToLayerPoint(this._latlng);this._setPosition(e)},setOpacity:function(e){this.options.opacity=e,this._container&&Z(this._container,e)},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center);this._setPosition(t)},_getAnchor:function(){return N(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),Nr=function(e,t){return new Mr(e,t)};rn.include({openTooltip:function(e,t,n){return this._initOverlay(Mr,e,t,n).openOn(this),this},closeTooltip:function(e){return e.close(),this}}),Gn.include({bindTooltip:function(e,t){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(Mr,this._tooltip,e,t),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&=(this._initTooltipInteractions(!0),this.closeTooltip(),null),this},_initTooltipInteractions:function(e){if(e||!this._tooltipHandlersAdded){var t=e?`off`:`on`,n={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?n.add=this._openTooltip:(n.mouseover=this._openTooltip,n.mouseout=this.closeTooltip,n.click=this._openTooltip,this._map?this._addFocusListeners():n.add=this._addFocusListeners),this._tooltip.options.sticky&&(n.mousemove=this._moveTooltip),this[t](n),this._tooltipHandlersAdded=!e}},openTooltip:function(e){return this._tooltip&&(this instanceof Jn||(this._tooltip._source=this),this._tooltip._prepareOpen(e)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(e){return this._tooltip&&this._tooltip.setContent(e),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(e){var t=typeof e.getElement==`function`&&e.getElement();t&&(Rt(t,`focus`,function(){this._tooltip._source=e,this.openTooltip()},this),Rt(t,`blur`,this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(e){var t=typeof e.getElement==`function`&&e.getElement();t&&t.setAttribute(`aria-describedby`,this._tooltip._container.id)},_openTooltip:function(e){if(this._tooltip&&this._map){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var t=this;this._map.once(`moveend`,function(){t._openOnceFlag=!1,t._openTooltip(e)})}else this._tooltip._source=e.layer||e.target,this.openTooltip(this._tooltip.options.sticky?e.latlng:void 0)}},_moveTooltip:function(e){var t=e.latlng,n,r;this._tooltip.options.sticky&&e.originalEvent&&(n=this._map.mouseEventToContainerPoint(e.originalEvent),r=this._map.containerPointToLayerPoint(n),t=this._map.layerPointToLatLng(r)),this._tooltip.setLatLng(t)}});var Pr=Xn.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:`leaflet-div-icon`},createIcon:function(e){var t=e&&e.tagName===`DIV`?e:document.createElement(`div`),n=this.options;if(n.html instanceof Element?(pt(t),t.appendChild(n.html)):t.innerHTML=n.html===!1?``:n.html,n.bgPos){var r=N(n.bgPos);t.style.backgroundPosition=-r.x+`px `+-r.y+`px`}return this._setIconStyles(t,`icon`),t},createShadow:function(){return null}});function Fr(e){return new Pr(e)}Xn.Default=Qn;var Ir=Gn.extend({options:{tileSize:256,opacity:1,updateWhenIdle:W.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:`tilePane`,className:``,keepBuffer:2},initialize:function(e){p(this,e)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(e){e._addZoomLimit(this)},onRemove:function(e){this._removeAllTiles(),ft(this._container),e._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(mt(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(ht(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(e){return this.options.opacity=e,this._updateOpacity(),this},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var e=this._clampZoom(this._map.getZoom());e!==this._tileZoom&&(this._tileZoom=e,this._updateLevels()),this._update()}return this},getEvents:function(){var e={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||=s(this._onMoveEnd,this.options.updateInterval,this),e.move=this._onMove),this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},createTile:function(){return document.createElement(`div`)},getTileSize:function(){var e=this.options.tileSize;return e instanceof j?e:new j(e,e)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(e){for(var t=this.getPane().children,n=-e(-1/0,1/0),r=0,i=t.length,a;r<i;r++)a=t[r].style.zIndex,t[r]!==this._container&&a&&(n=e(n,+a));isFinite(n)&&(this.options.zIndex=n+e(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!W.ielt9){Z(this._container,this.options.opacity);var e=+new Date,t=!1,n=!1;for(var r in this._tiles){var i=this._tiles[r];if(i.current&&i.loaded){var a=Math.min(1,(e-i.loaded)/200);Z(i.el,a),a<1?t=!0:(i.active?n=!0:this._onOpaqueTile(i),i.active=!0)}}n&&!this._noPrune&&this._pruneTiles(),t&&(E(this._fadeFrame),this._fadeFrame=T(this._updateOpacity,this))}},_onOpaqueTile:l,_initContainer:function(){this._container||(this._container=dt(`div`,`leaflet-layer `+(this.options.className||``)),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var e=this._tileZoom,t=this.options.maxZoom;if(e!==void 0){for(var n in this._levels)n=Number(n),this._levels[n].el.children.length||n===e?(this._levels[n].el.style.zIndex=t-Math.abs(e-n),this._onUpdateLevel(n)):(ft(this._levels[n].el),this._removeTilesAtZoom(n),this._onRemoveLevel(n),delete this._levels[n]);var r=this._levels[e],i=this._map;return r||(r=this._levels[e]={},r.el=dt(`div`,`leaflet-tile-container leaflet-zoom-animated`,this._container),r.el.style.zIndex=t,r.origin=i.project(i.unproject(i.getPixelOrigin()),e).round(),r.zoom=e,this._setZoomTransform(r,i.getCenter(),i.getZoom()),r.el.offsetWidth,this._onCreateLevel(r)),this._level=r,r}},_onUpdateLevel:l,_onRemoveLevel:l,_onCreateLevel:l,_pruneTiles:function(){if(this._map){var e,t,n=this._map.getZoom();if(n>this.options.maxZoom||n<this.options.minZoom)this._removeAllTiles();else{for(e in this._tiles)t=this._tiles[e],t.retain=t.current;for(e in this._tiles)if(t=this._tiles[e],t.current&&!t.active){var r=t.coords;this._retainParent(r.x,r.y,r.z,r.z-5)||this._retainChildren(r.x,r.y,r.z,r.z+2)}for(e in this._tiles)this._tiles[e].retain||this._removeTile(e)}}},_removeTilesAtZoom:function(e){for(var t in this._tiles)this._tiles[t].coords.z===e&&this._removeTile(t)},_removeAllTiles:function(){for(var e in this._tiles)this._removeTile(e)},_invalidateAll:function(){for(var e in this._levels)ft(this._levels[e].el),this._onRemoveLevel(Number(e)),delete this._levels[e];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(e,t,n,r){var i=Math.floor(e/2),a=Math.floor(t/2),o=n-1,s=new j(+i,+a);s.z=+o;var c=this._tileCoordsToKey(s),l=this._tiles[c];return l&&l.active?(l.retain=!0,!0):(l&&l.loaded&&(l.retain=!0),o>r&&this._retainParent(i,a,o,r))},_retainChildren:function(e,t,n,r){for(var i=2*e;i<2*e+2;i++)for(var a=2*t;a<2*t+2;a++){var o=new j(i,a);o.z=n+1;var s=this._tileCoordsToKey(o),c=this._tiles[s];c&&c.active?c.retain=!0:(c&&c.loaded&&(c.retain=!0),n+1<r&&this._retainChildren(i,a,n+1,r))}},_resetView:function(e){var t=e&&(e.pinch||e.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),t,t)},_animateZoom:function(e){this._setView(e.center,e.zoom,!0,e.noUpdate)},_clampZoom:function(e){var t=this.options;return t.minNativeZoom!==void 0&&e<t.minNativeZoom?t.minNativeZoom:t.maxNativeZoom!==void 0&&t.maxNativeZoom<e?t.maxNativeZoom:e},_setView:function(e,t,n,r){var i=Math.round(t);i=this.options.maxZoom!==void 0&&i>this.options.maxZoom||this.options.minZoom!==void 0&&i<this.options.minZoom?void 0:this._clampZoom(i);var a=this.options.updateWhenZooming&&i!==this._tileZoom;(!r||a)&&(this._tileZoom=i,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),i!==void 0&&this._update(e),n||this._pruneTiles(),this._noPrune=!!n),this._setZoomTransforms(e,t)},_setZoomTransforms:function(e,t){for(var n in this._levels)this._setZoomTransform(this._levels[n],e,t)},_setZoomTransform:function(e,t,n){var r=this._map.getZoomScale(n,e.zoom),i=e.origin.multiplyBy(r).subtract(this._map._getNewPixelOrigin(t,n)).round();W.any3d?Q(e.el,i,r):Ct(e.el,i)},_resetGrid:function(){var e=this._map,t=e.options.crs,n=this._tileSize=this.getTileSize(),r=this._tileZoom,i=this._map.getPixelWorldBounds(this._tileZoom);i&&(this._globalTileRange=this._pxBoundsToTileRange(i)),this._wrapX=t.wrapLng&&!this.options.noWrap&&[Math.floor(e.project([0,t.wrapLng[0]],r).x/n.x),Math.ceil(e.project([0,t.wrapLng[1]],r).x/n.y)],this._wrapY=t.wrapLat&&!this.options.noWrap&&[Math.floor(e.project([t.wrapLat[0],0],r).y/n.x),Math.ceil(e.project([t.wrapLat[1],0],r).y/n.y)]},_onMoveEnd:function(){this._map&&!this._map._animatingZoom&&this._update()},_getTiledPixelBounds:function(e){var t=this._map,n=t._animatingZoom?Math.max(t._animateToZoom,t.getZoom()):t.getZoom(),r=t.getZoomScale(n,this._tileZoom),i=t.project(e,this._tileZoom).floor(),a=t.getSize().divideBy(r*2);return new P(i.subtract(a),i.add(a))},_update:function(e){var t=this._map;if(t){var n=this._clampZoom(t.getZoom());if(e===void 0&&(e=t.getCenter()),this._tileZoom!==void 0){var r=this._getTiledPixelBounds(e),i=this._pxBoundsToTileRange(r),a=i.getCenter(),o=[],s=this.options.keepBuffer,c=new P(i.getBottomLeft().subtract([s,-s]),i.getTopRight().add([s,-s]));if(!(isFinite(i.min.x)&&isFinite(i.min.y)&&isFinite(i.max.x)&&isFinite(i.max.y)))throw Error(`Attempted to load an infinite number of tiles`);for(var l in this._tiles){var u=this._tiles[l].coords;u.z===this._tileZoom&&c.contains(new j(u.x,u.y))||(this._tiles[l].current=!1)}if(Math.abs(n-this._tileZoom)>1)this._setView(e,n);else{for(var d=i.min.y;d<=i.max.y;d++)for(var f=i.min.x;f<=i.max.x;f++){var p=new j(f,d);if(p.z=this._tileZoom,this._isValidTile(p)){var m=this._tiles[this._tileCoordsToKey(p)];m?m.current=!0:o.push(p)}}if(o.sort(function(e,t){return e.distanceTo(a)-t.distanceTo(a)}),o.length!==0){this._loading||(this._loading=!0,this.fire(`loading`));var h=document.createDocumentFragment();for(f=0;f<o.length;f++)this._addTile(o[f],h);this._level.el.appendChild(h)}}}}},_isValidTile:function(e){var t=this._map.options.crs;if(!t.infinite){var n=this._globalTileRange;if(!t.wrapLng&&(e.x<n.min.x||e.x>n.max.x)||!t.wrapLat&&(e.y<n.min.y||e.y>n.max.y))return!1}if(!this.options.bounds)return!0;var r=this._tileCoordsToBounds(e);return te(this.options.bounds).overlaps(r)},_keyToBounds:function(e){return this._tileCoordsToBounds(this._keyToTileCoords(e))},_tileCoordsToNwSe:function(e){var t=this._map,n=this.getTileSize(),r=e.scaleBy(n),i=r.add(n);return[t.unproject(r,e.z),t.unproject(i,e.z)]},_tileCoordsToBounds:function(e){var t=this._tileCoordsToNwSe(e),n=new I(t[0],t[1]);return this.options.noWrap||(n=this._map.wrapLatLngBounds(n)),n},_tileCoordsToKey:function(e){return e.x+`:`+e.y+`:`+e.z},_keyToTileCoords:function(e){var t=e.split(`:`),n=new j(+t[0],+t[1]);return n.z=+t[2],n},_removeTile:function(e){var t=this._tiles[e];t&&(ft(t.el),delete this._tiles[e],this.fire(`tileunload`,{tile:t.el,coords:this._keyToTileCoords(e)}))},_initTile:function(e){_t(e,`leaflet-tile`);var t=this.getTileSize();e.style.width=t.x+`px`,e.style.height=t.y+`px`,e.onselectstart=l,e.onmousemove=l,W.ielt9&&this.options.opacity<1&&Z(e,this.options.opacity)},_addTile:function(e,t){var n=this._getTilePos(e),r=this._tileCoordsToKey(e),a=this.createTile(this._wrapCoords(e),i(this._tileReady,this,e));this._initTile(a),this.createTile.length<2&&T(i(this._tileReady,this,e,null,a)),Ct(a,n),this._tiles[r]={el:a,coords:e,current:!0},t.appendChild(a),this.fire(`tileloadstart`,{tile:a,coords:e})},_tileReady:function(e,t,n){t&&this.fire(`tileerror`,{error:t,tile:n,coords:e});var r=this._tileCoordsToKey(e);n=this._tiles[r],n&&(n.loaded=+new Date,this._map._fadeAnimated?(Z(n.el,0),E(this._fadeFrame),this._fadeFrame=T(this._updateOpacity,this)):(n.active=!0,this._pruneTiles()),t||(_t(n.el,`leaflet-tile-loaded`),this.fire(`tileload`,{tile:n.el,coords:e})),this._noTilesToLoad()&&(this._loading=!1,this.fire(`load`),W.ielt9||!this._map._fadeAnimated?T(this._pruneTiles,this):setTimeout(i(this._pruneTiles,this),250)))},_getTilePos:function(e){return e.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(e){var t=new j(this._wrapX?c(e.x,this._wrapX):e.x,this._wrapY?c(e.y,this._wrapY):e.y);return t.z=e.z,t},_pxBoundsToTileRange:function(e){var t=this.getTileSize();return new P(e.min.unscaleBy(t).floor(),e.max.unscaleBy(t).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var e in this._tiles)if(!this._tiles[e].loaded)return!1;return!0}});function Lr(e){return new Ir(e)}var Rr=Ir.extend({options:{minZoom:0,maxZoom:18,subdomains:`abc`,errorTileUrl:``,zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(e,t){this._url=e,t=p(this,t),t.detectRetina&&W.retina&&t.maxZoom>0?(t.tileSize=Math.floor(t.tileSize/2),t.zoomReverse?(t.zoomOffset--,t.minZoom=Math.min(t.maxZoom,t.minZoom+1)):(t.zoomOffset++,t.maxZoom=Math.max(t.minZoom,t.maxZoom-1)),t.minZoom=Math.max(0,t.minZoom)):t.zoomReverse?t.minZoom=Math.min(t.maxZoom,t.minZoom):t.maxZoom=Math.max(t.minZoom,t.maxZoom),typeof t.subdomains==`string`&&(t.subdomains=t.subdomains.split(``)),this.on(`tileunload`,this._onTileRemove)},setUrl:function(e,t){return this._url===e&&t===void 0&&(t=!0),this._url=e,t||this.redraw(),this},createTile:function(e,t){var n=document.createElement(`img`);return Rt(n,`load`,i(this._tileOnLoad,this,t,n)),Rt(n,`error`,i(this._tileOnError,this,t,n)),(this.options.crossOrigin||this.options.crossOrigin===``)&&(n.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),typeof this.options.referrerPolicy==`string`&&(n.referrerPolicy=this.options.referrerPolicy),n.alt=``,n.src=this.getTileUrl(e),n},getTileUrl:function(e){var t={r:W.retina?`@2x`:``,s:this._getSubdomain(e),x:e.x,y:e.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var r=this._globalTileRange.max.y-e.y;this.options.tms&&(t.y=r),t[`-y`]=r}return g(this._url,n(t,this.options))},_tileOnLoad:function(e,t){W.ielt9?setTimeout(i(e,this,null,t),0):e(null,t)},_tileOnError:function(e,t,n){var r=this.options.errorTileUrl;r&&t.getAttribute(`src`)!==r&&(t.src=r),e(n,t)},_onTileRemove:function(e){e.tile.onload=null},_getZoomForUrl:function(){var e=this._tileZoom,t=this.options.maxZoom,n=this.options.zoomReverse,r=this.options.zoomOffset;return n&&(e=t-e),e+r},_getSubdomain:function(e){var t=Math.abs(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[t]},_abortLoading:function(){var e,t;for(e in this._tiles)if(this._tiles[e].coords.z!==this._tileZoom&&(t=this._tiles[e].el,t.onload=l,t.onerror=l,!t.complete)){t.src=y;var n=this._tiles[e].coords;ft(t),delete this._tiles[e],this.fire(`tileabort`,{tile:t,coords:n})}},_removeTile:function(e){var t=this._tiles[e];if(t)return t.el.setAttribute(`src`,y),Ir.prototype._removeTile.call(this,e)},_tileReady:function(e,t,n){if(!(!this._map||n&&n.getAttribute(`src`)===y))return Ir.prototype._tileReady.call(this,e,t,n)}});function zr(e,t){return new Rr(e,t)}var Br=Rr.extend({defaultWmsParams:{service:`WMS`,request:`GetMap`,layers:``,styles:``,format:`image/jpeg`,transparent:!1,version:`1.1.1`},options:{crs:null,uppercase:!1},initialize:function(e,t){this._url=e;var r=n({},this.defaultWmsParams);for(var i in t)i in this.options||(r[i]=t[i]);t=p(this,t);var a=t.detectRetina&&W.retina?2:1,o=this.getTileSize();r.width=o.x*a,r.height=o.y*a,this.wmsParams=r},onAdd:function(e){this._crs=this.options.crs||e.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var t=this._wmsVersion>=1.3?`crs`:`srs`;this.wmsParams[t]=this._crs.code,Rr.prototype.onAdd.call(this,e)},getTileUrl:function(e){var t=this._tileCoordsToNwSe(e),n=this._crs,r=F(n.project(t[0]),n.project(t[1])),i=r.min,a=r.max,o=(this._wmsVersion>=1.3&&this._crs===Un?[i.y,i.x,a.y,a.x]:[i.x,i.y,a.x,a.y]).join(`,`),s=Rr.prototype.getTileUrl.call(this,e);return s+m(this.wmsParams,s,this.options.uppercase)+(this.options.uppercase?`&BBOX=`:`&bbox=`)+o},setParams:function(e,t){return n(this.wmsParams,e),t||this.redraw(),this}});function Vr(e,t){return new Br(e,t)}Rr.WMS=Br,zr.wms=Vr;var Hr=Gn.extend({options:{padding:.1},initialize:function(e){p(this,e),o(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),_t(this._container,`leaflet-zoom-animated`)),this.getPane().appendChild(this._container),this._update(),this.on(`update`,this._updatePaths,this)},onRemove:function(){this.off(`update`,this._updatePaths,this),this._destroyContainer()},getEvents:function(){var e={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(e.zoomanim=this._onAnimZoom),e},_onAnimZoom:function(e){this._updateTransform(e.center,e.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(e,t){var n=this._map.getZoomScale(t,this._zoom),r=this._map.getSize().multiplyBy(.5+this.options.padding),i=this._map.project(this._center,t),a=r.multiplyBy(-n).add(i).subtract(this._map._getNewPixelOrigin(e,t));W.any3d?Q(this._container,a,n):Ct(this._container,a)},_reset:function(){for(var e in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[e]._reset()},_onZoomEnd:function(){for(var e in this._layers)this._layers[e]._project()},_updatePaths:function(){for(var e in this._layers)this._layers[e]._update()},_update:function(){var e=this.options.padding,t=this._map.getSize(),n=this._map.containerPointToLayerPoint(t.multiplyBy(-e)).round();this._bounds=new P(n,n.add(t.multiplyBy(1+e*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Ur=Hr.extend({options:{tolerance:0},getEvents:function(){var e=Hr.prototype.getEvents.call(this);return e.viewprereset=this._onViewPreReset,e},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Hr.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var e=this._container=document.createElement(`canvas`);Rt(e,`mousemove`,this._onMouseMove,this),Rt(e,`click dblclick mousedown mouseup contextmenu`,this._onClick,this),Rt(e,`mouseout`,this._handleMouseOut,this),e._leaflet_disable_events=!0,this._ctx=e.getContext(`2d`)},_destroyContainer:function(){E(this._redrawRequest),delete this._ctx,ft(this._container),Bt(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var e;for(var t in this._redrawBounds=null,this._layers)e=this._layers[t],e._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Hr.prototype._update.call(this);var e=this._bounds,t=this._container,n=e.getSize(),r=W.retina?2:1;Ct(t,e.min),t.width=r*n.x,t.height=r*n.y,t.style.width=n.x+`px`,t.style.height=n.y+`px`,W.retina&&this._ctx.scale(2,2),this._ctx.translate(-e.min.x,-e.min.y),this.fire(`update`)}},_reset:function(){Hr.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(e){this._updateDashArray(e),this._layers[o(e)]=e;var t=e._order={layer:e,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=t),this._drawLast=t,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(e){this._requestRedraw(e)},_removePath:function(e){var t=e._order,n=t.next,r=t.prev;n?n.prev=r:this._drawLast=r,r?r.next=n:this._drawFirst=n,delete e._order,delete this._layers[o(e)],this._requestRedraw(e)},_updatePath:function(e){this._extendRedrawBounds(e),e._project(),e._update(),this._requestRedraw(e)},_updateStyle:function(e){this._updateDashArray(e),this._requestRedraw(e)},_updateDashArray:function(e){if(typeof e.options.dashArray==`string`){for(var t=e.options.dashArray.split(/[, ]+/),n=[],r,i=0;i<t.length;i++){if(r=Number(t[i]),isNaN(r))return;n.push(r)}e.options._dashArray=n}else e.options._dashArray=e.options.dashArray},_requestRedraw:function(e){this._map&&(this._extendRedrawBounds(e),this._redrawRequest=this._redrawRequest||T(this._redraw,this))},_extendRedrawBounds:function(e){if(e._pxBounds){var t=(e.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new P,this._redrawBounds.extend(e._pxBounds.min.subtract([t,t])),this._redrawBounds.extend(e._pxBounds.max.add([t,t]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var e=this._redrawBounds;if(e){var t=e.getSize();this._ctx.clearRect(e.min.x,e.min.y,t.x,t.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var e,t=this._redrawBounds;if(this._ctx.save(),t){var n=t.getSize();this._ctx.beginPath(),this._ctx.rect(t.min.x,t.min.y,n.x,n.y),this._ctx.clip()}this._drawing=!0;for(var r=this._drawFirst;r;r=r.next)e=r.layer,(!t||e._pxBounds&&e._pxBounds.intersects(t))&&e._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(e,t){if(this._drawing){var n,r,i,a,o=e._parts,s=o.length,c=this._ctx;if(s){for(c.beginPath(),n=0;n<s;n++){for(r=0,i=o[n].length;r<i;r++)a=o[n][r],c[r?`lineTo`:`moveTo`](a.x,a.y);t&&c.closePath()}this._fillStroke(c,e)}}},_updateCircle:function(e){if(this._drawing&&!e._empty()){var t=e._point,n=this._ctx,r=Math.max(Math.round(e._radius),1),i=(Math.max(Math.round(e._radiusY),1)||r)/r;i!==1&&(n.save(),n.scale(1,i)),n.beginPath(),n.arc(t.x,t.y/i,r,0,Math.PI*2,!1),i!==1&&n.restore(),this._fillStroke(n,e)}},_fillStroke:function(e,t){var n=t.options;n.fill&&(e.globalAlpha=n.fillOpacity,e.fillStyle=n.fillColor||n.color,e.fill(n.fillRule||`evenodd`)),n.stroke&&n.weight!==0&&(e.setLineDash&&e.setLineDash(t.options&&t.options._dashArray||[]),e.globalAlpha=n.opacity,e.lineWidth=n.weight,e.strokeStyle=n.color,e.lineCap=n.lineCap,e.lineJoin=n.lineJoin,e.stroke())},_onClick:function(e){for(var t=this._map.mouseEventToLayerPoint(e),n,r,i=this._drawFirst;i;i=i.next)n=i.layer,n.options.interactive&&n._containsPoint(t)&&(e.type!==`click`&&e.type!==`preclick`||!this._map._draggableMoved(n))&&(r=n);this._fireEvent(r?[r]:!1,e)},_onMouseMove:function(e){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var t=this._map.mouseEventToLayerPoint(e);this._handleMouseHover(e,t)}},_handleMouseOut:function(e){var t=this._hoveredLayer;t&&(vt(this._container,`leaflet-interactive`),this._fireEvent([t],e,`mouseout`),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(e,t){if(!this._mouseHoverThrottled){for(var n,r,a=this._drawFirst;a;a=a.next)n=a.layer,n.options.interactive&&n._containsPoint(t)&&(r=n);r!==this._hoveredLayer&&(this._handleMouseOut(e),r&&(_t(this._container,`leaflet-interactive`),this._fireEvent([r],e,`mouseover`),this._hoveredLayer=r)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,e),this._mouseHoverThrottled=!0,setTimeout(i(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(e,t,n){this._map._fireDOMEvent(t,n||t.type,e)},_bringToFront:function(e){var t=e._order;if(t){var n=t.next,r=t.prev;if(n)n.prev=r;else return;r?r.next=n:n&&(this._drawFirst=n),t.prev=this._drawLast,this._drawLast.next=t,t.next=null,this._drawLast=t,this._requestRedraw(e)}},_bringToBack:function(e){var t=e._order;if(t){var n=t.next,r=t.prev;if(r)r.next=n;else return;n?n.prev=r:r&&(this._drawLast=r),t.prev=null,t.next=this._drawFirst,this._drawFirst.prev=t,this._drawFirst=t,this._requestRedraw(e)}}});function Wr(e){return W.canvas?new Ur(e):null}var Gr=(function(){try{return document.namespaces.add(`lvml`,`urn:schemas-microsoft-com:vml`),function(e){return document.createElement(`<lvml:`+e+` class="lvml">`)}}catch{}return function(e){return document.createElement(`<`+e+` xmlns="urn:schemas-microsoft.com:vml" class="lvml">`)}})(),Kr={_initContainer:function(){this._container=dt(`div`,`leaflet-vml-container`)},_update:function(){this._map._animatingZoom||(Hr.prototype._update.call(this),this.fire(`update`))},_initPath:function(e){var t=e._container=Gr(`shape`);_t(t,`leaflet-vml-shape `+(this.options.className||``)),t.coordsize=`1 1`,e._path=Gr(`path`),t.appendChild(e._path),this._updateStyle(e),this._layers[o(e)]=e},_addPath:function(e){var t=e._container;this._container.appendChild(t),e.options.interactive&&e.addInteractiveTarget(t)},_removePath:function(e){var t=e._container;ft(t),e.removeInteractiveTarget(t),delete this._layers[o(e)]},_updateStyle:function(e){var t=e._stroke,n=e._fill,r=e.options,i=e._container;i.stroked=!!r.stroke,i.filled=!!r.fill,r.stroke?(t||=e._stroke=Gr(`stroke`),i.appendChild(t),t.weight=r.weight+`px`,t.color=r.color,t.opacity=r.opacity,r.dashArray?t.dashStyle=_(r.dashArray)?r.dashArray.join(` `):r.dashArray.replace(/( *, *)/g,` `):t.dashStyle=``,t.endcap=r.lineCap.replace(`butt`,`flat`),t.joinstyle=r.lineJoin):t&&(i.removeChild(t),e._stroke=null),r.fill?(n||=e._fill=Gr(`fill`),i.appendChild(n),n.color=r.fillColor||r.color,n.opacity=r.fillOpacity):n&&(i.removeChild(n),e._fill=null)},_updateCircle:function(e){var t=e._point.round(),n=Math.round(e._radius),r=Math.round(e._radiusY||n);this._setPath(e,e._empty()?`M0 0`:`AL `+t.x+`,`+t.y+` `+n+`,`+r+` 0,23592600`)},_setPath:function(e,t){e._path.v=t},_bringToFront:function(e){mt(e._container)},_bringToBack:function(e){ht(e._container)}},qr=W.vml?Gr:le,Jr=Hr.extend({_initContainer:function(){this._container=qr(`svg`),this._container.setAttribute(`pointer-events`,`none`),this._rootGroup=qr(`g`),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ft(this._container),Bt(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Hr.prototype._update.call(this);var e=this._bounds,t=e.getSize(),n=this._container;this._svgSize&&this._svgSize.equals(t)||(this._svgSize=t,n.setAttribute(`width`,t.x),n.setAttribute(`height`,t.y)),Ct(n,e.min),n.setAttribute(`viewBox`,[e.min.x,e.min.y,t.x,t.y].join(` `)),this.fire(`update`)}},_initPath:function(e){var t=e._path=qr(`path`);e.options.className&&_t(t,e.options.className),e.options.interactive&&_t(t,`leaflet-interactive`),this._updateStyle(e),this._layers[o(e)]=e},_addPath:function(e){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(e._path),e.addInteractiveTarget(e._path)},_removePath:function(e){ft(e._path),e.removeInteractiveTarget(e._path),delete this._layers[o(e)]},_updatePath:function(e){e._project(),e._update()},_updateStyle:function(e){var t=e._path,n=e.options;t&&(n.stroke?(t.setAttribute(`stroke`,n.color),t.setAttribute(`stroke-opacity`,n.opacity),t.setAttribute(`stroke-width`,n.weight),t.setAttribute(`stroke-linecap`,n.lineCap),t.setAttribute(`stroke-linejoin`,n.lineJoin),n.dashArray?t.setAttribute(`stroke-dasharray`,n.dashArray):t.removeAttribute(`stroke-dasharray`),n.dashOffset?t.setAttribute(`stroke-dashoffset`,n.dashOffset):t.removeAttribute(`stroke-dashoffset`)):t.setAttribute(`stroke`,`none`),n.fill?(t.setAttribute(`fill`,n.fillColor||n.color),t.setAttribute(`fill-opacity`,n.fillOpacity),t.setAttribute(`fill-rule`,n.fillRule||`evenodd`)):t.setAttribute(`fill`,`none`))},_updatePoly:function(e,t){this._setPath(e,ue(e._parts,t))},_updateCircle:function(e){var t=e._point,n=Math.max(Math.round(e._radius),1),r=Math.max(Math.round(e._radiusY),1)||n,i=`a`+n+`,`+r+` 0 1,0 `,a=e._empty()?`M0 0`:`M`+(t.x-n)+`,`+t.y+i+n*2+`,0 `+i+-n*2+`,0 `;this._setPath(e,a)},_setPath:function(e,t){e._path.setAttribute(`d`,t)},_bringToFront:function(e){mt(e._path)},_bringToBack:function(e){ht(e._path)}});W.vml&&Jr.include(Kr);function Yr(e){return W.svg||W.vml?new Jr(e):null}rn.include({getRenderer:function(e){var t=e.options.renderer||this._getPaneRenderer(e.options.pane)||this.options.renderer||this._renderer;return t||=this._renderer=this._createRenderer(),this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer:function(e){if(e===`overlayPane`||e===void 0)return!1;var t=this._paneRenderers[e];return t===void 0&&(t=this._createRenderer({pane:e}),this._paneRenderers[e]=t),t},_createRenderer:function(e){return this.options.preferCanvas&&Wr(e)||Yr(e)}});var Xr=lr.extend({initialize:function(e,t){lr.prototype.initialize.call(this,this._boundsToLatLngs(e),t)},setBounds:function(e){return this.setLatLngs(this._boundsToLatLngs(e))},_boundsToLatLngs:function(e){return e=te(e),[e.getSouthWest(),e.getNorthWest(),e.getNorthEast(),e.getSouthEast()]}});function Zr(e,t){return new Xr(e,t)}Jr.create=qr,Jr.pointsToPath=ue,dr.geometryToLayer=fr,dr.coordsToLatLng=mr,dr.coordsToLatLngs=hr,dr.latLngToCoords=gr,dr.latLngsToCoords=_r,dr.getFeature=vr,dr.asFeature=yr,rn.mergeOptions({boxZoom:!0});var Qr=hn.extend({initialize:function(e){this._map=e,this._container=e._container,this._pane=e._panes.overlayPane,this._resetStateTimeout=0,e.on(`unload`,this._destroy,this)},addHooks:function(){Rt(this._container,`mousedown`,this._onMouseDown,this)},removeHooks:function(){Bt(this._container,`mousedown`,this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ft(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(e){if(!e.shiftKey||e.which!==1&&e.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),Tt(),kt(),this._startPoint=this._map.mouseEventToContainerPoint(e),Rt(document,{contextmenu:Yt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(e){this._moved||(this._moved=!0,this._box=dt(`div`,`leaflet-zoom-box`,this._container),_t(this._container,`leaflet-crosshair`),this._map.fire(`boxzoomstart`)),this._point=this._map.mouseEventToContainerPoint(e);var t=new P(this._point,this._startPoint),n=t.getSize();Ct(this._box,t.min),this._box.style.width=n.x+`px`,this._box.style.height=n.y+`px`},_finish:function(){this._moved&&(ft(this._box),vt(this._container,`leaflet-crosshair`)),Et(),At(),Bt(document,{contextmenu:Yt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(e){if((e.which===1||e.button===1)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(i(this._resetState,this),0);var t=new I(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(t).fire(`boxzoomend`,{boxZoomBounds:t})}},_onKeyDown:function(e){e.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});rn.addInitHook(`addHandler`,`boxZoom`,Qr),rn.mergeOptions({doubleClickZoom:!0});var $r=hn.extend({addHooks:function(){this._map.on(`dblclick`,this._onDoubleClick,this)},removeHooks:function(){this._map.off(`dblclick`,this._onDoubleClick,this)},_onDoubleClick:function(e){var t=this._map,n=t.getZoom(),r=t.options.zoomDelta,i=e.originalEvent.shiftKey?n-r:n+r;t.options.doubleClickZoom===`center`?t.setZoom(i):t.setZoomAround(e.containerPoint,i)}});rn.addInitHook(`addHandler`,`doubleClickZoom`,$r),rn.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var ei=hn.extend({addHooks:function(){if(!this._draggable){var e=this._map;this._draggable=new vn(e._mapPane,e._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on(`predrag`,this._onPreDragLimit,this),e.options.worldCopyJump&&(this._draggable.on(`predrag`,this._onPreDragWrap,this),e.on(`zoomend`,this._onZoomEnd,this),e.whenReady(this._onZoomEnd,this))}_t(this._map._container,`leaflet-grab leaflet-touch-drag`),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){vt(this._map._container,`leaflet-grab`),vt(this._map._container,`leaflet-touch-drag`),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var e=this._map;if(e._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var t=te(this._map.options.maxBounds);this._offsetLimit=F(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;e.fire(`movestart`).fire(`dragstart`),e.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(e){if(this._map.options.inertia){var t=this._lastTime=+new Date,n=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(n),this._times.push(t),this._prunePositions(t)}this._map.fire(`move`,e).fire(`drag`,e)},_prunePositions:function(e){for(;this._positions.length>1&&e-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var e=this._map.getSize().divideBy(2),t=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=t.subtract(e).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(e,t){return e-(e-t)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var e=this._draggable._newPos.subtract(this._draggable._startPos),t=this._offsetLimit;e.x<t.min.x&&(e.x=this._viscousLimit(e.x,t.min.x)),e.y<t.min.y&&(e.y=this._viscousLimit(e.y,t.min.y)),e.x>t.max.x&&(e.x=this._viscousLimit(e.x,t.max.x)),e.y>t.max.y&&(e.y=this._viscousLimit(e.y,t.max.y)),this._draggable._newPos=this._draggable._startPos.add(e)}},_onPreDragWrap:function(){var e=this._worldWidth,t=Math.round(e/2),n=this._initialWorldOffset,r=this._draggable._newPos.x,i=(r-t+n)%e+t-n,a=(r+t+n)%e-t-n,o=Math.abs(i+n)<Math.abs(a+n)?i:a;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=o},_onDragEnd:function(e){var t=this._map,n=t.options,r=!n.inertia||e.noInertia||this._times.length<2;if(t.fire(`dragend`,e),r)t.fire(`moveend`);else{this._prunePositions(+new Date);var i=this._lastPos.subtract(this._positions[0]),a=(this._lastTime-this._times[0])/1e3,o=n.easeLinearity,s=i.multiplyBy(o/a),c=s.distanceTo([0,0]),l=Math.min(n.inertiaMaxSpeed,c),u=s.multiplyBy(l/c),d=l/(n.inertiaDeceleration*o),f=u.multiplyBy(-d/2).round();!f.x&&!f.y?t.fire(`moveend`):(f=t._limitOffset(f,t.options.maxBounds),T(function(){t.panBy(f,{duration:d,easeLinearity:o,noMoveStart:!0,animate:!0})}))}}});rn.addInitHook(`addHandler`,`dragging`,ei),rn.mergeOptions({keyboard:!0,keyboardPanDelta:80});var ti=hn.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(e){this._map=e,this._setPanDelta(e.options.keyboardPanDelta),this._setZoomDelta(e.options.zoomDelta)},addHooks:function(){var e=this._map._container;e.tabIndex<=0&&(e.tabIndex=`0`),Rt(e,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),Bt(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var e=document.body,t=document.documentElement,n=e.scrollTop||t.scrollTop,r=e.scrollLeft||t.scrollLeft;this._map._container.focus(),window.scrollTo(r,n)}},_onFocus:function(){this._focused=!0,this._map.fire(`focus`)},_onBlur:function(){this._focused=!1,this._map.fire(`blur`)},_setPanDelta:function(e){for(var t=this._panKeys={},n=this.keyCodes,r=0,i=n.left.length;r<i;r++)t[n.left[r]]=[-1*e,0];for(r=0,i=n.right.length;r<i;r++)t[n.right[r]]=[e,0];for(r=0,i=n.down.length;r<i;r++)t[n.down[r]]=[0,e];for(r=0,i=n.up.length;r<i;r++)t[n.up[r]]=[0,-1*e]},_setZoomDelta:function(e){for(var t=this._zoomKeys={},n=this.keyCodes,r=0,i=n.zoomIn.length;r<i;r++)t[n.zoomIn[r]]=e;for(r=0,i=n.zoomOut.length;r<i;r++)t[n.zoomOut[r]]=-e},_addHooks:function(){Rt(document,`keydown`,this._onKeyDown,this)},_removeHooks:function(){Bt(document,`keydown`,this._onKeyDown,this)},_onKeyDown:function(e){if(!(e.altKey||e.ctrlKey||e.metaKey)){var t=e.keyCode,n=this._map,r;if(t in this._panKeys){if(!n._panAnim||!n._panAnim._inProgress){if(r=this._panKeys[t],e.shiftKey&&(r=N(r).multiplyBy(3)),n.options.maxBounds&&(r=n._limitOffset(N(r),n.options.maxBounds)),n.options.worldCopyJump){var i=n.wrapLatLng(n.unproject(n.project(n.getCenter()).add(r)));n.panTo(i)}else n.panBy(r)}}else if(t in this._zoomKeys)n.setZoom(n.getZoom()+(e.shiftKey?3:1)*this._zoomKeys[t]);else if(t===27&&n._popup&&n._popup.options.closeOnEscapeKey)n.closePopup();else return;Yt(e)}}});rn.addInitHook(`addHandler`,`keyboard`,ti),rn.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var ni=hn.extend({addHooks:function(){Rt(this._map._container,`wheel`,this._onWheelScroll,this),this._delta=0},removeHooks:function(){Bt(this._map._container,`wheel`,this._onWheelScroll,this)},_onWheelScroll:function(e){var t=$t(e),n=this._map.options.wheelDebounceTime;this._delta+=t,this._lastMousePos=this._map.mouseEventToContainerPoint(e),this._startTime||=+new Date;var r=Math.max(n-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(i(this._performZoom,this),r),Yt(e)},_performZoom:function(){var e=this._map,t=e.getZoom(),n=this._map.options.zoomSnap||0;e._stop();var r=this._delta/(this._map.options.wheelPxPerZoomLevel*4),i=4*Math.log(2/(1+Math.exp(-Math.abs(r))))/Math.LN2,a=n?Math.ceil(i/n)*n:i,o=e._limitZoom(t+(this._delta>0?a:-a))-t;this._delta=0,this._startTime=null,o&&(e.options.scrollWheelZoom===`center`?e.setZoom(t+o):e.setZoomAround(this._lastMousePos,t+o))}});rn.addInitHook(`addHandler`,`scrollWheelZoom`,ni);var ri=600;rn.mergeOptions({tapHold:W.touchNative&&W.safari&&W.mobile,tapTolerance:15});var ii=hn.extend({addHooks:function(){Rt(this._map._container,`touchstart`,this._onDown,this)},removeHooks:function(){Bt(this._map._container,`touchstart`,this._onDown,this)},_onDown:function(e){if(clearTimeout(this._holdTimeout),e.touches.length===1){var t=e.touches[0];this._startPos=this._newPos=new j(t.clientX,t.clientY),this._holdTimeout=setTimeout(i(function(){this._cancel(),this._isTapValid()&&(Rt(document,`touchend`,Jt),Rt(document,`touchend touchcancel`,this._cancelClickPrevent),this._simulateEvent(`contextmenu`,t))},this),ri),Rt(document,`touchend touchcancel contextmenu`,this._cancel,this),Rt(document,`touchmove`,this._onMove,this)}},_cancelClickPrevent:function e(){Bt(document,`touchend`,Jt),Bt(document,`touchend touchcancel`,e)},_cancel:function(){clearTimeout(this._holdTimeout),Bt(document,`touchend touchcancel contextmenu`,this._cancel,this),Bt(document,`touchmove`,this._onMove,this)},_onMove:function(e){var t=e.touches[0];this._newPos=new j(t.clientX,t.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(e,t){var n=new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY});n._simulated=!0,t.target.dispatchEvent(n)}});rn.addInitHook(`addHandler`,`tapHold`,ii),rn.mergeOptions({touchZoom:W.touch,bounceAtZoomLimits:!0});var ai=hn.extend({addHooks:function(){_t(this._map._container,`leaflet-touch-zoom`),Rt(this._map._container,`touchstart`,this._onTouchStart,this)},removeHooks:function(){vt(this._map._container,`leaflet-touch-zoom`),Bt(this._map._container,`touchstart`,this._onTouchStart,this)},_onTouchStart:function(e){var t=this._map;if(!(!e.touches||e.touches.length!==2||t._animatingZoom||this._zooming)){var n=t.mouseEventToContainerPoint(e.touches[0]),r=t.mouseEventToContainerPoint(e.touches[1]);this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),t.options.touchZoom!==`center`&&(this._pinchStartLatLng=t.containerPointToLatLng(n.add(r)._divideBy(2))),this._startDist=n.distanceTo(r),this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0,t._stop(),Rt(document,`touchmove`,this._onTouchMove,this),Rt(document,`touchend touchcancel`,this._onTouchEnd,this),Jt(e)}},_onTouchMove:function(e){if(e.touches&&e.touches.length===2&&this._zooming){var t=this._map,n=t.mouseEventToContainerPoint(e.touches[0]),r=t.mouseEventToContainerPoint(e.touches[1]),a=n.distanceTo(r)/this._startDist;if(this._zoom=t.getScaleZoom(a,this._startZoom),!t.options.bounceAtZoomLimits&&(this._zoom<t.getMinZoom()&&a<1||this._zoom>t.getMaxZoom()&&a>1)&&(this._zoom=t._limitZoom(this._zoom)),t.options.touchZoom===`center`){if(this._center=this._startLatLng,a===1)return}else{var o=n._add(r)._divideBy(2)._subtract(this._centerPoint);if(a===1&&o.x===0&&o.y===0)return;this._center=t.unproject(t.project(this._pinchStartLatLng,this._zoom).subtract(o),this._zoom)}this._moved||=(t._moveStart(!0,!1),!0),E(this._animRequest);var s=i(t._move,t,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=T(s,this,!0),Jt(e)}},_onTouchEnd:function(){!this._moved||!this._zooming?this._zooming=!1:(this._zooming=!1,E(this._animRequest),Bt(document,`touchmove`,this._onTouchMove,this),Bt(document,`touchend touchcancel`,this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))}});rn.addInitHook(`addHandler`,`touchZoom`,ai),rn.BoxZoom=Qr,rn.DoubleClickZoom=$r,rn.Drag=ei,rn.Keyboard=ti,rn.ScrollWheelZoom=ni,rn.TapHold=ii,rn.TouchZoom=ai,e.Bounds=P,e.Browser=W,e.CRS=B,e.Canvas=Ur,e.Circle=ar,e.CircleMarker=rr,e.Class=O,e.Control=on,e.DivIcon=Pr,e.DivOverlay=kr,e.DomEvent=tn,e.DomUtil=Lt,e.Draggable=vn,e.Evented=A,e.FeatureGroup=Jn,e.GeoJSON=dr,e.GridLayer=Ir,e.Handler=hn,e.Icon=Xn,e.ImageOverlay=Cr,e.LatLng=R,e.LatLngBounds=I,e.Layer=Gn,e.LayerGroup=Kn,e.LineUtil=Rn,e.Map=rn,e.Marker=er,e.Mixin=gn,e.Path=nr,e.Point=j,e.PolyUtil=Sn,e.Polygon=lr,e.Polyline=sr,e.Popup=Ar,e.PosAnimation=nn,e.Projection=Vn,e.Rectangle=Xr,e.Renderer=Hr,e.SVG=Jr,e.SVGOverlay=Dr,e.TileLayer=Rr,e.Tooltip=Mr,e.Transformation=ae,e.Util=D,e.VideoOverlay=Tr,e.bind=i,e.bounds=F,e.canvas=Wr,e.circle=or,e.circleMarker=ir,e.control=sn,e.divIcon=Fr,e.extend=n,e.featureGroup=Yn,e.geoJSON=xr,e.geoJson=Sr,e.gridLayer=Lr,e.icon=Zn,e.imageOverlay=wr,e.latLng=z,e.latLngBounds=te,e.layerGroup=qn,e.map=an,e.marker=tr,e.point=N,e.polygon=ur,e.polyline=cr,e.popup=jr,e.rectangle=Zr,e.setOptions=p,e.stamp=o,e.svg=Yr,e.svgOverlay=Or,e.tileLayer=zr,e.tooltip=Nr,e.transformation=oe,e.version=t,e.videoOverlay=Er;var oi=window.L;e.noConflict=function(){return window.L=oi,this},window.L=e}))}))(),1);function gs({places:e,selected:t,onPick:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(n);o.current=n,(0,v.useEffect)(()=>{if(!r.current)return;let e=hs.default.map(r.current,{zoomControl:!0,attributionControl:!0}).setView([46.8,8.2],7);hs.default.tileLayer(`https://tile.openstreetmap.org/{z}/{x}/{y}.png`,{maxZoom:19,attribution:`&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">OpenStreetMap</a>`}).addTo(e),a.current=hs.default.layerGroup().addTo(e),i.current=e;let t=new ResizeObserver(()=>e.invalidateSize());return t.observe(r.current),()=>{t.disconnect(),e.remove(),i.current=null}},[]);let s=e.map(e=>`${e.slug}@${e.lat},${e.lng}`).join(`|`);return(0,v.useEffect)(()=>{let n=i.current,r=a.current;if(!n||!r)return;r.clearLayers();let s=getComputedStyle(document.documentElement).getPropertyValue(`--color-accent`).trim()||`#2563eb`;for(let n of e){let e=n.slug===t;hs.default.circleMarker([n.lat,n.lng],{radius:e?10:7,weight:2,color:`#fff`,fillColor:e?s:`#be123c`,fillOpacity:1}).bindTooltip(n.title,{direction:`top`,offset:[0,-8],permanent:e}).on(`click`,()=>o.current(n.slug)).addTo(r).getElement()?.setAttribute(`data-place`,n.slug)}let c=e.find(e=>e.slug===t);c?n.flyTo([c.lat,c.lng],Math.max(n.getZoom(),15),{duration:.6}):e.length===1?n.setView([e[0].lat,e[0].lng],14):e.length>1&&n.fitBounds(hs.default.latLngBounds(e.map(e=>[e.lat,e.lng])),{padding:[32,32],maxZoom:15})},[s,t]),(0,z.jsx)(`div`,{ref:r,className:`places-map size-full min-h-[240px] overflow-hidden rounded-lg border border-line`,role:`region`,"aria-label":`map of the places`})}var _s=e=>e.slice(0,10),vs=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,ys=e=>new Date(Number(e.slice(0,4)),Number(e.slice(5,7))-1,1),bs=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function xs({events:e,selected:t,onPick:n}){let r=e.find(e=>e.slug===t),[i,a]=(0,v.useState)(()=>ys(r?r.start:vs(new Date)));(0,v.useEffect)(()=>{r&&a(ys(r.start))},[r?.slug,r?.start]);let o=new Date(i),s=(o.getDay()+6)%7,c=new Date(o.getFullYear(),o.getMonth(),1-s),l=new Date(o.getFullYear(),o.getMonth()+1,0).getDate(),u=Math.ceil((s+l)/7),d=Array.from({length:u*7},(e,t)=>new Date(c.getFullYear(),c.getMonth(),c.getDate()+t)),f=vs(new Date),p=t=>e.filter(e=>_s(e.start)<=t&&t<=_s(e.end||e.start)).sort((e,t)=>e.start.localeCompare(t.start)),m=e.filter(e=>_s(e.start)<=vs(d[d.length-1])&&_s(e.end||e.start)>=vs(d[0])).length,h=e=>a(new Date(i.getFullYear(),i.getMonth()+e,1));return(0,z.jsxs)(`div`,{className:`events-calendar flex min-h-0 flex-1 flex-col gap-2`,role:`region`,"aria-label":`calendar of the events`,children:[(0,z.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[(0,z.jsxs)(`h3`,{className:`m-0 flex-1 text-base font-semibold text-fg`,"aria-live":`polite`,children:[i.toLocaleDateString([],{month:`long`,year:`numeric`}),(0,z.jsxs)(`span`,{className:`ms-2 text-xs font-normal text-fg-2`,children:[m,` event`,m===1?``:`s`]})]}),(0,z.jsx)(`button`,{type:`button`,className:`cursor-pointer rounded-full px-2.5 py-1 text-xs text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>a(ys(f)),children:`today`}),(0,z.jsx)(`button`,{type:`button`,"aria-label":`previous month`,className:`grid size-7 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>h(-1),children:(0,z.jsx)(B,{name:`chevron_left`,className:`ms-sm`})}),(0,z.jsx)(`button`,{type:`button`,"aria-label":`next month`,className:`grid size-7 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>h(1),children:(0,z.jsx)(B,{name:`chevron_right`,className:`ms-sm`})})]}),(0,z.jsx)(`div`,{className:`grid flex-none grid-cols-7 text-center text-2xs tracking-wide text-fg-2 uppercase`,children:bs.map(e=>(0,z.jsx)(`span`,{children:e},e))}),(0,z.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-7 overflow-y-auto rounded-lg border border-line bg-line`,style:{gridTemplateRows:`repeat(${u}, minmax(44px, 1fr))`,gap:1},children:d.map(e=>{let r=vs(e),a=p(r),o=e.getMonth()!==i.getMonth();return(0,z.jsxs)(`div`,{"data-day":r,className:I(`flex min-h-0 min-w-0 flex-col gap-px overflow-hidden bg-surface p-0.5`,o&&`bg-[color-mix(in_srgb,var(--color-surface-2)_35%,var(--color-surface))]`),children:[(0,z.jsx)(`span`,{className:I(`self-end px-1 text-2xs tabular-nums`,o?`text-fg-2/60`:`text-fg-2`,r===f&&`rounded-full bg-accent px-1.5 font-semibold text-on-accent`),children:e.getDate()}),a.slice(0,4).map(e=>{let i=_s(e.start)===r&&e.start.length>10?e.start.slice(11,16):``;return(0,z.jsxs)(`button`,{type:`button`,"data-event":e.slug,"aria-pressed":e.slug===t,title:`${e.title} · ${e.start.replace(`T`,` `)}${e.end?`–${e.end.replace(`T`,` `)}`:``}`,className:I(`block w-full cursor-pointer truncate rounded px-1 text-left text-2xs leading-4`,e.slug===t?`bg-accent text-on-accent`:`bg-[color-mix(in_srgb,#a16207_16%,var(--color-surface))] text-fg hover:brightness-95`),onClick:()=>n(e.slug),children:[i&&(0,z.jsx)(`span`,{className:`me-1 tabular-nums opacity-70`,children:i}),e.title]},e.slug)}),a.length>4&&(0,z.jsxs)(`span`,{className:`px-1 text-2xs text-fg-2`,children:[`+`,a.length-4,` more`]})]},r)})})]})}var Ss=(e,t,n=!1)=>A.url(`files.raw`,{query:{scope:e,path:t,download:n}}),Cs=(e,t=``,n)=>`/files/${encodeURIComponent(e)}${t?`/${t.split(`/`).map(encodeURIComponent).join(`/`)}`:``}${n?`?file=${encodeURIComponent(n)}`:``}`,ws=`inline-grid size-7 shrink-0 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,Ts=`whitespace-nowrap border-b border-line px-2.5 py-1.5 text-left`;function Es({here:e,onClick:t,children:n}){return(0,z.jsx)(`button`,{type:`button`,onClick:t,className:I(`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 Ds(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 Os({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,z.jsxs)(`div`,{className:`runs-screen files-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`files`}),(0,z.jsxs)(jt,{children:[(r??[]).filter(e=>e.scope===`workspace`).map(t=>(0,z.jsx)(ks,{s:t,active:e===t.scope,icon:`home_storage`},t.scope)),s.length>0&&(0,z.jsx)(kt,{title:`projects`,divided:!0}),s.map(t=>(0,z.jsx)(ks,{s:t,active:e===t.scope,icon:`folder_special`},t.scope))]})]}),(0,z.jsx)(`div`,{className:`runs-main min-w-0`,children:(0,z.jsx)(As,{scope:e,dir:t,file:n,onOpen:(t,n)=>H(Cs(e,t,n)),onChanged:()=>o(e=>e+1)},e)})]})}function ks({s:e,active:t,icon:n}){return(0,z.jsx)(gt,{href:Cs(e.scope),active:t,size:`sm`,leading:(0,z.jsx)(B,{name:n,className:`ms-sm`}),title:e.label,sub:(0,z.jsxs)(`span`,{className:`font-mono`,children:[e.root,`/`]}),meta:e.count})}function As({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);!n?.ok||!n.data||typeof n.data!=`object`?(l(n?.error??`could not load the folder`),s(null)):(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=P(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=P(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,z.jsxs)(`div`,{className:I(`files-browser h-full min-h-0`,a?`flex flex-col gap-2 px-1.5 py-1`:I(`grid gap-4`,n?`grid-cols-1 min-[900px]:grid-cols-[minmax(280px,1fr)_minmax(0,1.3fr)]`:`grid-cols-1`)),children:[ee&&(0,z.jsxs)(`div`,{className:I(`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,z.jsxs)(`div`,{className:I(`flex items-center gap-1`,a?`px-1 pb-1.5 pt-0.5`:`px-0.5 pb-2.5 pt-1`),children:[(0,z.jsxs)(`nav`,{className:I(`flex min-w-0 flex-wrap items-center`,a?`text-sm`:`text-md`),"aria-label":`Folder`,children:[(0,z.jsx)(Es,{here:!O.length,onClick:()=>r(``),children:o?.label??(e===`workspace`?`Workspace`:e.replace(/^project:/,``))}),O.map((e,t)=>(0,z.jsxs)(`span`,{className:`inline-flex items-center text-fg-2`,children:[(0,z.jsx)(B,{name:`chevron_right`,className:`ms-sm`}),(0,z.jsx)(Es,{here:t===O.length-1,onClick:()=>r(O.slice(0,t+1).join(`/`)),children:e})]},t))]}),(0,z.jsx)(`span`,{className:`flex-1`}),a?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(q,{icon:`create_new_folder`,label:`New folder`,size:`sm`,onClick:()=>h(``)}),(0,z.jsx)(q,{icon:`upload`,label:`Upload files`,size:`sm`,onClick:()=>x.current?.click()})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`create_new_folder`,onClick:()=>h(``),title:`New folder`,children:`folder`}),(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`upload`,onClick:()=>x.current?.click(),title:`Upload files`,children:`upload`})]}),(0,z.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,z.jsx)(rt,{children:u}),c&&(0,z.jsx)(rt,{tone:`bad`,children:c}),(0,z.jsxs)(`div`,{className:`files-list flex min-h-0 flex-1 flex-col gap-px overflow-y-auto`,role:`list`,children:[m!==null&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,z.jsx)(B,{name:`create_new_folder`,className:`text-[20px] text-fg-2`}),(0,z.jsx)(Z,{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,z.jsxs)(`div`,{role:`listitem`,className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,z.jsx)(B,{name:Ds(i),className:`text-[20px] text-fg-2`}),(0,z.jsx)(Z,{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,z.jsx)(`div`,{role:`listitem`,children:(0,z.jsx)(gt,{className:`files-row`,active:i.path===n,onClick:()=>i.type===`dir`?r(i.path):r(t,i.path),label:i.name,leading:(0,z.jsx)(B,{name:Ds(i),className:`text-[20px] text-fg-2`}),title:(0,z.jsx)(`span`,{className:`font-normal`,children:i.name}),titleExtra:i.local?(0,z.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,z.jsxs)(z.Fragment,{children:[i.type===`dir`?`${i.count??0} file${i.count===1?``:`s`}`:W(i.size??0),!a&&` · ${G(i.modifiedAt)}`]}),actions:(0,z.jsxs)(z.Fragment,{children:[i.type===`file`&&(0,z.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:Ss(e,i.path,!0),title:`Download`,"aria-label":`Download ${i.name}`,children:(0,z.jsx)(B,{name:`download`,className:`ms-sm`})}),(0,z.jsx)(q,{icon:`edit`,size:`sm`,label:`Rename ${i.name}`,onClick:()=>_({path:i.path,name:i.name})}),y===i.path?(0,z.jsx)(K,{variant:`danger`,size:`sm`,autoFocus:!0,onClick:()=>void D(i.path),onBlur:()=>b(null),children:`move to trash`}):(0,z.jsx)(q,{icon:`delete`,size:`sm`,label:`Delete ${i.name}`,onClick:()=>b(i.path)})]})})},i.path)),o&&o.entries.length===0&&m===null&&(0,z.jsxs)(Y,{icon:`upload_file`,action:(0,z.jsxs)(`span`,{className:`font-mono text-2xs opacity-80`,children:[o.root,`/`,t?`${t}/`:``]}),children:[`Drop files here, or`,` `,(0,z.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,z.jsx)(Y,{children:`loading…`})]})]}),n&&(0,z.jsx)(js,{scope:e,path:n,entry:k,onClose:()=>r(t),compact:a})]})}function js({scope:e,path:t,entry:n,onClose:r,compact:i}){let a=n?.mime??``,o=t.split(`/`).pop()??t,s=Ss(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,z.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,z.jsx)(`iframe`,{className:I(`w-full border-0 bg-white`,i?`min-h-[60vh]`:`min-h-[70vh]`),src:s,title:o}):a.startsWith(`video/`)?(0,z.jsx)(`video`,{className:`m-auto max-h-full w-full p-4`,src:s,controls:!0}):a.startsWith(`audio/`)?(0,z.jsx)(`audio`,{className:`m-auto w-full p-4`,src:s,controls:!0}):c&&l!==null?/markdown/.test(a)?(0,z.jsx)(`div`,{className:`md-body files-md px-5 py-4`,dangerouslySetInnerHTML:{__html:fo.sanitize(Mi.parse(l,{async:!1}))}}):/csv|tab-separated/.test(a)?(0,z.jsx)(Ms,{text:l,tab:/tab-separated/.test(a)}):(0,z.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,z.jsx)(Y,{children:`loading…`}):(0,z.jsx)(Y,{icon:Ds(n),action:(0,z.jsx)(K,{variant:`primary`,size:`sm`,icon:`download`,href:void 0,onClick:()=>window.location.href=Ss(e,t,!0),children:`download`}),children:`No preview for this kind of file.`}):(0,z.jsx)(Y,{children:`loading…`}),(0,z.jsxs)(`section`,{className:I(`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,z.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-3 py-2`,children:[i&&(0,z.jsx)(q,{icon:`arrow_back`,label:`Back to the folder`,size:`sm`,onClick:r}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold`,title:t,children:o}),n?.size!==void 0&&(0,z.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-2`,children:W(n.size)}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(`a`,{className:ws,href:s,target:`_blank`,rel:`noopener`,title:`Open in a new tab`,"aria-label":`Open in a new tab`,children:(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`})}),(0,z.jsx)(`a`,{className:ws,href:Ss(e,t,!0),title:`Download`,"aria-label":`Download`,children:(0,z.jsx)(B,{name:`download`,className:`ms-sm`})}),!i&&(0,z.jsx)(q,{icon:`close`,label:`Close the preview`,size:`sm`,onClick:r})]}),(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-auto [&>*]:flex-1`,children:d})]})}function Ms({text:e,tab:t}){let n=t?` `:e.split(`
87
87
  `)[0].includes(`;`)&&!e.split(`
88
- `)[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,z.jsx)(`div`,{className:`overflow-auto`,children:(0,z.jsxs)(`table`,{className:`border-collapse text-[12.5px]`,children:[i&&(0,z.jsx)(`thead`,{children:(0,z.jsx)(`tr`,{children:i.map((e,t)=>(0,z.jsx)(`th`,{className:I(Ts,`sticky top-0 bg-surface font-semibold`),children:e},t))})}),(0,z.jsx)(`tbody`,{children:a.map((e,t)=>(0,z.jsx)(`tr`,{children:e.map((e,t)=>(0,z.jsx)(`td`,{className:Ts,children:e},t))},t))})]})})}var Ns=`modulepreload`,Ps=function(e){return`/`+e},Fs={},Is=function(e){return e.pathname.endsWith(`.css`)},Ls=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Rs=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=Ps(t,n);let r=s(t),i=Is(r);return Ls(Fs,r.href,()=>{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 t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Ns,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).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)})},zs=(0,v.lazy)(()=>Rs(()=>import(`./editor-A9_YWc5F.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),Bs=()=>Rs(()=>import(`./editor-A9_YWc5F.js`),__vite__mapDeps([0,1,2,3,4,5,6])),Vs=encodeURIComponent,Hs=e=>e?{project:e}:{},Us=e=>e.project?`/projects/${Vs(e.project)}/boards/${Vs(e.board)}`:`/boards/${Vs(e.board)}`,Ws=(e,t)=>`${Us(e)}/${Vs(t)}`,Gs=(e,t)=>e.order-t.order||e.number-t.number,Ks=e=>e.trim()?To(fo.sanitize(Mi.parse(e,{async:!1}))):``,qs=()=>new Date().toISOString().slice(0,10),Js=e=>e.find(e=>e.done);function Ys({project:e,board:t}){let n={project:e,board:t},r=Hs(e),i=F(`boards.get`,{board:t,query:r},{interval:5e3}),a=F(`agents.list`,{},{interval:6e4}),o=e=>(a?.agents??[]).find(t=>t.slug===e),[s,c]=(0,v.useState)(null),l=JSON.stringify(i?.items??null);(0,v.useEffect)(()=>c(null),[l]);let u=s??i?.items??[],[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(null),ee=i?.columns??[],j=new Set(ee.map(e=>e.slug)),M=u.filter(e=>!j.has(e.status)),N=[...ee.map(e=>({col:e,tasks:u.filter(t=>t.status===e.slug).sort(Gs)})),...M.length?[{col:{slug:``,label:`No column`},tasks:M.sort(Gs)}]:[]],te=[...new Set(u.map(e=>e.assignee).filter(e=>!!e))].sort(),R=[...new Set(u.flatMap(e=>e.tags))].sort(),ne=N.some(e=>e.col.done&&e.tasks.length>10),re=w??!ne,ie=_.trim().toLowerCase(),ae=e=>(!ie||`${e.title} ${e.slug} ${e.assignee??``} ${e.tags.join(` `)}`.toLowerCase().includes(ie))&&(!b||e.assignee===b)&&(!S||e.tags.includes(S)),oe=!!ie||!!b||!!S,se=(0,v.useMemo)(()=>Ks(i?.notes??``),[i?.notes]),ce=async(e,n,i)=>{let a=u.find(t=>t.slug===e);if(!a||!n||i===e)return;let o=u.filter(t=>t.status===n&&t.slug!==e).sort(Gs),s=i?o.findIndex(e=>e.slug===i):-1,l=[...o];if(l.splice(s<0?o.length:s,0,{...a,status:n}),a.status===n&&l.map(e=>e.slug).join()===u.filter(e=>e.status===n).sort(Gs).map(e=>e.slug).join())return;let d=new Map(l.map((e,t)=>[e.slug,(t+1)*10]));c(u.map(e=>d.has(e.slug)?{...e,status:n,order:d.get(e.slug)}:e)),f(``);let p=await A.request(`tasks.move`,{board:t,task:e,query:r,body:{status:n,...i?{before:i}:{}}});p.ok||(f(P(p)),c(null))},le=()=>{D(null),k(null)},ue=(e,t)=>({draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.slug),D(e.slug)},onDragEnd:le,onDragOver:n=>{if(!E||!e.status||!j.has(e.status))return;n.preventDefault(),n.stopPropagation(),n.dataTransfer.dropEffect=`move`;let r=n.currentTarget.getBoundingClientRect(),i=n.clientY>r.top+r.height/2,a=t.findIndex(t=>t.slug===e.slug),o=i?t[a+1]?.slug??null:e.slug;(O?.status!==e.status||O.before!==o)&&k({status:e.status,before:o})},onDrop:e=>{if(!E||!O)return;e.preventDefault(),e.stopPropagation();let{status:t,before:n}=O;le(),ce(E,t,n)}}),de=e=>({onDragOver:t=>{E&&e.slug&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,(O?.status!==e.slug||O.before!==null)&&k({status:e.slug,before:null}))},onDrop:e=>{if(!E||!O)return;e.preventDefault();let{status:t,before:n}=O;le(),ce(E,t,n)}}),V=(e,t)=>E&&O&&O.status===e&&O.before===t?(0,z.jsx)(`div`,{className:`relative h-0`,"aria-hidden":!0,children:(0,z.jsx)(`div`,{className:`absolute inset-x-1 -top-1 h-0.5 rounded-full bg-accent`})}):null,fe=async()=>{let n=await A.request(`boards.delete`,{board:t,query:r});if(!n.ok)return f(P(n));H(e?`/projects/${Vs(e)}`:`/boards`,{replace:!0})};return i?(0,z.jsxs)(`div`,{className:`chat-main flex min-h-0 flex-col gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,z.jsx)(B,{name:`view_kanban`,className:`text-[26px] text-fg-2`}),(0,z.jsx)(ot,{children:i.title}),(0,z.jsxs)(J,{title:`tasks on the board`,children:[i.tasks,` `,i.tasks===1?`task`:`tasks`]}),(0,z.jsx)($e,{n:i.review,title:`waiting for review`}),i.agent&&(0,z.jsxs)(J,{tone:`accent`,title:`tasks entering todo without an assignee go to this agent`,children:[`→ `,i.agent]}),(0,z.jsx)(`span`,{className:`flex-1`}),i.notes.trim()&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:p?`expand_less`:`gavel`,"aria-expanded":p,onClick:()=>m(e=>!e),children:`rules`}),(0,z.jsx)(q,{size:`sm`,icon:`settings`,label:`board settings: columns, default agent, rules`,href:`${Us(n)}/settings`}),!e&&(h?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,onClick:()=>void fe(),children:`move to trash`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>g(!1),children:`cancel`})]}):(0,z.jsx)(q,{size:`sm`,icon:`delete`,label:`move the board, tasks and all, to the trash`,onClick:()=>g(!0)}))]}),i.configError&&(0,z.jsxs)(rt,{tone:`bad`,children:[`board.md: `,i.configError,` — the columns show defaults; fix the file by hand.`]}),d&&(0,z.jsx)(rt,{tone:`bad`,children:d}),p&&(0,z.jsx)(X,{title:`rules`,className:`flex-none`,children:se?(0,z.jsx)(`div`,{className:`md-body px-[18px] py-3 text-sm`,dangerouslySetInnerHTML:{__html:se}}):(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`no rules yet — the body of board.md`})}),(0,z.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-2`,children:[(0,z.jsx)(Z,{value:_,className:`h-8 w-auto min-w-[180px] text-sm`,placeholder:`filter tasks…`,"aria-label":`filter tasks`,onChange:e=>y(e.target.value)}),te.length>0&&(0,z.jsxs)(St,{className:`h-8 w-auto text-sm`,value:b,"aria-label":`assignee`,onChange:e=>x(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`anyone`}),te.map(e=>(0,z.jsx)(`option`,{value:e,children:Xs(e)},e))]}),R.length>0&&(0,z.jsxs)(St,{className:`h-8 w-auto text-sm`,value:S,"aria-label":`tag`,onChange:e=>C(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`any tag`}),R.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),oe&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`close`,onClick:()=>{y(``),x(``),C(``)},children:`clear`}),(0,z.jsx)(`span`,{className:`flex-1`}),N.some(e=>e.col.done&&e.tasks.length>0)&&(0,z.jsx)(Tt,{checked:re,onChange:T,className:`text-xs`,children:`show finished`})]}),(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3 overflow-x-auto overflow-y-hidden pb-2`,children:N.map(({col:e,tasks:t})=>{let r=e.done&&!re?[]:t.filter(ae),a=e.limit!==void 0&&t.length>e.limit;return(0,z.jsxs)(`section`,{className:`flex max-h-full min-w-[208px] max-w-[360px] flex-1 basis-0 flex-col rounded-card border border-line bg-surface-2`,"aria-label":e.label,"data-column":e.slug||void 0,children:[(0,z.jsxs)(`div`,{className:`flex flex-none items-center gap-2 px-3 pt-2.5 pb-1.5`,children:[(0,z.jsx)(it,{className:`truncate text-fg`,children:e.label}),(0,z.jsxs)(`span`,{className:I(`text-2xs font-semibold tabular-nums`,a?`rounded-full bg-ask-soft px-1.5 text-on-ask-soft`:`text-fg-2`),title:e.limit===void 0?`${t.length} tasks`:`${t.length} of a limit of ${e.limit}`,children:[t.length,e.limit!==void 0&&`/${e.limit}`]}),e.review&&(0,z.jsx)(B,{name:`rate_review`,className:`ms-sm text-fg-2`}),e.done&&(0,z.jsx)(B,{name:`check_circle`,className:`ms-sm text-fg-2`})]}),(0,z.jsxs)(`div`,{className:`flex min-h-[48px] flex-col gap-1.5 overflow-y-auto px-2 pb-1`,...de(e),children:[r.map(r=>(0,z.jsxs)(v.Fragment,{children:[V(e.slug,r.slug),(0,z.jsx)(Zs,{at:n,task:r,agent:r.assignee?o(r.assignee):void 0,dragging:E===r.slug,...ue(r,t)})]},r.slug)),V(e.slug,null),e.done&&!re&&t.length>0&&(0,z.jsxs)(Mt,{className:`px-1 py-1.5`,children:[t.length,` finished, hidden`]}),E&&(0,z.jsx)(`div`,{className:`h-6`})]}),e.slug&&!i.configError&&(0,z.jsx)(Qs,{at:n,status:e.slug,onError:f})]},e.slug||`~`)})})]}):(0,z.jsx)(Y,{children:`loading…`})}var Xs=e=>e.startsWith(`human:`)?e.slice(6):e;function Zs({at:e,task:t,agent:n,dragging:r,...i}){let a=!!t.due&&t.due.slice(0,10)<qs();return(0,z.jsxs)(`article`,{...i,className:I(`flex cursor-grab flex-col gap-1 rounded-card border border-line bg-surface px-2.5 py-2 active:cursor-grabbing`,r&&`opacity-40`),"data-task":t.slug,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(U,{href:Ws(e,t.slug),className:`min-w-0 flex-1 text-sm font-medium leading-snug text-fg no-underline [overflow-wrap:anywhere] hover:underline`,children:t.title}),(0,z.jsxs)(`span`,{className:`flex-none font-mono text-2xs text-fg-2`,children:[`#`,t.number]})]}),t.configError&&(0,z.jsx)(`span`,{className:`text-2xs text-bad`,children:`unreadable frontmatter`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-2`,children:[t.assignee?(0,z.jsxs)(`span`,{className:`inline-flex h-5 items-center gap-1 rounded-full bg-surface-2 px-1.5 font-medium text-fg`,title:`assigned to ${n?`${n.name} (${t.assignee})`:t.assignee}`,children:[n?.emoji?(0,z.jsx)(`span`,{"aria-hidden":!0,children:n.emoji}):(0,z.jsx)(B,{name:`person`,className:`ms-sm text-[13px]`}),n?.name??Xs(t.assignee)]}):(0,z.jsxs)(`span`,{className:`inline-flex h-5 items-center gap-1 rounded-full px-1.5 text-fg-2 ring-1 ring-inset ring-line`,title:`nobody is assigned`,children:[(0,z.jsx)(B,{name:`person_off`,className:`ms-sm text-[13px]`}),` unassigned`]}),t.due&&(0,z.jsxs)(`span`,{className:I(`inline-flex items-center gap-0.5`,a&&`text-bad`),title:a?`overdue`:`due`,children:[(0,z.jsx)(B,{name:`event`,className:`ms-sm text-[13px]`}),` `,t.due]}),t.files>0&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,title:`files in the task folder`,children:[(0,z.jsx)(B,{name:`attach_file`,className:`ms-sm text-[13px]`}),` `,t.files]}),t.stale&&(0,z.jsx)(J,{tone:`ask`,title:`assigned, in a work column, and nothing logged for a while`,children:`stale`})]}),t.tags.length>0&&(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.tags.map(e=>(0,z.jsx)(J,{children:e},e))}),t.lastLog&&(0,z.jsx)(`div`,{className:`truncate text-2xs text-fg-2 opacity-80`,title:t.lastLog,children:t.lastLog})]})}function Qs({at:e,status:t,onError:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),l=async()=>{let r=a.trim();if(!r||s)return;c(!0);let i=await A.request(`tasks.create`,{board:e.board,query:Hs(e.project),body:{title:r,status:t}});if(c(!1),!i.ok)return n(P(i));n(``),o(``)};return r?(0,z.jsxs)(`div`,{className:`flex items-center gap-1 p-1.5`,children:[(0,z.jsx)(Z,{autoFocus:!0,value:a,className:`h-8 text-sm`,placeholder:`task title — Enter adds`,"aria-label":`new task in ${t}`,disabled:s,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(i(!1),o(``))},onBlur:()=>!a.trim()&&i(!1)}),(0,z.jsx)(q,{size:`sm`,icon:`close`,label:`close`,onClick:()=>{i(!1),o(``)}})]}):(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,className:`m-1 justify-start`,onClick:()=>i(!0),children:`task`})}function $s({at:e,columns:t,agents:n,onClose:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(()=>(t.find(e=>e.slug===`todo`)??t[0])?.slug??``),[c,l]=(0,v.useState)(``),u=F(`me.get`,{}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let _=async()=>{let t=i.trim();if(!t||p)return;m(!0);let n=await A.request(`tasks.create`,{board:e.board,query:Hs(e.project),body:{title:t,...o?{status:o}:{},...c?{assignee:c}:{},...d.trim()?{notes:d.trim()+`
88
+ `)[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,z.jsx)(`div`,{className:`overflow-auto`,children:(0,z.jsxs)(`table`,{className:`border-collapse text-[12.5px]`,children:[i&&(0,z.jsx)(`thead`,{children:(0,z.jsx)(`tr`,{children:i.map((e,t)=>(0,z.jsx)(`th`,{className:I(Ts,`sticky top-0 bg-surface font-semibold`),children:e},t))})}),(0,z.jsx)(`tbody`,{children:a.map((e,t)=>(0,z.jsx)(`tr`,{children:e.map((e,t)=>(0,z.jsx)(`td`,{className:Ts,children:e},t))},t))})]})})}var Ns=`modulepreload`,Ps=function(e){return`/`+e},Fs={},Is=function(e){return e.pathname.endsWith(`.css`)},Ls=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Rs=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=Ps(t,n);let r=s(t),i=Is(r);return Ls(Fs,r.href,()=>{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 t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Ns,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).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)})},zs=(0,v.lazy)(()=>Rs(()=>import(`./editor-TtOHfgtL.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),Bs=()=>Rs(()=>import(`./editor-TtOHfgtL.js`),__vite__mapDeps([0,1,2,3,4,5,6])),Vs=encodeURIComponent,Hs=e=>e?{project:e}:{},Us=e=>e.project?`/projects/${Vs(e.project)}/boards/${Vs(e.board)}`:`/boards/${Vs(e.board)}`,Ws=(e,t)=>`${Us(e)}/${Vs(t)}`,Gs=(e,t)=>e.order-t.order||e.number-t.number,Ks=e=>e.trim()?To(fo.sanitize(Mi.parse(e,{async:!1}))):``,qs=()=>new Date().toISOString().slice(0,10),Js=e=>e.find(e=>e.done);function Ys({project:e,board:t}){let n={project:e,board:t},r=Hs(e),i=F(`boards.get`,{board:t,query:r},{interval:5e3}),a=F(`agents.list`,{},{interval:6e4}),o=e=>(a?.agents??[]).find(t=>t.slug===e),[s,c]=(0,v.useState)(null),l=JSON.stringify(i?.items??null);(0,v.useEffect)(()=>c(null),[l]);let u=s??i?.items??[],[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(null),ee=i?.columns??[],j=new Set(ee.map(e=>e.slug)),M=u.filter(e=>!j.has(e.status)),N=[...ee.map(e=>({col:e,tasks:u.filter(t=>t.status===e.slug).sort(Gs)})),...M.length?[{col:{slug:``,label:`No column`},tasks:M.sort(Gs)}]:[]],te=[...new Set(u.map(e=>e.assignee).filter(e=>!!e))].sort(),R=[...new Set(u.flatMap(e=>e.tags))].sort(),ne=N.some(e=>e.col.done&&e.tasks.length>10),re=w??!ne,ie=_.trim().toLowerCase(),ae=e=>(!ie||`${e.title} ${e.slug} ${e.assignee??``} ${e.tags.join(` `)}`.toLowerCase().includes(ie))&&(!b||e.assignee===b)&&(!S||e.tags.includes(S)),oe=!!ie||!!b||!!S,se=(0,v.useMemo)(()=>Ks(i?.notes??``),[i?.notes]),ce=async(e,n,i)=>{let a=u.find(t=>t.slug===e);if(!a||!n||i===e)return;let o=u.filter(t=>t.status===n&&t.slug!==e).sort(Gs),s=i?o.findIndex(e=>e.slug===i):-1,l=[...o];if(l.splice(s<0?o.length:s,0,{...a,status:n}),a.status===n&&l.map(e=>e.slug).join()===u.filter(e=>e.status===n).sort(Gs).map(e=>e.slug).join())return;let d=new Map(l.map((e,t)=>[e.slug,(t+1)*10]));c(u.map(e=>d.has(e.slug)?{...e,status:n,order:d.get(e.slug)}:e)),f(``);let p=await A.request(`tasks.move`,{board:t,task:e,query:r,body:{status:n,...i?{before:i}:{}}});p.ok||(f(P(p)),c(null))},le=()=>{D(null),k(null)},ue=(e,t)=>({draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.slug),D(e.slug)},onDragEnd:le,onDragOver:n=>{if(!E||!e.status||!j.has(e.status))return;n.preventDefault(),n.stopPropagation(),n.dataTransfer.dropEffect=`move`;let r=n.currentTarget.getBoundingClientRect(),i=n.clientY>r.top+r.height/2,a=t.findIndex(t=>t.slug===e.slug),o=i?t[a+1]?.slug??null:e.slug;(O?.status!==e.status||O.before!==o)&&k({status:e.status,before:o})},onDrop:e=>{if(!E||!O)return;e.preventDefault(),e.stopPropagation();let{status:t,before:n}=O;le(),ce(E,t,n)}}),de=e=>({onDragOver:t=>{E&&e.slug&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,(O?.status!==e.slug||O.before!==null)&&k({status:e.slug,before:null}))},onDrop:e=>{if(!E||!O)return;e.preventDefault();let{status:t,before:n}=O;le(),ce(E,t,n)}}),V=(e,t)=>E&&O&&O.status===e&&O.before===t?(0,z.jsx)(`div`,{className:`relative h-0`,"aria-hidden":!0,children:(0,z.jsx)(`div`,{className:`absolute inset-x-1 -top-1 h-0.5 rounded-full bg-accent`})}):null,fe=async()=>{let n=await A.request(`boards.delete`,{board:t,query:r});if(!n.ok)return f(P(n));H(e?`/projects/${Vs(e)}`:`/boards`,{replace:!0})};return i?(0,z.jsxs)(`div`,{className:`chat-main flex min-h-0 flex-col gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,z.jsx)(B,{name:`view_kanban`,className:`text-[26px] text-fg-2`}),(0,z.jsx)(ot,{children:i.title}),(0,z.jsxs)(J,{title:`tasks on the board`,children:[i.tasks,` `,i.tasks===1?`task`:`tasks`]}),(0,z.jsx)($e,{n:i.review,title:`waiting for review`}),i.agent&&(0,z.jsxs)(J,{tone:`accent`,title:`tasks entering todo without an assignee go to this agent`,children:[`→ `,i.agent]}),(0,z.jsx)(`span`,{className:`flex-1`}),i.notes.trim()&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:p?`expand_less`:`gavel`,"aria-expanded":p,onClick:()=>m(e=>!e),children:`rules`}),(0,z.jsx)(q,{size:`sm`,icon:`settings`,label:`board settings: columns, default agent, rules`,href:`${Us(n)}/settings`}),!e&&(h?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,onClick:()=>void fe(),children:`move to trash`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>g(!1),children:`cancel`})]}):(0,z.jsx)(q,{size:`sm`,icon:`delete`,label:`move the board, tasks and all, to the trash`,onClick:()=>g(!0)}))]}),i.configError&&(0,z.jsxs)(rt,{tone:`bad`,children:[`board.md: `,i.configError,` — the columns show defaults; fix the file by hand.`]}),d&&(0,z.jsx)(rt,{tone:`bad`,children:d}),p&&(0,z.jsx)(X,{title:`rules`,className:`flex-none`,children:se?(0,z.jsx)(`div`,{className:`md-body px-[18px] py-3 text-sm`,dangerouslySetInnerHTML:{__html:se}}):(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`no rules yet — the body of board.md`})}),(0,z.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-2`,children:[(0,z.jsx)(Z,{value:_,className:`h-8 w-auto min-w-[180px] text-sm`,placeholder:`filter tasks…`,"aria-label":`filter tasks`,onChange:e=>y(e.target.value)}),te.length>0&&(0,z.jsxs)(St,{className:`h-8 w-auto text-sm`,value:b,"aria-label":`assignee`,onChange:e=>x(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`anyone`}),te.map(e=>(0,z.jsx)(`option`,{value:e,children:Xs(e)},e))]}),R.length>0&&(0,z.jsxs)(St,{className:`h-8 w-auto text-sm`,value:S,"aria-label":`tag`,onChange:e=>C(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`any tag`}),R.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),oe&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`close`,onClick:()=>{y(``),x(``),C(``)},children:`clear`}),(0,z.jsx)(`span`,{className:`flex-1`}),N.some(e=>e.col.done&&e.tasks.length>0)&&(0,z.jsx)(Tt,{checked:re,onChange:T,className:`text-xs`,children:`show finished`})]}),(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3 overflow-x-auto overflow-y-hidden pb-2`,children:N.map(({col:e,tasks:t})=>{let r=e.done&&!re?[]:t.filter(ae),a=e.limit!==void 0&&t.length>e.limit;return(0,z.jsxs)(`section`,{className:`flex max-h-full min-w-[208px] max-w-[360px] flex-1 basis-0 flex-col rounded-card border border-line bg-surface-2`,"aria-label":e.label,"data-column":e.slug||void 0,children:[(0,z.jsxs)(`div`,{className:`flex flex-none items-center gap-2 px-3 pt-2.5 pb-1.5`,children:[(0,z.jsx)(it,{className:`truncate text-fg`,children:e.label}),(0,z.jsxs)(`span`,{className:I(`text-2xs font-semibold tabular-nums`,a?`rounded-full bg-ask-soft px-1.5 text-on-ask-soft`:`text-fg-2`),title:e.limit===void 0?`${t.length} tasks`:`${t.length} of a limit of ${e.limit}`,children:[t.length,e.limit!==void 0&&`/${e.limit}`]}),e.review&&(0,z.jsx)(B,{name:`rate_review`,className:`ms-sm text-fg-2`}),e.done&&(0,z.jsx)(B,{name:`check_circle`,className:`ms-sm text-fg-2`})]}),(0,z.jsxs)(`div`,{className:`flex min-h-[48px] flex-col gap-1.5 overflow-y-auto px-2 pb-1`,...de(e),children:[r.map(r=>(0,z.jsxs)(v.Fragment,{children:[V(e.slug,r.slug),(0,z.jsx)(Zs,{at:n,task:r,agent:r.assignee?o(r.assignee):void 0,dragging:E===r.slug,...ue(r,t)})]},r.slug)),V(e.slug,null),e.done&&!re&&t.length>0&&(0,z.jsxs)(Mt,{className:`px-1 py-1.5`,children:[t.length,` finished, hidden`]}),E&&(0,z.jsx)(`div`,{className:`h-6`})]}),e.slug&&!i.configError&&(0,z.jsx)(Qs,{at:n,status:e.slug,onError:f})]},e.slug||`~`)})})]}):(0,z.jsx)(Y,{children:`loading…`})}var Xs=e=>e.startsWith(`human:`)?e.slice(6):e;function Zs({at:e,task:t,agent:n,dragging:r,...i}){let a=!!t.due&&t.due.slice(0,10)<qs();return(0,z.jsxs)(`article`,{...i,className:I(`flex cursor-grab flex-col gap-1 rounded-card border border-line bg-surface px-2.5 py-2 active:cursor-grabbing`,r&&`opacity-40`),"data-task":t.slug,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(U,{href:Ws(e,t.slug),className:`min-w-0 flex-1 text-sm font-medium leading-snug text-fg no-underline [overflow-wrap:anywhere] hover:underline`,children:t.title}),(0,z.jsxs)(`span`,{className:`flex-none font-mono text-2xs text-fg-2`,children:[`#`,t.number]})]}),t.configError&&(0,z.jsx)(`span`,{className:`text-2xs text-bad`,children:`unreadable frontmatter`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-2`,children:[t.assignee?(0,z.jsxs)(`span`,{className:`inline-flex h-5 items-center gap-1 rounded-full bg-surface-2 px-1.5 font-medium text-fg`,title:`assigned to ${n?`${n.name} (${t.assignee})`:t.assignee}`,children:[n?.emoji?(0,z.jsx)(`span`,{"aria-hidden":!0,children:n.emoji}):(0,z.jsx)(B,{name:`person`,className:`ms-sm text-[13px]`}),n?.name??Xs(t.assignee)]}):(0,z.jsxs)(`span`,{className:`inline-flex h-5 items-center gap-1 rounded-full px-1.5 text-fg-2 ring-1 ring-inset ring-line`,title:`nobody is assigned`,children:[(0,z.jsx)(B,{name:`person_off`,className:`ms-sm text-[13px]`}),` unassigned`]}),t.due&&(0,z.jsxs)(`span`,{className:I(`inline-flex items-center gap-0.5`,a&&`text-bad`),title:a?`overdue`:`due`,children:[(0,z.jsx)(B,{name:`event`,className:`ms-sm text-[13px]`}),` `,t.due]}),t.files>0&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,title:`files in the task folder`,children:[(0,z.jsx)(B,{name:`attach_file`,className:`ms-sm text-[13px]`}),` `,t.files]}),t.stale&&(0,z.jsx)(J,{tone:`ask`,title:`assigned, in a work column, and nothing logged for a while`,children:`stale`})]}),t.tags.length>0&&(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.tags.map(e=>(0,z.jsx)(J,{children:e},e))}),t.lastLog&&(0,z.jsx)(`div`,{className:`truncate text-2xs text-fg-2 opacity-80`,title:t.lastLog,children:t.lastLog})]})}function Qs({at:e,status:t,onError:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),l=async()=>{let r=a.trim();if(!r||s)return;c(!0);let i=await A.request(`tasks.create`,{board:e.board,query:Hs(e.project),body:{title:r,status:t}});if(c(!1),!i.ok)return n(P(i));n(``),o(``)};return r?(0,z.jsxs)(`div`,{className:`flex items-center gap-1 p-1.5`,children:[(0,z.jsx)(Z,{autoFocus:!0,value:a,className:`h-8 text-sm`,placeholder:`task title — Enter adds`,"aria-label":`new task in ${t}`,disabled:s,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(i(!1),o(``))},onBlur:()=>!a.trim()&&i(!1)}),(0,z.jsx)(q,{size:`sm`,icon:`close`,label:`close`,onClick:()=>{i(!1),o(``)}})]}):(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,className:`m-1 justify-start`,onClick:()=>i(!0),children:`task`})}function $s({at:e,columns:t,agents:n,onClose:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(()=>(t.find(e=>e.slug===`todo`)??t[0])?.slug??``),[c,l]=(0,v.useState)(``),u=F(`me.get`,{}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let _=async()=>{let t=i.trim();if(!t||p)return;m(!0);let n=await A.request(`tasks.create`,{board:e.board,query:Hs(e.project),body:{title:t,...o?{status:o}:{},...c?{assignee:c}:{},...d.trim()?{notes:d.trim()+`
89
89
  `}:{}}});if(m(!1),!n.ok)return g(P(n));r()};return(0,b.createPortal)((0,z.jsx)(`div`,{className:`fixed inset-0 z-40 flex animate-fade items-start justify-center bg-black/38 px-4 pt-[12vh] pb-4`,onMouseDown:r,children:(0,z.jsxs)(`form`,{role:`dialog`,"aria-label":`new task`,className:`relative w-[min(520px,100%)] animate-modal rounded-card border border-line bg-surface p-5 shadow-modal`,onMouseDown:e=>e.stopPropagation(),onSubmit:e=>{e.preventDefault(),_()},children:[(0,z.jsx)(q,{icon:`close`,label:`close (esc)`,className:`absolute top-3 right-3 rounded-full`,onClick:r}),(0,z.jsx)(`h2`,{className:`m-0 mb-4 text-base font-semibold text-fg`,children:`New task`}),(0,z.jsxs)(Ct,{children:[(0,z.jsx)(Q,{label:`title`,children:(0,z.jsx)(Z,{autoFocus:!0,value:i,"aria-label":`new task title`,placeholder:`what is to be done`,disabled:p,onChange:e=>a(e.target.value)})}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`column`,children:(0,z.jsx)(St,{value:o,"aria-label":`new task column`,disabled:p,onChange:e=>s(e.target.value),children:t.map(e=>(0,z.jsx)(`option`,{value:e.slug,children:e.label},e.slug))})}),(0,z.jsx)(Q,{label:`assignee`,children:(0,z.jsxs)(St,{value:c,"aria-label":`new task assignee`,disabled:p,onChange:e=>l(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`unassigned`}),u&&(0,z.jsxs)(`option`,{value:u.actor,children:[`👤 `,u.handle,` (me)`]}),n.map(e=>(0,z.jsxs)(`option`,{value:e.slug,children:[e.emoji?`${e.emoji} `:``,e.name]},e.slug))]})})]}),(0,z.jsx)(Q,{label:`notes`,hint:`what the task is about; an assigned agent in a work column starts on it right away`,children:(0,z.jsx)(xt,{value:d,"aria-label":`new task notes`,rows:4,disabled:p,onChange:e=>f(e.target.value)})}),h&&(0,z.jsx)(rt,{tone:`bad`,children:h}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(K,{variant:`quiet`,onClick:r,children:`cancel`}),(0,z.jsx)(K,{type:`submit`,variant:`primary`,icon:`add`,disabled:p||!i.trim(),children:`add task`})]})]})]})}),document.body)}var ec={presentations:`slideshow`,contacts:`person`,places:`location_on`,events:`event`,projects:`folder`,knowledge:`menu_book`,workflows:`account_tree`,agents:`smart_toy`,repos:`source`,vibeables:`web`,boards:`view_kanban`,tasks:`task_alt`};function tc({refs:e,busy:t,onChange:n}){let r=De(),i=F(`presentations.list`,r.presentations?{query:{all:`1`}}:null,{interval:3e4}),[a,o]=(0,v.useState)([]),s=e.join(`,`);(0,v.useEffect)(()=>{if(!e.length)return o([]);let t=!0;return A.request(`refs.resolve`,{body:{tokens:e}}).then(e=>t&&e.ok&&o(e.data.refs)),()=>{t=!1}},[s]);let c=(i?.presentations??[]).filter(t=>!e.includes(`presentation:${t.name}`));return!e.length&&!r.presentations?null:(0,z.jsx)(Q,{label:`Links`,hint:`what this task is about: its agent gets them with the task`,className:`px-2`,children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`list`,"aria-label":`links`,children:[e.map(r=>{let i=a.find(e=>e.token===r);return(0,z.jsxs)(`span`,{role:`listitem`,className:`inline-flex max-w-full items-center gap-1 rounded-full border border-line bg-surface py-0.5 pl-2 pr-1 text-xs`,children:[(0,z.jsx)(B,{name:ec[i?.kind??``]??`link`,className:`ms-sm text-fg-2`}),i?.found?(0,z.jsx)(U,{href:i.href,className:`min-w-0 truncate text-fg no-underline hover:underline`,title:r,children:i.label||r}):(0,z.jsx)(`span`,{className:I(`min-w-0 truncate`,i&&`text-fg-2 line-through`),title:i?`${r} — not found`:r,children:r}),(0,z.jsx)(q,{icon:`close`,label:`unlink ${r}`,size:`sm`,disabled:t,onClick:()=>n(e.filter(e=>e!==r))})]},r)}),r.presentations&&c.length>0&&(0,z.jsxs)(St,{value:``,"aria-label":`link a presentation`,className:`h-7 w-auto max-w-full text-xs`,disabled:t,onChange:t=>t.target.value&&n([...e,t.target.value]),children:[(0,z.jsx)(`option`,{value:``,children:`+ link a presentation…`}),c.map(e=>(0,z.jsxs)(`option`,{value:`presentation:${e.name}`,children:[e.title,e.project?` · ${e.project}`:``]},`${e.project??``}/${e.name}`))]})]})})}function nc(e){let t=[],n=``;for(let r of e.split(`
90
90
  `)){let e=/^##\s+(\S+)/.exec(r);if(e){n=e[1];continue}let i=/^[*-]\s+(\d{1,2}:\d{2})\s+(.*)$/.exec(r);if(!i)continue;let a=i[2].trim(),o,s=/\s\(([^()]+)\)$/.exec(a);s&&(o=s[1],a=a.slice(0,s.index).trim()),t.push({day:n,time:i[1],text:a,...o?{actor:o}:{}})}return t}function rc(e){let t=e.split(`/`).filter(Boolean);return t.length===3?{project:t[0],board:t[1],task:t[2]}:t.length===2?{board:t[0],task:t[1]}:null}function ic({project:e,board:t,task:n,embedded:r=!1}){let i={project:e,board:t},a=Hs(e),o=F(`tasks.get`,{board:t,task:n,query:a},{interval:5e3}),s=F(`boards.get`,{board:t,query:a},{interval:15e3}),c=F(`agents.list`,{},{interval:3e4}),l=s?.columns??[],[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(``),x=Yt(),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(``),[ee,j]=(0,v.useState)({dir:``}),M=async e=>{p(!0),d(``);let r=await A.request(`tasks.save`,{board:t,task:n,query:a,body:e});if(p(!1),!r.ok)return d(P(r))},N=async e=>{p(!0),d(``);let r=await A.request(`tasks.move`,{board:t,task:n,query:a,body:{status:e}});if(p(!1),!r.ok)return d(P(r))},te=async()=>{let e=O.trim();if(!e)return;p(!0),d(``);let r=await A.request(`tasks.log`,{board:t,task:n,query:a,body:{entry:e}});if(p(!1),!r.ok)return d(P(r));k(``)},R=async()=>{let e=await A.request(`tasks.delete`,{board:t,task:n,query:a});if(!e.ok)return d(P(e));H(Us(i),{replace:!0})},ne=async r=>{if(!o||f)return;p(!0),d(``);let i=`npx kraftwerk tasks show ${o.number}${e?` --project ${e}`:``} --board ${t}`,s=g.trim(),c=await Kt({who:y||void 0,project:e,scope:y||e?void 0:{kind:`general`},task:o.ref,text:`Work on task ${o.number} ${o.title} (task:${o.slug} on board ${t}): read it with \`${i}\`${s?`\n\n${s}`:``}`,files:r});if(`error`in c)return p(!1),d(c.error),!1;y&&o.assignee!==y&&await A.request(`tasks.save`,{board:t,task:n,query:a,body:{assignee:y,wake:!1}}).catch(()=>null),p(!1),_(``),x(c.href)},[re,ie]=(0,v.useState)(null),[ae,oe]=(0,v.useState)(`saved`),[se,ce]=(0,v.useState)(null),le=(0,v.useRef)(null),ue=(0,v.useRef)(null),de=(0,v.useRef)(!1),V=(0,v.useRef)(null),fe=(0,v.useRef)(null),pe=o?.notes;(0,v.useEffect)(()=>{if(pe===void 0||pe===le.current||ue.current!==null||fe.current||se!==null)return;let e=!0;return Bs().then(({unwrapParagraphs:t})=>{e&&(le.current=pe,de.current=!1,ie(e=>({key:(e?.key??0)+1,body:t(pe)})))}),()=>{e=!1}},[pe,se]);async function me(){fe.current&&await fe.current;let e=ue.current;if(e===null)return;ue.current=null,oe(`saving`);let r=(async()=>{let r=await A.request(`tasks.save`,{board:t,task:n,query:a,body:{notes:e},keepalive:!0});r.ok?(le.current=r.data.notes,d(``),oe(ue.current===null?`saved`:`unsaved`)):(d(P(r)),oe(`error`),ue.current===null&&(ue.current=e))})();fe.current=r,await r,fe.current=null}function he(e){de.current&&(ue.current=e,oe(`unsaved`),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>void me(),1e3))}(0,v.useEffect)(()=>{let e=()=>{ue.current!==null&&me()};return window.addEventListener(`beforeunload`,e),window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`beforeunload`,e),window.removeEventListener(`pagehide`,e),V.current&&clearTimeout(V.current),ue.current!==null&&me()}},[]);let ge=async()=>{if(se===null)return;p(!0);let e=await A.request(`tasks.save`,{board:t,task:n,query:a,body:{notes:se}});if(p(!1),!e.ok)return d(P(e));le.current=null,ce(null)},_e=(0,v.useMemo)(()=>nc(o?.log??``),[o?.log]),ve=o?.sessions??[],ye=e=>{let[t,n]=e.split(`/`);return ve.find(e=>e.agent===t)??(t===`kraftwerk-chat`&&n?ve.find(e=>e.agent===n):void 0)},be=(c?.agents??[]).filter(e=>!e.archived),xe=F(`me.get`,{}),Se=s?.people??[];if(!o)return(0,z.jsx)(Y,{children:`loading…`});let Ce=Js(l),we=l.find(e=>e.slug===o.status),Te=(e,t)=>{if(t!==null){if(e===`title`){let e=t.trim();e&&e!==o.title&&M({title:e}),C(null)}else if(e===`due`){let e=t.trim();e!==(o.due??``)&&M({due:e||null}),T(null)}else{let e=t.split(`,`).map(e=>e.trim()).filter(Boolean);e.join(`,`)!==o.tags.join(`,`)&&M({tags:e}),D(null)}}},Ee=e=>t=>{t.key===`Enter`&&(t.preventDefault(),e(),t.target.blur())},De=t=>{if(!t)return{emoji:`•`,name:``};if(t.startsWith(`human:`)&&t!==xe?.actor)return{emoji:`👤`,name:t.slice(6)};if(t.startsWith(`human`))return{emoji:`🙂`,name:`You`};let n=t.split(`/`)[0];if(n===`kraftwerk-chat`)return e?{emoji:`🧭`,name:`Assistant`}:{emoji:`🎩`,name:`Ralv`};let r=(c?.agents??[]).find(e=>e.slug===n);return r?{emoji:r.emoji||`🤖`,name:r.name}:{emoji:`🤖`,name:n}},Oe=`h-8 border-transparent bg-transparent px-2 text-sm shadow-none hover:bg-surface-2 focus:bg-surface`;return(0,z.jsx)(`div`,{className:I(`task-page @container min-h-0 overflow-y-auto`,!r&&`chat-main`),"data-embedded":r||void 0,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[1120px] flex-col gap-5`,children:[(0,z.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-2`,children:[(0,z.jsxs)(U,{href:Us(i),className:`inline-flex items-center gap-1 text-fg-2 no-underline hover:text-fg`,title:`back to the board`,children:[(0,z.jsx)(B,{name:`arrow_back`,className:`ms-sm`}),` `,s?.title??t]}),(0,z.jsxs)(`span`,{className:`font-mono`,children:[`#`,o.number]}),o.stale&&(0,z.jsx)(J,{tone:`ask`,children:`stale`}),o.configError&&(0,z.jsx)(J,{tone:`bad`,title:o.configError,children:`unreadable frontmatter`}),(0,z.jsx)(`span`,{className:`flex-1`}),Ce&&o.status!==Ce.slug&&(0,z.jsxs)(K,{size:`sm`,icon:`check`,disabled:f,onClick:()=>void N(Ce.slug),title:`move to ${Ce.label}`,children:[`mark `,Ce.label.toLowerCase()]}),m?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,onClick:()=>void R(),children:`move to trash`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>h(!1),children:`cancel`})]}):(0,z.jsx)(q,{icon:`delete`,label:`remove`,size:`sm`,onClick:()=>h(!0)})]}),(0,z.jsx)(`textarea`,{rows:1,value:S??o.title,"aria-label":`task title`,className:`block w-full resize-none border-0 bg-transparent p-0 font-[inherit] text-2xl leading-tight font-semibold text-fg shadow-none outline-none focus:shadow-none focus:outline-none focus-visible:outline-none [field-sizing:content]`,onChange:e=>C(e.target.value.replace(/\n/g,` `)),onBlur:()=>Te(`title`,S),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())}})]}),u&&(0,z.jsx)(rt,{tone:`bad`,children:u}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-x-8 gap-y-6 @[880px]:grid-cols-[minmax(0,1fr)_280px] @[880px]:grid-rows-[auto_1fr]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 @[880px]:row-span-2`,children:[!r&&(0,z.jsx)(Rt,{label:`work on this task`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`task_alt`,className:`ms-sm`}),` #`,o.number]}),chipTitle:`the chat starts with this task`,value:g,onChange:_,minRows:1,inputLabel:`what to do on the task`,placeholder:`Work on this — add what to do or look at (optional)`,onSend:ne,sendLabel:`work on this`,busy:f,skills:!0,who:y,onWho:e=>be.some(t=>t.slug===e)&&b(e),attach:!0,controls:(0,z.jsx)(Bt,{label:`work with`,value:y,onChange:b,agents:be,byDefault:e?`🧭 Assistant (default)`:`🎩 Ralv (default)`}),hint:`starts a chat about this task`}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`description`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Description`}),ae!==`saved`&&(0,z.jsx)(`span`,{className:I(`text-xs`,ae===`error`?`text-bad`:`text-fg-2`),children:ae===`saving`?`saving…`:ae===`unsaved`?`unsaved`:`not saved`}),(0,z.jsx)(`span`,{className:`flex-1`}),se===null&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`code`,title:`edit the text as markdown`,onClick:()=>ce(o.notes),children:`markdown`})]}),(0,z.jsx)(`div`,{className:`overflow-hidden rounded-card border border-line bg-surface`,children:se===null?(0,z.jsx)(`div`,{className:`task-doc`,onPointerDownCapture:()=>de.current=!0,onKeyDownCapture:()=>de.current=!0,onPasteCapture:()=>de.current=!0,onDropCapture:()=>de.current=!0,children:re?(0,z.jsx)(v.Suspense,{fallback:(0,z.jsx)(nt,{className:`px-[18px] py-2`,children:`loading the editor…`}),children:(0,z.jsx)(zs,{markdown:re.body,autoFocus:!1,onChange:he,onError:()=>ce(o.notes)},re.key)}):(0,z.jsx)(nt,{className:`px-[18px] py-2`,children:`loading…`})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(xt,{value:se,"aria-label":`task markdown`,rows:14,className:`rounded-none border-0 font-mono text-[13px]`,onChange:e=>ce(e.target.value)}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-line px-[18px] py-2`,children:[(0,z.jsx)(K,{size:`sm`,variant:`primary`,busy:f,onClick:()=>void ge(),children:`save`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>{ce(null),le.current=null},children:`cancel`})]})]})})]}),!o.cloud&&(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`files`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Files`}),(0,z.jsx)(`div`,{className:`rounded-card border border-line bg-surface px-2 py-1`,title:`the task's folder: drop files on the list`,children:(0,z.jsx)(As,{compact:!0,scope:`task:${o.ref}`,dir:ee.dir,file:ee.file,onOpen:(e,t)=>j({dir:e,file:t})},o.ref)})]}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`activity`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Activity`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Z,{value:O,placeholder:`Add a comment…`,"aria-label":`log entry`,disabled:f,onChange:e=>k(e.target.value),onKeyDown:Ee(()=>void te())}),(0,z.jsx)(K,{icon:`send`,busy:f,disabled:!O.trim(),onClick:()=>void te(),children:`comment`})]}),_e.length===0?(0,z.jsx)(nt,{className:`py-2`,children:`nothing happened yet`}):(0,z.jsx)(`ol`,{className:`m-0 flex list-none flex-col p-0`,children:_e.map((e,t)=>{let n=e.actor?ye(e.actor):void 0,r=De(e.actor);return(0,z.jsxs)(v.Fragment,{children:[(t===0||_e[t-1].day!==e.day)&&(0,z.jsx)(it,{className:`pt-3 pb-1`,children:e.day}),(0,z.jsxs)(`li`,{className:`flex gap-3 border-t border-line py-2.5 first:border-t-0`,children:[(0,z.jsx)(`span`,{className:`grid size-7 flex-none place-items-center rounded-full bg-surface-2 text-[14px] leading-none`,"aria-hidden":!0,children:r.emoji}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2 text-xs text-fg-2`,children:[r.name&&(0,z.jsx)(`span`,{className:`font-semibold text-fg`,title:e.actor,children:r.name}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:e.time}),n&&(0,z.jsx)(U,{href:n.href,className:`text-fg-2 underline decoration-dotted hover:text-fg`,title:`open the session ${n.name??n.agent} worked in`,children:`open session`})]}),(0,z.jsx)(ac,{text:e.text})]})]})]},t)})})]})]}),(0,z.jsxs)(`aside`,{className:`order-first flex min-w-0 flex-col gap-4 @[880px]:order-none`,"aria-label":`details`,children:[(0,z.jsxs)(`dl`,{className:`m-0 grid grid-cols-[76px_minmax(0,1fr)] items-center gap-x-2 gap-y-1 text-sm @min-[520px]:@max-[879px]:grid-cols-[76px_minmax(0,1fr)_76px_minmax(0,1fr)]`,children:[(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Status`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsxs)(St,{value:we?o.status:``,"aria-label":`status`,className:Oe,disabled:f||!l.length,onChange:e=>e.target.value&&void M({status:e.target.value}),children:[!we&&(0,z.jsx)(`option`,{value:``,children:o.status||`no column`}),l.map(e=>(0,z.jsx)(`option`,{value:e.slug,children:e.label},e.slug))]})}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Assignee`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsxs)(St,{value:o.assignee??``,"aria-label":`assignee`,className:Oe,disabled:f,onChange:e=>void M({assignee:e.target.value||null}),children:[(0,z.jsx)(`option`,{value:``,children:`unassigned`}),xe&&(0,z.jsxs)(`option`,{value:xe.actor,children:[`👤 `,xe.handle,` (me)`]}),Se.filter(e=>`human:${e.handle}`!==xe?.actor).map(e=>(0,z.jsxs)(`option`,{value:`human:${e.handle}`,children:[`👤 `,e.handle]},e.id)),o.assignee&&o.assignee!==xe?.actor&&!Se.some(e=>`human:${e.handle}`===o.assignee)&&!be.some(e=>e.slug===o.assignee)&&(0,z.jsx)(`option`,{value:o.assignee,children:Xs(o.assignee)}),be.map(e=>(0,z.jsxs)(`option`,{value:e.slug,children:[e.emoji?`${e.emoji} `:``,e.name]},e.slug))]})}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Due`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(Z,{type:`date`,value:w??o.due??``,"aria-label":`due date`,className:I(Oe,`w-full`),onChange:e=>T(e.target.value),onBlur:()=>Te(`due`,w),onKeyDown:Ee(()=>Te(`due`,w))})}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Tags`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(Z,{value:E??o.tags.join(`, `),placeholder:`none`,"aria-label":`tags`,title:`comma-separated`,className:Oe,onChange:e=>D(e.target.value),onBlur:()=>Te(`tags`,E),onKeyDown:Ee(()=>Te(`tags`,E))})})]}),(0,z.jsx)(tc,{refs:o.refs,busy:f,onChange:e=>void M({refs:e})})]}),(0,z.jsxs)(`aside`,{className:`flex min-w-0 flex-col gap-5`,"aria-label":`chats and facts`,children:[ve.length>0&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,"aria-label":`sessions`,children:[(0,z.jsx)(`h3`,{className:`m-0 px-2 text-sm font-semibold text-fg`,children:`Chats`}),ve.map(e=>(0,z.jsxs)(U,{href:e.href,className:`flex items-center gap-2 rounded-control px-2 py-1 text-sm text-fg no-underline hover:bg-surface-2`,title:e.title||e.id,children:[(0,z.jsx)(`span`,{className:`flex-none`,children:e.emoji||`💬`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name??e.agent}),(0,z.jsx)(`span`,{className:`flex-none text-xs text-fg-2`,children:e.busy?`working`:G(e.updatedAt)})]},e.id))]}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-2 text-xs text-fg-2`,children:[(0,z.jsxs)(`span`,{children:[`created `,o.created,o.updatedAt?` · changed ${G(o.updatedAt)}`:``]}),(0,z.jsxs)(`code`,{className:`font-mono text-2xs [overflow-wrap:anywhere]`,title:`how agents and the CLI refer to this task`,children:[`task:`,o.slug]})]})]})]})]})})}function ac({text:e}){let[t,n]=(0,v.useState)(!1),r=e.length>280;return(0,z.jsxs)(`div`,{className:`text-sm [overflow-wrap:anywhere]`,children:[(0,z.jsx)(`span`,{className:I(r&&!t&&`line-clamp-3`),children:e}),r&&(0,z.jsx)(`button`,{type:`button`,className:`mt-0.5 block cursor-pointer border-0 bg-transparent p-0 text-xs text-accent hover:underline`,onClick:()=>n(!t),children:t?`show less`:`show more`})]})}function oc({project:e,board:t}){let n={project:e,board:t},r=Hs(e),i=F(`agents.list`,{},{interval:3e4}),a=De(),o=F(`projects.list`,!e&&a.projects?{}:null,{interval:6e4}),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)([]),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(!1),[ee,j]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!0;return A.request(`boards.get`,{board:t,query:r}).then(t=>{if(!e)return;if(!t.ok)return f(P(t));let n=t.data;c(n),m(n.title),g(n.columns.map(e=>({slug:e.slug,label:e.label,limit:e.limit===void 0?``:String(e.limit),review:!!e.review,done:!!e.done}))),y(n.agent??``),x(n.staleAfter??``),u(n.projects??[]),C(n.notes)}),()=>{e=!1}},[t,e]);let M=()=>{T(!0),k(!1),j(``)},N=(e,t)=>{g(n=>n.map((n,r)=>r===e?{...n,...t}:n)),M()},I=(e,t)=>{g(n=>{let r=e+t;if(r<0||r>=n.length)return n;let i=[...n];return[i[e],i[r]]=[i[r],i[e]],i}),M()},te=async()=>{D(!0),j(``);let n={title:p.trim(),columns:h.map(e=>({slug:e.slug.trim(),label:e.label.trim()||e.slug.trim(),...e.limit.trim()?{limit:Number(e.limit)}:{},...e.review?{review:!0}:{},...e.done?{done:!0}:{}})),agent:_||null,staleAfter:b.trim()||null,...e?{}:{projects:l},notes:S},i=await A.request(`boards.save`,{board:t,query:r,body:n});if(D(!1),!i.ok)return j(P(i));c(i.data),T(!1),k(!0)};if(d)return(0,z.jsx)(Y,{icon:`view_kanban`,children:d});if(!s)return(0,z.jsx)(Y,{children:`loading…`});let R=(i?.agents??[]).filter(e=>!e.archived),ne=(o?.projects??[]).filter(e=>e.status!==`archived`||l.includes(e.slug));return(0,z.jsx)(`div`,{className:`chat-main flex min-h-0 flex-col gap-3 overflow-y-auto`,children:(0,z.jsxs)(ct,{className:`animate-none`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsxs)(U,{href:Us(n),className:`inline-flex items-center gap-1 text-sm text-fg-2 no-underline hover:text-fg`,children:[(0,z.jsx)(B,{name:`arrow_back`,className:`ms-sm`}),` `,s.title]}),(0,z.jsx)(ot,{children:`board settings`}),(0,z.jsx)(`span`,{className:`flex-1`}),ee&&(0,z.jsx)(`span`,{className:`text-sm text-bad`,children:ee}),O&&!w&&(0,z.jsx)(`span`,{className:`text-sm text-fg-2`,children:`saved`}),(0,z.jsx)(K,{variant:`primary`,icon:`save`,busy:E,disabled:!w||E||!p.trim()||h.length===0,onClick:()=>void te(),children:`save`})]}),s.configError&&(0,z.jsxs)(rt,{tone:`bad`,children:[`board.md: `,s.configError,` — the values below are defaults; saving overwrites the file.`]}),(0,z.jsx)(X,{title:`board`,children:(0,z.jsxs)(Ct,{className:`max-w-[760px]`,children:[(0,z.jsx)(Q,{label:`title`,children:(0,z.jsx)(Z,{value:p,"aria-label":`board title`,onChange:e=>{m(e.target.value),M()}})}),!s.cloud&&(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`default agent`,hint:`a task entering the pick column without an assignee goes to this agent, which is woken`,className:`flex-1`,children:(0,z.jsxs)(St,{value:_,"aria-label":`default agent`,onChange:e=>{y(e.target.value),M()},children:[(0,z.jsx)(`option`,{value:``,children:`none`}),_&&!R.some(e=>e.slug===_)&&(0,z.jsx)(`option`,{value:_,children:_}),R.map(e=>(0,z.jsxs)(`option`,{value:e.slug,children:[e.emoji?`${e.emoji} `:``,e.name]},e.slug))]})}),(0,z.jsx)(Q,{label:`stale after`,hint:`a task in a work column with nothing logged for this long is marked stale (default 1d)`,children:(0,z.jsx)(Z,{value:b,placeholder:`1d`,"aria-label":`stale after`,className:`w-[120px]`,onChange:e=>{x(e.target.value),M()}})})]})]})}),!e&&!s.cloud&&a.projects&&(0,z.jsx)(X,{title:`linked projects`,children:(0,z.jsxs)(Ct,{children:[ne.length===0?(0,z.jsx)(nt,{children:`No projects yet.`}):(0,z.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,children:ne.map(e=>(0,z.jsx)(Tt,{checked:l.includes(e.slug),onChange:t=>{u(n=>t?[...n,e.slug]:n.filter(t=>t!==e.slug)),M()},children:e.title},e.slug))}),(0,z.jsx)(nt,{children:`The board stays a workspace board. Each linked project lists it with its own boards, shows it in its context column, and its chats are briefed with it.`})]})}),(0,z.jsxs)(X,{title:`columns`,actions:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,onClick:()=>{g(e=>[...e,{slug:``,label:``,limit:``,review:!1,done:!1}]),M()},children:`column`}),children:[(0,z.jsx)(`div`,{className:`flex flex-col divide-y divide-line`,children:h.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-[18px] py-2`,"data-column-row":t,children:[(0,z.jsx)(Z,{value:e.slug,placeholder:`slug`,"aria-label":`column ${t+1} slug`,className:`h-8 w-[130px] font-mono text-xs`,onChange:e=>N(t,{slug:e.target.value})}),(0,z.jsx)(Z,{value:e.label,placeholder:`label`,"aria-label":`column ${t+1} label`,className:`h-8 w-[160px] text-sm`,onChange:e=>N(t,{label:e.target.value})}),(0,z.jsx)(Z,{value:e.limit,placeholder:`limit`,inputMode:`numeric`,"aria-label":`column ${t+1} limit`,className:`h-8 w-[70px] text-sm`,onChange:e=>N(t,{limit:e.target.value.replace(/\D/g,``)})}),(0,z.jsx)(Tt,{checked:e.review,onChange:e=>N(t,{review:e}),className:`text-xs`,children:`review`}),(0,z.jsx)(Tt,{checked:e.done,onChange:e=>N(t,{done:e}),className:`text-xs`,children:`done`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(q,{size:`sm`,icon:`arrow_upward`,label:`move column ${e.label||e.slug||t+1} up`,disabled:t===0,onClick:()=>I(t,-1)}),(0,z.jsx)(q,{size:`sm`,icon:`arrow_downward`,label:`move column ${e.label||e.slug||t+1} down`,disabled:t===h.length-1,onClick:()=>I(t,1)}),(0,z.jsx)(q,{size:`sm`,icon:`close`,label:`remove column ${e.label||e.slug||t+1}`,onClick:()=>{g(e=>e.filter((e,n)=>n!==t)),M()}})]},t))}),(0,z.jsxs)(nt,{className:`px-[18px] py-3`,children:[`In order, left to right. The first column is where drafts sit; agents pick from `,(0,z.jsx)(`code`,{children:`todo`}),` (else the second column); a `,(0,z.jsx)(`b`,{children:`review`}),` column waits for a human and counts as attention; a `,(0,z.jsx)(`b`,{children:`done`}),` column is finished work. Tasks in a removed column keep their status and show under "No column".`]})]}),!s.cloud&&(0,z.jsx)(X,{title:`rules`,children:(0,z.jsxs)(Ct,{children:[(0,z.jsx)(xt,{value:S,"aria-label":`rules`,rows:8,className:`font-mono text-[13px]`,placeholder:`What the board is for and the rules agents follow — Markdown, the body of board.md`,onChange:e=>{C(e.target.value),M()}}),(0,z.jsxs)(nt,{children:[`Everything here is `,(0,z.jsx)(`code`,{children:`board.md`}),` in `,(0,z.jsx)(`code`,{title:s.path,children:s.path}),`: frontmatter (title, columns, agent, stale_after`,e?``:`, projects`,`) and these rules as its body. The file can be edited by hand just as well.`]})]})})]})})}function sc({seg:e,project:t}){let n=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,r=e[0]===`new`,i=e[1]?decodeURIComponent(e[1]):void 0,a=F(`boards.list`,t?{query:{project:t}}:{},{interval:1e4}),o=a?.boards??[],s=t?`/projects/${Vs(t)}/boards`:`/boards`,c=e=>({...t?{project:t}:{},board:e}),l=e=>({...e.project?{project:e.project}:{},board:e.board}),u=o.filter(e=>e.project===t),d=t?o.filter(e=>!e.project):[],f=o.find(e=>e.board===n&&e.project===t),p;return p=n?.startsWith(`@`)&&!t?i===`settings`?(0,z.jsx)(oc,{board:n},`${n}/settings`):i?(0,z.jsx)(ic,{board:n,task:i},`${n}/${i}`):(0,z.jsx)(Ys,{board:n},n):r?(0,z.jsx)(uc,{root:a?.root,project:t,cloudState:a&&`cloud`in a?a.cloud:void 0}):a&&!a.enabled?(0,z.jsx)(Y,{icon:`view_kanban`,children:a.error&&!/are off/.test(a.error)?(0,z.jsx)(`span`,{className:`text-bad`,children:a.error}):(0,z.jsxs)(z.Fragment,{children:[`Boards are off. Turn them on in `,(0,z.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,z.jsx)(`code`,{children:`boards:`}),` block to kraftwerk.yml.`]})}):a?a.error?(0,z.jsx)(Y,{icon:`view_kanban`,children:(0,z.jsx)(`span`,{className:`text-bad`,children:a.error})}):r?(0,z.jsx)(uc,{root:a.root,project:t}):!n&&t?u.length===0&&d.length===0?(0,z.jsx)(dc,{slug:t}):(0,z.jsx)(lc,{to:Us(l(u[0]??d[0]))}):!n&&o.length===0?(0,z.jsx)(uc,{root:a.root}):n&&i===`settings`?(0,z.jsx)(oc,{...c(n)},`${t??``}/${n}/settings`):n&&i?(0,z.jsx)(ic,{...c(n),task:i},`${t??``}/${n}/${i}`):n?(0,z.jsx)(Ys,{...c(n)},`${t??``}/${n}`):(0,z.jsx)(Y,{icon:`view_kanban`,action:(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`${s}/new`,children:`new board`}),children:`Workspace boards: the work that belongs to no project, as columns of tasks. A project's boards live with the project.`}):(0,z.jsx)(Y,{children:`loading…`}),(0,z.jsxs)(`div`,{className:`runs-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:t?`${t} · boards`:`boards`,count:a?.enabled?o.length:void 0,action:a?.enabled&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,href:`${s}/new`,children:`new`})}),(0,z.jsxs)(jt,{label:`boards`,children:[o.map(e=>(0,z.jsx)(gt,{href:Us(l(e)),active:!!f&&f===e,size:`sm`,leading:(0,z.jsx)(B,{name:e.cloud?`cloud`:t&&!e.project?`link`:`view_kanban`,className:`ms-sm`}),title:e.title,titleExtra:(0,z.jsx)($e,{n:e.review,title:`waiting for review`}),sub:e.configError?`unreadable board.md`:`${e.cloud?`cloud · `:t&&!e.project?`workspace board · `:``}${e.tasks} ${e.tasks===1?`task`:`tasks`}`,subTone:e.configError?`bad`:`plain`,meta:e.updatedAt&&(0,z.jsx)(`span`,{title:e.updatedAt,children:G(e.updatedAt)})},`${e.project??``}/${e.board}`)),a&&!a.enabled&&(0,z.jsx)(Mt,{children:a.error}),a?.enabled&&o.length===0&&(0,z.jsxs)(Mt,{children:[`no `,t?``:`workspace `,`boards yet`]}),!t&&a&&`cloud`in a&&a.cloud?.local&&(0,z.jsx)(Mt,{children:(0,z.jsxs)(`a`,{href:`#/settings/cloud`,className:`inline-flex items-center gap-1 text-accent`,title:`Cloud boards are shared with everyone on the workspace — they need cloud mode`,children:[(0,z.jsx)(B,{name:`cloud`,className:`ms-sm`}),` shared boards: try cloud mode`]})}),!t&&a&&`cloud`in a&&a.cloud?.offline&&(0,z.jsx)(Mt,{children:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:a.cloud.error,children:[(0,z.jsx)(B,{name:`cloud_off`,className:`ms-sm`}),` cloud boards offline`]})}),t&&a?.enabled&&(0,z.jsx)(cc,{project:t}),t&&(0,z.jsx)(Mt,{children:(0,z.jsx)(U,{href:`/projects/${Vs(t)}`,className:`text-accent`,children:`← back to the project`})})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:p})]})}function cc({project:e}){let t=F(`boards.list`,{},{interval:3e4}),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),o=(t?.boards??[]).filter(t=>!t.projects?.includes(e));if(!t?.enabled||o.length===0)return null;let s=async t=>{let n=o.find(e=>e.board===t);if(!n)return;a(!0),r(``);let i=await A.request(`boards.save`,{board:n.board,query:{},body:{projects:[...n.projects??[],e]}});if(a(!1),!i.ok)return r(P(i));H(Us({board:n.board}))};return(0,z.jsxs)(Mt,{children:[(0,z.jsxs)(St,{value:``,disabled:i,"aria-label":`link a workspace board`,className:`h-8 text-sm`,onChange:e=>void s(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`link a workspace board…`}),o.map(e=>(0,z.jsx)(`option`,{value:e.board,children:e.title},e.board))]}),n&&(0,z.jsx)(`span`,{className:`text-sm text-bad`,children:n})]})}function lc({to:e}){return(0,v.useEffect)(()=>H(e,{replace:!0}),[e]),(0,z.jsx)(Y,{children:`opening the board…`})}function uc({root:e,project:t,cloudState:n}){let[r,i]=(0,v.useState)(``),a=!t&&!!n&&!n.error&&!n.local,[o,s]=(0,v.useState)(`local`),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),f=async()=>{let e=r.trim();if(!e||c)return;l(!0),d(``);let n=await A.request(`boards.create`,{body:{title:e,...t?{project:t}:{},...o===`cloud`?{cloud:!0}:{}}});if(l(!1),!n.ok)return d(P(n));H(Us({...t?{project:t}:{},board:n.data.board}),{replace:!0})};return(0,z.jsxs)(ct,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(B,{name:`view_kanban`,className:`text-[26px] text-fg-2`}),(0,z.jsx)(ot,{children:`new board`})]}),(0,z.jsx)(X,{children:(0,z.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),f()},children:(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsx)(Q,{label:`title`,children:(0,z.jsx)(Z,{value:r,"aria-label":`board title`,autoFocus:!0,placeholder:`e.g. Marketing`,onChange:e=>i(e.target.value)})}),!t&&(0,z.jsxs)(Q,{label:`where`,children:[(0,z.jsxs)(St,{value:o,"aria-label":`where the board lives`,onChange:e=>s(e.target.value),children:[(0,z.jsx)(`option`,{value:`local`,children:`this workspace's files — single player`}),(0,z.jsxs)(`option`,{value:`cloud`,disabled:!a,children:[`kraftwerk cloud — shared with everyone on the workspace`,a?``:n?.local?` (needs cloud mode)`:n?.offline?` (offline)`:` (not available)`]})]}),n?.local&&(0,z.jsxs)(nt,{className:`mt-1.5`,children:[(0,z.jsx)(B,{name:`cloud`,className:`ms-sm align-[-3px] text-accent`}),` Want to share a board with others? Cloud boards need the workspace in cloud mode —`,` `,(0,z.jsx)(`a`,{href:`#/settings/cloud`,className:`text-accent`,children:`switch to cloud`}),`.`]})]}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(K,{variant:`primary`,type:`submit`,icon:`add`,busy:c,disabled:!r.trim()||c,children:`create board`}),(0,z.jsx)(K,{variant:`quiet`,href:t?`/projects/${Vs(t)}/boards`:`/boards`,children:`cancel`}),u&&(0,z.jsx)(`span`,{className:`text-sm text-bad`,children:u})]}),(0,z.jsx)(nt,{children:o===`cloud`?(0,z.jsx)(z.Fragment,{children:`Kept in kraftwerk cloud, not in this workspace's files: everyone on the workspace sees and edits it, here or in the cloud's web app. Tasks go to people on the workspace or to agents.`}):(0,z.jsxs)(z.Fragment,{children:[`One folder `,t?(0,z.jsxs)(z.Fragment,{children:[`under the project's `,(0,z.jsx)(`code`,{children:`boards/`})]}):(0,z.jsxs)(z.Fragment,{children:[`under `,(0,z.jsx)(`code`,{title:e,children:e??`the boards root`})]}),` with board.md and a tasks/ folder; the columns start as Draft, Todo, In progress, Review, Done and are changed in the board's settings.`]})})]})})})]})}function dc({slug:e}){let[t,n]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let t=!0;return A.request(`boards.ensure`,{body:{project:e}}).then(r=>{t&&(r.ok?H(`/projects/${Vs(e)}/boards/${Vs(r.data.board)}`,{replace:!0}):n(P(r)))}),()=>{t=!1}},[e]),t?(0,z.jsx)(Y,{icon:`view_kanban`,children:(0,z.jsx)(`span`,{className:`text-bad`,children:t})}):(0,z.jsx)(Y,{children:`opening the board…`})}function fc({project:e,board:t}){let n={project:e,board:t},r=F(`boards.get`,{board:t,query:Hs(e)},{interval:1e4}),i=F(`agents.list`,{},{interval:6e4}),[a,o]=(0,v.useState)(!1);if(!r)return null;let s=new Set(r.columns.map(e=>e.slug)),c=[...r.columns,...r.items.some(e=>!s.has(e.status))?[{slug:``,label:`No column`}]:[]].map(e=>({col:e,tasks:r.items.filter(t=>e.slug?t.status===e.slug:!s.has(t.status)).sort(Gs)})),l=e=>(i?.agents??[]).find(t=>t.slug===e),u=r.tasks;return(0,z.jsxs)(`section`,{className:`flex flex-col gap-2.5 pb-3`,"aria-label":`board ${r.title}`,children:[a&&(0,z.jsx)($s,{at:n,columns:r.columns,agents:i?.agents??[],onClose:()=>o(!1)}),(0,z.jsx)(gt,{href:Us(n),size:`sm`,leading:(0,z.jsx)(B,{name:`view_kanban`,className:`ms-sm`}),title:r.title,titleExtra:(0,z.jsx)($e,{n:r.review,title:`waiting for review`}),meta:u===0?`empty`:`${u} task${u===1?``:`s`}`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5`,children:[(0,z.jsx)(K,{size:`sm`,icon:`add`,onClick:()=>o(!0),children:`new task`}),u===0&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`Nothing on the board yet.`})]}),(0,z.jsx)(`div`,{className:`board-glance flex gap-2 overflow-x-auto px-2.5 pb-1`,"aria-label":`columns`,children:c.map(({col:e,tasks:t})=>{let r=e.limit!==void 0&&t.length>e.limit,i=e.done?3:8;return(0,z.jsxs)(`div`,{role:`group`,"aria-label":e.label,className:I(`flex w-[168px] flex-none flex-col gap-1 rounded-card bg-surface-2 p-1.5`,e.review&&t.length>0&&`bg-ask-soft`,r&&`bg-bad-soft`),children:[(0,z.jsxs)(U,{href:Us(n),title:`${e.label}: ${t.length}${e.limit===void 0?``:` of ${e.limit}`}`,className:`flex items-baseline gap-1.5 px-1 pt-0.5 pb-1 no-underline`,children:[(0,z.jsx)(it,{className:I(`truncate`,e.review&&`text-on-ask-soft`,r&&`text-on-bad-soft`),children:e.label}),(0,z.jsxs)(`span`,{className:`text-2xs tabular-nums text-fg-2`,children:[t.length,e.limit===void 0?``:`/${e.limit}`]})]}),t.slice(0,i).map(t=>{let r=t.assignee?l(t.assignee):void 0;return(0,z.jsxs)(U,{href:Ws(n,t.slug),title:t.title,className:I(`flex min-w-0 flex-col gap-1 rounded-control border border-line bg-surface px-2 py-1.5 text-xs text-fg no-underline transition-colors hover:border-accent`,e.done&&`opacity-70`),children:[(0,z.jsx)(`span`,{className:`line-clamp-2 font-medium`,children:t.title}),(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-2xs text-fg-2`,children:[(0,z.jsxs)(`span`,{className:`font-mono`,children:[`#`,t.number]}),t.due&&(0,z.jsx)(`span`,{className:`tabular-nums`,children:t.due.slice(5)}),t.stale&&(0,z.jsx)(B,{name:`hourglass_bottom`,className:`ms-sm text-[13px] text-on-ask-soft`}),t.assignee&&(0,z.jsx)(`span`,{className:`ml-auto`,title:r?`${r.name} (${t.assignee})`:t.assignee,children:r?.emoji?r.emoji:Xs(t.assignee)})]})]},t.slug)}),t.length>i&&(0,z.jsxs)(U,{href:Us(n),className:`px-1 text-2xs text-fg-2 no-underline hover:text-fg`,children:[t.length-i,` more`]})]},e.slug||`~`)})})]})}function pc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var mc=pc();function hc(e){mc=e}var gc={exec:()=>null};function _c(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function vc(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(bc.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var yc=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),bc={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,listInterruptsParagraph:/^ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {0,3}>)([ \t]+)/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\][ \t]+\S/,listReplaceTask:/^\[[ xX]\][ \t]+/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:_c(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:_c(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:_c(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:_c(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:_c(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:_c(e=>RegExp(`^ {0,${e}}(?:</?(?:${Fc})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:_c(e=>RegExp(`^ {0,${e}}>`)),nestedContainerMarkers:/^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/},xc=/^(?:[ \t]*(?:\n|$))+/,Sc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Cc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/,wc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Tc=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ec=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Dc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/,Oc=vc(Dc).replace(/bull/g,Ec).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),kc=vc(Dc).replace(/bull/g,Ec).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ac=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,jc=/^[^\n]+/,Mc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/,Nc=vc(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Mc).replace(`title`,/(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex(),Pc=vc(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Ec).getRegex(),Fc=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Ic=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Lc=vc(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Ic).replace(`tag`,Fc).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Rc=e=>vc(Ac).replace(`hr`,wc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Fc).getRegex(),zc=Rc(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Bc=Rc(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Vc={blockquote:vc(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Bc).getRegex(),code:Sc,def:Nc,fences:Cc,heading:Tc,hr:wc,html:Lc,lheading:Oc,list:Pc,newline:xc,paragraph:zc,table:gc,text:jc},Hc=vc(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,wc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Fc).getRegex(),Uc={...Vc,lheading:kc,table:Hc,paragraph:vc(Ac).replace(`hr`,wc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Hc).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Fc).getRegex()},Wc={...Vc,html:vc(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace(`comment`,Ic).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:gc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:vc(Ac).replace(`hr`,wc).replace(`heading`,` *#{1,6} *[^
91
91
  ]`).replace(`lheading`,Oc).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Gc=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Kc=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,qc=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Jc=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Yc=/[\p{P}\p{S}]/u,Xc=/[\s\p{P}\p{S}]/u,Zc=/[^\s\p{P}\p{S}]/u,Qc=vc(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Xc).getRegex(),$c=/[\p{Pi}\p{Ps}"']/u,el=/(?!~)[\p{P}\p{S}]/u,tl=/(?!~)[\s\p{P}\p{S}]/u,nl=/(?:[^\s\p{P}\p{S}]|~)/u,rl=vc(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,yc?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),il=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,al=vc(il,`u`).replace(/punct/g,Yc).getRegex(),ol=vc(il,`u`).replace(/punct/g,el).getRegex(),sl=vc(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,$c).replace(/punct/g,Yc).getRegex(),cl=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,ll=vc(cl,`gu`).replace(/notPunctSpace/g,Zc).replace(/punctSpace/g,Xc).replace(/punct/g,Yc).getRegex(),ul=vc(cl,`gu`).replace(/notPunctSpace/g,nl).replace(/punctSpace/g,tl).replace(/punct/g,el).getRegex(),dl=vc(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Zc).replace(/punctSpace/g,Xc).replace(/punct/g,Yc).getRegex(),fl=vc(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Zc).replace(/punctSpace/g,Xc).replace(/punct/g,Yc).getRegex(),pl=vc(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Zc).replace(/punctSpace/g,Xc).replace(/punct/g,Yc).getRegex(),ml=vc(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Yc).getRegex(),hl=vc(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Zc).replace(/punctSpace/g,Xc).replace(/punct/g,Yc).getRegex(),gl=vc(/\\(punct)/,`gu`).replace(/punct/g,Yc).getRegex(),_l=vc(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,Yc).getRegex(),vl=vc(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),yl=vc(Ic).replace(`(?:-->|$)`,`-->`).getRegex(),bl=vc(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,yl).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xl=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Sl=vc(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,xl).getRegex(),Cl=vc(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,Sl).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex(),wl=vc(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Sl).replace(`ref`,Mc).getRegex(),Tl=vc(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Mc).getRegex(),El=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,Dl=vc(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,xl).getRegex(),Ol=vc(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,vc(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Dl).replace(`ref`,El).getRegex()).replace(`nolink`,vc(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,El).getRegex()).getRegex(),kl=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Al=vc(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),jl={_backpedal:gc,anyPunctuation:gl,anyPunctuationOutsideCode:_l,autolink:vl,blockSkip:rl,br:qc,code:Kc,del:gc,delLDelim:gc,delRDelim:gc,emStrongLDelim:al,emStrongRDelimAst:ll,emStrongRDelimUnd:fl,escape:Gc,link:Cl,nolink:Tl,punctuation:Qc,reflink:wl,reflinkSearch:Ol,tag:bl,text:Jc,url:gc},Ml={...jl,emStrongLDelim:sl,emStrongRDelimAst:dl,emStrongRDelimUnd:pl,link:vc(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Sl).getRegex(),reflink:vc(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Sl).getRegex()},Nl={...jl,emStrongRDelimAst:ul,emStrongLDelim:ol,delLDelim:ml,delRDelim:hl,url:vc(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,Al).replace(`protocol`,kl).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:vc(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|wwwStart|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,kl).replace(/emailProtocol/g,/(?:mailto|xmpp):/).replace(`wwwStart`,yc?`(?<![^\\s*_~(])www\\.`:`www\\.`).getRegex()},Pl={...Nl,br:vc(qc).replace(`{2,}`,`*`).getRegex(),text:vc(Nl.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Fl={normal:Vc,gfm:Uc,pedantic:Wc},Il={normal:jl,gfm:Nl,breaks:Pl,pedantic:Ml},Ll={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Rl=e=>Ll[e];function zl(e,t){if(t){if(bc.escapeTest.test(e))return e.replace(bc.escapeReplace,Rl)}else if(bc.escapeTestNoEncode.test(e))return e.replace(bc.escapeReplaceNoEncode,Rl);return e}function Bl(e){return bc.numericCharacterReference.test(e)?e.replace(bc.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&amp;`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&amp;`:String.fromCodePoint(r)}):e}function Vl(e){try{e=encodeURI(e).replace(bc.percentDecode,`%`)}catch{return null}return e}function Hl(e,t){let n=e.replace(bc.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(bc.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(bc.slashPipe,`|`);return n}function Ul(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Wl(e){let t=e.split(`
@@ -335,7 +335,7 @@ series:
335
335
  </body></html>`,Jh=[{name:`Rectangle`,icon:`rectangle`,html:`<div></div>`,w:3,h:1.8,patch:{fill:`accent`}},{name:`Rounded`,icon:`rounded_corner`,html:`<div></div>`,w:3,h:1.8,patch:{fill:`accent`,radius:12}},{name:`Circle`,icon:`circle`,html:`<div></div>`,w:2,h:2,patch:{fill:`accent`,radius:999}},{name:`Line`,icon:`horizontal_rule`,html:`<svg viewBox="0 0 100 10" preserveAspectRatio="none" style="width:100%;height:100%;overflow:visible"><line x1="0" y1="5" x2="100" y2="5" stroke="currentColor" stroke-width="3" vector-effect="non-scaling-stroke"/></svg>`,w:4,h:.3,patch:{color:`text`}},{name:`Arrow`,icon:`arrow_right_alt`,html:`<svg viewBox="0 0 100 20" preserveAspectRatio="none" style="width:100%;height:100%;overflow:visible"><line x1="0" y1="10" x2="92" y2="10" stroke="currentColor" stroke-width="3" vector-effect="non-scaling-stroke"/><polygon points="88,2 100,10 88,18" fill="currentColor"/></svg>`,w:4,h:.5,patch:{color:`accent`}},{name:`Star`,icon:`star`,html:`<svg viewBox="0 0 100 100" style="width:100%;height:100%"><polygon points="50,4 61,38 97,38 68,59 79,94 50,73 21,94 32,59 3,38 39,38" fill="currentColor"/></svg>`,w:1.6,h:1.6,patch:{color:`accent`}}],Yh=[];function Xh({project:e,name:t}){let n={project:e,name:t},r=Mh(e),i=F(`presentations.get`,{name:t,query:r},{interval:4e3}),a=F(`presentations.links`,{name:t,query:r},{interval:3e4}),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(0),[g,_]=(0,v.useState)([]),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(`none`),[T,E]=(0,v.useState)(void 0),[D,O]=(0,v.useState)(``),[k,ee]=(0,v.useState)(!1),[j,M]=(0,v.useState)(null),[N,te]=(0,v.useState)(!1),[R,ne]=(0,v.useState)(null),[re,ie]=(0,v.useState)(`none`),[ae,oe]=(0,v.useState)(null),[se,ce]=(0,v.useState)(!1),[le,ue]=(0,v.useState)(null),[de,V]=(0,v.useState)(0),[fe,pe]=(0,v.useState)(0),[me,he]=(0,v.useState)(()=>{try{return localStorage.getItem(Ih(n))}catch{return null}}),[ge,_e]=(0,v.useState)(``),[ve,ye]=(0,v.useState)(0),be=(0,v.useRef)(null),xe=(0,v.useRef)(void 0),Se=(0,v.useRef)(null),Ce=(0,v.useRef)(null),we=(0,v.useRef)(null),Te=(0,v.useRef)([]),Ee=(0,v.useRef)([]),De=(0,v.useRef)(null);De.current=o;let Oe=(0,v.useRef)(null);(0,v.useEffect)(()=>{i&&!c&&!y&&i.updatedAt!==xe.current&&(xe.current=i.updatedAt,Oe.current=Vh(i),s(Vh(i)),(j===null||C!==`source`)&&M(i.source))},[i,c,C,j,y]);let ke=(0,v.useCallback)(async e=>{d(!0),p(``);let n=await A.request(`presentations.save`,{name:t,query:r,body:{title:e.title,template:e.template,numbers:e.numbers!==!1,slides:e.slides,...xe.current?{base:xe.current}:{}}});if(d(!1),!n.ok&&n.status===409){let n=await A.call(`presentations.get`,{name:t,query:r}).catch(()=>null);if(!n||!Oe.current)return p(`the deck changed elsewhere; reload to see it`);let{draft:i,lost:a}=Zm(Oe.current,e,Vh(n));xe.current=n.updatedAt,Oe.current=Vh(n),De.current=i,s(i),O(a.length?`Changed elsewhere meanwhile: your edit to slide ${a.join(`, `)} gave way to theirs (⌘Z brings it back).`:`Changed elsewhere meanwhile: merged with your edits.`),ke(i)}else{if(!n.ok)return p(P(n));if(Oe.current=e,(n.data.deck.css??``)!==e.css){let i=e.css.trim(),a=n.data.source.replace(/^---\n([\s\S]*?)\n---\n/,(e,t)=>`---\n${t.replace(/^css: [\s\S]*?(?=^\S|$(?![\s\S]))/m,``).replace(/\n+$/,``)}${i?`\ncss: |\n${i.split(`
336
336
  `).map(e=>` ${e}`).join(`
337
337
  `)}`:``}\n---\n`),o=await A.request(`presentations.save`,{name:t,query:r,body:{source:a}});if(!o.ok)return p(P(o));xe.current=o.data.updatedAt,M(o.data.source)}else xe.current=n.data.updatedAt,M(n.data.source);l(!1)}},[t,e]),Ae=(e,t)=>{let n=De.current;if(!n)return;let r=e(n),i=Te.current[Te.current.length-1];t&&i?.mark===t&&Date.now()-i.at<1500?i.at=Date.now():Te.current.push({draft:n,mark:t,at:Date.now()}),Te.current.length>200&&Te.current.shift(),Ee.current=[],De.current=r,s(r),l(!0),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>void ke(r),600)},je=e=>{De.current=e,s(e),l(!0),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>void ke(e),600)},Me=()=>{let e=Te.current.pop();e&&De.current&&(Ee.current.push(De.current),je(e.draft))},Ne=()=>{let e=Ee.current.pop();e&&De.current&&(Te.current.push({draft:De.current,at:Date.now()}),je(e))};(0,v.useEffect)(()=>()=>{be.current&&clearTimeout(be.current)},[]);let Pe=i?.themes??[],Fe=(o&&Pe.find(e=>e.slug===o.template))??i?.theme;oh(Fe?[Fe,...Pe.filter(e=>e.slug!==Fe.slug)]:[],o?.css);let Ie=`${i?.updatedAt??``}-${de}`,Le=(0,v.useMemo)(()=>Fh(n,Ie),[t,e,Ie]),Re=o?.slides??[],ze=Math.min(m,Math.max(0,Re.length-1)),Be=Re[ze],Ve=lh(Be,Fe,Le),He=Re.filter(e=>!Uh(e)).length,Ue=e=>o?.numbers===!1?void 0:{n:Re.slice(0,e+1).filter(e=>!Uh(e)).length,of:He},We=(e,t)=>Ae(t=>({...t,slides:t.slides.map((t,n)=>n===ze?{...t,...e}:t)}),t),Ge=(e,t,n)=>{Be&&Ve&&Fe&&We({content:Mm(Be.content,e,t,ph(Fe,Ve.layout))},n)};(0,v.useEffect)(()=>{let e=e=>{let t=e.target,n=!!t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)),r=e.metaKey||e.ctrlKey;r&&e.key.toLowerCase()===`z`&&!n?(e.preventDefault(),e.shiftKey?Ne():Me()):r&&e.key.toLowerCase()===`y`&&!n?(e.preventDefault(),Ne()):!n&&e.key===`PageDown`?h(e=>Math.min(e+1,Re.length-1)):!n&&e.key===`PageUp`&&h(e=>Math.max(0,e-1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let W=eg(n,ze+1,g.length===1?g[0]:void 0,!!o),Ke=(0,v.useRef)(null),qe=!!i&&!!o;if((0,v.useEffect)(()=>{if(!qe)return;let e=null;try{e=sessionStorage.getItem(zh(n)),e&&sessionStorage.removeItem(zh(n))}catch{}e&&Ke.current?.(Bh(e))},[qe]),!i||!o||!Fe)return(0,z.jsx)(Y,{children:`loading…`});let Je=Object.entries(Fe.layouts),Ye=i.warnings.filter(e=>e.slide===0),Xe=e=>i.warnings.filter(t=>t.slide===e),Ze=e?`/projects/${jh(e)}/presentations`:`/presentations`,Qe=e=>{h(e),_([]),b(null),S(null)},$e=e=>{Ae(t=>({...t,slides:[...t.slides.slice(0,ze+1),{layout:e,extra:{},content:``},...t.slides.slice(ze+1)]})),Qe(ze+1),ie(`none`)},et=e=>{let t=e=>{let t=structuredClone(e.extra??{});return delete t.id,{...e,extra:t}};Ae(n=>({...n,slides:[...n.slides.slice(0,e+1),t(n.slides[e]),...n.slides.slice(e+1)]})),Qe(e+1)},J=e=>{Re.length<=1||(Ae(t=>({...t,slides:t.slides.filter((t,n)=>n!==e)})),Qe(Math.max(0,e<=ze?ze-1:ze)))},tt=e=>Ae(t=>({...t,slides:t.slides.map((t,n)=>{if(n!==e)return t;let r={...t.extra};return r.hidden===!0?delete r.hidden:r.hidden=!0,{...t,extra:r}})})),it=(e,t)=>{e===t||t<0||t>=Re.length||(Ae(n=>{let r=[...n.slides],[i]=r.splice(e,1);return r.splice(t,0,i),{...n,slides:r}}),Qe(t))},at=(e,t)=>{let n=1;for(;t.has(`${e}${n}`);)n++;return t.add(`${e}${n}`),`${e}${n}`},ot=(e,t,n,r,i,a,o={})=>{if(!Be||!Ve)return;let s=at(t,new Set(Ve.slots.map(e=>e.name))),c=gm/160,l=Lm(Fe.size)/160,u={x:ah((c-r)/2),y:ah((l-i)/2),w:r,h:i};We({...fh(Be,{[s]:{kind:e,...u,...e===`markdown`||e===`text`?{size:18}:e===`table`||e===`chart`?{size:13}:e===`html`?{size:15}:{},...o}}),content:Mm(Be.content,s,n,ph(Fe,Ve.layout))}),_([s]),b(a===`edit`?s:null),S(a===`source`?s:null),ie(`none`)},st=async e=>{p(``);let n=await A.request(`presentations.upload`,{name:t,query:r,headers:{"x-file-name":encodeURIComponent(e.name),"content-type":e.type||`application/octet-stream`},body:e}).catch(()=>null);return n?.ok?(V(e=>e+1),n.data.path):(p(n?P(n):`could not upload ${e.name}`),null)},ct=async(e,t)=>{if(!Be||!Ve)return;let n=await st(e);if(!n)return;let r=`![${e.name.replace(/\.[^.]+$/,``)}](${n})`,i=t&&Ve.slots.find(e=>e.name===t)||Ve.slots.find(e=>e.kind===`image`&&!e.md);i?(Ge(i.name,r),_([i.name])):ot(`image`,`image`,r,4,3,`none`)},lt=e=>{if(!Be||!Ve)return;let t=ph(Fe,Ve.layout),n=Be.content,r={};for(let i of e){let e=Ve.slots.find(e=>e.name===i);e&&(n=Mm(n,i,``,t),e.own&&(r[i]=null))}We({...fh(Be,r),content:n}),_([]),x&&e.includes(x)&&S(null)},ut=e=>{Be&&Ve&&(Yh=Ve.slots.filter(t=>e.includes(t.name)).map(e=>{let t=dh(Be)[e.name]??{};return{kind:e.kind,base:e.name.replace(/\d+$/,``)||`box`,md:e.md??``,patch:{...t,kind:e.kind,x:e.x,y:e.y,w:e.w,h:e.h,...e.size?{size:e.size}:{},...e.color?{color:e.color}:{},...e.bold?{bold:!0}:{},...e.italic?{italic:!0}:{},...e.align?{align:e.align}:{},...e.valign?{valign:e.valign}:{},...e.font?{font:e.font}:{},...e.class?{class:e.class}:{}}}}),ye(e=>e+1))},dt=(e=.2)=>{if(!Be||!Ve||!Yh.length)return;let t=new Set(Ve.slots.map(e=>e.name)),n={},r=Be.content,i=[];for(let a of Yh){let o=at(a.base,t);n[o]={...a.patch,x:ah((a.patch.x??0)+e),y:ah((a.patch.y??0)+e)},r=Mm(r,o,a.md,ph(Fe,Ve.layout)),i.push(o)}We({...fh(Be,n),content:r}),_(i)},ft=e=>{ut(e),dt()},pt=(e,t)=>{if(t)return void Z(`In the box "${e}" on slide ${ze+1}: ${t}`);_e(`In the box "${e}" on slide ${ze+1}: `),requestAnimationFrame(()=>we.current?.focus())},mt=i.comments??[],ht=mt.filter(e=>!e.resolved),gt=e=>ht.filter(t=>t.n===e).length,_t={};for(let e of ht)e.n===ze+1&&(_t[e.slot??``]=(_t[e.slot??``]??0)+1);let vt=e=>{S(null),E(e),w(`comments`)},yt=async()=>{let e=`presentation:${t}`;try{await navigator.clipboard.writeText(e),O(`Copied ${e}: paste it into a chat, a task or a note, and it links here.`)}catch{O(e)}ie(`none`)},bt=async e=>{let t=`${location.origin}${location.pathname}#${Nh(n)}${e===`present`?`/present`:``}`;try{await navigator.clipboard.writeText(t),O(`Link copied: ${t}`)}catch{O(t)}ie(`none`)},Z=async r=>{let a=(r??ge).trim();if(!a)return;p(``);let s=e?` --project ${e}`:``,c=me,l=!1;if(!c){let t=e?{kind:`project`,slug:e}:{kind:`general`},r=await A.request(`chats.create`,{body:{agent:`claude`,scope:t}});if(!r.ok)return p(P(r));c=r.data.id,l=!0,he(c);try{localStorage.setItem(Ih(n),c)}catch{}}let u=l?`You are working on the presentation "${o.title}" (presentation:${t}, file ${i.path}/deck.md) beside me; I see every change you save at once. I am on slide ${ze+1}. ${a}\n\nEdit deck.md directly (slots hold markdown or HTML; \`npx kraftwerk presentations show ${t}${s}\` lists the layouts, slots and the theme's pieces), then run \`npx kraftwerk presentations check ${t}${s}\` and look at the PNGs \`npx kraftwerk presentations render ${t} --png${s}\` writes before you answer. Keep your answer short.`:`(slide ${ze+1}) ${a}`,d=await A.request(`chats.message`,{id:c,body:{text:u}});if(!d.ok)return p(P(d));r===void 0&&_e(``),w(`chat`),S(null)};Ke.current=e=>void Z(e);let St=e=>{S(null),w(t=>t===e?`none`:e)},Q=Ve?.slots.find(e=>e.name===x)??null,Tt=`inline-flex h-8 items-center gap-1.5 rounded-control px-2 text-sm text-fg-2 hover:bg-surface-2 hover:text-fg`,Et=`relative flex items-center gap-0.5 rounded-full border border-line bg-surface px-1.5 py-1`,Dt=Q||C!==`none`;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,"aria-label":`presentation toolbar`,children:[(0,z.jsxs)(`div`,{className:Et,children:[(0,z.jsx)(q,{icon:`arrow_back`,label:`all presentations`,size:`sm`,href:Ze}),(0,z.jsx)(`input`,{value:o.title,"aria-label":`presentation title`,className:`h-8 w-[200px] border-0 bg-transparent px-1 text-sm font-semibold text-fg outline-none`,onChange:e=>Ae(t=>({...t,title:e.target.value}),`title`)})]}),(0,z.jsxs)(`div`,{className:Et,children:[(0,z.jsxs)(`button`,{type:`button`,className:Tt,"aria-haspopup":`menu`,"aria-expanded":re===`slide`,onClick:()=>ie(e=>e===`slide`?`none`:`slide`),children:[(0,z.jsx)(B,{name:`add_to_photos`,className:`ms-sm`}),`slide`]}),(0,z.jsxs)(`button`,{type:`button`,className:Tt,title:`a text box on this slide`,onClick:()=>ot(`markdown`,`text`,`Text`,4,.9,`edit`),children:[(0,z.jsx)(B,{name:`title`,className:`ms-sm`}),`text`]}),(0,z.jsxs)(`button`,{type:`button`,className:Tt,title:`a picture on this slide (png, jpg, gif) — or drop one onto the slide`,onClick:()=>{Ce.current=null,Se.current?.click()},children:[(0,z.jsx)(B,{name:`image`,className:`ms-sm`}),`picture`]}),(0,z.jsxs)(`button`,{type:`button`,className:Tt,title:`a chart on this slide`,onClick:()=>ot(`chart`,`chart`,Wh,6,3.2,`source`),children:[(0,z.jsx)(B,{name:`bar_chart`,className:`ms-sm`}),`chart`]}),(0,z.jsxs)(`button`,{type:`button`,className:Tt,title:`a table on this slide`,onClick:()=>ot(`table`,`table`,Gh,6,1.6,`none`),children:[(0,z.jsx)(B,{name:`table`,className:`ms-sm`}),`table`]}),(0,z.jsxs)(`button`,{type:`button`,className:Tt,"aria-haspopup":`menu`,"aria-expanded":re===`shapes`,title:`rectangles, circles, lines, arrows`,onClick:()=>ie(e=>e===`shapes`?`none`:`shapes`),children:[(0,z.jsx)(B,{name:`category`,className:`ms-sm`}),`shapes`]}),(0,z.jsxs)(`button`,{type:`button`,className:Tt,"aria-haspopup":`menu`,"aria-expanded":re===`insert`,title:`HTML, embeds and the theme's pieces`,onClick:()=>ie(e=>e===`insert`?`none`:`insert`),children:[(0,z.jsx)(B,{name:`widgets`,className:`ms-sm`}),`more`]}),re===`slide`&&(0,z.jsx)(_h,{label:`new slide`,onClose:()=>ie(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[520px]`,children:(0,z.jsx)(`div`,{className:`grid grid-cols-3 gap-2 p-1`,children:Je.map(([e,t])=>(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`flex flex-col items-start gap-1 rounded-md p-1 text-left hover:bg-surface-2`,title:t.description,onClick:()=>$e(e),children:[(0,z.jsx)(uh,{slide:{layout:e,extra:{},content:``},theme:Fe,asset:Le,width:152}),(0,z.jsx)(`span`,{className:`text-xs text-fg`,children:e})]},e))})}),re===`shapes`&&(0,z.jsx)(_h,{label:`shapes`,onClose:()=>ie(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[240px]`,children:Jh.map(e=>(0,z.jsx)(vh,{icon:e.icon,title:e.name,onClick:()=>ot(`html`,e.name.toLowerCase(),e.html,e.w,e.h,`none`,e.patch)},e.name))}),re===`insert`&&(0,z.jsxs)(_h,{label:`insert`,onClose:()=>ie(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[340px]`,children:[(0,z.jsx)(vh,{icon:`code`,title:`HTML`,sub:`any markup; the theme's classes apply`,onClick:()=>ot(`html`,`html`,Kh,6,1.2,`source`)}),(0,z.jsx)(vh,{icon:`public`,title:`Embed`,sub:`a web page by URL, or a page of your own with scripts`,onClick:()=>ot(`embed`,`embed`,qh,4,2.4,`source`)}),Fe.snippets.length>0&&(0,z.jsx)(`div`,{className:`mt-1 border-t border-line px-2 pb-1 pt-2 text-[11px] uppercase tracking-wider text-fg-2`,children:`from the theme`}),Fe.snippets.map(e=>(0,z.jsx)(vh,{icon:`dashboard_customize`,title:e.name,sub:e.description,onClick:()=>ot(e.kind===`markdown`?`markdown`:`html`,e.name.toLowerCase().replace(/[^a-z0-9]+/g,``)||`piece`,e.content,Math.min(e.w,10),e.h,`none`)},e.name))]}),(0,z.jsx)(`input`,{ref:Se,type:`file`,accept:`image/png,image/jpeg,image/gif`,"aria-label":`picture file`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&ct(t,Ce.current)}})]}),Be&&!se&&(0,z.jsxs)(`div`,{className:Et,children:[(0,z.jsx)(`span`,{className:`pl-1.5 text-xs text-fg-2`,children:`layout`}),(0,z.jsx)(`select`,{value:Ve?.layout??Be.layout??``,"aria-label":`layout`,className:`h-8 cursor-pointer border-0 bg-transparent pr-1 text-sm text-fg outline-none`,onChange:e=>We({layout:e.target.value}),children:Je.map(([e,t])=>(0,z.jsx)(`option`,{value:e,title:t.description,children:e},e))})]}),(0,z.jsxs)(`div`,{className:Et,children:[(0,z.jsx)(`button`,{type:`button`,className:Tt,disabled:!Te.current.length,title:`undo (⌘Z)`,"aria-label":`undo`,onClick:Me,children:(0,z.jsx)(B,{name:`undo`,className:`ms-sm`})}),(0,z.jsx)(`button`,{type:`button`,className:Tt,disabled:!Ee.current.length,title:`redo (⇧⌘Z)`,"aria-label":`redo`,onClick:Ne,children:(0,z.jsx)(B,{name:`redo`,className:`ms-sm`})}),(0,z.jsxs)(`button`,{type:`button`,className:Tt,"aria-haspopup":`menu`,"aria-expanded":re===`zoom`,"aria-label":`zoom`,title:`zoom`,onClick:()=>ie(e=>e===`zoom`?`none`:`zoom`),children:[le?`${Math.round(le*100)}%`:`fit`,(0,z.jsx)(B,{name:`expand_more`,className:`ms-sm`})]}),(0,z.jsx)(`button`,{type:`button`,className:I(Tt,se&&`bg-surface-2 text-fg`),"aria-pressed":se,"aria-label":`grid view`,title:`all slides at once`,onClick:()=>ce(e=>!e),children:(0,z.jsx)(B,{name:`grid_view`,className:`ms-sm`})}),re===`zoom`&&(0,z.jsx)(_h,{label:`zoom`,onClose:()=>ie(`none`),className:`absolute right-0 top-[calc(100%+6px)] w-[140px]`,children:[null,.5,.75,1,1.5].map(e=>(0,z.jsx)(vh,{title:e?`${e*100}%`:`fit`,onClick:()=>{ue(e),ie(`none`)}},String(e)))})]}),(0,z.jsx)(`span`,{className:`flex-1`}),W.length>0&&(0,z.jsx)(`div`,{className:`flex items-center -space-x-1.5`,role:`group`,"aria-label":`also here`,children:W.map(e=>(0,z.jsx)(`button`,{type:`button`,title:`${e.who} · slide ${e.slide}${e.slot?` · ${e.slot}`:``}`,"aria-label":`${e.who} on slide ${e.slide}`,className:`grid h-7 w-7 place-items-center rounded-full border-2 border-bg text-[11px] font-semibold uppercase text-white`,style:{background:e.color},onClick:()=>Qe(e.slide-1),children:e.who.replace(/[^a-z0-9]/gi,``).slice(0,2)||`?`},e.client))}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,"aria-live":`polite`,children:u?`saving…`:c?`unsaved`:i.updatedAt?`saved ${G(i.updatedAt)}`:``}),(0,z.jsxs)(`div`,{className:Et,children:[(0,z.jsxs)(`button`,{type:`button`,className:I(Tt,C===`format`&&`bg-surface-2 text-fg`),"aria-pressed":C===`format`,onClick:()=>St(`format`),children:[(0,z.jsx)(B,{name:`tune`,className:`ms-sm`}),`format`]}),(0,z.jsxs)(`button`,{type:`button`,className:I(Tt,C===`design`&&`bg-surface-2 text-fg`),"aria-pressed":C===`design`,onClick:()=>St(`design`),children:[(0,z.jsx)(B,{name:`palette`,className:`ms-sm`}),`design`]}),(0,z.jsxs)(`button`,{type:`button`,className:I(Tt,C===`chat`&&`bg-surface-2 text-fg`),"aria-pressed":C===`chat`,onClick:()=>St(`chat`),children:[(0,z.jsx)(B,{name:`forum`,className:`ms-sm`}),`chat`]}),(0,z.jsxs)(`button`,{type:`button`,className:I(Tt,C===`comments`&&`bg-surface-2 text-fg`),"aria-pressed":C===`comments`,"aria-label":`comments`,onClick:()=>C===`comments`?w(`none`):vt(g.length===1?g[0]:void 0),children:[(0,z.jsx)(B,{name:`comment`,className:`ms-sm`}),ht.length>0&&(0,z.jsx)(`span`,{className:`rounded-full bg-[#f59e0b] px-1.5 text-[11px] font-semibold text-black`,children:ht.length})]}),(0,z.jsx)(`button`,{type:`button`,className:I(Tt,C===`history`&&`bg-surface-2 text-fg`),"aria-pressed":C===`history`,"aria-label":`version history`,title:`version history`,onClick:()=>St(`history`),children:(0,z.jsx)(B,{name:`history`,className:`ms-sm`})}),(0,z.jsx)(`button`,{type:`button`,className:Tt,"aria-haspopup":`menu`,"aria-expanded":re===`share`,"aria-label":`share`,onClick:()=>ie(e=>e===`share`?`none`:`share`),children:(0,z.jsx)(B,{name:`share`,className:`ms-sm`})}),re===`share`&&(0,z.jsxs)(_h,{label:`share`,onClose:()=>ie(`none`),className:`absolute right-0 top-[calc(100%+6px)] w-[280px]`,children:[(0,z.jsx)(vh,{icon:`link`,title:`Copy link to the editor`,sub:`for anyone with this workspace (paired devices, members)`,onClick:()=>void bt(`edit`)}),(0,z.jsx)(vh,{icon:`slideshow`,title:`Copy link to present mode`,onClick:()=>void bt(`present`)}),(0,z.jsx)(vh,{icon:`html`,title:`Download as one HTML file`,sub:`opens anywhere, no kraftwerk needed`,onClick:()=>(ie(`none`),window.location.href=Ph(n,`html`))}),(0,z.jsx)(vh,{icon:`alternate_email`,title:`Copy reference`,sub:`presentation:${t} — paste into a chat, a task or a note`,onClick:()=>void yt()}),(0,z.jsx)(yh,{}),(0,z.jsx)(`div`,{className:`px-2 pb-1 pt-0.5 text-[11px] font-semibold uppercase tracking-wide text-fg-2`,children:`linked from tasks`}),a?.tasks.length?a.tasks.map(e=>(0,z.jsx)(vh,{icon:`task_alt`,title:`${e.number} ${e.title}`,sub:`${e.project?`${e.project} · `:``}${e.board} · ${e.status}${e.assignee?` · ${e.assignee}`:``}`,onClick:()=>(ie(`none`),H(e.href))},e.ref)):(0,z.jsx)(`div`,{className:`px-2 pb-1.5 text-xs text-fg-2`,children:`none yet — link the deck from a task's links`})]})]}),(0,z.jsxs)(`div`,{className:Et,children:[(0,z.jsxs)(U,{href:`${Nh(n)}/present`,className:I(Tt,`font-semibold text-fg no-underline`),"aria-label":`present`,children:[(0,z.jsx)(B,{name:`play_arrow`,className:`ms-sm`}),`present`]}),(0,z.jsx)(`button`,{type:`button`,className:I(Tt,`px-1`),"aria-haspopup":`menu`,"aria-expanded":re===`present`,"aria-label":`present options`,onClick:()=>ie(e=>e===`present`?`none`:`present`),children:(0,z.jsx)(B,{name:`expand_more`,className:`ms-sm`})}),(0,z.jsxs)(`a`,{className:I(Tt,`no-underline`),href:Ph(n,`pptx`),download:!0,title:`download as PowerPoint`,"aria-label":`pptx`,children:[(0,z.jsx)(B,{name:`download`,className:`ms-sm`}),`pptx`]}),(0,z.jsx)(`a`,{className:I(Tt,`no-underline`),href:Ph(n,`pdf`),download:!0,title:`download as PDF`,"aria-label":`pdf`,children:(0,z.jsx)(B,{name:`picture_as_pdf`,className:`ms-sm`})}),(0,z.jsx)(`a`,{className:I(Tt,`no-underline`),href:Ph(n,`html`),download:!0,title:`download as one HTML file`,"aria-label":`html`,children:(0,z.jsx)(B,{name:`html`,className:`ms-sm`})}),re===`present`&&(0,z.jsxs)(_h,{label:`present`,onClose:()=>ie(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[230px]`,children:[(0,z.jsx)(vh,{icon:`play_arrow`,title:`From the start`,onClick:()=>H(`${Nh(n)}/present`)}),(0,z.jsx)(vh,{icon:`slideshow`,title:`From slide ${ze+1}`,onClick:()=>H(`${Nh(n)}/present/${ze+1}`)}),(0,z.jsx)(vh,{icon:`co_present`,title:`With notes (presenter view)`,sub:`current and next slide, notes, a clock`,onClick:()=>H(`${Nh(n)}/presenter/${ze+1}`)})]})]}),(0,z.jsxs)(`div`,{className:Et,children:[(0,z.jsxs)(`button`,{type:`button`,className:I(Tt,C===`markdown`&&`bg-surface-2 text-fg`),"aria-pressed":C===`markdown`,title:`this slide's markdown`,onClick:()=>St(`markdown`),children:[(0,z.jsx)(B,{name:`notes`,className:`ms-sm`}),(0,z.jsx)(`span`,{className:`sr-only`,children:`markdown`})]}),(0,z.jsxs)(`button`,{type:`button`,className:I(Tt,C===`source`&&`bg-surface-2 text-fg`),"aria-pressed":C===`source`,title:`the whole deck.md`,onClick:()=>St(`source`),children:[(0,z.jsx)(B,{name:`code`,className:`ms-sm`}),(0,z.jsx)(`span`,{className:`sr-only`,children:`source`})]}),N?(0,z.jsxs)(`span`,{className:`flex items-center gap-1 pl-1`,children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,onClick:()=>void kt(),children:`move to trash`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>te(!1),children:`keep`})]}):(0,z.jsx)(q,{icon:`delete`,label:`remove presentation`,size:`sm`,onClick:()=>te(!0)})]})]}),f&&(0,z.jsx)(rt,{tone:`bad`,children:f}),D&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-1.5 text-sm`,role:`status`,children:[(0,z.jsx)(B,{name:`info`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:D}),(0,z.jsx)(q,{icon:`close`,label:`dismiss`,size:`sm`,onClick:()=>O(``)})]}),Ye.length>0&&(0,z.jsx)(rg,{items:Ye}),C===`source`?(0,z.jsx)(X,{title:`deck.md`,children:(0,z.jsxs)(Ct,{children:[(0,z.jsx)(xt,{value:j??``,"aria-label":`deck source`,spellCheck:!1,className:`min-h-[60vh] font-mono text-[13px] leading-5`,onChange:e=>{M(e.target.value),l(!0)}}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(K,{variant:`primary`,icon:`save`,busy:u,disabled:!c||u,onClick:()=>void Ot(),children:`save deck.md`}),(0,z.jsxs)(nt,{children:[(0,z.jsxs)(`code`,{children:[i.path,`/deck.md`]}),` — slides are separated by `,(0,z.jsx)(`code`,{children:`---`}),` lines; a YAML block right after one sets `,(0,z.jsx)(`code`,{children:`layout:`}),` and `,(0,z.jsx)(`code`,{children:`slots:`}),`; `,(0,z.jsx)(`code`,{children:`::slot::`}),` marks a slot, `,(0,z.jsx)(`code`,{children:`::notes::`}),` the speaker notes.`]})]})]})}):(0,z.jsxs)(`div`,{className:I(`grid items-start gap-4`,Dt?`grid-cols-[172px_minmax(0,1fr)_minmax(300px,380px)]`:`grid-cols-[172px_minmax(0,1fr)]`),children:[(0,z.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center px-1 text-xs text-fg-2`,children:[(0,z.jsxs)(`span`,{children:[Re.length,` `,Re.length===1?`slide`:`slides`]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(q,{icon:`add`,label:`add slide`,size:`sm`,onClick:()=>$e(Ve?.layout&&Ve.layout!==`title`?Ve.layout:Fe.default??`content`)})]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,role:`list`,"aria-label":`slides`,children:Re.map((e,t)=>(0,z.jsxs)(`div`,{role:`listitem`,"aria-current":t===ze,draggable:!0,className:I(`group relative flex items-start gap-1.5`,R===t&&`opacity-40`),onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,ne(t)},onDragOver:e=>{R!==null&&e.preventDefault()},onDrop:e=>{e.preventDefault(),R!==null&&it(R,t),ne(null)},onDragEnd:()=>ne(null),onContextMenu:e=>{e.preventDefault(),Qe(t),oe({i:t,x:e.clientX,y:e.clientY})},children:[(0,z.jsx)(`span`,{className:I(`w-4 pt-1 text-right text-[11px]`,t===ze?`font-semibold text-fg`:`text-fg-2`),children:t+1}),(0,z.jsx)(`button`,{type:`button`,"aria-label":`slide ${t+1}${Uh(e)?` (hidden)`:``}`,className:I(`min-w-0 flex-1 overflow-hidden rounded-md border-2`,t===ze?`border-accent`:`border-transparent hover:border-line-strong`,Uh(e)&&`opacity-45`),title:Hh(e),onClick:()=>Qe(t),onKeyDown:e=>{e.key===`Backspace`||e.key===`Delete`?(e.preventDefault(),J(t)):e.key===`ArrowDown`&&e.altKey?it(t,t+1):e.key===`ArrowUp`&&e.altKey&&it(t,t-1)},children:(0,z.jsx)(uh,{slide:e,theme:Fe,asset:Le,width:136,number:Ue(t)})}),W.some(e=>e.slide===t+1)&&(0,z.jsx)(`span`,{className:`pointer-events-none absolute left-6 top-1 flex gap-0.5`,"aria-label":`${W.filter(e=>e.slide===t+1).map(e=>e.who).join(`, `)} here`,children:W.filter(e=>e.slide===t+1).map(e=>(0,z.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full border border-white`,style:{background:e.color}},e.client))}),gt(t+1)>0&&(0,z.jsx)(`span`,{className:`pointer-events-none absolute right-1 bottom-1 rounded-full bg-[#f59e0b] px-1.5 text-[10px] font-semibold text-black`,"aria-label":`${gt(t+1)} open comments`,children:gt(t+1)}),Uh(e)&&(0,z.jsx)(B,{name:`visibility_off`,className:`ms-sm pointer-events-none absolute left-[calc(50%+4px)] top-[calc(50%-10px)] text-fg-2`}),Xe(t+1).length>0&&(0,z.jsx)(B,{name:Xe(t+1).some(e=>e.level===`error`)?`error`:`warning`,className:I(`ms-sm absolute left-6 top-1`,Xe(t+1).some(e=>e.level===`error`)?`text-bad`:`text-ask`)}),(0,z.jsxs)(`span`,{className:`absolute right-1 top-1 hidden gap-0.5 rounded-md bg-surface/90 group-hover:flex`,children:[(0,z.jsx)(q,{icon:`content_copy`,label:`duplicate slide ${t+1}`,size:`sm`,onClick:()=>et(t)}),(0,z.jsx)(q,{icon:`delete`,label:`remove slide ${t+1}`,size:`sm`,disabled:Re.length<=1,onClick:()=>J(t)})]})]},t))})]}),ae&&(0,z.jsxs)(_h,{label:`slide actions`,onClose:()=>oe(null),className:`fixed w-[220px]`,style:{left:ae.x,top:ae.y},children:[(0,z.jsx)(vh,{icon:`library_add`,title:`Duplicate`,onClick:()=>(et(ae.i),oe(null))}),(0,z.jsx)(vh,{icon:Uh(Re[ae.i])?`visibility`:`visibility_off`,title:Uh(Re[ae.i])?`Show`:`Hide`,sub:`hidden slides stay out of present mode and the exports`,onClick:()=>(tt(ae.i),oe(null))}),(0,z.jsx)(vh,{icon:`arrow_upward`,title:`Move up`,keys:`⌥↑`,disabled:ae.i===0,onClick:()=>(it(ae.i,ae.i-1),oe(null))}),(0,z.jsx)(vh,{icon:`arrow_downward`,title:`Move down`,keys:`⌥↓`,disabled:ae.i>=Re.length-1,onClick:()=>(it(ae.i,ae.i+1),oe(null))}),(0,z.jsx)(yh,{}),(0,z.jsx)(vh,{icon:`delete`,title:`Delete`,keys:`⌫`,danger:!0,disabled:Re.length<=1,onClick:()=>(J(ae.i),oe(null))})]}),se?(0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4`,role:`list`,"aria-label":`all slides`,children:Re.map((e,t)=>(0,z.jsxs)(`button`,{type:`button`,role:`listitem`,className:I(`flex flex-col gap-1 rounded-md p-1 text-left hover:bg-surface-2`,t===ze&&`ring-2 ring-accent`,Uh(e)&&`opacity-45`),onClick:()=>{Qe(t),ce(!1)},children:[(0,z.jsx)(uh,{slide:e,theme:Fe,asset:Le,width:280,number:Ue(t)}),(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[t+1,` · `,Hh(e)||e.layout,Uh(e)?` · hidden`:``]})]},t))}):Be&&Ve&&(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,z.jsx)(bh,{view:Ve,theme:Fe,slide:Be,number:Ue(ze),zoom:le,selected:g,editing:y,onSelect:e=>{_(e),x&&!e.includes(x)&&S(null)},onEditing:b,onSource:e=>{Ve.slots.find(t=>t.name===e)?.kind===`image`?(Ce.current=e,Se.current?.click()):S(e)},onPatches:(e,t)=>We(fh(Be,e),t),onText:(e,t)=>Ge(e,t),onRemove:lt,onDuplicate:ft,onCopy:ut,onPaste:()=>dt(),canPaste:ve>=0&&Yh.length>0,onAsk:pt,onFormat:()=>{S(null),w(`format`)},onDropFile:e=>void ct(e),onWidth:pe,pins:_t,others:W.filter(e=>e.slide===ze+1&&e.slot).map(e=>({slot:e.slot,who:e.who,color:e.color})),onComments:vt}),(0,z.jsxs)(`div`,{className:`flex w-full items-start gap-3`,style:{maxWidth:fe||void 0},children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:Xe(ze+1).length>0?(0,z.jsx)(rg,{items:Xe(ze+1)}):(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`no warnings on this slide · double click a box to edit it · ⇧ or a frame for several · right click for more`})}),(0,z.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-fg-2 hover:text-fg`,"aria-expanded":k,onClick:()=>ee(e=>!e),children:[(0,z.jsx)(B,{name:k?`expand_less`:`expand_more`,className:`ms-sm`}),`speaker notes`,Be.notes?.trim()?` ·`:``]})]}),(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,style:{maxWidth:fe||void 0},children:[k&&(0,z.jsx)(xt,{value:Be.notes??``,"aria-label":`speaker notes`,rows:3,placeholder:`what you say on this slide`,onChange:e=>We({notes:e.target.value},`notes`)}),(0,z.jsxs)(`form`,{className:`mt-1 flex items-center gap-2 rounded-2xl border border-line bg-surface px-3 py-1.5`,onSubmit:e=>{e.preventDefault(),Z()},children:[(0,z.jsx)(B,{name:`auto_awesome`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`input`,{ref:we,value:ge,"aria-label":`ask an agent`,placeholder:`ask an agent to change slide ${ze+1} or the deck…`,className:`h-8 min-w-0 flex-1 border-0 bg-transparent text-sm text-fg outline-none placeholder:text-fg-2`,onChange:e=>_e(e.target.value)}),(0,z.jsx)(q,{icon:`arrow_upward`,label:`send to an agent`,size:`sm`,disabled:!ge.trim(),onClick:()=>void Z()})]})]})]}),Q&&Be?(0,z.jsx)(Ah,{s:Q,onChange:e=>Ge(Q.name,e,`src:${Q.name}`),onClose:()=>S(null)},`${ze}:${Q.name}`):C===`format`&&Be&&Ve?(0,z.jsx)(Oh,{theme:Fe,slide:Be,view:Ve,selected:g,assets:i.assets,onPatches:(e,t)=>We(fh(Be,e),t),onSlide:e=>We(e),numbers:o.numbers!==!1,onNumbers:e=>Ae(t=>({...t,numbers:e})),onUpload:st,onClose:()=>w(`none`)}):C===`design`?(0,z.jsx)(Zh,{themes:Pe,current:o.template,css:o.css,slide:Be,asset:Le,onTemplate:e=>Ae(t=>({...t,template:e})),onCss:e=>Ae(t=>({...t,css:e}),`css`)}):C===`history`?(0,z.jsx)(tg,{at:n,theme:Fe,asset:Le,onRestore:e=>{Ae(t=>({...t,title:e.deck.title||t.title,template:e.deck.template||t.template,css:e.deck.css??``,numbers:e.deck.numbers!==!1,slides:e.deck.slides.map(e=>({...e,extra:{...e.extra}}))})),h(0),O(`Restored the version from ${new Date(e.at).toLocaleString()}. ⌘Z takes it back; the version before it is in the history too.`)},onClose:()=>w(`none`)}):C===`comments`?(0,z.jsx)(ng,{at:n,comments:mt,slide:ze+1,slot:T,onSlot:E,onGo:(e,t)=>(Qe(e-1),t&&_([t])),onClose:()=>w(`none`)}):C===`chat`?(0,z.jsxs)(`div`,{className:`sticky top-3 flex h-[calc(100vh-130px)] flex-col overflow-hidden rounded-xl border border-line bg-surface`,role:`region`,"aria-label":`agent chat`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2 text-sm`,children:[(0,z.jsx)(B,{name:`forum`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`font-semibold`,children:`Agent`}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`edits deck.md; the slide follows`}),(0,z.jsx)(`span`,{className:`flex-1`}),me&&(0,z.jsx)(q,{icon:`add_comment`,label:`new chat`,size:`sm`,onClick:()=>{he(null);try{localStorage.removeItem(Ih(n))}catch{}}}),(0,z.jsx)(q,{icon:`close`,label:`close chat`,size:`sm`,onClick:()=>w(`none`)})]}),me?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,z.jsx)(Ko,{id:me},me)}):(0,z.jsx)(Y,{icon:`auto_awesome`,children:`Ask below the slide: “make slide 3 a comparison”, “add a chart of these numbers”, “tighten every title”. The agent edits the deck and you watch it change.`})]}):C===`markdown`&&Be?(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-1 text-xs text-fg-2`,children:[`slots:`,Ve?.slots.map(e=>(0,z.jsx)(`code`,{className:`rounded bg-surface-2 px-1`,title:`${e.kind}${e.required?`, required`:``}`,children:e.name===`title`?`# title`:`::${e.name}::`},e.name))]}),(0,z.jsx)(xt,{value:Be.content,"aria-label":`slide content`,spellCheck:!1,className:`min-h-[380px] font-mono text-[13px] leading-5`,onChange:e=>We({content:e.target.value},`md`)}),i.assets.length>0&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`pictures: `,i.assets.join(`, `)]})]}):null]})]});async function Ot(){if(j===null)return;d(!0),p(``);let e=await A.request(`presentations.save`,{name:t,query:r,body:{source:j}});if(d(!1),!e.ok)return p(P(e));xe.current=e.data.updatedAt,Te.current.push({draft:De.current,at:Date.now()}),s(Vh(e.data)),M(e.data.source),l(!1)}async function kt(){let e=await A.request(`presentations.delete`,{name:t,query:r});if(!e.ok)return p(P(e));H(Ze,{replace:!0})}}function Zh({themes:e,current:t,css:n,slide:r,asset:i,onTemplate:a,onCss:o}){let[s,c]=(0,v.useState)(n);return(0,z.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-3 overflow-auto rounded-xl border border-line bg-surface p-3`,role:`region`,"aria-label":`design`,children:[(0,z.jsx)(`div`,{className:`text-sm font-semibold`,children:`Theme`}),(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:e.map(e=>(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":e.slug===t,"aria-label":`theme ${e.name}`,className:I(`flex flex-col gap-1 rounded-md border-2 p-1 text-left`,e.slug===t?`border-accent`:`border-transparent hover:border-line-strong`),onClick:()=>a(e.slug),children:[r&&(0,z.jsx)(uh,{slide:r,theme:e,asset:i,width:150}),(0,z.jsx)(`span`,{className:`text-xs text-fg`,children:e.name})]},e.slug))}),(0,z.jsxs)(nt,{children:[`A theme is a folder: `,(0,z.jsx)(`code`,{children:`templates/<name>/template.yml`}),` (layouts, colors, fonts, pieces) and `,(0,z.jsx)(`code`,{children:`theme.css`}),` with its fonts and pictures beside it. `,(0,z.jsx)(`code`,{children:`kraftwerk presentations templates init <name>`}),` starts one from the default; agents can write them too.`]}),(0,z.jsx)(`div`,{className:`text-sm font-semibold`,children:`This deck's CSS`}),(0,z.jsx)(`textarea`,{value:s,"aria-label":`deck css`,spellCheck:!1,placeholder:`.layout-title { background: linear-gradient(135deg, #0284c7, #312e81); }
338
- .slot-title { letter-spacing: -0.03em; }`,className:`min-h-[180px] resize-y rounded-md border border-line bg-bg p-2 font-mono text-[12px] leading-5 text-fg outline-none focus:border-accent`,onChange:e=>{c(e.target.value),o(e.target.value)}}),(0,z.jsxs)(nt,{children:[`Over the theme, for this deck only: `,(0,z.jsx)(`code`,{children:`.layout-<name>`}),` a layout, `,(0,z.jsx)(`code`,{children:`.slot-<name>`}),` a box, `,(0,z.jsx)(`code`,{children:`--c-accent`}),` and the other colors as variables, `,(0,z.jsx)(`code`,{children:`attr(data-nn)`}),` the slide number.`]})]})}var Qh=[`#e11d48`,`#7c3aed`,`#059669`,`#d97706`,`#0891b2`,`#db2777`,`#4f46e5`,`#65a30d`],$h=e=>Qh[[...e].reduce((e,t)=>e*31+t.charCodeAt(0)>>>0,7)%Qh.length];function eg(e,t,n,r){let i=(0,v.useMemo)(()=>`t${Math.random().toString(36).slice(2,10)}`,[]),[a,o]=(0,v.useState)([]),s=Mh(e.project),c=e.project?`${e.project}/${e.name}`:e.name;return(0,v.useEffect)(()=>N.subscribe(`deck.${c}@${i}`,{},e=>o(e.viewers??[])),[c,i]),(0,v.useEffect)(()=>{if(!r)return;let a=()=>void A.request(`presentations.presence`,{name:e.name,query:s,body:{client:i,slide:t,...n?{slot:n}:{}}}).catch(()=>{});a();let o=setInterval(a,8e3);return()=>clearInterval(o)},[c,i,t,n,r]),(0,v.useEffect)(()=>{let t=()=>void A.request(`presentations.presence`,{name:e.name,query:s,body:{client:i,slide:1,leave:!0}}).catch(()=>{});return window.addEventListener(`pagehide`,t),()=>{window.removeEventListener(`pagehide`,t),t()}},[c,i]),a.filter(e=>e.client!==i).map(e=>({...e,color:$h(e.client)}))}function tg({at:e,theme:t,asset:n,onRestore:r,onClose:i}){let a=Mh(e.project),o=F(`presentations.history`,{name:e.name,query:a},{interval:8e3}),[s,c]=(0,v.useState)(null),l=F(`presentations.version`,s?{name:e.name,id:s,query:a}:null,{interval:6e5}),u=l&&l.id===s?l:null;return(0,z.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-3 text-sm`,role:`region`,"aria-label":`version history`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(B,{name:`history`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`font-semibold`,children:`Version history`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(q,{icon:`close`,label:`close history`,size:`sm`,onClick:i})]}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`Kept before saves (once a minute while you edit) and whenever an agent or a tool changes deck.md. The newest 50 stay.`}),o&&o.versions.length===0&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`No earlier versions yet.`}),(0,z.jsx)(`ul`,{className:`flex flex-col gap-1`,"aria-label":`versions`,children:(o?.versions??[]).map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsxs)(`button`,{type:`button`,"aria-current":s===e.id,className:I(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-surface-2`,s===e.id&&`bg-surface-2`),onClick:()=>c(s===e.id?null:e.id),children:[(0,z.jsxs)(`span`,{className:`flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-fg`,children:new Date(e.at).toLocaleString()}),(0,z.jsxs)(`span`,{className:`block text-xs text-fg-2`,children:[G(e.at),` · `,e.title,` · `,e.slides,` slide`,e.slides===1?``:`s`]})]}),(0,z.jsx)(B,{name:s===e.id?`expand_less`:`expand_more`,className:`ms-sm text-fg-2`})]}),s===e.id&&u&&(0,z.jsxs)(`div`,{className:`mt-1 flex flex-col gap-2 rounded-md border border-line p-2`,children:[(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,"aria-label":`slides of this version`,children:u.deck.slides.map((e,r)=>(0,z.jsx)(`div`,{className:`overflow-hidden rounded border border-line`,children:(0,z.jsx)(uh,{slide:e,theme:t,asset:n,width:128,number:u.deck.numbers===!1?void 0:{n:r+1,of:u.deck.slides.length}})},r))}),(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`restore`,onClick:()=>r(u),children:`restore this version`})]})]},e.id))})]})}function ng({at:e,comments:t,slide:n,slot:r,onSlot:i,onGo:a,onClose:o}){let s=Mh(e.project),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(``),g=async()=>{if(!c.trim())return;let t=await A.request(`presentations.comment`,{name:e.name,query:s,body:{slide:n,text:c,...r?{slot:r}:{}}});if(!t.ok)return h(P(t));l(``),h(``)},_=async(t,n)=>{let r=await A.request(`presentations.commentSave`,{name:e.name,id:t,query:s,body:n});if(!r.ok)return h(P(r));p(e=>({...e,[t]:``}))},y=async t=>{let n=await A.request(`presentations.commentDelete`,{name:e.name,id:t,query:s});n.ok||h(P(n))},b=t.filter(e=>u||!e.resolved).sort((e,t)=>(e.n===n?-1:0)-(t.n===n?-1:0)||(e.n??999)-(t.n??999)||e.at.localeCompare(t.at));return(0,z.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-3 text-sm`,role:`region`,"aria-label":`comments`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(B,{name:`comment`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`font-semibold`,children:`Comments`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-fg-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),"aria-label":`show resolved`}),`resolved`]}),(0,z.jsx)(q,{icon:`close`,label:`close comments`,size:`sm`,onClick:o})]}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-1.5 rounded-lg border border-line bg-bg p-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`on slide `,n,r?(0,z.jsxs)(z.Fragment,{children:[` `,`· box `,(0,z.jsx)(`b`,{children:r}),` `,(0,z.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>i(void 0),children:`(the whole slide)`})]}):` (select a box to comment on it)`]}),(0,z.jsx)(`textarea`,{value:c,"aria-label":`new comment`,rows:2,placeholder:`What should change here?`,className:`resize-y rounded-md border border-line bg-surface p-1.5 text-sm text-fg outline-none focus:border-accent`,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),void g())}),(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(K,{size:`sm`,variant:`primary`,type:`submit`,disabled:!c.trim(),children:`comment`})})]}),m&&(0,z.jsx)(`span`,{className:`text-xs text-bad`,children:m}),b.length===0&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`No `,u?``:`open `,"comments. Agents see them too: `kraftwerk presentations comments`."]}),(0,z.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`comment list`,children:b.map(e=>(0,z.jsxs)(`li`,{className:I(`flex flex-col gap-1 rounded-lg border p-2`,e.n===n?`border-accent/50`:`border-line`,e.resolved&&`opacity-60`),"aria-label":`comment by ${e.author}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-2`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`font-semibold text-fg hover:text-accent`,onClick:()=>e.n&&a(e.n,e.slot),children:[`slide `,e.n??`?`,e.slot?` · ${e.slot}`:``]}),(0,z.jsxs)(`span`,{children:[`· `,e.author]}),(0,z.jsxs)(`span`,{children:[`· `,G(e.at)]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(q,{icon:e.resolved?`replay`:`check_circle`,label:e.resolved?`reopen`:`resolve`,size:`sm`,onClick:()=>void _(e.id,{resolved:!e.resolved})}),(0,z.jsx)(q,{icon:`delete`,label:`delete comment`,size:`sm`,onClick:()=>void y(e.id)})]}),(0,z.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.text}),e.replies.map((e,t)=>(0,z.jsxs)(`p`,{className:`ml-3 border-l-2 border-line pl-2 text-xs`,children:[(0,z.jsx)(`b`,{children:e.author}),` · `,G(e.at),(0,z.jsx)(`br`,{}),e.text]},t)),!e.resolved&&(0,z.jsx)(`form`,{className:`flex gap-1`,onSubmit:t=>{t.preventDefault(),f[e.id]?.trim()&&_(e.id,{reply:f[e.id]})},children:(0,z.jsx)(`input`,{value:f[e.id]??``,"aria-label":`reply to ${e.id}`,placeholder:`reply…`,className:`h-7 min-w-0 flex-1 rounded-md border border-line bg-bg px-1.5 text-xs text-fg outline-none focus:border-accent`,onChange:t=>p(n=>({...n,[e.id]:t.target.value}))})})]},e.id))})]})}function rg({items:e}){return(0,z.jsx)(`ul`,{className:`flex flex-col gap-1 text-xs`,"aria-label":`warnings`,children:e.map((e,t)=>(0,z.jsxs)(`li`,{className:I(`flex items-start gap-1.5`,e.level===`error`?`text-bad`:`text-fg-2`),children:[(0,z.jsx)(B,{name:e.level===`error`?`error`:`warning`,className:`ms-sm mt-px`}),(0,z.jsxs)(`span`,{children:[e.slide?`slide ${e.slide}`:`deck`,e.slot?` · ${e.slot}`:``,`: `,e.message]})]},t))})}function ig({project:e,name:t,presenter:n,start:r}){let i={project:e,name:t},a=F(`presentations.get`,{name:t,query:Mh(e)},{interval:1e4}),o=(a?.deck.slides??[]).map((e,t)=>({s:e,i:t})).filter(e=>!Uh(e.s)),s=Math.max(1,o.findIndex(e=>e.i>=r-1)+1),[c,l]=(0,v.useState)(s),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({w:window.innerWidth,h:window.innerHeight}),[m]=(0,v.useState)(Date.now()),[h,g]=(0,v.useState)(Date.now()),_=o.length,y=e=>a?.deck.numbers===!1?void 0:{n:e,of:_},b=Nh(i),x=e=>l(Math.min(Math.max(1,e),Math.max(1,_))),S=a?.theme;oh(S?[S]:[],a?.deck.css);let C=(0,v.useMemo)(()=>Fh(i,a?.updatedAt??``),[t,e,a?.updatedAt]),w=o[c-1]?.s,T=o[c]?.s,E=lh(w,S,C),D=lh(T,S,C);(0,v.useEffect)(()=>l(s),[s]),(0,v.useEffect)(()=>{let e=()=>p({w:window.innerWidth,h:window.innerHeight}),t=setInterval(()=>g(Date.now()),1e3),n=e=>{e.key===`ArrowRight`||e.key===` `||e.key===`PageDown`||e.key===`Enter`?(e.preventDefault(),l(e=>Math.min(e+1,Math.max(1,_)))):e.key===`ArrowLeft`||e.key===`PageUp`||e.key===`Backspace`?(e.preventDefault(),l(e=>Math.max(1,e-1))):e.key===`Home`?l(1):e.key===`End`?l(Math.max(1,_)):e.key===`Escape`?H(b):e.key===`n`||e.key===`N`?d(e=>!e):(e.key===`f`||e.key===`F`)&&document.documentElement.requestFullscreen?.().catch(()=>{})};return window.addEventListener(`keydown`,n),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,e),clearInterval(t)}},[_,b]);let O=S?Lm(S.size):900,k=Math.floor((h-m)/1e3),ee=`${String(Math.floor(k/60)).padStart(2,`0`)}:${String(k%60).padStart(2,`0`)}`;if(n){let e=Math.min(f.w*.62,(f.h-120)*gm/O);return(0,z.jsxs)(`div`,{className:`fixed inset-0 z-[1000] flex select-none flex-col gap-4 bg-[#111] p-6 text-white`,role:`region`,"aria-label":`presenter view`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-white/70`,children:[(0,z.jsx)(`button`,{type:`button`,className:`hover:text-white`,onClick:()=>H(b),children:`← back to the editor (Esc)`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(`span`,{children:a?.title}),(0,z.jsxs)(`span`,{className:`tabular-nums`,"aria-label":`slide counter`,children:[c,` / `,_]}),(0,z.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums text-white`,"aria-label":`elapsed time`,children:ee})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-6`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-white/50`,children:`now`}),E&&S&&(0,z.jsx)(`div`,{role:`img`,"aria-label":`slide ${c} of ${_}`,children:(0,z.jsx)(ch,{view:E,theme:S,width:e,number:y(c)})})]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,z.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-white/50`,children:`next`}),D&&S?(0,z.jsx)(ch,{view:D,theme:S,width:Math.min(360,f.w*.3),thumb:!0,number:y(c+1)}):(0,z.jsx)(`span`,{className:`text-sm text-white/40`,children:`the end`}),(0,z.jsx)(`span`,{className:`mt-2 text-xs uppercase tracking-wider text-white/50`,children:`notes`}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap text-xl leading-8 text-white/90`,"aria-label":`speaker notes`,children:w?.notes||(0,z.jsx)(`span`,{className:`text-white/40`,children:`no notes on this slide`})})]})]})]})}let A=f.h-36-(u?Math.min(f.h*.3,180):0),j=Math.min(f.w,A*gm/O);return(0,z.jsxs)(`div`,{className:`fixed inset-0 z-[1000] flex select-none flex-col bg-black text-white`,role:`region`,"aria-label":`presentation`,children:[(0,z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center`,children:[E&&S?(0,z.jsx)(`div`,{className:E.transition===`slide`?`animate-[deckslide_420ms_cubic-bezier(.2,.7,.2,1)] motion-reduce:animate-none`:E.transition===`zoom`?`animate-[deckzoom_380ms_cubic-bezier(.2,.7,.2,1)] motion-reduce:animate-none`:E.transition===`none`?``:`animate-[deckfade_300ms_ease-out] motion-reduce:animate-none`,"data-transition":E.transition,role:`img`,"aria-label":`slide ${c} of ${_}`,children:(0,z.jsx)(ch,{view:E,theme:S,width:j,number:y(c)})},c):(0,z.jsx)(`span`,{className:`text-white/60`,children:a?`this deck has no slides`:`loading…`}),(0,z.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 left-0 w-1/4 cursor-w-resize opacity-0`,"aria-label":`previous slide`,onClick:()=>x(c-1)}),(0,z.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 w-1/4 cursor-e-resize opacity-0`,"aria-label":`next slide`,onClick:()=>x(c+1)})]}),u&&(0,z.jsx)(`div`,{className:`max-h-[30vh] overflow-auto border-t border-white/20 bg-black/90 px-6 py-3 text-base leading-6 text-white/90`,"aria-label":`speaker notes`,children:w?.notes||(0,z.jsx)(`span`,{className:`text-white/50`,children:`no notes on this slide`})}),(0,z.jsxs)(`div`,{className:`flex h-9 items-center gap-3 px-4 text-xs text-white/60`,children:[(0,z.jsx)(`button`,{type:`button`,className:`hover:text-white`,onClick:()=>H(b),children:`← back to the editor (Esc)`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(`span`,{children:a?.title}),(0,z.jsxs)(`span`,{children:[c,` / `,_]}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:ee}),(0,z.jsx)(`button`,{type:`button`,className:I(`hover:text-white`,u&&`text-white`),onClick:()=>d(e=>!e),"aria-pressed":u,children:`notes (N)`}),(0,z.jsx)(`span`,{children:`fullscreen (F)`})]})]})}function ag({project:e,name:t}){let n={project:e,name:t},r=F(`presentations.get`,{name:t,query:Mh(e)},{interval:1e4}),i=r?.theme;oh(i?[i]:[],r?.deck.css);let a=(0,v.useMemo)(()=>Fh(n,r?.updatedAt??``),[t,e,r?.updatedAt]),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=o.current;if(!e)return;let t=new ResizeObserver(()=>c(Math.floor(e.clientWidth)));return t.observe(e),()=>t.disconnect()},[]);let l=r?.deck.slides??[],u=r?.deck.numbers!==!1;return(0,z.jsxs)(`div`,{ref:o,className:`deck-glance flex flex-col gap-3`,"aria-label":`slides`,children:[!r&&(0,z.jsx)(Y,{children:`loading…`}),r&&l.length===0&&(0,z.jsx)(Y,{icon:`slideshow`,children:`No slides yet.`}),i&&s>0&&l.map((e,t)=>(0,z.jsx)(U,{href:Nh(n),className:I(`block overflow-hidden rounded-lg border border-line no-underline shadow-sm transition-shadow hover:shadow-md`,Uh(e)&&`opacity-40`),title:`slide ${t+1}`,"data-slide":t+1,children:(0,z.jsx)(uh,{slide:e,theme:i,asset:a,width:s-2,number:u?{n:t+1,of:l.length}:void 0})},t))]})}var og=e=>e==null?``:String(e),sg={contacts:{singular:`contact`,icon:`person`,what:`people and organisations the workspace works with`,fields:[{name:`role`,label:`role`,type:`text`,hint:`What they do (CTO, project lead)`},{name:`org`,label:`organisation`,type:`text`,hint:`Company or organisation`},{name:`email`,label:`email`,type:`email`,hint:`Email address`},{name:`phone`,label:`phone`,type:`text`,hint:`Phone number`},{name:`place`,label:`place`,type:`ref`,refKind:`places`,hint:`Slug of the place they are usually at`},{name:`url`,label:`website`,type:`url`,hint:`https://…`}],describe:e=>[og(e.role),og(e.org)].filter(Boolean).join(`, `)},places:{singular:`place`,icon:`location_on`,what:`addresses and points of interest`,fields:[{name:`address`,label:`address`,type:`text`,hint:`Street, number, postcode, town`},{name:`lat`,label:`latitude`,type:`number`,hint:`47.05`},{name:`lng`,label:`longitude`,type:`number`,hint:`8.30`},{name:`url`,label:`website`,type:`url`,hint:`https://…`}],describe:e=>og(e.address)},events:{singular:`event`,icon:`event`,what:`dated, one-off entries — a meeting, a launch, a deadline`,fields:[{name:`start`,label:`start`,type:`date`,required:!0,hint:`2026-11-03 or 2026-11-03T14:00`},{name:`end`,label:`end`,type:`date`,hint:`not before start`},{name:`place`,label:`place`,type:`ref`,refKind:`places`,hint:`Slug of the place`},{name:`contacts`,label:`contacts`,type:`refs`,refKind:`contacts`,hint:`Contact slugs, comma-separated`},{name:`project`,label:`project`,type:`ref`,refKind:`projects`,hint:`Slug of the project`},{name:`url`,label:`link`,type:`url`,hint:`https://…`}],describe:e=>`${og(e.start).replace(`T`,` `)}${e.end?`–${og(e.end).replace(`T`,` `)}`:``}`}},cg=(e,t)=>`${e}.${t}`,lg=(e,t)=>A.request(cg(e,`get`),{slug:t}),ug=(e,t,n)=>A.request(cg(e,`save`),{slug:t,body:n}),dg=(e,t)=>A.request(cg(e,`create`),{body:t}),fg=(e,t)=>A.request(cg(e,`delete`),{slug:t}),pg=()=>new Date().toISOString().slice(0,10);function mg(e,t){if(e!==`events`)return t;let n=pg(),r=t.filter(e=>og(e.end||e.start).slice(0,10)>=n),i=t.filter(e=>og(e.end||e.start).slice(0,10)<n).reverse();return[...r,...i]}function hg({kind:e,slug:t}){let n=sg[e],r=F(cg(e,`list`),{}),[i,a]=(0,v.useState)(``),o=mg(e,r?.items??[]),s=i.trim()?o.filter(e=>`${e.title} ${e.slug} ${n.describe(e)} ${e.tags.join(` `)}`.toLowerCase().includes(i.trim().toLowerCase())):o,c=t===`new`,l=e===`events`?new Set(o.filter(e=>og(e.end||e.start).slice(0,10)<pg()).map(e=>e.slug)):new Set;return(0,z.jsxs)(`div`,{className:`runs-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:e,count:r?.items.length,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,href:`/${e}/new`,children:`new`})}),o.length>6&&(0,z.jsx)(At,{value:i,placeholder:`find a ${n.singular}…`,"aria-label":`find a ${n.singular}`,onChange:e=>a(e.target.value)}),(0,z.jsxs)(jt,{label:e,children:[s.map(r=>(0,z.jsx)(gt,{href:`/${e}/${encodeURIComponent(r.slug)}`,active:r.slug===t,size:`sm`,dim:l.has(r.slug),leading:r.configError?(0,z.jsx)(et,{tone:`bad`,title:r.configError}):(0,z.jsx)(B,{name:n.icon,className:`ms-sm`}),title:r.title,sub:r.configError?`unreadable frontmatter`:n.describe(r)||void 0},r.slug)),r&&!r.enabled&&(0,z.jsx)(Mt,{children:r.error}),r?.enabled&&o.length===0&&(0,z.jsxs)(Mt,{children:[`no `,e,` yet`]})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:t&&!c?(0,z.jsx)(vg,{kind:e,slug:t},`${e}/${t}`):c?(0,z.jsx)(yg,{kind:e}):(0,z.jsx)(Y,{icon:n.icon,action:r?.enabled?(0,z.jsxs)(K,{variant:`primary`,icon:`add`,href:`/${e}/new`,children:[`new `,n.singular]}):void 0,children:r&&!r.enabled?r.error:(0,z.jsxs)(z.Fragment,{children:[e,`: `,n.what,`. One Markdown file each under the `,e,` root; reference one anywhere as `,(0,z.jsxs)(`code`,{children:[n.singular,`:<slug>`]}),`.`]})})})]})}function gg({field:e,value:t,onChange:n,disabled:r}){return(0,z.jsx)(Z,{value:t,placeholder:e.hint,"aria-label":`${e.label}`,inputMode:e.type===`number`?`decimal`:void 0,type:e.type===`email`?`email`:`text`,disabled:r,onChange:e=>n(e.target.value)})}function _g({links:e,refKind:t}){return e?.length?(0,z.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,z.jsxs)(J,{tone:e.found?`neutral`:`bad`,title:e.found?e.label:`not found in this workspace`,children:[e.found?(0,z.jsx)(U,{href:`/${t}/${encodeURIComponent(e.slug)}`,className:`text-inherit no-underline hover:underline`,children:e.slug}):e.slug,!e.found&&` · not found`]},e.slug))}):null}function vg({kind:e,slug:t}){let n=sg[e],[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!0),O=e=>{i(e),c(e.title),u(Object.fromEntries(n.fields.map(t=>[t.name,Array.isArray(e[t.name])?e[t.name].join(`, `):og(e[t.name])]))),f(e.tags.join(`, `)),m(e.notes),g(!1)};(0,v.useEffect)(()=>{let n=!0;return lg(e,t).then(e=>{n&&(e.ok?O(e.data):o(P(e)))}),()=>{n=!1}},[e,t]);let k=()=>{g(!0),x(!1),C(``)},ee=async(n,r={})=>{y(!0),C(``);try{let a=await ug(e,t,n);if(!a.ok)throw Error(P(a));r.keepEdits?i(a.data):(O(a.data),D(!0)),x(!0)}catch(e){C(e.message)}finally{y(!1)}},A=()=>ee({title:s,tags:d,notes:p,...Object.fromEntries(n.fields.map(e=>[e.name,l[e.name]??``]))}),j=async()=>{let n=await fg(e,t);if(!n.ok)return C(P(n));H(`/${e}`,{replace:!0})},M=(0,v.useMemo)(()=>p.trim()?To(fo.sanitize(Mi.parse(p,{async:!1}))):``,[p]);if(a&&!r)return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:n.icon,title:t}),(0,z.jsx)(rt,{tone:`bad`,children:a})]});if(!r)return(0,z.jsx)(Y,{children:`loading…`});let N=e===`places`?og(r.mapsUrl):``;return(0,z.jsxs)(ct,{className:`${n.singular}-page`,children:[(0,z.jsx)(st,{icon:n.icon,title:(0,z.jsx)(Z,{value:s,"aria-label":`${n.singular} title`,className:`h-auto border-0 bg-transparent px-0 text-xl font-semibold shadow-none`,onChange:e=>{c(e.target.value),k()}}),sub:(0,z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`code`,{className:`font-mono text-xs`,children:[n.singular,`:`,r.slug]}),r.updatedAt&&(0,z.jsxs)(`span`,{children:[`changed `,G(r.updatedAt)]}),N&&(0,z.jsxs)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent`,children:[(0,z.jsx)(B,{name:`map`,className:`ms-sm`}),` open in Google Maps`]})]}),actions:(0,z.jsxs)(z.Fragment,{children:[S&&(0,z.jsx)(`span`,{className:`text-sm text-bad`,children:S}),b&&!h&&(0,z.jsx)(`span`,{className:`text-sm text-fg-2`,children:`saved`}),(0,z.jsx)(K,{variant:`primary`,icon:`save`,busy:_,disabled:!h||_||!s.trim(),onClick:()=>void A(),children:`save`}),w?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{variant:`danger`,onClick:()=>void j(),children:`move to trash`}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>T(!1),children:`cancel`})]}):(0,z.jsx)(K,{variant:`quiet`,icon:`delete`,title:`move to the trash`,onClick:()=>T(!0),children:`remove`})]})}),r.configError&&(0,z.jsxs)(rt,{tone:`bad`,children:[`frontmatter: `,r.configError,` — the fields below show defaults and cannot be saved; fix the file by hand first.`]}),(0,z.jsx)(X,{title:`fields`,className:`flex-none`,children:(0,z.jsxs)(Ct,{className:`max-w-[760px]`,children:[n.fields.map(e=>(0,z.jsx)(Q,{label:`${e.label}${e.required?` *`:``}`,hint:e.type===`ref`||e.type===`refs`?(0,z.jsx)(_g,{links:r.links[e.name],refKind:e.refKind}):void 0,children:(0,z.jsx)(gg,{field:e,value:l[e.name]??``,onChange:t=>{u(n=>({...n,[e.name]:t})),k()}})},e.name)),(0,z.jsx)(wt,{children:(0,z.jsx)(Q,{label:`tags`,className:`flex-1`,children:(0,z.jsx)(Z,{value:d,placeholder:`comma-separated`,"aria-label":`tags`,onChange:e=>{f(e.target.value),k()}})})}),r.extra&&Object.keys(r.extra).length>0&&(0,z.jsxs)(`div`,{className:`text-xs text-fg-2`,children:[`Also in the file, kept as written: `,Object.entries(r.extra).map(([e,t])=>`${e}: ${typeof t==`string`?t:JSON.stringify(t)}`).join(` · `)]})]})}),(0,z.jsx)(X,{title:`notes`,className:`flex-none`,actions:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:E?`edit`:`visibility`,onClick:()=>D(e=>!e),children:E?`edit`:`preview`}),children:E?M?(0,z.jsx)(`div`,{className:`md-body px-[18px] py-3`,dangerouslySetInnerHTML:{__html:M}}):(0,z.jsx)(`div`,{className:`px-[18px] py-3 text-xs text-fg-2`,children:`no notes yet — Markdown; reference other entries as contact:<slug>, place:<slug>, event:<slug>`}):(0,z.jsx)(Ct,{children:(0,z.jsx)(xt,{value:p,"aria-label":`notes`,rows:10,className:`font-mono text-[13px]`,placeholder:`Markdown notes`,onChange:e=>{m(e.target.value),k()}})})}),(0,z.jsx)(ux,{records:r.records,saving:_,onSave:e=>ee({records:e},{keepEdits:!0})})]})}function yg({kind:e}){let t=sg[e];return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:t.icon,title:`new ${t.singular}`,sub:`a Markdown file under the ${e} root; the file name derives from the title`}),(0,z.jsx)(X,{children:(0,z.jsx)(bg,{kind:e})})]})}function bg({kind:e,onCreated:t,onCancel:n}){let r=sg[e],[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),f=async()=>{l(!0),d(``);try{let n=await dg(e,{title:i,...o});if(!n.ok)throw Error(P(n));t?t(n.data.slug):H(`/${e}/${encodeURIComponent(n.data.slug)}`,{replace:!0})}catch(e){d(e.message)}finally{l(!1)}};return(0,z.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&f()},children:(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsx)(Q,{label:`title`,children:(0,z.jsx)(Z,{value:i,"aria-label":`${r.singular} title`,autoFocus:!0,placeholder:e===`contacts`?`e.g. Anna Meier`:e===`places`?`e.g. NETNODE Office`:`e.g. Kickoff`,onChange:e=>a(e.target.value)})}),r.fields.map(e=>(0,z.jsx)(Q,{label:`${e.label}${e.required?` *`:``}`,children:(0,z.jsx)(gg,{field:e,value:o[e.name]??``,onChange:t=>s(n=>({...n,[e.name]:t}))})},e.name)),(0,z.jsxs)(wt,{children:[(0,z.jsxs)(K,{variant:`primary`,type:`submit`,icon:`add`,busy:c,disabled:!i.trim()||c,children:[`create `,r.singular]}),n?(0,z.jsx)(K,{variant:`quiet`,onClick:n,children:`cancel`}):(0,z.jsx)(K,{variant:`quiet`,href:`/${e}`,children:`cancel`}),u&&(0,z.jsx)(`span`,{className:`text-sm text-bad`,children:u})]})]})})}function xg(){return F(`workflows.runner`,{slug:`any`},{interval:15e3})}var Sg=e=>!!e?.available&&!!e?.image;function Cg(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function wg(e,t){return(await A.call(`workflows.run`,{slug:e,body:t})).runId}function Tg(e,t,n,r){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=xg();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]);let h=!u&&(!t||!!i.trim())&&(!o||Sg(m));async function g(){if(h){d(!0),p(null);try{let t=await wg(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):H(`/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 Eg({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=Yt(),a=Tg(e,t,n,r??(e=>i(`/runs/${e}`))),o=Cg(a.docker);return(0,z.jsx)(Rt,{label:`run ${e}`,className:`run-form`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`account_tree`,className:`ms-sm`}),` `,e]}),chipTitle:`the workflow this starts`,value:a.request,onChange:a.setRequest,inputLabel:`request`,placeholder:`Request`,noInput:t?void 0:`This workflow takes no request.`,onSend:()=>void a.launch(),sendLabel:`Run`,sendIcon:`play_arrow`,busy:a.busy,disabled:!a.canRun,error:a.error,controls:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Dg,{label:`Docker sandbox`,hint:o,checked:a.sandbox,onChange:a.setSandbox}),a.sandbox&&(0,z.jsx)(Dg,{label:`Forward SSH agent`,hint:`keys and known hosts from this machine`,checked:a.ssh,onChange:a.setSsh})]}),hint:a.sandbox?o:`runs on this machine`})}function Dg({label:e,hint:t,checked:n,onChange:r}){return(0,z.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,title:t,className:`inline-flex cursor-pointer items-center gap-1.5 rounded-full border-0 bg-transparent px-2.5 py-1 text-sm font-medium text-fg transition-colors hover:bg-surface-2`,onClick:()=>r(!n),children:[(0,z.jsx)(`span`,{className:`-mx-1.5 inline-flex scale-[0.7]`,children:(0,z.jsx)(Et,{checked:n})}),e]})}function Og({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,z.jsx)(`section`,{className:I(kg,`decision-panel is-decided`),"aria-label":`decision`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,z.jsx)(`div`,{className:Ag,children:n.title??`Decision`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-base`,children:[(0,z.jsx)(J,{tone:`ok`,children:f(r.decision)}),r.note&&(0,z.jsxs)(`span`,{className:`text-fg-2`,children:[`“`,r.note,`”`]}),r.decidedAt&&(0,z.jsx)(`span`,{className:`text-xs tabular-nums text-fg-2`,children:Ke(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,z.jsx)(`section`,{className:I(kg,`decision-panel`),"aria-label":`decision needed`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(et,{tone:`working`}),(0,z.jsx)(`div`,{className:Ag,children:n.title??`This run needs your decision`})]}),n.prompt&&(0,z.jsx)(`p`,{className:`m-0 max-w-[80ch] text-base text-fg-2`,children:n.prompt}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2 self-start`,role:`radiogroup`,"aria-label":`options`,children:n.options.map(e=>(0,z.jsx)(K,{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,z.jsx)(Z,{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,z.jsx)(rt,{tone:`bad`,children:u}),(0,z.jsx)(`div`,{className:`flex gap-2`,children:(0,z.jsx)(K,{variant:`primary`,onClick:m,disabled:!p,busy:c,children:c?`Saving…`:`Submit decision`})})]})})}var kg=`mb-[18px] overflow-hidden rounded-card border border-line bg-surface`,Ag=`text-[16px] font-medium text-fg`;function jg(e){return e===`ok`?`ok`:e===`running`?`working`:e===`failed`||e===`blocked`?`bad`:`idle`}function Mg({status:e}){return(0,z.jsx)(`span`,{"data-ui":`status`,"data-status":e,className:`inline-flex`,children:(0,z.jsx)(J,{tone:e===`ok`?`ok`:e===`failed`||e===`blocked`?`bad`:e===`running`?`accent`:`neutral`,children:e})})}function Ng(){return(0,z.jsx)(`span`,{"data-ui":`decision`,className:`inline-flex`,children:(0,z.jsx)(J,{tone:`accent`,children:`decision needed`})})}function Pg({label:e,children:t,className:n}){return(0,z.jsxs)(`div`,{className:n,children:[(0,z.jsx)(it,{className:`mb-px block`,children:e}),(0,z.jsx)(`div`,{className:`font-mono text-md font-medium tabular-nums text-fg`,children:t})]})}var Fg=`mb-[22px] flex flex-wrap gap-[26px]`;function Ig({id:e,workflow:t}){let n=F(`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,z.jsxs)(`div`,{className:`runs-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`runs`,back:{href:`/workflows`,label:`back to workflows`},count:i?`${o.length} / ${r.length}`:r.length}),(0,z.jsx)(At,{icon:`filter_list`,value:i,placeholder:`filter by workflow or request`,"aria-label":`filter runs`,onChange:e=>a(e.target.value)}),(0,z.jsxs)(jt,{label:`runs list`,children:[o.map(t=>(0,z.jsx)(Lg,{r:t,active:t.id===e},t.id)),n&&r.length===0&&(0,z.jsx)(Mt,{children:`no runs yet`}),r.length>0&&o.length===0&&(0,z.jsxs)(Mt,{children:[`no run matches “`,i,`”`]})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:(0,z.jsx)(Rg,{id:e},e)})]})}function Lg({r:e,active:t}){return(0,z.jsx)(gt,{href:`/runs/${e.id}`,active:t,size:`sm`,leading:(0,z.jsx)(et,{tone:jg(e.status),title:e.status}),title:e.workflow??`unknown`,meta:Ke(e.startedAt),sub:(0,z.jsxs)(`span`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.request,children:e.status===`running`&&e.currentPhase?`${e.currentPhase}`:e.request??``}),(0,z.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.status===`running`?(0,z.jsx)(qe,{since:e.startedAt}):Ue(e.durationMs)})]})})}function Rg({id:e}){let t=F(`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=Se();if(!t)return(0,z.jsx)(Y,{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=>!Gg(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);n?.ok?H(t?.workflow?`/workflows/${encodeURIComponent(t.workflow)}`:`/workflows`):c(n?.error??`remove failed`)}return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5`,children:[(0,z.jsx)(et,{tone:jg(t.status),title:t.status}),(0,z.jsx)(ot,{size:`lg`,children:t.workflow?(0,z.jsx)(U,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,className:`text-inherit no-underline hover:text-accent`,children:t.workflow}):`unknown workflow`}),(0,z.jsx)(Mg,{status:t.status}),u&&(0,z.jsxs)(J,{children:[(0,z.jsx)(B,{name:`science`,className:`ms-sm mr-1`}),` sandbox`]}),(0,z.jsx)(`span`,{className:`font-mono text-xs text-fg-2`,children:e.replace(/^run-/,``)}),n?(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`stop`,busy:a,onClick:p,children:a?`stopping…`:`stop`}):(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,onClick:m,title:`delete this run's folder`,children:`remove`}),s&&(0,z.jsx)(`span`,{className:`text-xs text-bad`,children:s}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,title:`chat with an agent about this run`,onClick:()=>void Yo(`claude`,{kind:`run`,runId:e}),children:`⌬ discuss`}),(0,z.jsx)(_t,{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,z.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:t.request}),d===`run`?(0,z.jsx)(zg,{run:t,live:n}):(0,z.jsx)(qg,{id:e,files:t.files,live:n})]})}function zg({run:e,live:t}){return(0,z.jsxs)(`div`,{className:`max-w-[1080px]`,children:[e.decision&&(0,z.jsx)(Og,{runId:e.id,decision:e.decision}),(0,z.jsxs)(`div`,{className:Fg,children:[(0,z.jsxs)(Pg,{label:`phases`,children:[e.phasesDone,e.phasesTotal==null?``:` / ${e.phasesTotal}`]}),(0,z.jsx)(Pg,{label:`duration`,children:t?(0,z.jsx)(qe,{since:e.startedAt}):Ue(e.durationMs)}),(0,z.jsx)(Pg,{label:`cost`,children:We(e.costUsd??Vg(e.phases))}),(0,z.jsxs)(Pg,{label:`tokens in / out`,children:[Ge(Bg(e.phases,`tokensIn`)),` / `,Ge(Bg(e.phases,`tokensOut`))]})]}),(0,z.jsx)(X,{title:`phase timeline`,actions:t&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-[7px] text-2xs text-fg-2`,children:[(0,z.jsx)(et,{tone:`working`}),` live · polling`]}),children:(0,z.jsx)(`div`,{className:`py-1.5`,children:e.phases.map(e=>(0,z.jsx)(Ug,{p:e},e.phase))})})]})}function Bg(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function Vg(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}var Hg=`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 Ug({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,z.jsxs)(`div`,{className:I(Hg,`py-2.5 pr-[18px] pl-[42px] before:left-[23px] first:before:top-4 last:before:h-4`),children:[(0,z.jsx)(`span`,{className:`absolute top-4 left-[19px] z-1 grid`,children:(0,z.jsx)(et,{tone:jg(e.status),title:e.status})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,z.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.phase}),e.kind===`agent`?(0,z.jsxs)(J,{tone:`accent`,children:[e.agent,e.model?` · ${e.model}`:``,e.protocol?` · ${e.protocol}`:``]}):(0,z.jsx)(J,{children:`script`}),e.status===`skipped`&&(0,z.jsx)(Mg,{status:`skipped`}),(0,z.jsxs)(`span`,{className:`ml-auto flex gap-3.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[e.attempts>1&&(0,z.jsxs)(`span`,{children:[`att `,e.attempts]}),e.status===`running`?(0,z.jsx)(qe,{since:e.startedAt}):e.durationMs!=null&&(0,z.jsx)(`span`,{children:Ue(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,z.jsxs)(`span`,{children:[Ge(e.tokensIn),` / `,Ge(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,z.jsx)(`span`,{children:We(e.costUsd)})]})]}),e.status===`running`&&e.lastActivity&&(0,z.jsxs)(`div`,{className:`mt-[3px] font-mono text-[11.5px] text-accent`,children:[`▸ `,e.lastActivity]}),e.summary&&e.status!==`running`&&(0,z.jsx)(`div`,{className:`mt-[3px] max-w-[72ch] text-[12.5px] text-fg-2`,children:e.summary}),e.gates.length>0&&(0,z.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,z.jsxs)(`span`,{className:I(`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,z.jsx)(B,{name:e.passed?`check`:`close`,className:`ms-sm`}),` `,e.gate]},e.gate))}),t.map(e=>(0,z.jsx)(`div`,{className:`mt-1 text-xs text-bad`,children:e.failure},e.gate))]})}var Wg=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function Gg(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function Kg(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)||Wg.has(t)?0:Gg(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function qg({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=Se(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!Gg(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&Gg(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(Kg(o))},[o,r]),(0,z.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,z.jsx)(X,{title:(0,z.jsxs)(z.Fragment,{children:[`files `,(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,o.length,`)`]})]}),className:`flex min-h-0 flex-col`,children:(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto max-[940px]:max-h-60`,children:[o.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:I(`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,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,z.jsx)(`span`,{className:`text-2xs tabular-nums text-fg-2`,children:W(e.size)})]},e.name)),o.length===0&&(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:t.length>0?`no result files — raw run files live in expert mode`:`no files yet`})]})}),(0,z.jsx)(X,{title:r??`viewer`,className:`flex min-h-0 flex-col`,actions:r&&(0,z.jsx)(`a`,{className:Jg,href:A.url(`runs.file`,{id:e,query:{name:r,raw:!0}}),target:`_blank`,children:`open raw ↗`}),children:r?(0,z.jsx)($g,{id:e,name:r,live:n}):(0,z.jsx)(Y,{className:`flex-1 justify-center`,children:`select a file`})})]})}var Jg=`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`,Yg=`flex min-h-0 flex-1 flex-col`,Xg=`min-h-0 flex-1`,Zg=`m-0 h-full overflow-auto px-[18px] py-3.5 text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,Qg=`block h-full min-h-[560px] w-full border-0 bg-white`;function $g({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,z.jsx)(`div`,{className:Yg,children:(0,z.jsx)(`div`,{className:Xg,children:(0,z.jsx)(`iframe`,{className:Qg,src:i,sandbox:`allow-scripts`,allow:`clipboard-write`,title:t})})}):r===`pdf`?(0,z.jsx)(`div`,{className:Yg,children:(0,z.jsx)(`div`,{className:Xg,children:(0,z.jsx)(`iframe`,{className:Qg,src:i,title:t})})}):Wg.has(r)?(0,z.jsx)(`div`,{className:Yg,children:(0,z.jsx)(`div`,{className:Xg,children:(0,z.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,z.jsx)(t_,{id:e,name:t,live:n}):(0,z.jsx)(n_,{id:e,name:t,live:n})}var e_=`flex items-center gap-3 border-b border-line/55 px-[18px] py-1.5 text-2xs text-fg-2`;function t_({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=F(`runs.fileText`,{id:e,query:{name:t}},{fast:n}),o=(0,v.useMemo)(()=>a?fo.sanitize(Mi.parse(a.content,{async:!1})):``,[a?.content]);return(0,z.jsxs)(`div`,{className:Yg,children:[(0,z.jsxs)(`div`,{className:e_,children:[(0,z.jsx)(_t,{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,z.jsxs)(`span`,{children:[`large file — showing the last `,W(4e5)]})]}),(0,z.jsx)(`div`,{className:I(Xg,`overflow-auto`),children:a?r===`rendered`?(0,z.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:{__html:o}}):(0,z.jsx)(`pre`,{className:Zg,children:a.content||`(empty)`}):(0,z.jsx)(`pre`,{className:Zg,children:`loading…`})})]})}function n_({id:e,name:t,live:n}){let r=F(`runs.fileText`,{id:e,query:{name:t}},{fast:n});return(0,z.jsxs)(`div`,{className:Yg,children:[r?.truncated&&(0,z.jsxs)(`div`,{className:e_,children:[`large file — showing the last `,W(4e5)]}),(0,z.jsx)(`div`,{className:Xg,children:(0,z.jsx)(`pre`,{className:Zg,children:r?r.content||`(empty)`:`loading…`})})]})}var r_=`\0done`,i_=5;function a_(e,t){return e.status===`ok`?r_:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??r_}var o_=[`var(--accent)`,`#4fb8a8`,`#a78bfa`,`#e5793b`];function s_(e){return e==null?`var(--text-2)`:o_[e%o_.length]}function c_({colour:e,children:t,small:n}){return(0,z.jsx)(`span`,{style:{"--aid":e},className:I(`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 l_({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,r_].map(e=>[e,[]]));for(let e of t)a.get(a_(e,i)).push(e);let o=a.get(r_)??[];return(0,z.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,z.jsx)(u_,{step:e.name,index:(0,z.jsx)(c_,{small:!0,colour:s_(e.agent?n.get(e.agent)??0:null),children:t+1}),count:i.length,children:(0,z.jsx)(d_,{cards:i,moreHref:r})},e.name)}),(0,z.jsx)(u_,{step:`done`,name:`done`,done:!0,index:(0,z.jsx)(c_,{small:!0,colour:`var(--ok)`,children:`✓`}),count:o.length,children:(0,z.jsx)(d_,{cards:o,moreHref:r})})]})}function u_({step:e,name:t,done:n,index:r,count:i,children:a}){return(0,z.jsxs)(`div`,{className:I(`board-col flex min-w-60 flex-[0_0_240px] flex-col gap-1.5`,n&&`is-done`),"data-step":e,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-0.5 pt-0.5 pb-1`,children:[r,(0,z.jsx)(`span`,{className:`board-col-name min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t??e,children:t??e}),(0,z.jsx)(`span`,{className:`board-col-count ml-auto font-mono text-[11.5px] tabular-nums text-fg-2`,children:i})]}),a]})}function d_({cards:e,moreHref:t}){return(0,z.jsxs)(`div`,{className:`flex min-h-14 flex-col gap-2 rounded-xl bg-surface-2/60 p-2`,children:[e.slice(0,i_).map(e=>(0,z.jsx)(f_,{r:e},e.id)),e.length===0&&(0,z.jsx)(`div`,{className:`board-col-empty py-3.5 text-center text-xs text-fg-2`,children:`—`}),e.length>i_&&(0,z.jsxs)(U,{href:t,className:`board-more block p-1.5 text-center text-xs text-fg-2 no-underline hover:text-accent`,children:[`+ `,e.length-i_,` more ↗`]})]})}function f_({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,z.jsxs)(U,{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,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(et,{tone:jg(e.status),title:e.status}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t,children:t})]}),(0,z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-2.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[(0,z.jsx)(`span`,{children:Ke(e.startedAt)}),(0,z.jsx)(`span`,{children:e.status===`running`?(0,z.jsx)(qe,{since:e.startedAt}):Ue(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,z.jsx)(`span`,{children:We(e.costUsd)})]}),(e.awaitingDecision||e.status===`failed`||e.status===`aborted`)&&(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[e.awaitingDecision&&(0,z.jsx)(Ng,{}),(e.status===`failed`||e.status===`aborted`)&&(0,z.jsx)(Mg,{status:e.status})]})]})}function p_({slug:e,tab:t}){let n=F(`workflows.get`,{slug:e}),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=F(`runs.list`,{},{fast:a>0||Date.now()-r<2e4});if(!n)return(0,z.jsx)(Y,{children:`loading…`});if(n.error)return(0,z.jsxs)(Y,{children:[(0,z.jsx)(J,{tone:`bad`,children:`broken workflow`}),(0,z.jsx)(`pre`,{className:`mt-3 text-left`,children:n.error}),(0,z.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,z.jsx)(h_,{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,z.jsxs)(z.Fragment,{children:[(0,z.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,z.jsx)(ot,{size:`lg`,className:`in-[.ctx-embed]:text-xl`,children:n.name??n.slug}),(0,z.jsx)(`span`,{className:`min-w-0 font-mono text-xs [overflow-wrap:anywhere] text-fg-2 in-[.ctx-embed]:hidden`,children:n.dir}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(_t,{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,z.jsxs)(z.Fragment,{children:[`runs `,(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,`)`]})]})}]})]}),n.description&&(0,z.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:n.description}),t===`overview`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`run-panel mb-[18px]`,children:(0,z.jsx)(Eg,{slug:n.slug,usesRequest:n.usesRequest,initialRequest:l[0]?.request,onLaunched:()=>i(Date.now())})}),(0,z.jsx)(X,{title:(0,z.jsxs)(z.Fragment,{children:[`board`,` `,(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,` runs`,d>0?`, ${d} live`:``,`)`]})]}),actions:l[0]&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,href:`${u}/runs`,className:`in-[.ctx-embed]:hidden`,children:`all runs ↗`}),children:(0,z.jsx)(l_,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})})]}),t===`details`&&(0,z.jsx)(m_,{wf:n,agentIdx:c}),t===`runs`&&(0,z.jsx)(g_,{runs:l})]})}function m_({wf:e,agentIdx:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:Fg,children:[(0,z.jsx)(Pg,{label:`agents`,children:e.agents.length}),(0,z.jsxs)(Pg,{label:`steps`,children:[e.steps.length,` `,(0,z.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,z.jsx)(Pg,{label:`workspace`,className:`max-w-[420px]`,children:(0,z.jsx)(`span`,{className:`text-[11.5px] font-normal whitespace-pre-wrap text-fg-2`,children:e.workspace})})]}),(0,z.jsx)(X,{title:`agents`,className:`mb-[18px]`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(280px,1fr))]`,children:[e.agents.map(e=>(0,z.jsx)(v_,{a:e,idx:t.get(e.id)??0},e.id)),e.agents.length===0&&(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`no agents — script-only workflow`})]})}),(0,z.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,z.jsx)(X,{title:`pipeline`,children:(0,z.jsx)(`div`,{className:`pipeline py-2`,children:e.steps.map((e,n)=>(0,z.jsx)(y_,{s:e,i:n,idx:e.agent?t.get(e.agent)??0:null},e.name))})}),(0,z.jsx)(X,{title:(0,z.jsxs)(z.Fragment,{children:[`folder `,(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,e.files.length,` files)`]})]}),children:(0,z.jsx)(`div`,{className:`max-h-[300px] overflow-auto`,children:e.files.map(e=>(0,z.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,z.jsx)(`div`,{className:`mt-[18px] in-[.ctx-embed]:hidden`,children:(0,z.jsx)(h_,{slug:e.slug})})]})}function h_({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`);H(`/workflows`,{replace:!0})}catch(e){o(e.message),n(!1)}finally{i(!1)}};return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{variant:`danger`,icon:`delete`,busy:r,onClick:()=>void s(),children:`confirm delete`}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>n(!1),children:`cancel`}),(0,z.jsx)(nt,{children:`its runs stay; the trash can put it back`})]}):(0,z.jsx)(K,{variant:`danger`,icon:`delete`,onClick:()=>n(!0),title:`Move the workflow's folder to the trash`,children:`delete workflow`})}),a&&(0,z.jsx)(rt,{tone:`bad`,children:a})]})}function g_({runs:e}){return e.length===0?(0,z.jsx)(Y,{children:`no runs of this workflow yet`}):(0,z.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,z.jsxs)(U,{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,z.jsx)(et,{tone:jg(e.status),title:e.status}),(0,z.jsx)(`span`,{className:`font-mono text-[12.5px] text-fg-2`,children:e.id.replace(/^run-/,``)}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,title:e.request,children:e.status===`running`&&e.currentPhase?e.currentPhase:e.request??``}),(0,z.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,z.jsx)(Ng,{}),(0,z.jsx)(Mg,{status:e.status}),(0,z.jsx)(`span`,{className:`h-1 w-[90px] overflow-hidden rounded-full bg-surface-2`,title:`${e.phasesDone}${t?` / ${t}`:``} steps`,children:(0,z.jsx)(`i`,{className:I(`block h-full rounded-full`,e.status===`ok`?`bg-ok`:e.status===`failed`?`bg-bad`:`bg-accent`),style:{width:`${n}%`}})}),(0,z.jsx)(`span`,{children:e.status===`running`?(0,z.jsx)(qe,{since:e.startedAt}):Ue(e.durationMs)}),(0,z.jsx)(`span`,{children:We(e.costUsd)}),(0,z.jsx)(`span`,{children:Ke(e.startedAt)})]})]},e.id)})})}var __=`border-line/55`;function v_({a:e,idx:t}){return(0,z.jsxs)(`div`,{className:I(`agent-card border-r border-b px-[18px] py-3.5`,__),children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`size-2.5 rounded-full`,style:{background:s_(t)}}),(0,z.jsx)(`b`,{className:`text-base font-medium text-fg`,children:e.name??e.id}),(0,z.jsxs)(`code`,{className:`text-2xs text-fg-2`,children:[`[`,e.id,`]`]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(J,{children:[e.model??`default`,e.effort?` · ${e.effort}`:``,e.protocol===`acp`?` · acp`:``]})]}),e.tools.length>0&&(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-[5px]`,children:e.tools.map(e=>(0,z.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,z.jsx)(`p`,{className:`mt-2 mb-0 text-xs leading-[1.55] whitespace-pre-wrap text-fg-2`,children:e.persona})]})}function y_({s:e,i:t,idx:n}){let r=e.kind===`script`?e.script:e.prompt;return(0,z.jsxs)(`div`,{className:I(`step-node flex gap-3.5 px-[18px] py-3 first:before:top-[18px] last:before:h-[18px] before:left-[31px]`,Hg),children:[(0,z.jsx)(c_,{colour:s_(n),children:t+1}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,z.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.name}),e.kind===`agent`?(0,z.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded-full border px-2 text-2xs font-semibold`,style:{color:s_(n??0),borderColor:`color-mix(in srgb, ${s_(n??0)} 50%, var(--line))`},children:[`agent · `,e.agent]}):(0,z.jsxs)(J,{children:[`script`,e.sourceRef?` · ${e.sourceRef}`:``]})]}),r&&(0,z.jsxs)(`details`,{className:`mt-1.5`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-2 select-none hover:text-accent`,children:e.kind===`agent`?`prompt`:`script`}),(0,z.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,z.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,z.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))})]})]})}async function b_(e,t){let n=window.open(``,`_blank`);if(!n)return;let r=t?`${e}/${t}`:e;n.document.write(`<title>${w_(r)}</title><body style="font-family:system-ui;padding:40px;color:#555">preparing ${w_(r)}…</body>`);let i,a=``;try{let[n,r]=await Promise.all([t?Promise.resolve([t]):A.call(`knowledge.get`,{bundle:e}).then(e=>e.concepts.map(e=>e.id)),A.call(`meta.get`).catch(()=>({}))]);if(a=r.workspaceName??``,i=await Promise.all(n.map(t=>A.call(`knowledge.concept`,{bundle:e,query:{id:t}}))),i.some(e=>typeof e?.id!=`string`))throw Error(`missing concept`)}catch{n.document.body.textContent=`could not load "${r}"`;return}let o=[],s=i.map(e=>{let t=[e.type,e.generated?.at?`updated ${e.generated.at.slice(0,10)}`:``,e.trustTier===`human-reviewed`?`human-reviewed`:``,(e.tags??[]).map(e=>`#${e}`).join(` `)].filter(Boolean).join(` · `),{md:n,notes:r}=S_(x_(e.body??``,null)),i=!e.title||e.title===e.id||e.title===e.id.split(`/`).pop(),{html:a,title:s}=C_(fo.sanitize(Mi.parse(n,{async:!1})),{title:e.title||e.id,meta:t,titleIsFallback:i});return o.push(s),`<article>
338
+ .slot-title { letter-spacing: -0.03em; }`,className:`min-h-[180px] resize-y rounded-md border border-line bg-bg p-2 font-mono text-[12px] leading-5 text-fg outline-none focus:border-accent`,onChange:e=>{c(e.target.value),o(e.target.value)}}),(0,z.jsxs)(nt,{children:[`Over the theme, for this deck only: `,(0,z.jsx)(`code`,{children:`.layout-<name>`}),` a layout, `,(0,z.jsx)(`code`,{children:`.slot-<name>`}),` a box, `,(0,z.jsx)(`code`,{children:`--c-accent`}),` and the other colors as variables, `,(0,z.jsx)(`code`,{children:`attr(data-nn)`}),` the slide number.`]})]})}var Qh=[`#e11d48`,`#7c3aed`,`#059669`,`#d97706`,`#0891b2`,`#db2777`,`#4f46e5`,`#65a30d`],$h=e=>Qh[[...e].reduce((e,t)=>e*31+t.charCodeAt(0)>>>0,7)%Qh.length];function eg(e,t,n,r){let i=(0,v.useMemo)(()=>`t${Math.random().toString(36).slice(2,10)}`,[]),[a,o]=(0,v.useState)([]),s=Mh(e.project),c=e.project?`${e.project}/${e.name}`:e.name;return(0,v.useEffect)(()=>N.subscribe(`deck.${c}@${i}`,{},e=>o(e.viewers??[])),[c,i]),(0,v.useEffect)(()=>{if(!r)return;let a=()=>void A.request(`presentations.presence`,{name:e.name,query:s,body:{client:i,slide:t,...n?{slot:n}:{}}}).catch(()=>{});a();let o=setInterval(a,8e3);return()=>clearInterval(o)},[c,i,t,n,r]),(0,v.useEffect)(()=>{let t=()=>void A.request(`presentations.presence`,{name:e.name,query:s,body:{client:i,slide:1,leave:!0}}).catch(()=>{});return window.addEventListener(`pagehide`,t),()=>{window.removeEventListener(`pagehide`,t),t()}},[c,i]),a.filter(e=>e.client!==i).map(e=>({...e,color:$h(e.client)}))}function tg({at:e,theme:t,asset:n,onRestore:r,onClose:i}){let a=Mh(e.project),o=F(`presentations.history`,{name:e.name,query:a},{interval:8e3}),[s,c]=(0,v.useState)(null),l=F(`presentations.version`,s?{name:e.name,id:s,query:a}:null,{interval:6e5}),u=l&&l.id===s?l:null;return(0,z.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-3 text-sm`,role:`region`,"aria-label":`version history`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(B,{name:`history`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`font-semibold`,children:`Version history`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(q,{icon:`close`,label:`close history`,size:`sm`,onClick:i})]}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`Kept before saves (once a minute while you edit) and whenever an agent or a tool changes deck.md. The newest 50 stay.`}),o&&o.versions.length===0&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`No earlier versions yet.`}),(0,z.jsx)(`ul`,{className:`flex flex-col gap-1`,"aria-label":`versions`,children:(o?.versions??[]).map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsxs)(`button`,{type:`button`,"aria-current":s===e.id,className:I(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-surface-2`,s===e.id&&`bg-surface-2`),onClick:()=>c(s===e.id?null:e.id),children:[(0,z.jsxs)(`span`,{className:`flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-fg`,children:new Date(e.at).toLocaleString()}),(0,z.jsxs)(`span`,{className:`block text-xs text-fg-2`,children:[G(e.at),` · `,e.title,` · `,e.slides,` slide`,e.slides===1?``:`s`]})]}),(0,z.jsx)(B,{name:s===e.id?`expand_less`:`expand_more`,className:`ms-sm text-fg-2`})]}),s===e.id&&u&&(0,z.jsxs)(`div`,{className:`mt-1 flex flex-col gap-2 rounded-md border border-line p-2`,children:[(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,"aria-label":`slides of this version`,children:u.deck.slides.map((e,r)=>(0,z.jsx)(`div`,{className:`overflow-hidden rounded border border-line`,children:(0,z.jsx)(uh,{slide:e,theme:t,asset:n,width:128,number:u.deck.numbers===!1?void 0:{n:r+1,of:u.deck.slides.length}})},r))}),(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`restore`,onClick:()=>r(u),children:`restore this version`})]})]},e.id))})]})}function ng({at:e,comments:t,slide:n,slot:r,onSlot:i,onGo:a,onClose:o}){let s=Mh(e.project),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(``),g=async()=>{if(!c.trim())return;let t=await A.request(`presentations.comment`,{name:e.name,query:s,body:{slide:n,text:c,...r?{slot:r}:{}}});if(!t.ok)return h(P(t));l(``),h(``)},_=async(t,n)=>{let r=await A.request(`presentations.commentSave`,{name:e.name,id:t,query:s,body:n});if(!r.ok)return h(P(r));p(e=>({...e,[t]:``}))},y=async t=>{let n=await A.request(`presentations.commentDelete`,{name:e.name,id:t,query:s});n.ok||h(P(n))},b=t.filter(e=>u||!e.resolved).sort((e,t)=>(e.n===n?-1:0)-(t.n===n?-1:0)||(e.n??999)-(t.n??999)||e.at.localeCompare(t.at));return(0,z.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-3 text-sm`,role:`region`,"aria-label":`comments`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(B,{name:`comment`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`font-semibold`,children:`Comments`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-fg-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),"aria-label":`show resolved`}),`resolved`]}),(0,z.jsx)(q,{icon:`close`,label:`close comments`,size:`sm`,onClick:o})]}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-1.5 rounded-lg border border-line bg-bg p-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`on slide `,n,r?(0,z.jsxs)(z.Fragment,{children:[` `,`· box `,(0,z.jsx)(`b`,{children:r}),` `,(0,z.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>i(void 0),children:`(the whole slide)`})]}):` (select a box to comment on it)`]}),(0,z.jsx)(`textarea`,{value:c,"aria-label":`new comment`,rows:2,placeholder:`What should change here?`,className:`resize-y rounded-md border border-line bg-surface p-1.5 text-sm text-fg outline-none focus:border-accent`,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),void g())}),(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(K,{size:`sm`,variant:`primary`,type:`submit`,disabled:!c.trim(),children:`comment`})})]}),m&&(0,z.jsx)(`span`,{className:`text-xs text-bad`,children:m}),b.length===0&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`No `,u?``:`open `,"comments. Agents see them too: `kraftwerk presentations comments`."]}),(0,z.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`comment list`,children:b.map(e=>(0,z.jsxs)(`li`,{className:I(`flex flex-col gap-1 rounded-lg border p-2`,e.n===n?`border-accent/50`:`border-line`,e.resolved&&`opacity-60`),"aria-label":`comment by ${e.author}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-2`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`font-semibold text-fg hover:text-accent`,onClick:()=>e.n&&a(e.n,e.slot),children:[`slide `,e.n??`?`,e.slot?` · ${e.slot}`:``]}),(0,z.jsxs)(`span`,{children:[`· `,e.author]}),(0,z.jsxs)(`span`,{children:[`· `,G(e.at)]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(q,{icon:e.resolved?`replay`:`check_circle`,label:e.resolved?`reopen`:`resolve`,size:`sm`,onClick:()=>void _(e.id,{resolved:!e.resolved})}),(0,z.jsx)(q,{icon:`delete`,label:`delete comment`,size:`sm`,onClick:()=>void y(e.id)})]}),(0,z.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.text}),e.replies.map((e,t)=>(0,z.jsxs)(`p`,{className:`ml-3 border-l-2 border-line pl-2 text-xs`,children:[(0,z.jsx)(`b`,{children:e.author}),` · `,G(e.at),(0,z.jsx)(`br`,{}),e.text]},t)),!e.resolved&&(0,z.jsx)(`form`,{className:`flex gap-1`,onSubmit:t=>{t.preventDefault(),f[e.id]?.trim()&&_(e.id,{reply:f[e.id]})},children:(0,z.jsx)(`input`,{value:f[e.id]??``,"aria-label":`reply to ${e.id}`,placeholder:`reply…`,className:`h-7 min-w-0 flex-1 rounded-md border border-line bg-bg px-1.5 text-xs text-fg outline-none focus:border-accent`,onChange:t=>p(n=>({...n,[e.id]:t.target.value}))})})]},e.id))})]})}function rg({items:e}){return(0,z.jsx)(`ul`,{className:`flex flex-col gap-1 text-xs`,"aria-label":`warnings`,children:e.map((e,t)=>(0,z.jsxs)(`li`,{className:I(`flex items-start gap-1.5`,e.level===`error`?`text-bad`:`text-fg-2`),children:[(0,z.jsx)(B,{name:e.level===`error`?`error`:`warning`,className:`ms-sm mt-px`}),(0,z.jsxs)(`span`,{children:[e.slide?`slide ${e.slide}`:`deck`,e.slot?` · ${e.slot}`:``,`: `,e.message]})]},t))})}function ig({project:e,name:t,presenter:n,start:r}){let i={project:e,name:t},a=F(`presentations.get`,{name:t,query:Mh(e)},{interval:1e4}),o=(a?.deck.slides??[]).map((e,t)=>({s:e,i:t})).filter(e=>!Uh(e.s)),s=Math.max(1,o.findIndex(e=>e.i>=r-1)+1),[c,l]=(0,v.useState)(s),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({w:window.innerWidth,h:window.innerHeight}),[m]=(0,v.useState)(Date.now()),[h,g]=(0,v.useState)(Date.now()),_=o.length,y=e=>a?.deck.numbers===!1?void 0:{n:e,of:_},b=Nh(i),x=e=>l(Math.min(Math.max(1,e),Math.max(1,_))),S=a?.theme;oh(S?[S]:[],a?.deck.css);let C=(0,v.useMemo)(()=>Fh(i,a?.updatedAt??``),[t,e,a?.updatedAt]),w=o[c-1]?.s,T=o[c]?.s,E=lh(w,S,C),D=lh(T,S,C);(0,v.useEffect)(()=>l(s),[s]),(0,v.useEffect)(()=>{let e=()=>p({w:window.innerWidth,h:window.innerHeight}),t=setInterval(()=>g(Date.now()),1e3),n=e=>{e.key===`ArrowRight`||e.key===` `||e.key===`PageDown`||e.key===`Enter`?(e.preventDefault(),l(e=>Math.min(e+1,Math.max(1,_)))):e.key===`ArrowLeft`||e.key===`PageUp`||e.key===`Backspace`?(e.preventDefault(),l(e=>Math.max(1,e-1))):e.key===`Home`?l(1):e.key===`End`?l(Math.max(1,_)):e.key===`Escape`?H(b):e.key===`n`||e.key===`N`?d(e=>!e):(e.key===`f`||e.key===`F`)&&document.documentElement.requestFullscreen?.().catch(()=>{})};return window.addEventListener(`keydown`,n),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,e),clearInterval(t)}},[_,b]);let O=S?Lm(S.size):900,k=Math.floor((h-m)/1e3),ee=`${String(Math.floor(k/60)).padStart(2,`0`)}:${String(k%60).padStart(2,`0`)}`;if(n){let e=Math.min(f.w*.62,(f.h-120)*gm/O);return(0,z.jsxs)(`div`,{className:`fixed inset-0 z-[1000] flex select-none flex-col gap-4 bg-[#111] p-6 text-white`,role:`region`,"aria-label":`presenter view`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-white/70`,children:[(0,z.jsx)(`button`,{type:`button`,className:`hover:text-white`,onClick:()=>H(b),children:`← back to the editor (Esc)`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(`span`,{children:a?.title}),(0,z.jsxs)(`span`,{className:`tabular-nums`,"aria-label":`slide counter`,children:[c,` / `,_]}),(0,z.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums text-white`,"aria-label":`elapsed time`,children:ee})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-6`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-white/50`,children:`now`}),E&&S&&(0,z.jsx)(`div`,{role:`img`,"aria-label":`slide ${c} of ${_}`,children:(0,z.jsx)(ch,{view:E,theme:S,width:e,number:y(c)})})]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,z.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-white/50`,children:`next`}),D&&S?(0,z.jsx)(ch,{view:D,theme:S,width:Math.min(360,f.w*.3),thumb:!0,number:y(c+1)}):(0,z.jsx)(`span`,{className:`text-sm text-white/40`,children:`the end`}),(0,z.jsx)(`span`,{className:`mt-2 text-xs uppercase tracking-wider text-white/50`,children:`notes`}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap text-xl leading-8 text-white/90`,"aria-label":`speaker notes`,children:w?.notes||(0,z.jsx)(`span`,{className:`text-white/40`,children:`no notes on this slide`})})]})]})]})}let A=f.h-36-(u?Math.min(f.h*.3,180):0),j=Math.min(f.w,A*gm/O);return(0,z.jsxs)(`div`,{className:`fixed inset-0 z-[1000] flex select-none flex-col bg-black text-white`,role:`region`,"aria-label":`presentation`,children:[(0,z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center`,children:[E&&S?(0,z.jsx)(`div`,{className:E.transition===`slide`?`animate-[deckslide_420ms_cubic-bezier(.2,.7,.2,1)] motion-reduce:animate-none`:E.transition===`zoom`?`animate-[deckzoom_380ms_cubic-bezier(.2,.7,.2,1)] motion-reduce:animate-none`:E.transition===`none`?``:`animate-[deckfade_300ms_ease-out] motion-reduce:animate-none`,"data-transition":E.transition,role:`img`,"aria-label":`slide ${c} of ${_}`,children:(0,z.jsx)(ch,{view:E,theme:S,width:j,number:y(c)})},c):(0,z.jsx)(`span`,{className:`text-white/60`,children:a?`this deck has no slides`:`loading…`}),(0,z.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 left-0 w-1/4 cursor-w-resize opacity-0`,"aria-label":`previous slide`,onClick:()=>x(c-1)}),(0,z.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 w-1/4 cursor-e-resize opacity-0`,"aria-label":`next slide`,onClick:()=>x(c+1)})]}),u&&(0,z.jsx)(`div`,{className:`max-h-[30vh] overflow-auto border-t border-white/20 bg-black/90 px-6 py-3 text-base leading-6 text-white/90`,"aria-label":`speaker notes`,children:w?.notes||(0,z.jsx)(`span`,{className:`text-white/50`,children:`no notes on this slide`})}),(0,z.jsxs)(`div`,{className:`flex h-9 items-center gap-3 px-4 text-xs text-white/60`,children:[(0,z.jsx)(`button`,{type:`button`,className:`hover:text-white`,onClick:()=>H(b),children:`← back to the editor (Esc)`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(`span`,{children:a?.title}),(0,z.jsxs)(`span`,{children:[c,` / `,_]}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:ee}),(0,z.jsx)(`button`,{type:`button`,className:I(`hover:text-white`,u&&`text-white`),onClick:()=>d(e=>!e),"aria-pressed":u,children:`notes (N)`}),(0,z.jsx)(`span`,{children:`fullscreen (F)`})]})]})}function ag({project:e,name:t}){let n={project:e,name:t},r=F(`presentations.get`,{name:t,query:Mh(e)},{interval:1e4}),i=r?.theme;oh(i?[i]:[],r?.deck.css);let a=(0,v.useMemo)(()=>Fh(n,r?.updatedAt??``),[t,e,r?.updatedAt]),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=o.current;if(!e)return;let t=new ResizeObserver(()=>c(Math.floor(e.clientWidth)));return t.observe(e),()=>t.disconnect()},[]);let l=r?.deck.slides??[],u=r?.deck.numbers!==!1;return(0,z.jsxs)(`div`,{ref:o,className:`deck-glance flex flex-col gap-3`,"aria-label":`slides`,children:[!r&&(0,z.jsx)(Y,{children:`loading…`}),r&&l.length===0&&(0,z.jsx)(Y,{icon:`slideshow`,children:`No slides yet.`}),i&&s>0&&l.map((e,t)=>(0,z.jsx)(U,{href:Nh(n),className:I(`block overflow-hidden rounded-lg border border-line no-underline shadow-sm transition-shadow hover:shadow-md`,Uh(e)&&`opacity-40`),title:`slide ${t+1}`,"data-slide":t+1,children:(0,z.jsx)(uh,{slide:e,theme:i,asset:a,width:s-2,number:u?{n:t+1,of:l.length}:void 0})},t))]})}var og=e=>e==null?``:String(e),sg={contacts:{singular:`contact`,icon:`person`,what:`people and organisations the workspace works with`,fields:[{name:`role`,label:`role`,type:`text`,hint:`What they do (CTO, project lead)`},{name:`org`,label:`organisation`,type:`text`,hint:`Company or organisation`},{name:`email`,label:`email`,type:`email`,hint:`Email address`},{name:`phone`,label:`phone`,type:`text`,hint:`Phone number`},{name:`place`,label:`place`,type:`ref`,refKind:`places`,hint:`Slug of the place they are usually at`},{name:`url`,label:`website`,type:`url`,hint:`https://…`}],describe:e=>[og(e.role),og(e.org)].filter(Boolean).join(`, `)},places:{singular:`place`,icon:`location_on`,what:`addresses and points of interest`,fields:[{name:`address`,label:`address`,type:`text`,hint:`Street, number, postcode, town`},{name:`lat`,label:`latitude`,type:`number`,hint:`47.05`},{name:`lng`,label:`longitude`,type:`number`,hint:`8.30`},{name:`url`,label:`website`,type:`url`,hint:`https://…`}],describe:e=>og(e.address)},events:{singular:`event`,icon:`event`,what:`dated, one-off entries — a meeting, a launch, a deadline`,fields:[{name:`start`,label:`start`,type:`date`,required:!0,hint:`2026-11-03 or 2026-11-03T14:00`},{name:`end`,label:`end`,type:`date`,hint:`not before start`},{name:`place`,label:`place`,type:`ref`,refKind:`places`,hint:`Slug of the place`},{name:`contacts`,label:`contacts`,type:`refs`,refKind:`contacts`,hint:`Contact slugs, comma-separated`},{name:`project`,label:`project`,type:`ref`,refKind:`projects`,hint:`Slug of the project`},{name:`url`,label:`link`,type:`url`,hint:`https://…`}],describe:e=>`${og(e.start).replace(`T`,` `)}${e.end?`–${og(e.end).replace(`T`,` `)}`:``}`}},cg=(e,t)=>`${e}.${t}`,lg=(e,t)=>A.request(cg(e,`get`),{slug:t}),ug=(e,t,n)=>A.request(cg(e,`save`),{slug:t,body:n}),dg=(e,t)=>A.request(cg(e,`create`),{body:t}),fg=(e,t)=>A.request(cg(e,`delete`),{slug:t}),pg=()=>new Date().toISOString().slice(0,10);function mg(e,t){if(e!==`events`)return t;let n=pg(),r=t.filter(e=>og(e.end||e.start).slice(0,10)>=n),i=t.filter(e=>og(e.end||e.start).slice(0,10)<n).reverse();return[...r,...i]}function hg({kind:e,slug:t}){let n=sg[e],r=F(cg(e,`list`),{}),[i,a]=(0,v.useState)(``),o=mg(e,r?.items??[]),s=i.trim()?o.filter(e=>`${e.title} ${e.slug} ${n.describe(e)} ${e.tags.join(` `)}`.toLowerCase().includes(i.trim().toLowerCase())):o,c=t===`new`,l=e===`events`?new Set(o.filter(e=>og(e.end||e.start).slice(0,10)<pg()).map(e=>e.slug)):new Set;return(0,z.jsxs)(`div`,{className:`runs-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:e,count:r?.items.length,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,href:`/${e}/new`,children:`new`})}),o.length>6&&(0,z.jsx)(At,{value:i,placeholder:`find a ${n.singular}…`,"aria-label":`find a ${n.singular}`,onChange:e=>a(e.target.value)}),(0,z.jsxs)(jt,{label:e,children:[s.map(r=>(0,z.jsx)(gt,{href:`/${e}/${encodeURIComponent(r.slug)}`,active:r.slug===t,size:`sm`,dim:l.has(r.slug),leading:r.configError?(0,z.jsx)(et,{tone:`bad`,title:r.configError}):(0,z.jsx)(B,{name:n.icon,className:`ms-sm`}),title:r.title,sub:r.configError?`unreadable frontmatter`:n.describe(r)||void 0},r.slug)),r&&!r.enabled&&(0,z.jsx)(Mt,{children:r.error}),r?.enabled&&o.length===0&&(0,z.jsxs)(Mt,{children:[`no `,e,` yet`]})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:t&&!c?(0,z.jsx)(vg,{kind:e,slug:t},`${e}/${t}`):c?(0,z.jsx)(yg,{kind:e}):(0,z.jsx)(Y,{icon:n.icon,action:r?.enabled?(0,z.jsxs)(K,{variant:`primary`,icon:`add`,href:`/${e}/new`,children:[`new `,n.singular]}):void 0,children:r&&!r.enabled?r.error:(0,z.jsxs)(z.Fragment,{children:[e,`: `,n.what,`. One Markdown file each under the `,e,` root; reference one anywhere as `,(0,z.jsxs)(`code`,{children:[n.singular,`:<slug>`]}),`.`]})})})]})}function gg({field:e,value:t,onChange:n,disabled:r}){return(0,z.jsx)(Z,{value:t,placeholder:e.hint,"aria-label":`${e.label}`,inputMode:e.type===`number`?`decimal`:void 0,type:e.type===`email`?`email`:`text`,disabled:r,onChange:e=>n(e.target.value)})}function _g({links:e,refKind:t}){return e?.length?(0,z.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,z.jsxs)(J,{tone:e.found?`neutral`:`bad`,title:e.found?e.label:`not found in this workspace`,children:[e.found?(0,z.jsx)(U,{href:`/${t}/${encodeURIComponent(e.slug)}`,className:`text-inherit no-underline hover:underline`,children:e.slug}):e.slug,!e.found&&` · not found`]},e.slug))}):null}function vg({kind:e,slug:t}){let n=sg[e],[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!0),O=e=>{i(e),c(e.title),u(Object.fromEntries(n.fields.map(t=>[t.name,Array.isArray(e[t.name])?e[t.name].join(`, `):og(e[t.name])]))),f(e.tags.join(`, `)),m(e.notes),g(!1)};(0,v.useEffect)(()=>{let n=!0;return lg(e,t).then(e=>{n&&(e.ok?O(e.data):o(P(e)))}),()=>{n=!1}},[e,t]);let k=()=>{g(!0),x(!1),C(``)},ee=async(n,r={})=>{y(!0),C(``);try{let a=await ug(e,t,n);if(!a.ok)throw Error(P(a));r.keepEdits?i(a.data):(O(a.data),D(!0)),x(!0)}catch(e){C(e.message)}finally{y(!1)}},A=()=>ee({title:s,tags:d,notes:p,...Object.fromEntries(n.fields.map(e=>[e.name,l[e.name]??``]))}),j=async()=>{let n=await fg(e,t);if(!n.ok)return C(P(n));H(`/${e}`,{replace:!0})},M=(0,v.useMemo)(()=>p.trim()?To(fo.sanitize(Mi.parse(p,{async:!1}))):``,[p]);if(a&&!r)return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:n.icon,title:t}),(0,z.jsx)(rt,{tone:`bad`,children:a})]});if(!r)return(0,z.jsx)(Y,{children:`loading…`});let N=e===`places`?og(r.mapsUrl):``;return(0,z.jsxs)(ct,{className:`${n.singular}-page`,children:[(0,z.jsx)(st,{icon:n.icon,title:(0,z.jsx)(Z,{value:s,"aria-label":`${n.singular} title`,className:`h-auto border-0 bg-transparent px-0 text-xl font-semibold shadow-none`,onChange:e=>{c(e.target.value),k()}}),sub:(0,z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`code`,{className:`font-mono text-xs`,children:[n.singular,`:`,r.slug]}),r.updatedAt&&(0,z.jsxs)(`span`,{children:[`changed `,G(r.updatedAt)]}),N&&(0,z.jsxs)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent`,children:[(0,z.jsx)(B,{name:`map`,className:`ms-sm`}),` open in Google Maps`]})]}),actions:(0,z.jsxs)(z.Fragment,{children:[S&&(0,z.jsx)(`span`,{className:`text-sm text-bad`,children:S}),b&&!h&&(0,z.jsx)(`span`,{className:`text-sm text-fg-2`,children:`saved`}),(0,z.jsx)(K,{variant:`primary`,icon:`save`,busy:_,disabled:!h||_||!s.trim(),onClick:()=>void A(),children:`save`}),w?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{variant:`danger`,onClick:()=>void j(),children:`move to trash`}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>T(!1),children:`cancel`})]}):(0,z.jsx)(K,{variant:`quiet`,icon:`delete`,title:`move to the trash`,onClick:()=>T(!0),children:`remove`})]})}),r.configError&&(0,z.jsxs)(rt,{tone:`bad`,children:[`frontmatter: `,r.configError,` — the fields below show defaults and cannot be saved; fix the file by hand first.`]}),(0,z.jsx)(X,{title:`fields`,className:`flex-none`,children:(0,z.jsxs)(Ct,{className:`max-w-[760px]`,children:[n.fields.map(e=>(0,z.jsx)(Q,{label:`${e.label}${e.required?` *`:``}`,hint:e.type===`ref`||e.type===`refs`?(0,z.jsx)(_g,{links:r.links[e.name],refKind:e.refKind}):void 0,children:(0,z.jsx)(gg,{field:e,value:l[e.name]??``,onChange:t=>{u(n=>({...n,[e.name]:t})),k()}})},e.name)),(0,z.jsx)(wt,{children:(0,z.jsx)(Q,{label:`tags`,className:`flex-1`,children:(0,z.jsx)(Z,{value:d,placeholder:`comma-separated`,"aria-label":`tags`,onChange:e=>{f(e.target.value),k()}})})}),r.extra&&Object.keys(r.extra).length>0&&(0,z.jsxs)(`div`,{className:`text-xs text-fg-2`,children:[`Also in the file, kept as written: `,Object.entries(r.extra).map(([e,t])=>`${e}: ${typeof t==`string`?t:JSON.stringify(t)}`).join(` · `)]})]})}),(0,z.jsx)(X,{title:`notes`,className:`flex-none`,actions:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:E?`edit`:`visibility`,onClick:()=>D(e=>!e),children:E?`edit`:`preview`}),children:E?M?(0,z.jsx)(`div`,{className:`md-body px-[18px] py-3`,dangerouslySetInnerHTML:{__html:M}}):(0,z.jsx)(`div`,{className:`px-[18px] py-3 text-xs text-fg-2`,children:`no notes yet — Markdown; reference other entries as contact:<slug>, place:<slug>, event:<slug>`}):(0,z.jsx)(Ct,{children:(0,z.jsx)(xt,{value:p,"aria-label":`notes`,rows:10,className:`font-mono text-[13px]`,placeholder:`Markdown notes`,onChange:e=>{m(e.target.value),k()}})})}),(0,z.jsx)(px,{records:r.records,saving:_,onSave:e=>ee({records:e},{keepEdits:!0})})]})}function yg({kind:e}){let t=sg[e];return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:t.icon,title:`new ${t.singular}`,sub:`a Markdown file under the ${e} root; the file name derives from the title`}),(0,z.jsx)(X,{children:(0,z.jsx)(bg,{kind:e})})]})}function bg({kind:e,onCreated:t,onCancel:n}){let r=sg[e],[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),f=async()=>{l(!0),d(``);try{let n=await dg(e,{title:i,...o});if(!n.ok)throw Error(P(n));t?t(n.data.slug):H(`/${e}/${encodeURIComponent(n.data.slug)}`,{replace:!0})}catch(e){d(e.message)}finally{l(!1)}};return(0,z.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&f()},children:(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsx)(Q,{label:`title`,children:(0,z.jsx)(Z,{value:i,"aria-label":`${r.singular} title`,autoFocus:!0,placeholder:e===`contacts`?`e.g. Anna Meier`:e===`places`?`e.g. NETNODE Office`:`e.g. Kickoff`,onChange:e=>a(e.target.value)})}),r.fields.map(e=>(0,z.jsx)(Q,{label:`${e.label}${e.required?` *`:``}`,children:(0,z.jsx)(gg,{field:e,value:o[e.name]??``,onChange:t=>s(n=>({...n,[e.name]:t}))})},e.name)),(0,z.jsxs)(wt,{children:[(0,z.jsxs)(K,{variant:`primary`,type:`submit`,icon:`add`,busy:c,disabled:!i.trim()||c,children:[`create `,r.singular]}),n?(0,z.jsx)(K,{variant:`quiet`,onClick:n,children:`cancel`}):(0,z.jsx)(K,{variant:`quiet`,href:`/${e}`,children:`cancel`}),u&&(0,z.jsx)(`span`,{className:`text-sm text-bad`,children:u})]})]})})}function xg(){return F(`workflows.runner`,{slug:`any`},{interval:15e3})}var Sg=e=>!!e?.available&&!!e?.image;function Cg(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function wg(e,t){return(await A.call(`workflows.run`,{slug:e,body:t})).runId}function Tg(e,t,n,r){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=xg();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]);let h=!u&&(!t||!!i.trim())&&(!o||Sg(m));async function g(){if(h){d(!0),p(null);try{let t=await wg(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):H(`/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 Eg({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=Yt(),a=Tg(e,t,n,r??(e=>i(`/runs/${e}`))),o=Cg(a.docker);return(0,z.jsx)(Rt,{label:`run ${e}`,className:`run-form`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`account_tree`,className:`ms-sm`}),` `,e]}),chipTitle:`the workflow this starts`,value:a.request,onChange:a.setRequest,inputLabel:`request`,placeholder:`Request`,noInput:t?void 0:`This workflow takes no request.`,onSend:()=>void a.launch(),sendLabel:`Run`,sendIcon:`play_arrow`,busy:a.busy,disabled:!a.canRun,error:a.error,controls:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Dg,{label:`Docker sandbox`,hint:o,checked:a.sandbox,onChange:a.setSandbox}),a.sandbox&&(0,z.jsx)(Dg,{label:`Forward SSH agent`,hint:`keys and known hosts from this machine`,checked:a.ssh,onChange:a.setSsh})]}),hint:a.sandbox?o:`runs on this machine`})}function Dg({label:e,hint:t,checked:n,onChange:r}){return(0,z.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,title:t,className:`inline-flex cursor-pointer items-center gap-1.5 rounded-full border-0 bg-transparent px-2.5 py-1 text-sm font-medium text-fg transition-colors hover:bg-surface-2`,onClick:()=>r(!n),children:[(0,z.jsx)(`span`,{className:`-mx-1.5 inline-flex scale-[0.7]`,children:(0,z.jsx)(Et,{checked:n})}),e]})}function Og({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,z.jsx)(`section`,{className:I(kg,`decision-panel is-decided`),"aria-label":`decision`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,z.jsx)(`div`,{className:Ag,children:n.title??`Decision`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-base`,children:[(0,z.jsx)(J,{tone:`ok`,children:f(r.decision)}),r.note&&(0,z.jsxs)(`span`,{className:`text-fg-2`,children:[`“`,r.note,`”`]}),r.decidedAt&&(0,z.jsx)(`span`,{className:`text-xs tabular-nums text-fg-2`,children:Ke(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,z.jsx)(`section`,{className:I(kg,`decision-panel`),"aria-label":`decision needed`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(et,{tone:`working`}),(0,z.jsx)(`div`,{className:Ag,children:n.title??`This run needs your decision`})]}),n.prompt&&(0,z.jsx)(`p`,{className:`m-0 max-w-[80ch] text-base text-fg-2`,children:n.prompt}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2 self-start`,role:`radiogroup`,"aria-label":`options`,children:n.options.map(e=>(0,z.jsx)(K,{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,z.jsx)(Z,{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,z.jsx)(rt,{tone:`bad`,children:u}),(0,z.jsx)(`div`,{className:`flex gap-2`,children:(0,z.jsx)(K,{variant:`primary`,onClick:m,disabled:!p,busy:c,children:c?`Saving…`:`Submit decision`})})]})})}var kg=`mb-[18px] overflow-hidden rounded-card border border-line bg-surface`,Ag=`text-[16px] font-medium text-fg`;function jg(e){return e===`ok`?`ok`:e===`running`?`working`:e===`failed`||e===`blocked`?`bad`:`idle`}function Mg({status:e}){return(0,z.jsx)(`span`,{"data-ui":`status`,"data-status":e,className:`inline-flex`,children:(0,z.jsx)(J,{tone:e===`ok`?`ok`:e===`failed`||e===`blocked`?`bad`:e===`running`?`accent`:`neutral`,children:e})})}function Ng(){return(0,z.jsx)(`span`,{"data-ui":`decision`,className:`inline-flex`,children:(0,z.jsx)(J,{tone:`accent`,children:`decision needed`})})}function Pg({label:e,children:t,className:n}){return(0,z.jsxs)(`div`,{className:n,children:[(0,z.jsx)(it,{className:`mb-px block`,children:e}),(0,z.jsx)(`div`,{className:`font-mono text-md font-medium tabular-nums text-fg`,children:t})]})}var Fg=`mb-[22px] flex flex-wrap gap-[26px]`;function Ig({id:e,workflow:t}){let n=F(`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,z.jsxs)(`div`,{className:`runs-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`runs`,back:{href:`/workflows`,label:`back to workflows`},count:i?`${o.length} / ${r.length}`:r.length}),(0,z.jsx)(At,{icon:`filter_list`,value:i,placeholder:`filter by workflow or request`,"aria-label":`filter runs`,onChange:e=>a(e.target.value)}),(0,z.jsxs)(jt,{label:`runs list`,children:[o.map(t=>(0,z.jsx)(Lg,{r:t,active:t.id===e},t.id)),n&&r.length===0&&(0,z.jsx)(Mt,{children:`no runs yet`}),r.length>0&&o.length===0&&(0,z.jsxs)(Mt,{children:[`no run matches “`,i,`”`]})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:(0,z.jsx)(Rg,{id:e},e)})]})}function Lg({r:e,active:t}){return(0,z.jsx)(gt,{href:`/runs/${e.id}`,active:t,size:`sm`,leading:(0,z.jsx)(et,{tone:jg(e.status),title:e.status}),title:e.workflow??`unknown`,meta:Ke(e.startedAt),sub:(0,z.jsxs)(`span`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.request,children:e.status===`running`&&e.currentPhase?`${e.currentPhase}`:e.request??``}),(0,z.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.status===`running`?(0,z.jsx)(qe,{since:e.startedAt}):Ue(e.durationMs)})]})})}function Rg({id:e}){let t=F(`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=Se();if(!t)return(0,z.jsx)(Y,{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=>!Gg(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);n?.ok?H(t?.workflow?`/workflows/${encodeURIComponent(t.workflow)}`:`/workflows`):c(n?.error??`remove failed`)}return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5`,children:[(0,z.jsx)(et,{tone:jg(t.status),title:t.status}),(0,z.jsx)(ot,{size:`lg`,children:t.workflow?(0,z.jsx)(U,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,className:`text-inherit no-underline hover:text-accent`,children:t.workflow}):`unknown workflow`}),(0,z.jsx)(Mg,{status:t.status}),u&&(0,z.jsxs)(J,{children:[(0,z.jsx)(B,{name:`science`,className:`ms-sm mr-1`}),` sandbox`]}),(0,z.jsx)(`span`,{className:`font-mono text-xs text-fg-2`,children:e.replace(/^run-/,``)}),n?(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`stop`,busy:a,onClick:p,children:a?`stopping…`:`stop`}):(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,onClick:m,title:`delete this run's folder`,children:`remove`}),s&&(0,z.jsx)(`span`,{className:`text-xs text-bad`,children:s}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,title:`chat with an agent about this run`,onClick:()=>void Yo(`claude`,{kind:`run`,runId:e}),children:`⌬ discuss`}),(0,z.jsx)(_t,{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,z.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:t.request}),d===`run`?(0,z.jsx)(zg,{run:t,live:n}):(0,z.jsx)(qg,{id:e,files:t.files,live:n})]})}function zg({run:e,live:t}){return(0,z.jsxs)(`div`,{className:`max-w-[1080px]`,children:[e.decision&&(0,z.jsx)(Og,{runId:e.id,decision:e.decision}),(0,z.jsxs)(`div`,{className:Fg,children:[(0,z.jsxs)(Pg,{label:`phases`,children:[e.phasesDone,e.phasesTotal==null?``:` / ${e.phasesTotal}`]}),(0,z.jsx)(Pg,{label:`duration`,children:t?(0,z.jsx)(qe,{since:e.startedAt}):Ue(e.durationMs)}),(0,z.jsx)(Pg,{label:`cost`,children:We(e.costUsd??Vg(e.phases))}),(0,z.jsxs)(Pg,{label:`tokens in / out`,children:[Ge(Bg(e.phases,`tokensIn`)),` / `,Ge(Bg(e.phases,`tokensOut`))]})]}),(0,z.jsx)(X,{title:`phase timeline`,actions:t&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-[7px] text-2xs text-fg-2`,children:[(0,z.jsx)(et,{tone:`working`}),` live · polling`]}),children:(0,z.jsx)(`div`,{className:`py-1.5`,children:e.phases.map(e=>(0,z.jsx)(Ug,{p:e},e.phase))})})]})}function Bg(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function Vg(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}var Hg=`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 Ug({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,z.jsxs)(`div`,{className:I(Hg,`py-2.5 pr-[18px] pl-[42px] before:left-[23px] first:before:top-4 last:before:h-4`),children:[(0,z.jsx)(`span`,{className:`absolute top-4 left-[19px] z-1 grid`,children:(0,z.jsx)(et,{tone:jg(e.status),title:e.status})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,z.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.phase}),e.kind===`agent`?(0,z.jsxs)(J,{tone:`accent`,children:[e.agent,e.model?` · ${e.model}`:``,e.protocol?` · ${e.protocol}`:``]}):(0,z.jsx)(J,{children:`script`}),e.status===`skipped`&&(0,z.jsx)(Mg,{status:`skipped`}),(0,z.jsxs)(`span`,{className:`ml-auto flex gap-3.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[e.attempts>1&&(0,z.jsxs)(`span`,{children:[`att `,e.attempts]}),e.status===`running`?(0,z.jsx)(qe,{since:e.startedAt}):e.durationMs!=null&&(0,z.jsx)(`span`,{children:Ue(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,z.jsxs)(`span`,{children:[Ge(e.tokensIn),` / `,Ge(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,z.jsx)(`span`,{children:We(e.costUsd)})]})]}),e.status===`running`&&e.lastActivity&&(0,z.jsxs)(`div`,{className:`mt-[3px] font-mono text-[11.5px] text-accent`,children:[`▸ `,e.lastActivity]}),e.summary&&e.status!==`running`&&(0,z.jsx)(`div`,{className:`mt-[3px] max-w-[72ch] text-[12.5px] text-fg-2`,children:e.summary}),e.gates.length>0&&(0,z.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,z.jsxs)(`span`,{className:I(`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,z.jsx)(B,{name:e.passed?`check`:`close`,className:`ms-sm`}),` `,e.gate]},e.gate))}),t.map(e=>(0,z.jsx)(`div`,{className:`mt-1 text-xs text-bad`,children:e.failure},e.gate))]})}var Wg=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function Gg(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function Kg(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)||Wg.has(t)?0:Gg(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function qg({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=Se(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!Gg(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&Gg(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(Kg(o))},[o,r]),(0,z.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,z.jsx)(X,{title:(0,z.jsxs)(z.Fragment,{children:[`files `,(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,o.length,`)`]})]}),className:`flex min-h-0 flex-col`,children:(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto max-[940px]:max-h-60`,children:[o.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:I(`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,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,z.jsx)(`span`,{className:`text-2xs tabular-nums text-fg-2`,children:W(e.size)})]},e.name)),o.length===0&&(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:t.length>0?`no result files — raw run files live in expert mode`:`no files yet`})]})}),(0,z.jsx)(X,{title:r??`viewer`,className:`flex min-h-0 flex-col`,actions:r&&(0,z.jsx)(`a`,{className:Jg,href:A.url(`runs.file`,{id:e,query:{name:r,raw:!0}}),target:`_blank`,children:`open raw ↗`}),children:r?(0,z.jsx)($g,{id:e,name:r,live:n}):(0,z.jsx)(Y,{className:`flex-1 justify-center`,children:`select a file`})})]})}var Jg=`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`,Yg=`flex min-h-0 flex-1 flex-col`,Xg=`min-h-0 flex-1`,Zg=`m-0 h-full overflow-auto px-[18px] py-3.5 text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,Qg=`block h-full min-h-[560px] w-full border-0 bg-white`;function $g({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,z.jsx)(`div`,{className:Yg,children:(0,z.jsx)(`div`,{className:Xg,children:(0,z.jsx)(`iframe`,{className:Qg,src:i,sandbox:`allow-scripts`,allow:`clipboard-write`,title:t})})}):r===`pdf`?(0,z.jsx)(`div`,{className:Yg,children:(0,z.jsx)(`div`,{className:Xg,children:(0,z.jsx)(`iframe`,{className:Qg,src:i,title:t})})}):Wg.has(r)?(0,z.jsx)(`div`,{className:Yg,children:(0,z.jsx)(`div`,{className:Xg,children:(0,z.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,z.jsx)(t_,{id:e,name:t,live:n}):(0,z.jsx)(n_,{id:e,name:t,live:n})}var e_=`flex items-center gap-3 border-b border-line/55 px-[18px] py-1.5 text-2xs text-fg-2`;function t_({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=F(`runs.fileText`,{id:e,query:{name:t}},{fast:n}),o=(0,v.useMemo)(()=>a?fo.sanitize(Mi.parse(a.content,{async:!1})):``,[a?.content]);return(0,z.jsxs)(`div`,{className:Yg,children:[(0,z.jsxs)(`div`,{className:e_,children:[(0,z.jsx)(_t,{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,z.jsxs)(`span`,{children:[`large file — showing the last `,W(4e5)]})]}),(0,z.jsx)(`div`,{className:I(Xg,`overflow-auto`),children:a?r===`rendered`?(0,z.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:{__html:o}}):(0,z.jsx)(`pre`,{className:Zg,children:a.content||`(empty)`}):(0,z.jsx)(`pre`,{className:Zg,children:`loading…`})})]})}function n_({id:e,name:t,live:n}){let r=F(`runs.fileText`,{id:e,query:{name:t}},{fast:n});return(0,z.jsxs)(`div`,{className:Yg,children:[r?.truncated&&(0,z.jsxs)(`div`,{className:e_,children:[`large file — showing the last `,W(4e5)]}),(0,z.jsx)(`div`,{className:Xg,children:(0,z.jsx)(`pre`,{className:Zg,children:r?r.content||`(empty)`:`loading…`})})]})}var r_=`\0done`,i_=5;function a_(e,t){return e.status===`ok`?r_:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??r_}var o_=[`var(--accent)`,`#4fb8a8`,`#a78bfa`,`#e5793b`];function s_(e){return e==null?`var(--text-2)`:o_[e%o_.length]}function c_({colour:e,children:t,small:n}){return(0,z.jsx)(`span`,{style:{"--aid":e},className:I(`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 l_({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,r_].map(e=>[e,[]]));for(let e of t)a.get(a_(e,i)).push(e);let o=a.get(r_)??[];return(0,z.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,z.jsx)(u_,{step:e.name,index:(0,z.jsx)(c_,{small:!0,colour:s_(e.agent?n.get(e.agent)??0:null),children:t+1}),count:i.length,children:(0,z.jsx)(d_,{cards:i,moreHref:r})},e.name)}),(0,z.jsx)(u_,{step:`done`,name:`done`,done:!0,index:(0,z.jsx)(c_,{small:!0,colour:`var(--ok)`,children:`✓`}),count:o.length,children:(0,z.jsx)(d_,{cards:o,moreHref:r})})]})}function u_({step:e,name:t,done:n,index:r,count:i,children:a}){return(0,z.jsxs)(`div`,{className:I(`board-col flex min-w-60 flex-[0_0_240px] flex-col gap-1.5`,n&&`is-done`),"data-step":e,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-0.5 pt-0.5 pb-1`,children:[r,(0,z.jsx)(`span`,{className:`board-col-name min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t??e,children:t??e}),(0,z.jsx)(`span`,{className:`board-col-count ml-auto font-mono text-[11.5px] tabular-nums text-fg-2`,children:i})]}),a]})}function d_({cards:e,moreHref:t}){return(0,z.jsxs)(`div`,{className:`flex min-h-14 flex-col gap-2 rounded-xl bg-surface-2/60 p-2`,children:[e.slice(0,i_).map(e=>(0,z.jsx)(f_,{r:e},e.id)),e.length===0&&(0,z.jsx)(`div`,{className:`board-col-empty py-3.5 text-center text-xs text-fg-2`,children:`—`}),e.length>i_&&(0,z.jsxs)(U,{href:t,className:`board-more block p-1.5 text-center text-xs text-fg-2 no-underline hover:text-accent`,children:[`+ `,e.length-i_,` more ↗`]})]})}function f_({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,z.jsxs)(U,{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,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(et,{tone:jg(e.status),title:e.status}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t,children:t})]}),(0,z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-2.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[(0,z.jsx)(`span`,{children:Ke(e.startedAt)}),(0,z.jsx)(`span`,{children:e.status===`running`?(0,z.jsx)(qe,{since:e.startedAt}):Ue(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,z.jsx)(`span`,{children:We(e.costUsd)})]}),(e.awaitingDecision||e.status===`failed`||e.status===`aborted`)&&(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[e.awaitingDecision&&(0,z.jsx)(Ng,{}),(e.status===`failed`||e.status===`aborted`)&&(0,z.jsx)(Mg,{status:e.status})]})]})}function p_({slug:e,tab:t}){let n=F(`workflows.get`,{slug:e}),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=F(`runs.list`,{},{fast:a>0||Date.now()-r<2e4});if(!n)return(0,z.jsx)(Y,{children:`loading…`});if(n.error)return(0,z.jsxs)(Y,{children:[(0,z.jsx)(J,{tone:`bad`,children:`broken workflow`}),(0,z.jsx)(`pre`,{className:`mt-3 text-left`,children:n.error}),(0,z.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,z.jsx)(h_,{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,z.jsxs)(z.Fragment,{children:[(0,z.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,z.jsx)(ot,{size:`lg`,className:`in-[.ctx-embed]:text-xl`,children:n.name??n.slug}),(0,z.jsx)(`span`,{className:`min-w-0 font-mono text-xs [overflow-wrap:anywhere] text-fg-2 in-[.ctx-embed]:hidden`,children:n.dir}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(_t,{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,z.jsxs)(z.Fragment,{children:[`runs `,(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,`)`]})]})}]})]}),n.description&&(0,z.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:n.description}),t===`overview`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`run-panel mb-[18px]`,children:(0,z.jsx)(Eg,{slug:n.slug,usesRequest:n.usesRequest,initialRequest:l[0]?.request,onLaunched:()=>i(Date.now())})}),(0,z.jsx)(X,{title:(0,z.jsxs)(z.Fragment,{children:[`board`,` `,(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,` runs`,d>0?`, ${d} live`:``,`)`]})]}),actions:l[0]&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,href:`${u}/runs`,className:`in-[.ctx-embed]:hidden`,children:`all runs ↗`}),children:(0,z.jsx)(l_,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})})]}),t===`details`&&(0,z.jsx)(m_,{wf:n,agentIdx:c}),t===`runs`&&(0,z.jsx)(g_,{runs:l})]})}function m_({wf:e,agentIdx:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:Fg,children:[(0,z.jsx)(Pg,{label:`agents`,children:e.agents.length}),(0,z.jsxs)(Pg,{label:`steps`,children:[e.steps.length,` `,(0,z.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,z.jsx)(Pg,{label:`workspace`,className:`max-w-[420px]`,children:(0,z.jsx)(`span`,{className:`text-[11.5px] font-normal whitespace-pre-wrap text-fg-2`,children:e.workspace})})]}),(0,z.jsx)(X,{title:`agents`,className:`mb-[18px]`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(280px,1fr))]`,children:[e.agents.map(e=>(0,z.jsx)(v_,{a:e,idx:t.get(e.id)??0},e.id)),e.agents.length===0&&(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`no agents — script-only workflow`})]})}),(0,z.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,z.jsx)(X,{title:`pipeline`,children:(0,z.jsx)(`div`,{className:`pipeline py-2`,children:e.steps.map((e,n)=>(0,z.jsx)(y_,{s:e,i:n,idx:e.agent?t.get(e.agent)??0:null},e.name))})}),(0,z.jsx)(X,{title:(0,z.jsxs)(z.Fragment,{children:[`folder `,(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,e.files.length,` files)`]})]}),children:(0,z.jsx)(`div`,{className:`max-h-[300px] overflow-auto`,children:e.files.map(e=>(0,z.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,z.jsx)(`div`,{className:`mt-[18px] in-[.ctx-embed]:hidden`,children:(0,z.jsx)(h_,{slug:e.slug})})]})}function h_({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`);H(`/workflows`,{replace:!0})}catch(e){o(e.message),n(!1)}finally{i(!1)}};return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{variant:`danger`,icon:`delete`,busy:r,onClick:()=>void s(),children:`confirm delete`}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>n(!1),children:`cancel`}),(0,z.jsx)(nt,{children:`its runs stay; the trash can put it back`})]}):(0,z.jsx)(K,{variant:`danger`,icon:`delete`,onClick:()=>n(!0),title:`Move the workflow's folder to the trash`,children:`delete workflow`})}),a&&(0,z.jsx)(rt,{tone:`bad`,children:a})]})}function g_({runs:e}){return e.length===0?(0,z.jsx)(Y,{children:`no runs of this workflow yet`}):(0,z.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,z.jsxs)(U,{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,z.jsx)(et,{tone:jg(e.status),title:e.status}),(0,z.jsx)(`span`,{className:`font-mono text-[12.5px] text-fg-2`,children:e.id.replace(/^run-/,``)}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,title:e.request,children:e.status===`running`&&e.currentPhase?e.currentPhase:e.request??``}),(0,z.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,z.jsx)(Ng,{}),(0,z.jsx)(Mg,{status:e.status}),(0,z.jsx)(`span`,{className:`h-1 w-[90px] overflow-hidden rounded-full bg-surface-2`,title:`${e.phasesDone}${t?` / ${t}`:``} steps`,children:(0,z.jsx)(`i`,{className:I(`block h-full rounded-full`,e.status===`ok`?`bg-ok`:e.status===`failed`?`bg-bad`:`bg-accent`),style:{width:`${n}%`}})}),(0,z.jsx)(`span`,{children:e.status===`running`?(0,z.jsx)(qe,{since:e.startedAt}):Ue(e.durationMs)}),(0,z.jsx)(`span`,{children:We(e.costUsd)}),(0,z.jsx)(`span`,{children:Ke(e.startedAt)})]})]},e.id)})})}var __=`border-line/55`;function v_({a:e,idx:t}){return(0,z.jsxs)(`div`,{className:I(`agent-card border-r border-b px-[18px] py-3.5`,__),children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`size-2.5 rounded-full`,style:{background:s_(t)}}),(0,z.jsx)(`b`,{className:`text-base font-medium text-fg`,children:e.name??e.id}),(0,z.jsxs)(`code`,{className:`text-2xs text-fg-2`,children:[`[`,e.id,`]`]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(J,{children:[e.model??`default`,e.effort?` · ${e.effort}`:``,e.protocol===`acp`?` · acp`:``]})]}),e.tools.length>0&&(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-[5px]`,children:e.tools.map(e=>(0,z.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,z.jsx)(`p`,{className:`mt-2 mb-0 text-xs leading-[1.55] whitespace-pre-wrap text-fg-2`,children:e.persona})]})}function y_({s:e,i:t,idx:n}){let r=e.kind===`script`?e.script:e.prompt;return(0,z.jsxs)(`div`,{className:I(`step-node flex gap-3.5 px-[18px] py-3 first:before:top-[18px] last:before:h-[18px] before:left-[31px]`,Hg),children:[(0,z.jsx)(c_,{colour:s_(n),children:t+1}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,z.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.name}),e.kind===`agent`?(0,z.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded-full border px-2 text-2xs font-semibold`,style:{color:s_(n??0),borderColor:`color-mix(in srgb, ${s_(n??0)} 50%, var(--line))`},children:[`agent · `,e.agent]}):(0,z.jsxs)(J,{children:[`script`,e.sourceRef?` · ${e.sourceRef}`:``]})]}),r&&(0,z.jsxs)(`details`,{className:`mt-1.5`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-2 select-none hover:text-accent`,children:e.kind===`agent`?`prompt`:`script`}),(0,z.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,z.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,z.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))})]})]})}async function b_(e,t){let n=window.open(``,`_blank`);if(!n)return;let r=t?`${e}/${t}`:e;n.document.write(`<title>${w_(r)}</title><body style="font-family:system-ui;padding:40px;color:#555">preparing ${w_(r)}…</body>`);let i,a=``;try{let[n,r]=await Promise.all([t?Promise.resolve([t]):A.call(`knowledge.get`,{bundle:e}).then(e=>e.concepts.map(e=>e.id)),A.call(`meta.get`).catch(()=>({}))]);if(a=r.workspaceName??``,i=await Promise.all(n.map(t=>A.call(`knowledge.concept`,{bundle:e,query:{id:t}}))),i.some(e=>typeof e?.id!=`string`))throw Error(`missing concept`)}catch{n.document.body.textContent=`could not load "${r}"`;return}let o=[],s=i.map(e=>{let t=[e.type,e.generated?.at?`updated ${e.generated.at.slice(0,10)}`:``,e.trustTier===`human-reviewed`?`human-reviewed`:``,(e.tags??[]).map(e=>`#${e}`).join(` `)].filter(Boolean).join(` · `),{md:n,notes:r}=S_(x_(e.body??``,null)),i=!e.title||e.title===e.id||e.title===e.id.split(`/`).pop(),{html:a,title:s}=C_(fo.sanitize(Mi.parse(n,{async:!1})),{title:e.title||e.id,meta:t,titleIsFallback:i});return o.push(s),`<article>
339
339
  ${a}
340
340
  ${r.length?`<ol class="notes">${r.map(e=>`<li id="fn-${w_(e.id)}">${fo.sanitize(Mi.parseInline(e.text,{async:!1}))}</li>`).join(``)}</ol>`:``}
341
341
  </article>`}).join(`
@@ -460,30 +460,30 @@ series:
460
460
  </table>
461
461
  <script>setTimeout(() => window.print(), 400);<\/script>
462
462
  </body>
463
- </html>`;n.location.href=URL.createObjectURL(new Blob([f],{type:`text/html`}))}function x_(e,t){return e.split(/(```[\s\S]*?```|`[^`]*`)/).map((e,n)=>n%2==1?e:e.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(e,n,r)=>{let i=n.trim().replace(/\.md$/,``),a=(r??i).trim();return t===null?a:`[${a}](#/knowledge/${encodeURIComponent(t)}/${i})`})).join(``)}function S_(e){let t=[];return{md:e.replace(/^\[\^([^\]]+)\]:[ \t]*(.+)$/gm,(e,n,r)=>(t.push({id:n,text:r.trim()}),``)).replace(/\[\^([^\]]+)\]/g,(e,n)=>{let r=t.findIndex(e=>e.id===n);return r>=0?`<sup class="fnref">${r+1}</sup>`:``}),notes:t}}function C_(e,t){let n=new DOMParser().parseFromString(e,`text/html`),r=t.title,i=n.body.firstElementChild;t.titleIsFallback&&i?.tagName===`H1`&&(r=i.textContent?.trim()||r,i.remove());let a=n.createElement(`header`);a.innerHTML=`<h1>${w_(r)}</h1><div class="meta">${w_(t.meta)}</div>`,n.body.prepend(a);for(let e of n.querySelectorAll(`table`)){e.classList.add(`md`);for(let t of e.querySelectorAll(`th, td`))(t.textContent??``).trim().length<=14&&t.classList.add(`nw`)}for(let e of[5,4,3,2,1])for(let t of Array.from(n.body.querySelectorAll(`:scope > h${e}`))){let r=n.createElement(`h${e+1}`);r.innerHTML=t.innerHTML,t.replaceWith(r)}for(let e of Array.from(n.body.querySelectorAll(`:scope > header, :scope > h2, :scope > h3, :scope > h4`))){let t=e.nextElementSibling;if(!t||/^H[1-6]$/.test(t.tagName))continue;let r=n.createElement(`div`);r.className=`keep`,e.replaceWith(r),r.append(e,t)}return{html:n.body.innerHTML,title:r}}function w_(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var T_=(0,v.lazy)(()=>Rs(()=>import(`./editor-A9_YWc5F.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),E_=()=>Rs(()=>import(`./editor-A9_YWc5F.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function D_({bundle:e,conceptId:t}){let n=F(`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&&H(`/knowledge/${encodeURIComponent(s.name)}`,{replace:!0})},[e,s?.name]),(0,z.jsxs)(`div`,{className:`runs-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`bundles`,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,href:`/knowledge/new`,children:`new`})}),(0,z.jsxs)(jt,{children:[a.map(t=>(0,z.jsx)(gt,{href:`/knowledge/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,z.jsx)(et,{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,z.jsx)(Mt,{children:`no bundles yet`})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:e&&!o?(0,z.jsx)(F_,{name:e,conceptId:t,onRemoved:()=>{i(t=>[...t,e]),H(`/knowledge`,{replace:!0})}},e):o||n&&!s?(0,z.jsx)(O_,{}):(0,z.jsx)(Y,{children:`loading…`})})]})}function O_(){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?H(`/knowledge/${encodeURIComponent(t)}`):r(P(n))}return(0,z.jsxs)(`div`,{className:`empty-action flex flex-col items-center gap-3 px-4 py-16`,children:[(0,z.jsxs)(`div`,{className:`flex w-full max-w-[520px] gap-2.5`,children:[(0,z.jsx)(Z,{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,z.jsx)(K,{variant:`primary`,icon:`add`,busy:i,disabled:!e.trim(),onClick:o,children:i?`creating…`:`new bundle`})]}),n&&(0,z.jsx)(rt,{tone:`bad`,children:n})]})}function k_({tier:e}){return(0,z.jsx)(J,{tone:e===`human-reviewed`?`ok`:e===`machine-confirmed`?`accent`:`neutral`,children:e})}var A_=e=>e===`deprecated`||e===`stale`?`bad`:e===`draft`?`accent`:`neutral`,j_=()=>(0,v.useContext)(_e)!==null,M_=`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`,N_=`@activity`;function P_({name:e}){let t=Yt(),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);return(0,z.jsx)(Rt,{label:`ask this bundle`,className:`bundle-ask`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`menu_book`,className:`ms-sm`}),` `,e]}),chipTitle:`the chat knows this bundle's pages`,value:n,onChange:r,minRows:1,inputLabel:`what to ask or change in the bundle`,placeholder:`Ask it something, or say what to add or correct (optional)`,onSend:async i=>{a(!0),s(``);let o=await Kt({scope:{kind:`knowledge`,bundle:e},text:n,files:i});if(a(!1),`error`in o)return s(o.error),!1;r(``),t(o.href)},sendLabel:`curate in chat`,busy:i,error:o,skills:!0,attach:!0,hint:`starts a chat on this bundle`})}function F_({name:e,conceptId:t,onRemoved:n}){let r=F(`knowledge.get`,{bundle:e}),i=j_(),[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);t?.ok?n?n():H(`/knowledge`,{replace:!0}):(c(t?.error??`delete failed`),o(!1))}if(!r)return(0,z.jsx)(Y,{children:`loading…`});if(`error`in r)return(0,z.jsx)(Y,{icon:`menu_book`,children:`bundle not found`});let u=t===N_?`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,z.jsxs)(`div`,{className:I(`agent-view @container flex flex-col`,i?`gap-2.5`:`gap-4`),children:[(0,z.jsxs)(`div`,{className:I(`flex flex-wrap items-center gap-x-4 gap-y-2`,i?`mb-0.5`:`mx-0.5 mt-1 mb-2`),children:[(0,z.jsx)(ot,{size:i?`md`:`lg`,children:e}),(0,z.jsxs)(`span`,{className:I(`text-fg-2`,i?`text-[12.5px]`:`text-base`),children:[d.length,` pages`]}),(0,z.jsx)(_t,{bare:!0,className:`self-end`,label:`bundle views`,value:u,items:[{id:`pages`,href:p,label:`pages`},{id:`activity`,href:`${p}/${N_}`,label:`activity`}]}),(0,z.jsx)(`span`,{className:`flex-1`}),!i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void b_(e),children:`export PDF`}),a?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void l(),children:`move to trash`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>o(!1),children:`cancel`})]}):(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`delete`,onClick:()=>o(!0),title:`Move the bundle to the trash`,children:`delete`})]})]}),s&&(0,z.jsx)(rt,{tone:`bad`,children:s}),(0,z.jsx)(P_,{name:e}),u===`activity`?r.log?(0,z.jsx)(R_,{name:e,log:r.log}):(0,z.jsx)(X,{children:(0,z.jsx)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:`no activity yet`})}):d.length===0?(0,z.jsx)(X,{children:(0,z.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,z.jsxs)(`code`,{children:[`kraftwerk knowledge put `,e,`/<path>`]}),`.`]})}):(0,z.jsxs)(`div`,{className:I(`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,z.jsx)(`aside`,{className:I(`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,z.jsx)(B_,{concepts:d,base:p,selected:f})}),(0,z.jsx)(`div`,{className:`min-w-0`,children:f&&(0,z.jsx)(H_,{bundle:e,conceptId:f},f)})]})]})}function I_(e){let t=[];for(let n of e.split(`
463
+ </html>`;n.location.href=URL.createObjectURL(new Blob([f],{type:`text/html`}))}function x_(e,t){return e.split(/(```[\s\S]*?```|`[^`]*`)/).map((e,n)=>n%2==1?e:e.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(e,n,r)=>{let i=n.trim().replace(/\.md$/,``),a=(r??i).trim();return t===null?a:`[${a}](#/knowledge/${encodeURIComponent(t)}/${i})`})).join(``)}function S_(e){let t=[];return{md:e.replace(/^\[\^([^\]]+)\]:[ \t]*(.+)$/gm,(e,n,r)=>(t.push({id:n,text:r.trim()}),``)).replace(/\[\^([^\]]+)\]/g,(e,n)=>{let r=t.findIndex(e=>e.id===n);return r>=0?`<sup class="fnref">${r+1}</sup>`:``}),notes:t}}function C_(e,t){let n=new DOMParser().parseFromString(e,`text/html`),r=t.title,i=n.body.firstElementChild;t.titleIsFallback&&i?.tagName===`H1`&&(r=i.textContent?.trim()||r,i.remove());let a=n.createElement(`header`);a.innerHTML=`<h1>${w_(r)}</h1><div class="meta">${w_(t.meta)}</div>`,n.body.prepend(a);for(let e of n.querySelectorAll(`table`)){e.classList.add(`md`);for(let t of e.querySelectorAll(`th, td`))(t.textContent??``).trim().length<=14&&t.classList.add(`nw`)}for(let e of[5,4,3,2,1])for(let t of Array.from(n.body.querySelectorAll(`:scope > h${e}`))){let r=n.createElement(`h${e+1}`);r.innerHTML=t.innerHTML,t.replaceWith(r)}for(let e of Array.from(n.body.querySelectorAll(`:scope > header, :scope > h2, :scope > h3, :scope > h4`))){let t=e.nextElementSibling;if(!t||/^H[1-6]$/.test(t.tagName))continue;let r=n.createElement(`div`);r.className=`keep`,e.replaceWith(r),r.append(e,t)}return{html:n.body.innerHTML,title:r}}function w_(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var T_=(0,v.lazy)(()=>Rs(()=>import(`./editor-TtOHfgtL.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),E_=()=>Rs(()=>import(`./editor-TtOHfgtL.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function D_({bundle:e,conceptId:t}){let n=F(`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&&H(`/knowledge/${encodeURIComponent(s.name)}`,{replace:!0})},[e,s?.name]),(0,z.jsxs)(`div`,{className:`runs-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`bundles`,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,href:`/knowledge/new`,children:`new`})}),(0,z.jsxs)(jt,{children:[a.map(t=>(0,z.jsx)(gt,{href:`/knowledge/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,z.jsx)(et,{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,z.jsx)(Mt,{children:`no bundles yet`})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:e&&!o?(0,z.jsx)(F_,{name:e,conceptId:t,onRemoved:()=>{i(t=>[...t,e]),H(`/knowledge`,{replace:!0})}},e):o||n&&!s?(0,z.jsx)(O_,{}):(0,z.jsx)(Y,{children:`loading…`})})]})}function O_(){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?H(`/knowledge/${encodeURIComponent(t)}`):r(P(n))}return(0,z.jsxs)(`div`,{className:`empty-action flex flex-col items-center gap-3 px-4 py-16`,children:[(0,z.jsxs)(`div`,{className:`flex w-full max-w-[520px] gap-2.5`,children:[(0,z.jsx)(Z,{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,z.jsx)(K,{variant:`primary`,icon:`add`,busy:i,disabled:!e.trim(),onClick:o,children:i?`creating…`:`new bundle`})]}),n&&(0,z.jsx)(rt,{tone:`bad`,children:n})]})}function k_({tier:e}){return(0,z.jsx)(J,{tone:e===`human-reviewed`?`ok`:e===`machine-confirmed`?`accent`:`neutral`,children:e})}var A_=e=>e===`deprecated`||e===`stale`?`bad`:e===`draft`?`accent`:`neutral`,j_=()=>(0,v.useContext)(_e)!==null,M_=`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`,N_=`@activity`;function P_({name:e}){let t=Yt(),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);return(0,z.jsx)(Rt,{label:`ask this bundle`,className:`bundle-ask`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`menu_book`,className:`ms-sm`}),` `,e]}),chipTitle:`the chat knows this bundle's pages`,value:n,onChange:r,minRows:1,inputLabel:`what to ask or change in the bundle`,placeholder:`Ask it something, or say what to add or correct (optional)`,onSend:async i=>{a(!0),s(``);let o=await Kt({scope:{kind:`knowledge`,bundle:e},text:n,files:i});if(a(!1),`error`in o)return s(o.error),!1;r(``),t(o.href)},sendLabel:`curate in chat`,busy:i,error:o,skills:!0,attach:!0,hint:`starts a chat on this bundle`})}function F_({name:e,conceptId:t,onRemoved:n}){let r=F(`knowledge.get`,{bundle:e}),i=j_(),[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);t?.ok?n?n():H(`/knowledge`,{replace:!0}):(c(t?.error??`delete failed`),o(!1))}if(!r)return(0,z.jsx)(Y,{children:`loading…`});if(`error`in r)return(0,z.jsx)(Y,{icon:`menu_book`,children:`bundle not found`});let u=t===N_?`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,z.jsxs)(`div`,{className:I(`agent-view @container flex flex-col`,i?`gap-2.5`:`gap-4`),children:[(0,z.jsxs)(`div`,{className:I(`flex flex-wrap items-center gap-x-4 gap-y-2`,i?`mb-0.5`:`mx-0.5 mt-1 mb-2`),children:[(0,z.jsx)(ot,{size:i?`md`:`lg`,children:e}),(0,z.jsxs)(`span`,{className:I(`text-fg-2`,i?`text-[12.5px]`:`text-base`),children:[d.length,` pages`]}),(0,z.jsx)(_t,{bare:!0,className:`self-end`,label:`bundle views`,value:u,items:[{id:`pages`,href:p,label:`pages`},{id:`activity`,href:`${p}/${N_}`,label:`activity`}]}),(0,z.jsx)(`span`,{className:`flex-1`}),!i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void b_(e),children:`export PDF`}),a?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void l(),children:`move to trash`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>o(!1),children:`cancel`})]}):(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`delete`,onClick:()=>o(!0),title:`Move the bundle to the trash`,children:`delete`})]})]}),s&&(0,z.jsx)(rt,{tone:`bad`,children:s}),(0,z.jsx)(P_,{name:e}),u===`activity`?r.log?(0,z.jsx)(R_,{name:e,log:r.log}):(0,z.jsx)(X,{children:(0,z.jsx)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:`no activity yet`})}):d.length===0?(0,z.jsx)(X,{children:(0,z.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,z.jsxs)(`code`,{children:[`kraftwerk knowledge put `,e,`/<path>`]}),`.`]})}):(0,z.jsxs)(`div`,{className:I(`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,z.jsx)(`aside`,{className:I(`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,z.jsx)(B_,{concepts:d,base:p,selected:f})}),(0,z.jsx)(`div`,{className:`min-w-0`,children:f&&(0,z.jsx)(H_,{bundle:e,conceptId:f},f)})]})]})}function I_(e){let t=[];for(let n of e.split(`
464
464
  `)){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 L_(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,z.jsx)(U,{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 R_({name:e,log:t}){let n=I_(t),[r,i]=(0,v.useState)(!1);return(0,z.jsx)(X,{title:`activity`,actions:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>i(!r),children:r?`timeline`:`raw log`}),children:r||n.length===0?(0,z.jsx)(`pre`,{className:M_,children:t}):(0,z.jsx)(`div`,{className:`pt-0.5 pb-2.5`,children:n.map((t,n)=>(0,z.jsxs)(v.Fragment,{children:[(0,z.jsx)(`div`,{className:I(`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,z.jsxs)(`div`,{className:`flex items-baseline gap-2.5 px-[18px] py-1`,children:[(0,z.jsx)(J,{tone:t.kind===`verification`?`ok`:t.kind===`creation`||t.kind===`initialization`?`accent`:`neutral`,children:t.kind}),(0,z.jsx)(`span`,{className:`min-w-0 text-[12.5px] leading-[1.55] break-words text-fg-2 [&_a]:text-accent`,children:L_(e,t.text)})]},n))]},t.date))})})}function z_(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 B_({concepts:e,base:t,selected:n}){let r=(0,v.useMemo)(()=>z_(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=j_();return(0,z.jsx)(V_,{folder:r,base:t,selected:n,closed:i,toggle:o,embedded:s})}function V_({folder:e,base:t,selected:n,closed:r,toggle:i,embedded:a}){return(0,z.jsxs)(z.Fragment,{children:[e.pages.map(e=>{let r=e.id===n;return(0,z.jsxs)(U,{href:`${t}/${e.id}`,"aria-current":r?`page`:void 0,className:I(`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,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(e.stale||e.error)&&(0,z.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,z.jsxs)(v.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,className:I(`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,z.jsx)(B,{name:`chevron_right`,className:I(`ms-sm flex-none text-[16px] transition-transform`,o&&`rotate-90`,!s&&`text-fg-2`)}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,z.jsx)(`span`,{className:`text-[10.5px] font-medium tracking-normal text-fg-2 tabular-nums opacity-70`,children:e.total})]}),o&&(0,z.jsx)(`div`,{className:`wiki-branch ml-[9px] flex flex-col gap-0.5 border-l border-line pl-1`,children:(0,z.jsx)(V_,{folder:e,base:t,selected:n,closed:r,toggle:i,embedded:a})})]},e.path)})]})}function H_({bundle:e,conceptId:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),c=j_(),[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 E_().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 j(){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(`
465
465
  `)?``:`
466
466
  `}${n.replace(/^\n+/,`
467
467
  `)}`:n,o=await A.request(`knowledge.putConcept`,{bundle:e,body:{id:t,content:a},keepalive:!0});if(!o.ok)throw Error(P(o));let s=o.data;if(s.error)throw Error(s.error);w.current=(await E_()).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 j(),1e3))}(0,v.useEffect)(()=>{let e=()=>{D.current!==null&&j()};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&&j()}},[]);async function N(){s(!0),await A.request(`knowledge.verify`,{bundle:e,body:{id:t}}).catch(()=>{}),s(!1),ee()}function F(){n&&(f(n.raw),g(``),u(`markdown`))}async function te(){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,z.jsx)(Y,{icon:`description`,children:`concept not found`});if(!n)return(0,z.jsx)(Y,{children:`loading…`});let R=b===`saving`?`saving…`:b===`unsaved`?`unsaved changes`:b===`error`?`not saved — ${S}`:`all changes saved`;return(0,z.jsxs)(`div`,{className:I(`agent-view flex flex-col`,c?`gap-2.5`:`gap-4`),children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,z.jsx)(ot,{size:c?`md`:`lg`,children:n.title}),n.type&&(0,z.jsx)(J,{children:n.type}),(0,z.jsx)(k_,{tier:n.trustTier}),n.status!==`stable`&&(0,z.jsx)(J,{tone:A_(n.status),children:n.status}),n.stale&&(0,z.jsxs)(J,{tone:`bad`,children:[`stale since `,n.staleAfter?.slice(0,10)]}),(0,z.jsx)(`span`,{className:`flex-1`}),!c&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void b_(e,n.id),children:`export PDF`}),(0,z.jsx)(K,{variant:`primary`,size:c?`sm`:`md`,icon:`check`,busy:o,onClick:N,children:o?`verifying…`:`verify (human)`})]}),n.error&&(0,z.jsx)(rt,{tone:`bad`,children:n.error}),(0,z.jsxs)(`div`,{className:I(`grid items-start`,c?`grid-cols-1 gap-3`:`grid-cols-[minmax(0,1fr)_320px] gap-4 max-[1020px]:grid-cols-1`),children:[(0,z.jsxs)(X,{className:`min-w-0`,title:`content`,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-[10.5px] text-fg-2`,children:[e,`/`,n.id,`.md`]}),l===`markdown`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>{u(`document`),g(``)},children:`cancel`}),(0,z.jsx)(K,{size:`sm`,icon:`check`,busy:p,onClick:()=>void te(),children:p?`saving…`:`save`})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:I(`text-xs whitespace-nowrap`,b===`error`?`text-bad`:b===`unsaved`||b===`saving`?`text-ask`:`text-fg-2`),children:R}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`code`,title:`The whole file as text, frontmatter included`,onClick:F,children:`edit markdown`})]})]}),children:[l===`markdown`?(0,z.jsxs)(z.Fragment,{children:[(0,z.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(`
468
468
  `).length+2)),onChange:e=>f(e.target.value),spellCheck:!1}),(0,z.jsxs)(nt,{className:`border-b border-line px-[18px] py-1.5`,children:[`full file (frontmatter + markdown body) — saving stamps provenance with you (`,(0,z.jsx)(`code`,{children:`human:<handle>`}),`) and logs an update.`]})]}):(0,z.jsxs)(`div`,{className:I(`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,z.jsx)(v.Suspense,{fallback:(0,z.jsx)(nt,{className:`border-b border-line px-[18px] py-1.5`,children:`loading the editor…`}),children:(0,z.jsx)(T_,{markdown:_.body,autoFocus:!1,onChange:M,onError:F},_.key)}):(0,z.jsx)(nt,{className:`border-b border-line px-[18px] py-1.5`,children:`loading…`}),(0,z.jsxs)(nt,{className:`border-b border-line px-[18px] py-1.5`,children:[`the page as a document, saved as you type; every save stamps provenance with you (`,(0,z.jsx)(`code`,{children:`human:<handle>`}),`) and logs an update.`]})]}),h&&(0,z.jsx)(`div`,{className:`px-3 py-1`,children:(0,z.jsx)(rt,{tone:`bad`,children:h})})]}),(0,z.jsxs)(`aside`,{className:I(`flex min-w-0 flex-col`,c?`gap-2.5`:`gap-4`),children:[(0,z.jsx)(X,{title:`about`,children:(0,z.jsxs)(mt,{compact:c,children:[(0,z.jsx)(ht,{label:`trust`,children:(0,z.jsx)(k_,{tier:n.trustTier})}),(0,z.jsx)(ht,{label:`generated`,dim:!n.generated,children:n.generated?`${n.generated.by??`?`} · ${(n.generated.at??`?`).slice(0,10)}`:`not stamped`}),(0,z.jsx)(ht,{label:`verified`,dim:n.verified.length===0,children:n.verified.length===0?`never`:n.verified.map((e,t)=>(0,z.jsxs)(`span`,{className:`block`,children:[e.by??`?`,` · `,(e.at??`?`).slice(0,10)]},t))}),n.staleAfter&&(0,z.jsxs)(ht,{label:`stale after`,dim:!n.stale,children:[n.staleAfter.slice(0,10),n.stale&&(0,z.jsx)(J,{tone:`bad`,children:`stale`})]}),n.tags.length>0&&(0,z.jsx)(ht,{label:`tags`,children:n.tags.map(e=>(0,z.jsx)(J,{children:e},e))})]})}),n.sources.length>0&&(0,z.jsx)(X,{title:`sources`,children:(0,z.jsx)(mt,{compact:c,children:n.sources.map((e,t)=>(0,z.jsxs)(`div`,{className:I(`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,z.jsxs)(`span`,{className:`text-fg [&_a]:text-accent`,children:[e.resource?.startsWith(`http`)?(0,z.jsx)(`a`,{href:e.resource,target:`_blank`,rel:`noreferrer`,children:e.title??e.resource}):e.title??e.resource??`?`,e.id&&(0,z.jsxs)(`span`,{className:`ml-2 font-mono text-2xs text-fg-2`,children:[`[^`,e.id,`]`]})]}),(0,z.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 U_=function(e,t){let n=e,r=G_[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=q_.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=q_.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=q_.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=q_.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=q_.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=q_.getErrorCorrectPolynomial(l),d=Y_(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=X_.getRSBlocks(e,t),i=Z_();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),q_.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=Q_(e);break;case`Alphanumeric`:n=$_(e);break;case`Byte`:n=ev(e);break;case`Kanji`:n=tv(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=X_.getRSBlocks(e,r),n=Z_();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),q_.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 ov(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+=`
469
469
  `}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+`
470
- `}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};U_.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},U_.createStringToBytes=function(e,t){let n=function(){let n=iv(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 W_={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},G_={L:1,M:0,Q:3,H:2},K_={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},q_=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 K_.PATTERN000:return function(e,t){return(e+t)%2==0};case K_.PATTERN001:return function(e,t){return e%2==0};case K_.PATTERN010:return function(e,t){return t%3==0};case K_.PATTERN011:return function(e,t){return(e+t)%3==0};case K_.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case K_.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case K_.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case K_.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=Y_([1],0);for(let n=0;n<e;n+=1)t=t.multiply(Y_([1,J_.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case W_.MODE_NUMBER:return 10;case W_.MODE_ALPHA_NUM:return 9;case W_.MODE_8BIT_BYTE:return 8;case W_.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case W_.MODE_NUMBER:return 12;case W_.MODE_ALPHA_NUM:return 11;case W_.MODE_8BIT_BYTE:return 16;case W_.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case W_.MODE_NUMBER:return 14;case W_.MODE_ALPHA_NUM:return 13;case W_.MODE_8BIT_BYTE:return 16;case W_.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}(),J_=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}(),Y_=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]^=J_.gexp(J_.glog(r.getAt(n))+J_.glog(e.getAt(i)));return Y_(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=J_.glog(r.getAt(0))-J_.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]^=J_.gexp(J_.glog(e.getAt(r))+t);return Y_(n,0).mod(e)},r},X_=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 G_.L:return e[(t-1)*4+0];case G_.M:return e[(t-1)*4+1];case G_.Q:return e[(t-1)*4+2];case G_.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}(),Z_=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},Q_=function(e){let t=W_.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},$_=function(e){let t=W_.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},ev=function(e){let t=W_.MODE_8BIT_BYTE,n=U_.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},tv=function(e){let t=W_.MODE_KANJI,n=U_.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},nv=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},rv=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},iv=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},av=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=nv(),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},ov=function(e,t,n){let r=av(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=nv();r.write(i);let a=rv(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};U_.stringToBytes;function sv(){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 cv(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(sv),[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?P(t):`could not reach kraftwerk`)};return(0,z.jsxs)(`main`,{className:`mx-auto flex min-h-screen w-full max-w-[420px] flex-col justify-center gap-5 px-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(B,{name:`phonelink_lock`,className:`text-[32px] text-fg-2`}),(0,z.jsx)(ot,{size:`lg`,children:`Pair this device`}),(0,z.jsxs)(`p`,{className:`m-0 text-sm leading-relaxed text-fg-2`,children:[`This kraftwerk runs on another machine. On that machine, run `,(0,z.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,z.jsxs)(`form`,{className:`flex flex-col gap-3.5`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,z.jsx)(Q,{label:`pairing code`,children:(0,z.jsx)(Z,{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,z.jsx)(Q,{label:`name of this device`,hint:`how it shows in the list of paired devices`,children:(0,z.jsx)(Z,{value:n,onChange:e=>r(e.target.value),"aria-label":`device name`})}),o&&(0,z.jsx)(rt,{tone:`bad`,children:o}),(0,z.jsx)(K,{variant:`primary`,type:`submit`,busy:i,disabled:!e.trim(),children:`pair`})]})]})}function lv({children:e}){return k()?(0,z.jsx)(cv,{}):(0,z.jsx)(z.Fragment,{children:e})}function uv({text:e,size:t=176}){let n=(0,v.useMemo)(()=>{let t=U_(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,z.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,z.jsx)(`path`,{d:n.d,fill:`currentColor`})})}function dv({onError:e}){let t=F(`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(P(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,z.jsx)(ft,{children:(0,z.jsx)(dt,{icon:t.enabled?`public`:`public_off`,title:`reach this machine from anywhere`,"data-relay":t.enabled?t.state:`off`,action:(0,z.jsx)(K,{size:`sm`,busy:n,variant:t.enabled?void 0:`primary`,onClick:()=>void i(),children:t.enabled?`turn off`:`turn on`}),children:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[a,t.enabled&&t.fingerprint&&(0,z.jsxs)(z.Fragment,{children:[` · machine key `,(0,z.jsx)(`code`,{children:t.fingerprint})]}),` — through the kraftwerk relay, end to end encrypted: it cannot read along`]})})})}function fv(){let e=F(`devices.self`,{},{interval:6e4}),t=e?.trust===`local`,n=F(`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,z.jsx)(X,{title:`devices`,children:(0,z.jsx)(ft,{children:(0,z.jsx)(dt,{icon:`phonelink_lock`,title:`this browser is paired as “${e.device?.name}”`,children:(0,z.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?P(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(P(n))};return(0,z.jsxs)(X,{title:`devices`,actions:(0,z.jsx)(K,{size:`sm`,icon:`add_link`,onClick:()=>void s(),children:`pair a device`}),children:[r&&(0,z.jsxs)(Ct,{className:`border-b border-line`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-3`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[22px] font-semibold tracking-widest text-fg`,"aria-label":`pairing code`,children:r.code}),(0,z.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,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,z.jsx)(uv,{text:r.remote}),(0,z.jsxs)(`span`,{className:`max-w-[28ch] text-sm text-fg-2`,children:[`From anywhere: scan this with the phone's camera, or open `,(0,z.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,z.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`On the device, open `,r.urls.map((e,t)=>(0,z.jsxs)(`span`,{children:[t>0&&` or `,(0,z.jsx)(`code`,{children:e})]},e)),` and enter the code.`]}):r.remote?null:(0,z.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`This kraftwerk only listens on this machine. Restart it with `,(0,z.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,z.jsx)(dv,{onError:o}),a&&(0,z.jsx)(`div`,{className:`px-[18px] pt-3`,children:(0,z.jsx)(rt,{tone:`bad`,children:a})}),n&&n.devices.length===0&&!r&&(0,z.jsx)(Y,{icon:`devices`,children:`no paired devices — a phone or another computer can use this kraftwerk once paired`}),n&&n.devices.length>0&&(0,z.jsx)(ft,{children:n.devices.map(e=>(0,z.jsx)(dt,{icon:`devices`,title:e.name,"data-device":e.id,action:(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`link_off`,onClick:()=>void c(e.id,e.name),"aria-label":`unpair ${e.name}`,children:`unpair`}),children:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`paired `,G(e.createdAt),` · `,e.lastSeenAt?`last seen ${G(e.lastSeenAt)}`:`not used yet`]})},e.id))})]})}var pv={enabled:!1,remote:`origin`,branch:``,interval:`300`,autosync:`pull`};function mv(e){let t=e.config.git;return t?{enabled:t.enabled!==!1,remote:t.remote??pv.remote,branch:t.branch??``,interval:String(t.interval??pv.interval),autosync:t.autosync??pv.autosync}:pv}var hv={enabled:!1,root:``};function gv(e){let t=e.config.repos;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}function _v(e){let t=e.config.vibeables;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}function vv(e){let t=e.config.projects;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}function yv(e){let t=e.config.boards;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}function bv(e){let t=e.config.presentations;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}var xv=[`contacts`,`places`,`events`],Sv={contacts:hv,places:hv,events:hv};function Cv(e){let t=t=>{let n=e.config[t];return n?{enabled:n.enabled!==!1,root:n.root??``}:hv};return{contacts:t(`contacts`),places:t(`places`),events:t(`events`)}}var wv={contacts:{icon:`person`,what:`keep people and organisations as contacts, referenced as contact:<slug>`,files:`one Markdown file per contact (frontmatter: role, org, email, phone, place, records; notes below)`},places:{icon:`location_on`,what:`keep addresses and points of interest as places, referenced as place:<slug>`,files:`one Markdown file per place (frontmatter: address, lat, lng, url, records; notes below); a Google Maps link derives from coordinates or the address`},events:{icon:`event`,what:`keep dated one-off entries as events, referenced as event:<slug>`,files:`one Markdown file per event, named by its date (frontmatter: start, end, place, contacts, project, records; notes below)`}};function Tv(){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,z.jsx)(X,{title:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`this machine in the cloud `,(0,z.jsx)(J,{tone:s,children:o})]}),actions:e.url&&(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(B,{name:`cloud`,className:`ms-sm`}),` open the cloud`]}),children:(0,z.jsxs)(Ct,{children:[e.state===`off`&&(0,z.jsxs)(nt,{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,z.jsx)(`code`,{children:`kraftwerk cloud on`}),` and `,(0,z.jsx)(`code`,{children:`kraftwerk login`}),` in a terminal turn it on and claim it.`]}),e.state===`connecting`&&(0,z.jsxs)(nt,{children:[`Registering with `,e.url,` …`]}),e.state===`error`&&(0,z.jsxs)(nt,{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,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(nt,{children:[`This machine`,e.machine?(0,z.jsxs)(z.Fragment,{children:[` (`,(0,z.jsx)(`code`,{children:e.machine}),`)`]}):null,` is registered at `,(0,z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),` under `,(0,z.jsx)(`strong`,{children:e.account}),`. Last heartbeat `,e.lastSeen?new Date(e.lastSeen).toLocaleTimeString():`pending`,`.`]}),(0,z.jsx)(`div`,{children:(0,z.jsx)(K,{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,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(nt,{children:[`This machine is registered at `,(0,z.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,z.jsx)(`code`,{children:`kraftwerk login`}),`:`]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,z.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,z.jsx)(K,{size:`sm`,icon:`content_copy`,onClick:()=>{navigator.clipboard.writeText(e.claimCode),r(!0),setTimeout(()=>r(!1),1500)},children:n?`copied`:`copy`}),e.claimUrl&&(0,z.jsxs)(`a`,{className:Qe(`primary`,`sm`),href:e.claimUrl,target:`_blank`,rel:`noreferrer`,onClick:()=>a(!0),children:[(0,z.jsx)(B,{name:`link`,className:`ms-sm`}),` sign in & claim`]}),i&&(0,z.jsx)(`span`,{className:`text-fg-dim text-sm`,children:`waiting for the claim …`})]}),(0,z.jsxs)(nt,{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,z.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]}),e.state!==`off`&&e.included===!1&&(0,z.jsxs)(nt,{children:[`This workspace is left out of the machine's record: `,(0,z.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]})})}function Ev(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null);(0,v.useEffect)(()=>{A.call(`meta.get`).then(e=>r({version:e.version,diskVersion:e.diskVersion})).catch(()=>{})},[]);let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(pv),[m,h]=(0,v.useState)(hv),[g,_]=(0,v.useState)(hv),[y,b]=(0,v.useState)(hv),[x,S]=(0,v.useState)(hv),[C,w]=(0,v.useState)(hv),[T,E]=(0,v.useState)(Sv),[D,O]=(0,v.useState)(!1),[k,ee]=(0,v.useState)(!1),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(``),I=F(`identity.get`,{},{interval:6e4}),te=(0,v.useCallback)(()=>{A.call(`settings.get`).then(e=>{t(e),a(e.config.name??``),s(e.config.icon??``),l(e.config.color??``),d(e.config.switcher??[]),p(mv(e)),h(gv(e)),_(_v(e)),b(vv(e)),S(yv(e)),w(bv(e)),E(Cv(e))}).catch(()=>P(`could not load settings`))},[]);(0,v.useEffect)(()=>te(),[te]);let R=()=>{O(!0),M(!1),P(``)};async function ne(){ee(!0),P(``);try{let e=await A.request(`settings.save`,{body:{name:i,icon:o,color:c,switcher:u,git:{...f,interval:f.interval===``?void 0:Number(f.interval)},repos:m,vibeables:g,projects:y,boards:x,presentations:C,...T}});if(!e.ok)throw Error(e.error||`save failed`);let n=e.data;t(n),d(n.config.switcher??[]),p(mv(n)),h(gv(n)),_(_v(n)),b(vv(n)),S(yv(n)),w(bv(n)),E(Cv(n)),O(!1),M(!0)}catch(e){P(e.message)}finally{ee(!1)}}let re=(e,t)=>{d(n=>n.map((n,r)=>r===e?{...n,...t}:n)),R()},ie=e=>{p(t=>({...t,...e})),R()},ae=e=>{h(t=>({...t,...e})),R()},oe=e=>{_(t=>({...t,...e})),R()},se=e=>{b(t=>({...t,...e})),R()},ce=e=>{S(t=>({...t,...e})),R()},le=e=>{w(t=>({...t,...e})),R()},ue=(e,t)=>{E(n=>({...n,[e]:{...n[e],...t}})),R()};if(!e)return(0,z.jsx)(Y,{children:N||`loading…`});let de=[[`identity`,I?.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`]],V=[{key:`repos`,icon:`source`,title:`Repositories`,what:`keep git repositories the agents work on under one folder`,files:"Saving creates the folder and adds it to .gitignore; every agent gets the list of clones as context and can add more with `kraftwerk repos add`.",href:`/repos`,form:m,set:ae,placeholder:`repos`},{key:`vibeables`,icon:`web`,title:`Apps`,what:`build small apps live in a chat, with a preview pane next to the thread`,files:`One folder per app, versioned with the workspace. Every chat gets a vibeable button; the agent then works inside the app folder.`,href:`/vibeables`,form:g,set:oe,placeholder:`kraftwerk-data/vibeables`},{key:`projects`,icon:`folder_special`,title:`Projects`,what:`gather a goal, its brief and its links in one folder, and chat inside it`,files:`One folder per project (project.yml, brief.md, state.md, log.md), versioned with the workspace. A chat opened in a project starts with all of it as context.`,href:`/projects`,form:y,set:se,placeholder:`kraftwerk-data/projects`},{key:`boards`,icon:`view_kanban`,title:`Boards`,what:`keep the work as boards of tasks; an assigned agent wakes up`,files:"One folder per workspace board; a project's boards live in projects/<slug>/boards/. Each task is a folder with task.md, log.md and its files. Agents use `kraftwerk tasks`.",href:`/boards`,form:x,set:ce,placeholder:`kraftwerk-data/boards`},{key:`presentations`,icon:`slideshow`,title:`Presentations`,what:`make slide decks from markdown, presented and exported as PowerPoint or PDF`,files:"One folder per deck (deck.md and its pictures), templates under templates/<slug>/template.yml; a project's decks live in projects/<slug>/presentations/. Agents use `kraftwerk presentations`.",href:`/presentations`,form:C,set:le,placeholder:`kraftwerk-data/presentations`},...xv.map(e=>({key:e,icon:wv[e].icon,title:e[0].toUpperCase()+e.slice(1),what:wv[e].what,files:`${wv[e].files[0].toUpperCase()}${wv[e].files.slice(1)}. Agents use \`kraftwerk ${e}\`.`,href:`/${e}`,form:T[e],set:t=>ue(e,t),placeholder:`kraftwerk-data/${e}`}))];return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[860px] flex-col gap-3`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`settings`,className:`text-[24px] text-fg-2`}),title:`Settings`,sub:n&&(0,z.jsxs)(`span`,{className:`settings-version font-mono text-xs`,title:`the kraftwerk version serving this workspace`,children:[`kraftwerk `,n.version,n.diskVersion&&n.diskVersion!==n.version?` · ${n.diskVersion} installed, runs after a restart`:``]}),actions:(0,z.jsxs)(z.Fragment,{children:[N&&(0,z.jsx)(rt,{tone:`bad`,children:N}),j&&!D&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12.5px] text-ok`,children:[(0,z.jsx)(B,{name:`check`,className:`ms-sm`}),` saved`]}),(0,z.jsx)(K,{variant:`primary`,size:`sm`,busy:k,disabled:!D,onClick:()=>void ne(),children:k?`saving…`:`save changes`})]})}),(0,z.jsxs)(X,{title:`workspace`,children:[(0,z.jsxs)(Dv,{title:`Name`,sub:`In the header, the browser tab and the workspace switcher.`,children:[(0,z.jsx)(Z,{"aria-label":`icon`,className:`h-8 w-12 flex-none px-0 text-center`,value:o,placeholder:`🤖`,onChange:e=>{s(e.target.value),R()}}),(0,z.jsx)(Z,{"aria-label":`name`,className:`h-8 text-sm`,value:i,placeholder:`my workspace`,onChange:e=>{a(e.target.value),R()}})]}),(0,z.jsxs)(Dv,{title:`Color`,sub:`Accent in the workspace switcher; empty derives one from the folder.`,children:[(0,z.jsx)(`input`,{type:`color`,"aria-label":`pick a color`,className:`h-8 w-9 flex-none cursor-pointer rounded-control border border-line bg-surface p-0.5`,value:/^#[0-9a-f]{6}$/i.test(c)?c:`#888888`,onChange:e=>{l(e.target.value),R()}}),(0,z.jsx)(Z,{"aria-label":`color`,className:`h-8 w-28 font-mono text-xs`,value:c,placeholder:`auto`,onChange:e=>{l(e.target.value),R()}})]}),(0,z.jsx)(Dv,{title:`Switcher entries`,sub:`Workspaces running on this machine appear by themselves; add remote instances or extra links.`,children:(0,z.jsx)(K,{size:`sm`,icon:`add`,onClick:()=>{d(e=>[...e,{name:``,url:`http://localhost:`}]),R()},children:`add entry`})}),u.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-line/55 px-[18px] py-2`,children:[(0,z.jsx)(Z,{"aria-label":`entry icon`,className:`h-8 w-12 flex-none px-0 text-center`,value:e.icon??``,placeholder:`•`,onChange:e=>re(t,{icon:e.target.value})}),(0,z.jsx)(Z,{"aria-label":`entry name`,className:`h-8 text-sm`,value:e.name,placeholder:`other workspace`,onChange:e=>re(t,{name:e.target.value})}),(0,z.jsx)(Z,{"aria-label":`entry url`,className:`h-8 font-mono text-xs`,value:e.url,placeholder:`http://localhost:1982`,onChange:e=>re(t,{url:e.target.value})}),(0,z.jsx)(q,{icon:`close`,label:`remove entry`,onClick:()=>{d(e=>e.filter((e,n)=>n!==t)),R()}})]},t))]}),(0,z.jsxs)(X,{title:`git sync`,actions:(0,z.jsx)(K,{size:`sm`,icon:`account_tree`,href:`/git`,children:`open git`}),children:[(0,z.jsx)(Ov,{id:`set-git`,icon:`sync`,title:`Sync with a git remote`,what:`sync workflows, knowledge, agents and skills with a git remote`,checked:f.enabled,onChange:e=>ie({enabled:e})}),(0,z.jsx)(my,{onSetup:te}),f.enabled&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Dv,{title:`Remote`,sub:`The remote to fetch from and push to.`,children:(0,z.jsx)(Z,{"aria-label":`remote`,className:`h-8 w-56 font-mono text-xs`,value:f.remote,placeholder:`origin`,onChange:e=>ie({remote:e.target.value})})}),(0,z.jsx)(Dv,{title:`Branch`,sub:`Empty follows the checked-out branch.`,children:(0,z.jsx)(Z,{"aria-label":`branch`,className:`h-8 w-56 font-mono text-xs`,value:f.branch,placeholder:`checked-out branch`,onChange:e=>ie({branch:e.target.value})})}),(0,z.jsx)(Dv,{title:`Interval`,sub:`Seconds between background fetches; 0 turns the timer off.`,children:(0,z.jsx)(Z,{"aria-label":`interval (s)`,className:`h-8 w-24 text-sm tabular-nums`,type:`number`,min:0,step:1,value:f.interval,placeholder:`300`,onChange:e=>ie({interval:e.target.value})})}),(0,z.jsx)(Dv,{title:`Autosync`,sub:`Pull fast-forwards when behind and clean; push also pushes commits. Sync commits what changed as well, and where both sides changed a file the remote's version wins and this machine's is kept beside it (name.konflikt-<handle>.ext).`,children:(0,z.jsxs)(St,{"aria-label":`autosync`,className:`h-8 w-64 text-sm`,value:f.autosync,onChange:e=>ie({autosync:e.target.value}),children:[(0,z.jsx)(`option`,{value:`pull`,children:`fetch and pull`}),(0,z.jsx)(`option`,{value:`push`,children:`fetch, pull and push`}),(0,z.jsx)(`option`,{value:`sync`,children:`sync: commit, pull and push`}),(0,z.jsx)(`option`,{value:`off`,children:`fetch only`})]})})]})]}),(0,z.jsx)(X,{title:`features`,children:V.map(e=>(0,z.jsx)(Ov,{id:`set-${e.key}`,icon:e.icon,title:e.title,what:e.what,checked:e.form.enabled,onChange:t=>e.set({enabled:t}),children:e.form.enabled&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Z,{"aria-label":`${e.key===`vibeables`?`vibeables`:e.key} root`,title:`Folder, relative to the workspace root. ${e.files}`,className:`h-7 w-[230px] font-mono text-xs max-[700px]:w-full`,value:e.form.root,placeholder:e.placeholder,onChange:t=>e.set({root:t.target.value})}),(0,z.jsx)(q,{icon:`arrow_forward`,label:`open ${e.title.toLowerCase()}`,href:e.href})]})},e.key))}),(0,z.jsx)(Jv,{}),(0,z.jsx)(fv,{}),(0,z.jsxs)(X,{title:`paths & port`,actions:(0,z.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,z.jsx)(`div`,{className:`flex flex-col py-1`,children:de.map(([e,t,n])=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[100px_minmax(0,1fr)] items-baseline gap-x-3 px-[18px] py-1.5 min-[900px]:grid-cols-[100px_minmax(0,1fr)_minmax(0,0.9fr)]`,children:[(0,z.jsx)(`span`,{className:`text-xs font-semibold text-fg-2`,children:e}),(0,z.jsx)(`code`,{className:`truncate text-xs`,title:t,children:t}),(0,z.jsx)(`span`,{className:`truncate text-2xs text-fg-2 max-[899px]:hidden`,title:n,children:n})]},e))}),(0,z.jsxs)(nt,{className:`border-t border-line/55 px-[18px] py-2.5`,children:[`Read-only here — edit `,(0,z.jsx)(`code`,{children:`kraftwerk.yml`}),` directly to change these.`]})]})]})}function Dv({title:e,sub:t,children:n}){return(0,z.jsxs)(`div`,{className:`flex items-center gap-4 px-[18px] py-2.5 [&+&]:border-t [&+&]:border-line/55 max-[700px]:flex-col max-[700px]:items-stretch max-[700px]:gap-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),t&&(0,z.jsx)(`div`,{className:`text-xs leading-snug text-fg-2`,children:t})]}),(0,z.jsx)(`div`,{className:`flex min-w-0 items-center justify-end gap-2 min-[701px]:w-[46%]`,children:n})]})}function Ov({id:e,icon:t,title:n,what:r,checked:i,onChange:a,children:o}){return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 px-[18px] py-2 [&+&]:border-t [&+&]:border-line/55`,children:[(0,z.jsx)(B,{name:t,className:`flex-none text-[18px] ${i?`text-accent`:`text-fg-2`}`}),(0,z.jsxs)(`label`,{htmlFor:e,className:`min-w-[200px] flex-1 cursor-pointer`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,z.jsx)(`span`,{className:`block text-xs leading-snug text-fg-2`,children:r})]}),o&&(0,z.jsx)(`div`,{className:`flex-none max-[700px]:order-last max-[700px]:w-full max-[700px]:ps-[30px]`,children:o}),(0,z.jsx)(`input`,{id:e,type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),className:`relative h-5 w-9 flex-none cursor-pointer appearance-none rounded-full border border-line bg-surface-2 transition-colors before:absolute before:top-1/2 before:left-[3px] before:size-3.5 before:-translate-y-1/2 before:rounded-full before:bg-fg-2 before:transition-[left,background-color] checked:border-accent checked:bg-accent checked:before:left-[17px] checked:before:bg-on-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`})]})}var kv=`#/settings/cloud`,Av={cloud:null,busy:!1,waiting:!1,error:``},jv=new Set,Mv=null,Nv=0,Pv=null,Fv=e=>{Av={...Av,...e};for(let e of jv)e()};async function Iv(){let e=await A.request(`workspace.cloud.get`,{});e.ok&&Fv({cloud:e.data})}function Lv(){Mv&&clearTimeout(Mv),Mv=null,jv.size&&(Mv=setTimeout(async()=>{Av.waiting&&Date.now()<Nv?await Rv(`cloud`):(Av.waiting&&Fv({waiting:!1}),await Iv()),Lv()},Av.waiting?2e3:15e3))}async function Rv(e){let t=await A.request(`workspace.cloud.set`,{body:{mode:e}});if(!t.ok)return Fv({error:t.error??`HTTP ${t.status}`,waiting:!1});let n=t.data;e===Pv&&(Fv({cloud:n,waiting:e===`cloud`&&n.mode!==`cloud`&&(n.next===`connect`||n.next===`claim`),error:``}),e===`cloud`&&n.mode===`cloud`&&setTimeout(()=>location.reload(),900))}async function zv(e){Pv=e,Fv({busy:!0,error:``,waiting:!1}),e===`cloud`&&(Nv=Date.now()+6e5),await Rv(e),Fv({busy:!1}),Lv()}function Bv(){let[,e]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let t=()=>e(e=>e+1);return jv.add(t),jv.size===1&&Iv().then(Lv),()=>{jv.delete(t),!jv.size&&Mv&&(clearTimeout(Mv),Mv=null)}},[]),{...Av,to:zv}}var Vv={local:{icon:`laptop_mac`,title:`Local`,tagline:`Just you, on this machine. No account.`,points:[`Everything lives in files in this folder — boards, projects, knowledge, chats`,`Agents run here, on your subscriptions and keys`,`Tasks go to agents or to you`,`Your work stays on this machine — only minimal usage info goes out (off in kraftwerk.yml)`]},cloud:{icon:`cloud`,title:`Cloud`,tagline:`Multiplayer, and reachable from anywhere.`,points:[`Sign in with your kraftwerk cloud account — every change is signed by its person`,`Cloud boards: shared with everyone on the workspace, tasks for people and agents`,`Invite teammates as members — no clone, no install`,`Reach your workspaces from another computer or your phone`]}},Hv=[{key:`machine`,label:`Connect this machine`,done:`connected to kraftwerk cloud`,todo:`the daemon registers this machine with kraftwerk cloud`},{key:`claim`,label:`Claim it with your account`,done:`claimed`,todo:`sign in (or sign up) in the browser — once per machine`},{key:`workspace`,label:`Register this workspace`,done:`known to the cloud by its id`,todo:`kraftwerk.yml gets the workspace's id (commit it)`},{key:`signin`,label:`Sign in here`,done:`people sign in with their cloud account`,todo:`this page asks you to sign in with the account`}];function Uv({mode:e,busy:t,onPick:n}){return(0,z.jsx)(`div`,{role:`radiogroup`,"aria-label":`workspace mode`,className:`inline-flex rounded-full border border-line bg-surface-2 p-0.5`,children:[`local`,`cloud`].map(r=>(0,z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===r,disabled:t,onClick:()=>e!==r&&n(r),className:I(`inline-flex cursor-pointer items-center gap-1.5 rounded-full border-0 px-3.5 py-1.5 font-[inherit] text-sm font-semibold transition-colors disabled:cursor-default`,e===r?r===`cloud`?`bg-accent text-on-accent`:`bg-surface text-fg shadow-[0_0_0_1px_var(--line)]`:`bg-transparent text-fg-2 hover:text-fg`),children:[(0,z.jsx)(B,{name:Vv[r].icon,className:`ms-sm`}),Vv[r].title]},r))})}function Wv({cloud:e,waiting:t}){let[n,r]=(0,v.useState)(!1),i=Hv.find(t=>!e.steps[t.key])?.key;return(0,z.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2.5 p-0`,children:Hv.map((a,o)=>{let s=e.steps[a.key],c=a.key===i;return(0,z.jsxs)(`li`,{className:`flex gap-3`,children:[(0,z.jsx)(`span`,{className:I(`grid size-6 flex-none place-items-center rounded-full text-xs font-bold`,s?`bg-ok text-on-accent`:c?`bg-accent/15 text-accent ring-1 ring-accent`:`bg-surface-2 text-fg-2`),children:s?(0,z.jsx)(B,{name:`check`,className:`text-[15px]`}):o+1}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,z.jsx)(`span`,{className:I(`text-sm font-semibold`,!s&&!c&&`text-fg-2`),children:a.label}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:s?a.done:a.todo}),c&&a.key===`machine`&&e.next===`connect`&&(0,z.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1.5 text-xs text-fg-2`,children:[(0,z.jsx)(`span`,{className:`size-2 animate-pulse rounded-full bg-accent`}),` connecting …`]}),c&&a.key===`claim`&&e.next===`claim`&&e.claimUrl&&(0,z.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`a`,{className:Qe(`primary`,`sm`),href:e.claimUrl,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),` sign in & claim`]}),e.claimCode&&(0,z.jsx)(`button`,{type:`button`,title:`copy the claim code`,onClick:()=>{navigator.clipboard.writeText(e.claimCode),r(!0),setTimeout(()=>r(!1),1500)},className:`cursor-pointer rounded-control border border-line bg-surface-2 px-2.5 py-1 font-mono text-sm tracking-[0.12em] text-fg`,children:n?`copied`:e.claimCode}),t&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-2`,children:[(0,z.jsx)(`span`,{className:`size-2 animate-pulse rounded-full bg-accent`}),` `,`waiting for the claim …`]})]})]})]},a.key)})})}function Gv({cloud:e,error:t}){let n=t||e.problem;return n?(0,z.jsxs)(`p`,{className:`m-0 flex items-start gap-1.5 rounded-control bg-bad/8 px-3 py-2 text-xs text-bad`,children:[(0,z.jsx)(B,{name:`error`,className:`ms-sm`}),(0,z.jsx)(`span`,{children:n})]}):null}function Kv({mode:e}){return(0,z.jsx)(`div`,{className:`grid gap-3 min-[720px]:grid-cols-2`,children:[`local`,`cloud`].map(t=>(0,z.jsxs)(`div`,{className:I(`flex flex-col gap-2 rounded-card border p-4`,e===t?t===`cloud`?`border-accent bg-accent/5`:`border-fg/30 bg-surface`:`border-line bg-surface`),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(B,{name:Vv[t].icon,className:I(`text-[22px]`,t===`cloud`?`text-accent`:`text-fg-2`)}),(0,z.jsx)(`span`,{className:`font-semibold`,children:Vv[t].title}),e===t&&(0,z.jsx)(`span`,{className:`ml-auto rounded-full bg-surface-2 px-2 py-0.5 text-2xs font-semibold text-fg-2`,children:`this workspace`})]}),(0,z.jsx)(`span`,{className:`text-sm text-fg-2`,children:Vv[t].tagline}),(0,z.jsx)(`ul`,{className:`m-0 flex flex-col gap-1.5 pl-0`,children:Vv[t].points.map(e=>(0,z.jsxs)(`li`,{className:`flex list-none gap-2 text-sm`,children:[(0,z.jsx)(B,{name:`check`,className:I(`ms-sm mt-px`,t===`cloud`?`text-accent`:`text-fg-2`)}),(0,z.jsx)(`span`,{children:e})]},e))})]},t))})}function qv(){let e=F(`me.get`,{},{interval:6e4}),t=Bv(),{cloud:n}=t;if(!n||e?.via===`member`)return null;let r=n.mode===`cloud`,i=r&&n.state!==`connected`,a=r&&n.workspaceUrl&&!n.deleted?n.workspaceUrl:null;return(0,z.jsxs)(`span`,{className:`inline-flex flex-none items-center gap-1`,children:[(0,z.jsx)(Nt,{align:`end`,className:`w-[min(380px,calc(100vw-24px))] p-0`,trigger:({toggle:e,open:t})=>(0,z.jsxs)(`button`,{type:`button`,className:I(`mode-chip inline-flex flex-none cursor-pointer items-center gap-1.5 rounded-full border px-2.5 py-1 font-[inherit] text-xs font-semibold transition-colors`,r&&n.deleted?`border-bad/40 bg-bad/10 text-bad hover:bg-bad/18`:r?`border-accent/40 bg-accent/10 text-accent hover:bg-accent/18`:`border-line bg-transparent text-fg-2 hover:text-fg`,t&&`ring-2 ring-accent/30`),"aria-label":`workspace mode: ${n.mode}`,title:r?n.deleted?`Deleted in kraftwerk cloud — switch to local to keep working`:i?`Cloud mode — the cloud does not answer right now`:`Cloud mode — multiplayer`:`Local mode — switch to cloud for multiplayer`,onClick:e,children:[(0,z.jsx)(B,{name:r?i?`cloud_off`:`cloud`:`laptop_mac`,className:`ms-sm`}),(0,z.jsx)(`span`,{className:`max-[640px]:hidden`,children:r?n.deleted?`cloud · deleted`:`cloud`:`local`}),!r&&(0,z.jsx)(`span`,{className:`rounded-full bg-accent/12 px-1.5 text-2xs text-accent max-[900px]:hidden`,children:`try cloud`})]}),children:e=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`span`,{className:`text-sm font-semibold`,children:`Workspace mode`}),(0,z.jsx)(Uv,{mode:t.waiting?`cloud`:n.mode,busy:t.busy,onPick:e=>void t.to(e)})]}),(0,z.jsx)(nt,{children:r?`Cloud: people sign in with their kraftwerk cloud account, cloud boards are shared, members join without a clone. Your files and agents stay on this machine.`:`Local: just you, everything in files on this machine. Switch to cloud to work with others and reach this workspace from anywhere — your files and agents stay here.`}),t.waiting&&(0,z.jsx)(Wv,{cloud:n,waiting:!0}),(0,z.jsx)(Gv,{cloud:n,error:t.error}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:kv,onClick:e,children:[(0,z.jsx)(B,{name:`info`,className:`ms-sm`}),` local or cloud?`]}),n.url&&(0,z.jsxs)(`a`,{className:Qe(`quiet`,`sm`),href:a??n.url,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),` `,a?`open in the cloud`:`open kraftwerk cloud`]})]})]})}),a&&(0,z.jsx)(`a`,{className:`cloud-link grid size-7 flex-none place-items-center rounded-full text-accent no-underline transition-colors hover:bg-accent/12`,href:a,target:`_blank`,rel:`noreferrer`,title:`Open this workspace in kraftwerk cloud`,"aria-label":`open this workspace in kraftwerk cloud`,children:(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`})})]})}function Jv(){let e=Bv(),{cloud:t}=e;return t?(0,z.jsx)(X,{title:`local or cloud`,actions:(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:kv,children:[(0,z.jsx)(B,{name:`info`,className:`ms-sm`}),` what's the difference?`]}),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 px-[18px] py-3.5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(Uv,{mode:e.waiting?`cloud`:t.mode,busy:e.busy,onPick:t=>void e.to(t)}),(0,z.jsx)(`span`,{className:`text-sm text-fg-2`,children:t.mode===`cloud`?Vv.cloud.tagline:Vv.local.tagline})]}),e.waiting&&(0,z.jsx)(Wv,{cloud:t,waiting:!0}),t.mode===`cloud`&&!e.waiting&&(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-fg-2`,children:[(0,z.jsx)(B,{name:`cloud_sync`,className:`ms-sm`}),`The workspace's files: kraftwerk sync keeps them in step through kraftwerk cloud, for everyone on it — set up and set under `,(0,z.jsx)(`a`,{href:`#/settings`,children:`git sync`}),`.`]}),(0,z.jsx)(Gv,{cloud:t,error:e.error})]})}):null}function Yv(){let e=Bv(),{cloud:t}=e,n=t?.mode;return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:n===`cloud`?`cloud`:`laptop_mac`,title:`Local or cloud`,sub:`kraftwerk runs fully on your machine. Cloud mode adds people — and a way in from anywhere.`,actions:t&&(0,z.jsx)(Uv,{mode:e.waiting?`cloud`:t.mode,busy:e.busy,onPick:t=>void e.to(t)})}),(0,z.jsx)(Kv,{mode:n}),t&&(0,z.jsx)(X,{title:n===`cloud`?`cloud mode is on`:`switching to cloud`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3.5 px-[18px] py-4`,children:[n!==`cloud`&&!e.waiting&&(0,z.jsx)(nt,{children:`One click does it: kraftwerk connects this machine, registers the workspace and — the only step you do yourself — opens the cloud so you can sign in and claim the machine. Then this page asks you to sign in. Switching back to local is just as quick.`}),(0,z.jsx)(Wv,{cloud:t,waiting:e.waiting}),(0,z.jsx)(Gv,{cloud:t,error:e.error}),(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n===`cloud`?(0,z.jsxs)(z.Fragment,{children:[t.workspaceUrl&&(0,z.jsxs)(`a`,{className:Qe(`primary`,`sm`),href:t.workspaceUrl,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),` open the workspace in the cloud`]}),(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:`#/boards`,children:[(0,z.jsx)(B,{name:`view_kanban`,className:`ms-sm`}),` create a cloud board`]})]}):(0,z.jsx)(K,{variant:`primary`,icon:`cloud`,busy:e.busy||e.waiting,onClick:()=>void e.to(`cloud`),children:e.waiting?t.next===`connect`?`connecting …`:`waiting for the claim …`:`switch to cloud`})})]})}),(0,z.jsx)(Zv,{}),(0,z.jsx)(Tv,{})]})}var Xv=[[`What goes to the cloud?`,(0,z.jsxs)(z.Fragment,{children:[`In both modes your files, chats, knowledge, runs and agent sessions stay on this machine. Even in local mode, kraftwerk reports minimal usage info: the daemon registers the machine (its name, your handle, hostname, platform and kraftwerk version) and the workspaces it serves (their names and ids, no folder paths, no content). It is on by default;`,` `,(0,z.jsxs)(`code`,{children:[`cloud: `,`{ enabled: false }`]}),` in a workspace's kraftwerk.yml leaves that workspace out, `,(0,z.jsx)(`code`,{children:`kraftwerk cloud off`}),` stops it for the whole machine. Once you claim the machine, the cloud also learns the folder paths and which routines ran. In cloud mode, cloud boards and their tasks live in the cloud.`]})],[`Do my agents run in the cloud?`,(0,z.jsx)(z.Fragment,{children:`No. Agents always run here, on your own subscriptions and keys. In cloud mode they can pick up tasks from cloud boards, signed as themselves.`})],[`Can I go back to local?`,(0,z.jsx)(z.Fragment,{children:`Any time, with the same switch: nobody needs to sign in any more and cloud boards disappear from view — they stay in the cloud until you switch back. Local boards are untouched either way.`})],[`What about my teammates?`,(0,z.jsxs)(z.Fragment,{children:[`In cloud mode, `,(0,z.jsx)(`code`,{children:`kraftwerk invite`}),` (or the cloud's workspace page) gives them a link: they join as members and open the workspace from their browser — no clone, no install. Someone with a clone of the repo signs in with their own account on their own machine.`]})],[`And in the terminal?`,(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`code`,{children:`kraftwerk cloud connect`}),` does the same as the switch,`,` `,(0,z.jsx)(`code`,{children:`kraftwerk cloud disconnect`}),` goes back;`,` `,(0,z.jsx)(`code`,{children:`kraftwerk boards create <title> --cloud`}),` makes a cloud board.`]})]];function Zv(){return(0,z.jsx)(X,{title:`questions`,children:(0,z.jsx)(`div`,{className:`flex flex-col divide-y divide-line`,children:Xv.map(([e,t])=>(0,z.jsxs)(`details`,{className:`group px-[18px] py-3`,children:[(0,z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-semibold`,children:[(0,z.jsx)(B,{name:`chevron_right`,className:`ms-sm transition-transform group-open:rotate-90`}),e]}),(0,z.jsx)(`p`,{className:`m-0 mt-2 pl-6 text-sm text-fg-2`,children:t})]},e))})})}function Qv(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 $v=[[/^(\+\+\+|---|diff |index )/,`text-fg-2 opacity-80`],[/^@@/,`text-accent`],[/^\+/,`text-ok`],[/^-/,`text-bad`]],ey=e=>$v.find(([t])=>t.test(e))?.[1]??``;function ty({file:e}){return(0,z.jsx)(ry,{source:{route:`git.diff`,input:{query:{path:e}}}})}var ny=e=>(e.route===`git.diff`||e.route===`repos.diff`||e.route,A.request(e.route,e.input));function ry({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(``),ny(e).then(e=>{if(t){if(!e.data||typeof e.data!=`object`)throw Error(`not json`);e.ok?(r(e.data.diff??``),a(!!e.data.truncated),s(e.data.error??``)):(r(``),a(!1),s(e.error??``))}}).catch(()=>t&&s(`could not load the diff`)),()=>{t=!1}},[c,t]),o?(0,z.jsx)(`div`,{className:I(iy,`text-bad`),children:o}):n===null?(0,z.jsx)(`div`,{className:iy,children:`loading…`}):n.trim()?(0,z.jsxs)(`pre`,{className:iy,children:[n.split(`
471
- `).map((e,t)=>(0,z.jsxs)(`span`,{className:ey(e),children:[e||` `,`
470
+ `}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};U_.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},U_.createStringToBytes=function(e,t){let n=function(){let n=iv(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 W_={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},G_={L:1,M:0,Q:3,H:2},K_={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},q_=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 K_.PATTERN000:return function(e,t){return(e+t)%2==0};case K_.PATTERN001:return function(e,t){return e%2==0};case K_.PATTERN010:return function(e,t){return t%3==0};case K_.PATTERN011:return function(e,t){return(e+t)%3==0};case K_.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case K_.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case K_.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case K_.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=Y_([1],0);for(let n=0;n<e;n+=1)t=t.multiply(Y_([1,J_.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case W_.MODE_NUMBER:return 10;case W_.MODE_ALPHA_NUM:return 9;case W_.MODE_8BIT_BYTE:return 8;case W_.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case W_.MODE_NUMBER:return 12;case W_.MODE_ALPHA_NUM:return 11;case W_.MODE_8BIT_BYTE:return 16;case W_.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case W_.MODE_NUMBER:return 14;case W_.MODE_ALPHA_NUM:return 13;case W_.MODE_8BIT_BYTE:return 16;case W_.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}(),J_=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}(),Y_=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]^=J_.gexp(J_.glog(r.getAt(n))+J_.glog(e.getAt(i)));return Y_(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=J_.glog(r.getAt(0))-J_.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]^=J_.gexp(J_.glog(e.getAt(r))+t);return Y_(n,0).mod(e)},r},X_=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 G_.L:return e[(t-1)*4+0];case G_.M:return e[(t-1)*4+1];case G_.Q:return e[(t-1)*4+2];case G_.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}(),Z_=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},Q_=function(e){let t=W_.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},$_=function(e){let t=W_.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},ev=function(e){let t=W_.MODE_8BIT_BYTE,n=U_.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},tv=function(e){let t=W_.MODE_KANJI,n=U_.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},nv=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},rv=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},iv=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},av=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=nv(),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},ov=function(e,t,n){let r=av(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=nv();r.write(i);let a=rv(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};U_.stringToBytes;function sv(){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 cv(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(sv),[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?P(t):`could not reach kraftwerk`)};return(0,z.jsxs)(`main`,{className:`mx-auto flex min-h-screen w-full max-w-[420px] flex-col justify-center gap-5 px-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(B,{name:`phonelink_lock`,className:`text-[32px] text-fg-2`}),(0,z.jsx)(ot,{size:`lg`,children:`Pair this device`}),(0,z.jsxs)(`p`,{className:`m-0 text-sm leading-relaxed text-fg-2`,children:[`This kraftwerk runs on another machine. On that machine, run `,(0,z.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,z.jsxs)(`form`,{className:`flex flex-col gap-3.5`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,z.jsx)(Q,{label:`pairing code`,children:(0,z.jsx)(Z,{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,z.jsx)(Q,{label:`name of this device`,hint:`how it shows in the list of paired devices`,children:(0,z.jsx)(Z,{value:n,onChange:e=>r(e.target.value),"aria-label":`device name`})}),o&&(0,z.jsx)(rt,{tone:`bad`,children:o}),(0,z.jsx)(K,{variant:`primary`,type:`submit`,busy:i,disabled:!e.trim(),children:`pair`})]})]})}function lv({children:e}){return k()?(0,z.jsx)(cv,{}):(0,z.jsx)(z.Fragment,{children:e})}function uv({text:e,size:t=176}){let n=(0,v.useMemo)(()=>{let t=U_(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,z.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,z.jsx)(`path`,{d:n.d,fill:`currentColor`})})}function dv({onError:e}){let t=F(`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(P(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,z.jsx)(ft,{children:(0,z.jsx)(dt,{icon:t.enabled?`public`:`public_off`,title:`reach this machine from anywhere`,"data-relay":t.enabled?t.state:`off`,action:(0,z.jsx)(K,{size:`sm`,busy:n,variant:t.enabled?void 0:`primary`,onClick:()=>void i(),children:t.enabled?`turn off`:`turn on`}),children:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[a,t.enabled&&t.fingerprint&&(0,z.jsxs)(z.Fragment,{children:[` · machine key `,(0,z.jsx)(`code`,{children:t.fingerprint})]}),` — through the kraftwerk relay, end to end encrypted: it cannot read along`]})})})}function fv(){let e=F(`devices.self`,{},{interval:6e4}),t=e?.trust===`local`,n=F(`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,z.jsx)(X,{title:`devices`,children:(0,z.jsx)(ft,{children:(0,z.jsx)(dt,{icon:`phonelink_lock`,title:`this browser is paired as “${e.device?.name}”`,children:(0,z.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?P(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(P(n))};return(0,z.jsxs)(X,{title:`devices`,actions:(0,z.jsx)(K,{size:`sm`,icon:`add_link`,onClick:()=>void s(),children:`pair a device`}),children:[r&&(0,z.jsxs)(Ct,{className:`border-b border-line`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-3`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[22px] font-semibold tracking-widest text-fg`,"aria-label":`pairing code`,children:r.code}),(0,z.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,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,z.jsx)(uv,{text:r.remote}),(0,z.jsxs)(`span`,{className:`max-w-[28ch] text-sm text-fg-2`,children:[`From anywhere: scan this with the phone's camera, or open `,(0,z.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,z.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`On the device, open `,r.urls.map((e,t)=>(0,z.jsxs)(`span`,{children:[t>0&&` or `,(0,z.jsx)(`code`,{children:e})]},e)),` and enter the code.`]}):r.remote?null:(0,z.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`This kraftwerk only listens on this machine. Restart it with `,(0,z.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,z.jsx)(dv,{onError:o}),a&&(0,z.jsx)(`div`,{className:`px-[18px] pt-3`,children:(0,z.jsx)(rt,{tone:`bad`,children:a})}),n&&n.devices.length===0&&!r&&(0,z.jsx)(Y,{icon:`devices`,children:`no paired devices — a phone or another computer can use this kraftwerk once paired`}),n&&n.devices.length>0&&(0,z.jsx)(ft,{children:n.devices.map(e=>(0,z.jsx)(dt,{icon:`devices`,title:e.name,"data-device":e.id,action:(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`link_off`,onClick:()=>void c(e.id,e.name),"aria-label":`unpair ${e.name}`,children:`unpair`}),children:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`paired `,G(e.createdAt),` · `,e.lastSeenAt?`last seen ${G(e.lastSeenAt)}`:`not used yet`]})},e.id))})]})}var pv={enabled:!1,remote:`origin`,branch:``,interval:`300`,autosync:`pull`};function mv(e){let t=e.config.git;return t?{enabled:t.enabled!==!1,remote:t.remote??pv.remote,branch:t.branch??``,interval:String(t.interval??pv.interval),autosync:t.autosync??pv.autosync}:pv}var hv={enabled:!1,root:``};function gv(e){let t=e.config.repos;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}function _v(e){let t=e.config.vibeables;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}function vv(e){let t=e.config.projects;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}function yv(e){let t=e.config.boards;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}function bv(e){let t=e.config.presentations;return t?{enabled:t.enabled!==!1,root:t.root??``}:hv}var xv=[`contacts`,`places`,`events`],Sv={contacts:hv,places:hv,events:hv};function Cv(e){let t=t=>{let n=e.config[t];return n?{enabled:n.enabled!==!1,root:n.root??``}:hv};return{contacts:t(`contacts`),places:t(`places`),events:t(`events`)}}var wv={contacts:{icon:`person`,what:`keep people and organisations as contacts, referenced as contact:<slug>`,files:`one Markdown file per contact (frontmatter: role, org, email, phone, place, records; notes below)`},places:{icon:`location_on`,what:`keep addresses and points of interest as places, referenced as place:<slug>`,files:`one Markdown file per place (frontmatter: address, lat, lng, url, records; notes below); a Google Maps link derives from coordinates or the address`},events:{icon:`event`,what:`keep dated one-off entries as events, referenced as event:<slug>`,files:`one Markdown file per event, named by its date (frontmatter: start, end, place, contacts, project, records; notes below)`}};function Tv(){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,z.jsx)(X,{title:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`this machine in the cloud `,(0,z.jsx)(J,{tone:s,children:o})]}),actions:e.url&&(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(B,{name:`cloud`,className:`ms-sm`}),` open the cloud`]}),children:(0,z.jsxs)(Ct,{children:[e.state===`off`&&(0,z.jsxs)(nt,{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,z.jsx)(`code`,{children:`kraftwerk cloud on`}),` and `,(0,z.jsx)(`code`,{children:`kraftwerk login`}),` in a terminal turn it on and claim it.`]}),e.state===`connecting`&&(0,z.jsxs)(nt,{children:[`Registering with `,e.url,` …`]}),e.state===`error`&&(0,z.jsxs)(nt,{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,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(nt,{children:[`This machine`,e.machine?(0,z.jsxs)(z.Fragment,{children:[` (`,(0,z.jsx)(`code`,{children:e.machine}),`)`]}):null,` is registered at `,(0,z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),` under `,(0,z.jsx)(`strong`,{children:e.account}),`. Last heartbeat `,e.lastSeen?new Date(e.lastSeen).toLocaleTimeString():`pending`,`.`]}),(0,z.jsx)(`div`,{children:(0,z.jsx)(K,{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,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(nt,{children:[`This machine is registered at `,(0,z.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,z.jsx)(`code`,{children:`kraftwerk login`}),`:`]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,z.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,z.jsx)(K,{size:`sm`,icon:`content_copy`,onClick:()=>{navigator.clipboard.writeText(e.claimCode),r(!0),setTimeout(()=>r(!1),1500)},children:n?`copied`:`copy`}),e.claimUrl&&(0,z.jsxs)(`a`,{className:Qe(`primary`,`sm`),href:e.claimUrl,target:`_blank`,rel:`noreferrer`,onClick:()=>a(!0),children:[(0,z.jsx)(B,{name:`link`,className:`ms-sm`}),` sign in & claim`]}),i&&(0,z.jsx)(`span`,{className:`text-fg-dim text-sm`,children:`waiting for the claim …`})]}),(0,z.jsxs)(nt,{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,z.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]}),e.state!==`off`&&e.included===!1&&(0,z.jsxs)(nt,{children:[`This workspace is left out of the machine's record: `,(0,z.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]})})}function Ev(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null);(0,v.useEffect)(()=>{A.call(`meta.get`).then(e=>r({version:e.version,diskVersion:e.diskVersion})).catch(()=>{})},[]);let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(pv),[m,h]=(0,v.useState)(hv),[g,_]=(0,v.useState)(hv),[y,b]=(0,v.useState)(hv),[x,S]=(0,v.useState)(hv),[C,w]=(0,v.useState)(hv),[T,E]=(0,v.useState)(Sv),[D,O]=(0,v.useState)(!1),[k,ee]=(0,v.useState)(!1),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(``),I=F(`identity.get`,{},{interval:6e4}),te=(0,v.useCallback)(()=>{A.call(`settings.get`).then(e=>{t(e),a(e.config.name??``),s(e.config.icon??``),l(e.config.color??``),d(e.config.switcher??[]),p(mv(e)),h(gv(e)),_(_v(e)),b(vv(e)),S(yv(e)),w(bv(e)),E(Cv(e))}).catch(()=>P(`could not load settings`))},[]);(0,v.useEffect)(()=>te(),[te]);let R=()=>{O(!0),M(!1),P(``)};async function ne(){ee(!0),P(``);try{let e=await A.request(`settings.save`,{body:{name:i,icon:o,color:c,switcher:u,git:{...f,interval:f.interval===``?void 0:Number(f.interval)},repos:m,vibeables:g,projects:y,boards:x,presentations:C,...T}});if(!e.ok)throw Error(e.error||`save failed`);let n=e.data;t(n),d(n.config.switcher??[]),p(mv(n)),h(gv(n)),_(_v(n)),b(vv(n)),S(yv(n)),w(bv(n)),E(Cv(n)),O(!1),M(!0)}catch(e){P(e.message)}finally{ee(!1)}}let re=(e,t)=>{d(n=>n.map((n,r)=>r===e?{...n,...t}:n)),R()},ie=e=>{p(t=>({...t,...e})),R()},ae=e=>{h(t=>({...t,...e})),R()},oe=e=>{_(t=>({...t,...e})),R()},se=e=>{b(t=>({...t,...e})),R()},ce=e=>{S(t=>({...t,...e})),R()},le=e=>{w(t=>({...t,...e})),R()},ue=(e,t)=>{E(n=>({...n,[e]:{...n[e],...t}})),R()};if(!e)return(0,z.jsx)(Y,{children:N||`loading…`});let de=[[`identity`,I?.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`]],V=[{key:`repos`,icon:`source`,title:`Repositories`,what:`keep git repositories the agents work on under one folder`,files:"Saving creates the folder and adds it to .gitignore; every agent gets the list of clones as context and can add more with `kraftwerk repos add`.",href:`/repos`,form:m,set:ae,placeholder:`repos`},{key:`vibeables`,icon:`web`,title:`Apps`,what:`build small apps live in a chat, with a preview pane next to the thread`,files:`One folder per app, versioned with the workspace. Every chat gets a vibeable button; the agent then works inside the app folder.`,href:`/vibeables`,form:g,set:oe,placeholder:`kraftwerk-data/vibeables`},{key:`projects`,icon:`folder_special`,title:`Projects`,what:`gather a goal, its brief and its links in one folder, and chat inside it`,files:`One folder per project (project.yml, brief.md, state.md, log.md), versioned with the workspace. A chat opened in a project starts with all of it as context.`,href:`/projects`,form:y,set:se,placeholder:`kraftwerk-data/projects`},{key:`boards`,icon:`view_kanban`,title:`Boards`,what:`keep the work as boards of tasks; an assigned agent wakes up`,files:"One folder per workspace board; a project's boards live in projects/<slug>/boards/. Each task is a folder with task.md, log.md and its files. Agents use `kraftwerk tasks`.",href:`/boards`,form:x,set:ce,placeholder:`kraftwerk-data/boards`},{key:`presentations`,icon:`slideshow`,title:`Presentations`,what:`make slide decks from markdown, presented and exported as PowerPoint or PDF`,files:"One folder per deck (deck.md and its pictures), templates under templates/<slug>/template.yml; a project's decks live in projects/<slug>/presentations/. Agents use `kraftwerk presentations`.",href:`/presentations`,form:C,set:le,placeholder:`kraftwerk-data/presentations`},...xv.map(e=>({key:e,icon:wv[e].icon,title:e[0].toUpperCase()+e.slice(1),what:wv[e].what,files:`${wv[e].files[0].toUpperCase()}${wv[e].files.slice(1)}. Agents use \`kraftwerk ${e}\`.`,href:`/${e}`,form:T[e],set:t=>ue(e,t),placeholder:`kraftwerk-data/${e}`}))];return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[860px] flex-col gap-3`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`settings`,className:`text-[24px] text-fg-2`}),title:`Settings`,sub:n&&(0,z.jsxs)(`span`,{className:`settings-version font-mono text-xs`,title:`the kraftwerk version serving this workspace`,children:[`kraftwerk `,n.version,n.diskVersion&&n.diskVersion!==n.version?` · ${n.diskVersion} installed, runs after a restart`:``]}),actions:(0,z.jsxs)(z.Fragment,{children:[N&&(0,z.jsx)(rt,{tone:`bad`,children:N}),j&&!D&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12.5px] text-ok`,children:[(0,z.jsx)(B,{name:`check`,className:`ms-sm`}),` saved`]}),(0,z.jsx)(K,{variant:`primary`,size:`sm`,busy:k,disabled:!D,onClick:()=>void ne(),children:k?`saving…`:`save changes`})]})}),(0,z.jsxs)(X,{title:`workspace`,children:[(0,z.jsxs)(Dv,{title:`Name`,sub:`In the header, the browser tab and the workspace switcher.`,children:[(0,z.jsx)(Z,{"aria-label":`icon`,className:`h-8 w-12 flex-none px-0 text-center`,value:o,placeholder:`🤖`,onChange:e=>{s(e.target.value),R()}}),(0,z.jsx)(Z,{"aria-label":`name`,className:`h-8 text-sm`,value:i,placeholder:`my workspace`,onChange:e=>{a(e.target.value),R()}})]}),(0,z.jsxs)(Dv,{title:`Color`,sub:`Accent in the workspace switcher; empty derives one from the folder.`,children:[(0,z.jsx)(`input`,{type:`color`,"aria-label":`pick a color`,className:`h-8 w-9 flex-none cursor-pointer rounded-control border border-line bg-surface p-0.5`,value:/^#[0-9a-f]{6}$/i.test(c)?c:`#888888`,onChange:e=>{l(e.target.value),R()}}),(0,z.jsx)(Z,{"aria-label":`color`,className:`h-8 w-28 font-mono text-xs`,value:c,placeholder:`auto`,onChange:e=>{l(e.target.value),R()}})]}),(0,z.jsx)(Dv,{title:`Switcher entries`,sub:`Workspaces running on this machine appear by themselves; add remote instances or extra links.`,children:(0,z.jsx)(K,{size:`sm`,icon:`add`,onClick:()=>{d(e=>[...e,{name:``,url:`http://localhost:`}]),R()},children:`add entry`})}),u.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-line/55 px-[18px] py-2`,children:[(0,z.jsx)(Z,{"aria-label":`entry icon`,className:`h-8 w-12 flex-none px-0 text-center`,value:e.icon??``,placeholder:`•`,onChange:e=>re(t,{icon:e.target.value})}),(0,z.jsx)(Z,{"aria-label":`entry name`,className:`h-8 text-sm`,value:e.name,placeholder:`other workspace`,onChange:e=>re(t,{name:e.target.value})}),(0,z.jsx)(Z,{"aria-label":`entry url`,className:`h-8 font-mono text-xs`,value:e.url,placeholder:`http://localhost:1982`,onChange:e=>re(t,{url:e.target.value})}),(0,z.jsx)(q,{icon:`close`,label:`remove entry`,onClick:()=>{d(e=>e.filter((e,n)=>n!==t)),R()}})]},t))]}),(0,z.jsxs)(X,{title:`git sync`,actions:(0,z.jsx)(K,{size:`sm`,icon:`account_tree`,href:`/git`,children:`open git`}),children:[(0,z.jsx)(Ov,{id:`set-git`,icon:`sync`,title:`Sync with a git remote`,what:`sync workflows, knowledge, agents and skills with a git remote`,checked:f.enabled,onChange:e=>ie({enabled:e})}),(0,z.jsx)(_y,{onSetup:te}),f.enabled&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Dv,{title:`Remote`,sub:`The remote to fetch from and push to.`,children:(0,z.jsx)(Z,{"aria-label":`remote`,className:`h-8 w-56 font-mono text-xs`,value:f.remote,placeholder:`origin`,onChange:e=>ie({remote:e.target.value})})}),(0,z.jsx)(Dv,{title:`Branch`,sub:`Empty follows the checked-out branch.`,children:(0,z.jsx)(Z,{"aria-label":`branch`,className:`h-8 w-56 font-mono text-xs`,value:f.branch,placeholder:`checked-out branch`,onChange:e=>ie({branch:e.target.value})})}),(0,z.jsx)(Dv,{title:`Interval`,sub:`Seconds between background fetches; 0 turns the timer off.`,children:(0,z.jsx)(Z,{"aria-label":`interval (s)`,className:`h-8 w-24 text-sm tabular-nums`,type:`number`,min:0,step:1,value:f.interval,placeholder:`300`,onChange:e=>ie({interval:e.target.value})})}),(0,z.jsx)(Dv,{title:`Autosync`,sub:`Pull fast-forwards when behind and clean; push also pushes commits. Sync commits what changed as well, and where both sides changed a file the remote's version wins and this machine's is kept beside it (name.konflikt-<handle>.ext).`,children:(0,z.jsxs)(St,{"aria-label":`autosync`,className:`h-8 w-64 text-sm`,value:f.autosync,onChange:e=>ie({autosync:e.target.value}),children:[(0,z.jsx)(`option`,{value:`pull`,children:`fetch and pull`}),(0,z.jsx)(`option`,{value:`push`,children:`fetch, pull and push`}),(0,z.jsx)(`option`,{value:`sync`,children:`sync: commit, pull and push`}),(0,z.jsx)(`option`,{value:`off`,children:`fetch only`})]})})]})]}),(0,z.jsx)(X,{title:`features`,children:V.map(e=>(0,z.jsx)(Ov,{id:`set-${e.key}`,icon:e.icon,title:e.title,what:e.what,checked:e.form.enabled,onChange:t=>e.set({enabled:t}),children:e.form.enabled&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Z,{"aria-label":`${e.key===`vibeables`?`vibeables`:e.key} root`,title:`Folder, relative to the workspace root. ${e.files}`,className:`h-7 w-[230px] font-mono text-xs max-[700px]:w-full`,value:e.form.root,placeholder:e.placeholder,onChange:t=>e.set({root:t.target.value})}),(0,z.jsx)(q,{icon:`arrow_forward`,label:`open ${e.title.toLowerCase()}`,href:e.href})]})},e.key))}),(0,z.jsx)(Zv,{}),(0,z.jsx)(fv,{}),(0,z.jsxs)(X,{title:`paths & port`,actions:(0,z.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,z.jsx)(`div`,{className:`flex flex-col py-1`,children:de.map(([e,t,n])=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[100px_minmax(0,1fr)] items-baseline gap-x-3 px-[18px] py-1.5 min-[900px]:grid-cols-[100px_minmax(0,1fr)_minmax(0,0.9fr)]`,children:[(0,z.jsx)(`span`,{className:`text-xs font-semibold text-fg-2`,children:e}),(0,z.jsx)(`code`,{className:`truncate text-xs`,title:t,children:t}),(0,z.jsx)(`span`,{className:`truncate text-2xs text-fg-2 max-[899px]:hidden`,title:n,children:n})]},e))}),(0,z.jsxs)(nt,{className:`border-t border-line/55 px-[18px] py-2.5`,children:[`Read-only here — edit `,(0,z.jsx)(`code`,{children:`kraftwerk.yml`}),` directly to change these.`]})]})]})}function Dv({title:e,sub:t,children:n}){return(0,z.jsxs)(`div`,{className:`flex items-center gap-4 px-[18px] py-2.5 [&+&]:border-t [&+&]:border-line/55 max-[700px]:flex-col max-[700px]:items-stretch max-[700px]:gap-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),t&&(0,z.jsx)(`div`,{className:`text-xs leading-snug text-fg-2`,children:t})]}),(0,z.jsx)(`div`,{className:`flex min-w-0 items-center justify-end gap-2 min-[701px]:w-[46%]`,children:n})]})}function Ov({id:e,icon:t,title:n,what:r,checked:i,onChange:a,children:o}){return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 px-[18px] py-2 [&+&]:border-t [&+&]:border-line/55`,children:[(0,z.jsx)(B,{name:t,className:`flex-none text-[18px] ${i?`text-accent`:`text-fg-2`}`}),(0,z.jsxs)(`label`,{htmlFor:e,className:`min-w-[200px] flex-1 cursor-pointer`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,z.jsx)(`span`,{className:`block text-xs leading-snug text-fg-2`,children:r})]}),o&&(0,z.jsx)(`div`,{className:`flex-none max-[700px]:order-last max-[700px]:w-full max-[700px]:ps-[30px]`,children:o}),(0,z.jsx)(`input`,{id:e,type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),className:`relative h-5 w-9 flex-none cursor-pointer appearance-none rounded-full border border-line bg-surface-2 transition-colors before:absolute before:top-1/2 before:left-[3px] before:size-3.5 before:-translate-y-1/2 before:rounded-full before:bg-fg-2 before:transition-[left,background-color] checked:border-accent checked:bg-accent checked:before:left-[17px] checked:before:bg-on-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`})]})}var kv=`#/settings/cloud`,Av={cloud:null,busy:!1,waiting:!1,error:``},jv=new Set,Mv=null,Nv=0,Pv=null,Fv=e=>{Av={...Av,...e};for(let e of jv)e()};async function Iv(){let e=await A.request(`workspace.cloud.get`,{});e.ok&&Fv({cloud:e.data})}function Lv(){Mv&&clearTimeout(Mv),Mv=null,jv.size&&(Mv=setTimeout(async()=>{Av.waiting&&Date.now()<Nv?await Rv(`cloud`):(Av.waiting&&Fv({waiting:!1}),await Iv()),Lv()},Av.waiting?2e3:15e3))}async function Rv(e){let t=await A.request(`workspace.cloud.set`,{body:{mode:e}});if(!t.ok)return Fv({error:t.error??`HTTP ${t.status}`,waiting:!1});let n=t.data;e===Pv&&(Fv({cloud:n,waiting:e===`cloud`&&n.mode!==`cloud`&&(n.next===`connect`||n.next===`claim`),error:``}),e===`cloud`&&n.mode===`cloud`&&setTimeout(()=>location.reload(),900))}async function zv(e){Pv=e,Fv({busy:!0,error:``,waiting:!1}),e===`cloud`&&(Nv=Date.now()+6e5),await Rv(e),Fv({busy:!1}),Lv()}function Bv(){let[,e]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let t=()=>e(e=>e+1);return jv.add(t),jv.size===1&&Iv().then(Lv),()=>{jv.delete(t),!jv.size&&Mv&&(clearTimeout(Mv),Mv=null)}},[]),{...Av,to:zv}}var Vv={local:{icon:`laptop_mac`,title:`Local`,tagline:`Just you, on this machine. No account.`,points:[`Everything lives in files in this folder — boards, projects, knowledge, chats`,`Agents run here, on your subscriptions and keys`,`Tasks go to agents or to you`,`Your work stays on this machine — only minimal usage info goes out (off in kraftwerk.yml)`]},cloud:{icon:`cloud`,title:`Cloud`,tagline:`Multiplayer, and reachable from anywhere.`,points:[`Sign in with your kraftwerk cloud account — every change is signed by its person`,`Cloud boards: shared with everyone on the workspace, tasks for people and agents`,`Invite teammates as members — no clone, no install`,`Reach your workspaces from another computer or your phone`]}},Hv=[{key:`machine`,label:`Connect this machine`,done:`connected to kraftwerk cloud`,todo:`the daemon registers this machine with kraftwerk cloud`},{key:`claim`,label:`Claim it with your account`,done:`claimed`,todo:`sign in (or sign up) in the browser — once per machine`},{key:`workspace`,label:`Register this workspace`,done:`known to the cloud by its id`,todo:`kraftwerk.yml gets the workspace's id (commit it)`},{key:`signin`,label:`Sign in here`,done:`people sign in with their cloud account`,todo:`this page asks you to sign in with the account`}];function Uv({mode:e,busy:t,onPick:n}){return(0,z.jsx)(`div`,{role:`radiogroup`,"aria-label":`workspace mode`,className:`inline-flex rounded-full border border-line bg-surface-2 p-0.5`,children:[`local`,`cloud`].map(r=>(0,z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===r,disabled:t,onClick:()=>e!==r&&n(r),className:I(`inline-flex cursor-pointer items-center gap-1.5 rounded-full border-0 px-3.5 py-1.5 font-[inherit] text-sm font-semibold transition-colors disabled:cursor-default`,e===r?r===`cloud`?`bg-accent text-on-accent`:`bg-surface text-fg shadow-[0_0_0_1px_var(--line)]`:`bg-transparent text-fg-2 hover:text-fg`),children:[(0,z.jsx)(B,{name:Vv[r].icon,className:`ms-sm`}),Vv[r].title]},r))})}function Wv({cloud:e,waiting:t}){let[n,r]=(0,v.useState)(!1),i=Hv.find(t=>!e.steps[t.key])?.key;return(0,z.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2.5 p-0`,children:Hv.map((a,o)=>{let s=e.steps[a.key],c=a.key===i;return(0,z.jsxs)(`li`,{className:`flex gap-3`,children:[(0,z.jsx)(`span`,{className:I(`grid size-6 flex-none place-items-center rounded-full text-xs font-bold`,s?`bg-ok text-on-accent`:c?`bg-accent/15 text-accent ring-1 ring-accent`:`bg-surface-2 text-fg-2`),children:s?(0,z.jsx)(B,{name:`check`,className:`text-[15px]`}):o+1}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,z.jsx)(`span`,{className:I(`text-sm font-semibold`,!s&&!c&&`text-fg-2`),children:a.label}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:s?a.done:a.todo}),c&&a.key===`machine`&&e.next===`connect`&&(0,z.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1.5 text-xs text-fg-2`,children:[(0,z.jsx)(`span`,{className:`size-2 animate-pulse rounded-full bg-accent`}),` connecting …`]}),c&&a.key===`claim`&&e.next===`claim`&&e.claimUrl&&(0,z.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`a`,{className:Qe(`primary`,`sm`),href:e.claimUrl,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),` sign in & claim`]}),e.claimCode&&(0,z.jsx)(`button`,{type:`button`,title:`copy the claim code`,onClick:()=>{navigator.clipboard.writeText(e.claimCode),r(!0),setTimeout(()=>r(!1),1500)},className:`cursor-pointer rounded-control border border-line bg-surface-2 px-2.5 py-1 font-mono text-sm tracking-[0.12em] text-fg`,children:n?`copied`:e.claimCode}),t&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-2`,children:[(0,z.jsx)(`span`,{className:`size-2 animate-pulse rounded-full bg-accent`}),` `,`waiting for the claim …`]})]})]})]},a.key)})})}function Gv({cloud:e,error:t}){let n=t||e.problem;return n?(0,z.jsxs)(`p`,{className:`m-0 flex items-start gap-1.5 rounded-control bg-bad/8 px-3 py-2 text-xs text-bad`,children:[(0,z.jsx)(B,{name:`error`,className:`ms-sm`}),(0,z.jsx)(`span`,{children:n})]}):null}function Kv({mode:e}){return(0,z.jsx)(`div`,{className:`grid gap-3 min-[720px]:grid-cols-2`,children:[`local`,`cloud`].map(t=>(0,z.jsxs)(`div`,{className:I(`flex flex-col gap-2 rounded-card border p-4`,e===t?t===`cloud`?`border-accent bg-accent/5`:`border-fg/30 bg-surface`:`border-line bg-surface`),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(B,{name:Vv[t].icon,className:I(`text-[22px]`,t===`cloud`?`text-accent`:`text-fg-2`)}),(0,z.jsx)(`span`,{className:`font-semibold`,children:Vv[t].title}),e===t&&(0,z.jsx)(`span`,{className:`ml-auto rounded-full bg-surface-2 px-2 py-0.5 text-2xs font-semibold text-fg-2`,children:`this workspace`})]}),(0,z.jsx)(`span`,{className:`text-sm text-fg-2`,children:Vv[t].tagline}),(0,z.jsx)(`ul`,{className:`m-0 flex flex-col gap-1.5 pl-0`,children:Vv[t].points.map(e=>(0,z.jsxs)(`li`,{className:`flex list-none gap-2 text-sm`,children:[(0,z.jsx)(B,{name:`check`,className:I(`ms-sm mt-px`,t===`cloud`?`text-accent`:`text-fg-2`)}),(0,z.jsx)(`span`,{children:e})]},e))})]},t))})}var qv={local:{icon:`laptop_mac`,title:`Local only`,text:`Runs on this machine. Not connected to kraftwerk cloud — nobody else gets in.`},connected:{icon:`cloud_sync`,title:`Local, cloud connected`,text:`Runs on this machine: files and agents are here. The cloud signs people in and shares boards — it works while this machine is on.`},hosted:{icon:`cloud_done`,title:`Runs in the cloud`,text:`Runs on kraftwerk cloud's hardware: files and agents are there, and it keeps running with every machine off.`}};function Jv({place:e}){return(0,z.jsx)(`ol`,{className:`places m-0 flex list-none flex-col gap-1 p-0`,children:Object.keys(qv).map(t=>{let n=t===e;return(0,z.jsxs)(`li`,{"aria-current":n?`true`:void 0,className:I(`flex items-start gap-2.5 rounded-control border px-2.5 py-2`,n?t===`hosted`?`border-accent bg-accent text-on-accent`:t===`connected`?`border-accent/50 bg-accent/10`:`border-fg/30 bg-surface-2`:`border-transparent opacity-55`),children:[(0,z.jsx)(B,{name:qv[t].icon,className:`mt-px text-[18px]`}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[qv[t].title,n&&(0,z.jsx)(`span`,{className:I(`rounded-full px-1.5 text-2xs font-semibold`,t===`hosted`?`bg-on-accent/20`:`bg-fg/10`),children:`this workspace`})]}),n&&(0,z.jsx)(`span`,{className:I(`text-xs`,t===`hosted`?`opacity-90`:`text-fg-2`),children:qv[t].text})]})]},t)})})}function Yv({hosted:e}){return(0,z.jsxs)(`span`,{className:I(`runs-chip inline-flex flex-none items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-semibold`,e?`border-accent bg-accent text-on-accent`:`border-line bg-transparent text-fg-2`),"data-runs":e?`cloud`:`machine`,title:e?qv.hosted.text:`Runs on a machine: its files and agents are there, not in kraftwerk cloud`,children:[(0,z.jsx)(B,{name:e?`cloud_done`:`laptop_mac`,className:`ms-sm`}),(0,z.jsx)(`span`,{className:`max-[640px]:hidden`,children:e?`runs in the cloud`:`runs on this machine`})]})}function Xv(){let e=F(`me.get`,{},{interval:6e4}),t=Bv(),{cloud:n}=t,r=e?.runsIn===`cloud`;if(!n||e?.via===`member`)return r?(0,z.jsx)(Yv,{hosted:!0}):null;let i=n.mode===`cloud`,a=r?`hosted`:i?`connected`:`local`,o=i&&n.state!==`connected`,s=i&&n.workspaceUrl&&!n.deleted?n.workspaceUrl:null;return(0,z.jsxs)(`span`,{className:`inline-flex flex-none items-center gap-1`,children:[!r&&(0,z.jsx)(Yv,{hosted:!1}),(0,z.jsx)(Nt,{align:`end`,className:`w-[min(380px,calc(100vw-24px))] p-0`,trigger:({toggle:e,open:t})=>(0,z.jsxs)(`button`,{type:`button`,className:I(`mode-chip inline-flex flex-none cursor-pointer items-center gap-1.5 rounded-full border px-2.5 py-1 font-[inherit] text-xs font-semibold transition-colors`,i&&n.deleted?`border-bad/40 bg-bad/10 text-bad hover:bg-bad/18`:r?`border-accent bg-accent text-on-accent hover:bg-accent-hover`:i?`border-accent/40 bg-accent/10 text-accent hover:bg-accent/18`:`border-line bg-transparent text-fg-2 hover:text-fg`,t&&`ring-2 ring-accent/30`),"aria-label":`workspace mode: ${n.mode}`,"data-place":a,title:i?n.deleted?`Deleted in kraftwerk cloud — switch to local to keep working`:o?`Cloud mode — the cloud does not answer right now`:r?qv.hosted.text:`Cloud connected — multiplayer; the workspace itself runs on this machine`:`Local only — connect to the cloud for multiplayer`,onClick:e,children:[(0,z.jsx)(B,{name:i?o?`cloud_off`:r?`cloud_done`:`cloud_sync`:`cloud_off`,className:`ms-sm`}),(0,z.jsx)(`span`,{className:`max-[640px]:hidden`,children:i?n.deleted?`cloud · deleted`:r?`runs in the cloud`:o?`cloud not answering`:`cloud connected`:`local only`}),!i&&(0,z.jsx)(`span`,{className:`rounded-full bg-accent/12 px-1.5 text-2xs text-accent max-[900px]:hidden`,children:`try cloud`})]}),children:e=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,z.jsx)(`span`,{className:`text-sm font-semibold`,children:`Where this workspace is`}),(0,z.jsx)(Jv,{place:a}),!r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-line pt-3`,children:[(0,z.jsx)(`span`,{className:`text-sm font-semibold`,children:`Cloud connection`}),(0,z.jsx)(Uv,{mode:t.waiting?`cloud`:n.mode,busy:t.busy,onPick:e=>void t.to(e)})]}),(0,z.jsx)(nt,{children:i?`Connected: people sign in with their kraftwerk cloud account, cloud boards are shared, members join without a clone. Your files and agents stay on this machine.`:`Just you, everything in files on this machine. Connect to the cloud to work with others and reach this workspace from anywhere — your files and agents stay here.`})]}),t.waiting&&(0,z.jsx)(Wv,{cloud:n,waiting:!0}),(0,z.jsx)(Gv,{cloud:n,error:t.error}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:kv,onClick:e,children:[(0,z.jsx)(B,{name:`info`,className:`ms-sm`}),` local or cloud?`]}),n.url&&(0,z.jsxs)(`a`,{className:Qe(`quiet`,`sm`),href:s??n.url,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),` `,s?`open in the cloud`:`open kraftwerk cloud`]})]})]})}),s&&(0,z.jsx)(`a`,{className:`cloud-link grid size-7 flex-none place-items-center rounded-full text-accent no-underline transition-colors hover:bg-accent/12`,href:s,target:`_blank`,rel:`noreferrer`,title:`Open this workspace in kraftwerk cloud`,"aria-label":`open this workspace in kraftwerk cloud`,children:(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`})})]})}function Zv(){let e=Bv(),{cloud:t}=e;return t?(0,z.jsx)(X,{title:`local or cloud`,actions:(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:kv,children:[(0,z.jsx)(B,{name:`info`,className:`ms-sm`}),` what's the difference?`]}),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 px-[18px] py-3.5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(Uv,{mode:e.waiting?`cloud`:t.mode,busy:e.busy,onPick:t=>void e.to(t)}),(0,z.jsx)(`span`,{className:`text-sm text-fg-2`,children:t.mode===`cloud`?Vv.cloud.tagline:Vv.local.tagline})]}),e.waiting&&(0,z.jsx)(Wv,{cloud:t,waiting:!0}),t.mode===`cloud`&&!e.waiting&&(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-fg-2`,children:[(0,z.jsx)(B,{name:`cloud_sync`,className:`ms-sm`}),`The workspace's files: kraftwerk sync keeps them in step through kraftwerk cloud, for everyone on it — set up and set under `,(0,z.jsx)(`a`,{href:`#/settings`,children:`git sync`}),`.`]}),(0,z.jsx)(Gv,{cloud:t,error:e.error})]})}):null}function Qv(){let e=Bv(),{cloud:t}=e,n=t?.mode;return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:n===`cloud`?`cloud`:`laptop_mac`,title:`Local or cloud`,sub:`kraftwerk runs fully on your machine. Cloud mode adds people — and a way in from anywhere.`,actions:t&&(0,z.jsx)(Uv,{mode:e.waiting?`cloud`:t.mode,busy:e.busy,onPick:t=>void e.to(t)})}),(0,z.jsx)(Kv,{mode:n}),t&&(0,z.jsx)(X,{title:n===`cloud`?`cloud mode is on`:`switching to cloud`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3.5 px-[18px] py-4`,children:[n!==`cloud`&&!e.waiting&&(0,z.jsx)(nt,{children:`One click does it: kraftwerk connects this machine, registers the workspace and — the only step you do yourself — opens the cloud so you can sign in and claim the machine. Then this page asks you to sign in. Switching back to local is just as quick.`}),(0,z.jsx)(Wv,{cloud:t,waiting:e.waiting}),(0,z.jsx)(Gv,{cloud:t,error:e.error}),(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n===`cloud`?(0,z.jsxs)(z.Fragment,{children:[t.workspaceUrl&&(0,z.jsxs)(`a`,{className:Qe(`primary`,`sm`),href:t.workspaceUrl,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),` open the workspace in the cloud`]}),(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:`#/boards`,children:[(0,z.jsx)(B,{name:`view_kanban`,className:`ms-sm`}),` create a cloud board`]})]}):(0,z.jsx)(K,{variant:`primary`,icon:`cloud`,busy:e.busy||e.waiting,onClick:()=>void e.to(`cloud`),children:e.waiting?t.next===`connect`?`connecting …`:`waiting for the claim …`:`switch to cloud`})})]})}),(0,z.jsx)(ey,{}),(0,z.jsx)(Tv,{})]})}var $v=[[`What goes to the cloud?`,(0,z.jsxs)(z.Fragment,{children:[`In both modes your files, chats, knowledge, runs and agent sessions stay on this machine. Even in local mode, kraftwerk reports minimal usage info: the daemon registers the machine (its name, your handle, hostname, platform and kraftwerk version) and the workspaces it serves (their names and ids, no folder paths, no content). It is on by default;`,` `,(0,z.jsxs)(`code`,{children:[`cloud: `,`{ enabled: false }`]}),` in a workspace's kraftwerk.yml leaves that workspace out, `,(0,z.jsx)(`code`,{children:`kraftwerk cloud off`}),` stops it for the whole machine. Once you claim the machine, the cloud also learns the folder paths and which routines ran. In cloud mode, cloud boards and their tasks live in the cloud.`]})],[`Do my agents run in the cloud?`,(0,z.jsx)(z.Fragment,{children:`No. Agents always run here, on your own subscriptions and keys. In cloud mode they can pick up tasks from cloud boards, signed as themselves.`})],[`Can I go back to local?`,(0,z.jsx)(z.Fragment,{children:`Any time, with the same switch: nobody needs to sign in any more and cloud boards disappear from view — they stay in the cloud until you switch back. Local boards are untouched either way.`})],[`What about my teammates?`,(0,z.jsxs)(z.Fragment,{children:[`In cloud mode, `,(0,z.jsx)(`code`,{children:`kraftwerk invite`}),` (or the cloud's workspace page) gives them a link: they join as members and open the workspace from their browser — no clone, no install. Someone with a clone of the repo signs in with their own account on their own machine.`]})],[`And in the terminal?`,(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`code`,{children:`kraftwerk cloud connect`}),` does the same as the switch,`,` `,(0,z.jsx)(`code`,{children:`kraftwerk cloud disconnect`}),` goes back;`,` `,(0,z.jsx)(`code`,{children:`kraftwerk boards create <title> --cloud`}),` makes a cloud board.`]})]];function ey(){return(0,z.jsx)(X,{title:`questions`,children:(0,z.jsx)(`div`,{className:`flex flex-col divide-y divide-line`,children:$v.map(([e,t])=>(0,z.jsxs)(`details`,{className:`group px-[18px] py-3`,children:[(0,z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-semibold`,children:[(0,z.jsx)(B,{name:`chevron_right`,className:`ms-sm transition-transform group-open:rotate-90`}),e]}),(0,z.jsx)(`p`,{className:`m-0 mt-2 pl-6 text-sm text-fg-2`,children:t})]},e))})})}function ty(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 ny=[[/^(\+\+\+|---|diff |index )/,`text-fg-2 opacity-80`],[/^@@/,`text-accent`],[/^\+/,`text-ok`],[/^-/,`text-bad`]],ry=e=>ny.find(([t])=>t.test(e))?.[1]??``;function iy({file:e}){return(0,z.jsx)(oy,{source:{route:`git.diff`,input:{query:{path:e}}}})}var ay=e=>(e.route===`git.diff`||e.route===`repos.diff`||e.route,A.request(e.route,e.input));function oy({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(``),ay(e).then(e=>{if(t){if(!e.data||typeof e.data!=`object`)throw Error(`not json`);e.ok?(r(e.data.diff??``),a(!!e.data.truncated),s(e.data.error??``)):(r(``),a(!1),s(e.error??``))}}).catch(()=>t&&s(`could not load the diff`)),()=>{t=!1}},[c,t]),o?(0,z.jsx)(`div`,{className:I(sy,`text-bad`),children:o}):n===null?(0,z.jsx)(`div`,{className:sy,children:`loading…`}):n.trim()?(0,z.jsxs)(`pre`,{className:sy,children:[n.split(`
471
+ `).map((e,t)=>(0,z.jsxs)(`span`,{className:ry(e),children:[e||` `,`
472
472
  `]},t)),i&&(0,z.jsxs)(`span`,{className:`text-fg-2 opacity-80`,children:[`… diff truncated, see the rest in a terminal`,`
473
- `]})]}):(0,z.jsx)(`div`,{className:iy,children:`no textual diff (binary or empty)`})}var iy=`git-diff mt-1.5 mb-0.5 max-h-[420px] basis-full overflow-auto rounded-xl bg-surface-2 px-3 py-2.5 font-mono text-[11.5px] leading-[1.5] whitespace-pre`,ay={modified:`text-accent`,added:`text-ok`,untracked:`text-ok`,deleted:`text-bad`,conflicted:`text-bad`};function oy({status:e,muted:t}){return(0,z.jsx)(`span`,{className:I(`flex-none rounded-full border border-line px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.4px] uppercase`,t?`text-fg-2`:ay[e]??`text-fg-2`),children:e})}var sy=`text-xs text-fg-2`,cy=`m-0 p-[18px] text-sm text-fg-2`;function ly(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(new Set),[i,a]=(0,v.useState)(new Set),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),m=(0,v.useRef)(!0),h=(0,v.useCallback)(async()=>{try{let e=await A.request(`git.status`,{query:{fresh:m.current}});m.current=!1,e.ok&&t(e.data)}catch{}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await h(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[h]),(0,v.useEffect)(()=>{if(!e?.files)return;let t=new Set(e.files.filter(e=>e.syncable).map(e=>e.path));r(e=>{let n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[e]);let g=async(e,t)=>{l(e),d(``),p(``);try{let n=await A.request(`git.${e}`,{body:t??{}});n.ok&&n.data.ok?p(e===`push`?`pushed`:e===`pull`?`pulled`:`fetched`):d(P(n)||`${e} failed`)}catch(t){d(t.message||`${e} failed`)}finally{l(``)}h()},_=async()=>{l(`commit`),d(``),p(``);try{let e=await A.request(`git.commit`,{body:{paths:[...n],message:o}});e.ok&&e.data.ok?(p(`committed ${n.size} file${n.size===1?``:`s`}`),r(new Set),s(``)):d(P(e)||`commit failed`)}catch(e){d(e.message||`commit failed`)}finally{l(``)}h()};if(!e)return(0,z.jsx)(Y,{children:`loading…`});if(!e.enabled)return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:`cloud_sync`,title:`Git sync`}),(0,z.jsx)(X,{children:(0,z.jsxs)(`p`,{className:cy,children:[`Git sync is off. Turn it on in `,(0,z.jsx)(`a`,{href:`#/settings`,children:`settings → git sync`}),` — in cloud mode with kraftwerk sync in one click — or add a `,(0,z.jsx)(`code`,{children:`git:`}),` block to kraftwerk.yml.`]})})]});let y=(e.files??[]).filter(e=>e.syncable),b=(e.files??[]).filter(e=>!e.syncable),x=(e,t)=>r(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:`cloud_sync`,title:`Git sync`,actions:(0,z.jsxs)(z.Fragment,{children:[f&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-sm text-ok`,children:[(0,z.jsx)(B,{name:`check`,className:`ms-sm`}),` `,f]}),u&&(0,z.jsx)(rt,{tone:`bad`,children:u})]})}),!e.error&&(0,z.jsx)(dy,{st:e}),(0,z.jsx)(X,{title:`branch`,actions:(0,z.jsxs)(z.Fragment,{children:[e.lastFetch&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.lastFetch,children:[`fetched `,G(e.lastFetch)]}),e.lastError&&(0,z.jsxs)(`span`,{className:`inline-flex max-w-[46ch] items-center gap-1 truncate text-xs text-bad`,title:e.lastError,children:[(0,z.jsx)(B,{name:`cloud_off`,className:`ms-sm`}),` `,e.lastError.split(`
474
- `)[0]]})]}),children:e.error?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 p-[18px] text-sm text-bad`,children:[(0,z.jsx)(B,{name:`error`,className:`ms-sm`}),` `,e.error]}):(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-[18px] py-3.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-base`,children:[(0,z.jsx)(B,{name:`account_tree`,className:`ms-sm`}),(0,z.jsx)(`strong`,{className:`font-mono`,children:e.branch}),(0,z.jsx)(`span`,{className:sy,children:e.upstream?`tracking ${e.upstream}`:`no upstream yet, push sets one`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[12.5px] font-semibold`,children:[e.diverged&&(0,z.jsx)(`span`,{className:`text-bad`,children:`diverged, resolve in a terminal`}),!!e.behind&&(0,z.jsxs)(`span`,{className:`text-accent`,children:[e.behind,` behind`]}),!!e.ahead&&(0,z.jsxs)(`span`,{className:`text-ok`,children:[e.ahead,` ahead`]}),!e.ahead&&!e.behind&&(0,z.jsx)(`span`,{className:I(`text-xs text-fg-2`,`font-normal`),children:`up to date`})]}),(0,z.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(K,{size:`sm`,icon:`refresh`,busy:c===`fetch`,disabled:!!c,onClick:()=>void g(`fetch`),children:`fetch`}),(0,z.jsx)(K,{size:`sm`,icon:`download`,busy:c===`pull`,disabled:!!c||!e.behind||e.diverged,title:e.diverged?`Diverged. Resolve in a terminal.`:`Fast-forward to the remote`,onClick:()=>void g(`pull`),children:`pull`}),(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`upload`,busy:c===`push`,disabled:!!c||!e.ahead&&!!e.upstream,title:e.upstream?`Push to the upstream`:`Push and set the upstream`,onClick:()=>void g(`push`),children:`push`})]})]})}),!!e.conflicts?.length&&(0,z.jsxs)(X,{title:`conflicts kept beside`,actions:(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`two people changed these at once — the version that reached the cloud first stays, the other is next to it`}),children:[e.conflicts.map(e=>(0,z.jsxs)(`div`,{className:I(`git-conflict px-[18px]`,gy),children:[(0,z.jsx)(B,{name:`call_split`,className:`ms-sm text-accent`}),(0,z.jsx)(`span`,{className:_y,children:e.path}),(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[e.by,`'s version:`]}),(0,z.jsx)(`span`,{className:I(_y,`text-accent`),children:e.copy}),(0,z.jsx)(`span`,{className:I(`text-xs text-fg-2`,`ml-auto`),title:e.at,children:G(e.at)})]},e.copy+e.at)),(0,z.jsx)(`p`,{className:I(`text-xs text-fg-2`,`m-0 border-t border-line px-[18px] py-2.5`),children:`Compare the two, keep what is right in the original, and delete the copy — the deletion syncs like any change.`})]}),(0,z.jsxs)(X,{title:`changes`,actions:(0,z.jsx)(`span`,{className:sy,children:y.length===0?`workspace clean`:`${n.size} of ${y.length} selected`}),children:[y.length===0&&b.length===0&&(0,z.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Nothing changed under the workspace paths.`}),y.map(e=>(0,z.jsxs)(`div`,{className:I(`git-row px-[18px]`,gy),children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,"aria-label":`select ${e.path}`,checked:n.has(e.path),onChange:t=>x(e.path,t.target.checked)}),(0,z.jsxs)(`button`,{type:`button`,className:`group/file flex min-w-0 flex-1 cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),children:[(0,z.jsx)(B,{name:i.has(e.path)?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,z.jsx)(oy,{status:e.status}),(0,z.jsx)(`span`,{className:I(_y,`group-hover/file:underline`),children:e.path})]}),i.has(e.path)&&(0,z.jsx)(ty,{file:e.path})]},e.path)),y.length>0&&(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5 border-t border-line bg-surface-2 px-[18px] py-3`,children:[(0,z.jsx)(Z,{className:`min-w-[220px] flex-1 text-sm`,placeholder:`Commit message`,"aria-label":`commit message`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!c&&o.trim()&&n.size>0&&_()}}),(0,z.jsx)(K,{size:`sm`,disabled:n.size===y.length,onClick:()=>r(new Set(y.map(e=>e.path))),children:`select all`}),(0,z.jsxs)(K,{size:`sm`,variant:`primary`,icon:`check`,busy:c===`commit`,disabled:!!c||n.size===0||!o.trim(),onClick:()=>void _(),children:[`commit `,n.size||``]})]}),b.length>0&&(0,z.jsxs)(`details`,{className:`border-t border-line px-[18px] py-2.5`,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer text-[12.5px] text-fg-2`,children:[b.length,e.blockedHidden?`+`:``,` change`,b.length===1&&!e.blockedHidden?``:`s`,` outside the workspace paths`]}),b.map(e=>(0,z.jsxs)(`div`,{className:I(`git-row blocked opacity-60`,gy),children:[(0,z.jsx)(oy,{status:e.status,muted:!0}),(0,z.jsx)(`span`,{className:_y,children:e.path}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:e.reason})]},e.path)),!!e.blockedHidden&&(0,z.jsx)(`div`,{className:I(`git-row blocked opacity-60`,gy),children:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`and `,e.blockedHidden,` more, not listed`]})})]})]}),!e.error&&(0,z.jsx)(fy,{refresh:`${e.branch}/${e.ahead}/${e.behind}/${e.lastPull}/${e.lastPush}/${e.lastAutoCommit}/${e.files?.length}`}),!e.error&&(0,z.jsx)(py,{st:e}),(0,z.jsxs)(`p`,{className:I(sy,`m-0`),children:[`Synced paths: `,(e.scope??[]).map((e,t)=>(0,z.jsxs)(`span`,{children:[t>0&&`, `,(0,z.jsx)(`code`,{children:e})]},e)),`. Run artifacts and files like `,(0,z.jsx)(`code`,{children:`.env`}),` are never staged.`,` `,e.interval&&e.autosync===`sync`?`kraftwerk sync every ${Qv(e.interval)}: commits what changed under these paths, takes the remote's changes in and pushes. Where both sides changed a file, the remote's version wins and yours is kept beside it.${e.lastAutoCommit?` Last automatic commit ${G(e.lastAutoCommit)}.`:``} `:e.interval?`Fetches every ${Qv(e.interval)}${e.autosync===`push`?`, fast-forwards when the working tree is clean and pushes what is committed`:e.autosync===`pull`?` and fast-forwards when the working tree is clean`:``}. `:`Background fetching is off. `,e.interval&&e.autosync===`sync`?`A commit by hand goes up at once.`:e.interval&&e.autosync===`push`?`Committing is always manual.`:`Commit and push are always manual.`]})]})}var uy={kraftwerk:{icon:`cloud_done`,label:`managed by kraftwerk`,text:`kraftwerk sync: this workspace's own repository in kraftwerk cloud. Everyone on the workspace pulls and pushes here, with their cloud account — access follows the workspace's members, no git provider to set up.`},custom:{icon:`construction`,label:`own git provider · expert mode`,text:`This workspace syncs through a git server of your own (GitHub, GitLab, Bitbucket, a server in-house). Hosting, access and credentials are yours to manage there; kraftwerk only fetches, pulls and pushes.`},none:{icon:`cloud_off`,label:`no remote yet`,text:"History stays on this machine. In cloud mode, kraftwerk sync gives the workspace a repository in kraftwerk cloud and keeps it in step with everyone's; or add a remote of your own with `git remote add`."}};function dy({st:e}){let{cloud:t}=Bv(),[n,r]=(0,v.useState)(!1),i=e.hosting??(e.remoteUrl?`custom`:`none`),a=uy[i],o=``;try{o=e.remoteUrl?new URL(e.remoteUrl).host:``}catch{o=e.remoteUrl?.match(/@([^:]+):/)?.[1]??``}return(0,z.jsx)(X,{title:`repository`,actions:(0,z.jsxs)(`span`,{className:I(`git-hosting inline-flex items-center gap-1 text-xs font-semibold`,i===`kraftwerk`?`text-ok`:i===`custom`?`text-accent`:`text-fg-2`),children:[(0,z.jsx)(B,{name:a.icon,className:`ms-sm`}),` `,a.label]}),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-[18px] py-3.5`,children:[e.remoteUrl?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:sy,children:e.remote??`origin`}),(0,z.jsx)(`code`,{className:`git-remote-url min-w-0 flex-1 truncate rounded-lg bg-surface-2 px-2.5 py-1.5 font-mono text-[12.5px]`,title:e.remoteUrl,children:e.remoteUrl}),(0,z.jsx)(K,{size:`sm`,icon:n?`check`:`content_copy`,onClick:()=>{navigator.clipboard?.writeText(e.remoteUrl).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})},children:n?`copied`:`copy`})]}):null,(0,z.jsxs)(`div`,{className:I(sy,`flex flex-wrap items-center gap-x-1.5`),children:[(0,z.jsx)(`span`,{children:a.text}),e.repoRoot&&(0,z.jsxs)(`span`,{children:[`Local folder `,(0,z.jsx)(`code`,{children:e.repoRoot}),`.`]}),i===`kraftwerk`&&t?.workspaceUrl&&(0,z.jsx)(`a`,{href:t.workspaceUrl,target:`_blank`,rel:`noreferrer`,children:`the workspace in kraftwerk cloud ↗`}),i===`custom`&&o&&(0,z.jsxs)(`span`,{children:[`Provider: `,(0,z.jsx)(`strong`,{children:o}),`.`]}),i===`none`&&(0,z.jsx)(`a`,{href:`#/settings`,children:`set up kraftwerk sync in settings → git sync`}),i===`custom`&&(0,z.jsx)(`a`,{href:`#/settings/cloud`,children:`what kraftwerk sync is`})]})]})})}function fy({refresh:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=!0;return A.request(`git.log`,{}).then(t=>e&&t.ok&&n(t.data.commits)).catch(()=>{}),()=>{e=!1}},[e]),!t)return null;let a=t.filter(e=>e.local).length;return(0,z.jsxs)(X,{title:`history · newest first`,actions:(0,z.jsx)(`span`,{className:sy,children:a?`${a} not pushed`:t.length?`all pushed`:``}),children:[t.length===0&&(0,z.jsx)(`p`,{className:I(`text-xs text-fg-2`,`m-0 px-[18px] py-3.5`),children:`No commits under the workspace paths yet.`}),t.map(e=>(0,z.jsxs)(`div`,{className:`git-commit border-line px-[18px] py-2 [&+&]:border-t`,"data-commit":e.short,children:[(0,z.jsxs)(`button`,{type:`button`,className:`group/item flex w-full cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,onClick:()=>i(r===e.hash?null:e.hash),title:e.hash,children:[(0,z.jsx)(B,{name:r===e.hash?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,z.jsx)(`code`,{className:`text-xs`,children:e.short}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm group-hover/item:underline`,children:e.subject}),e.local&&(0,z.jsx)(`span`,{className:`flex-none rounded-md border border-accent px-1.5 text-[10.5px] font-semibold tracking-wide text-accent uppercase`,children:`not pushed`}),(0,z.jsxs)(`span`,{className:I(sy,`ml-auto flex-none`),children:[e.author,` · `,G(e.committedAt)]})]}),r===e.hash&&(0,z.jsx)(ry,{source:{route:`git.commitDiff`,input:{hash:e.hash}}})]},e.hash))]})}function py({st:e}){let t=e.ignores??[],n=t.reduce((e,t)=>e+t.rules.length+(t.more??0),0);return(0,z.jsx)(X,{title:`ignored`,actions:(0,z.jsx)(`span`,{className:sy,children:t.length?`${n} rule${n===1?``:`s`} in ${t.length} file${t.length===1?``:`s`}`:`no .gitignore`}),children:(0,z.jsxs)(`div`,{className:`git-ignored flex flex-col gap-2 px-[18px] py-3.5`,children:[(0,z.jsxs)(`div`,{className:sy,children:[`Files matching these rules never reach git: they are not listed above, not committed and not synced. Edit a `,(0,z.jsx)(`code`,{children:`.gitignore`}),` to change that.`]}),t.map((e,t)=>(0,z.jsxs)(`details`,{open:t===0,className:`git-ignore-file rounded-lg border border-line`,children:[(0,z.jsxs)(`summary`,{className:`flex cursor-pointer items-center gap-2 px-2.5 py-1.5 text-[12.5px]`,children:[(0,z.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.path}),(0,z.jsx)(`span`,{className:sy,children:e.rules.length+(e.more??0)})]}),(0,z.jsxs)(`pre`,{className:`m-0 overflow-x-auto border-t border-line bg-surface-2 px-2.5 py-2 font-mono text-[12.5px] leading-relaxed`,children:[e.rules.length?e.rules.join(`
475
- `):`(no rules)`,e.more?`\n… ${e.more} more`:``]})]},e.path))]})})}function my({onSetup:e}){let[t,n]=(0,v.useState)(null),r=(0,v.useCallback)(async()=>{try{let e=await A.request(`git.status`,{query:{fresh:!0}});e.ok&&n(e.data)}catch{}},[]);if((0,v.useEffect)(()=>void r(),[r]),!t)return null;let i=t.enabled?t.hosting??(t.remoteUrl?`custom`:`none`):`none`,a=uy[i];return(0,z.jsxs)(z.Fragment,{children:[t.remoteUrl&&(0,z.jsxs)(`div`,{className:`git-remote-summary flex flex-wrap items-center gap-2 border-t border-line px-[18px] py-3`,children:[(0,z.jsxs)(`span`,{className:I(`inline-flex items-center gap-1 text-xs font-semibold`,i===`kraftwerk`?`text-ok`:`text-accent`),children:[(0,z.jsx)(B,{name:a.icon,className:`ms-sm`}),` `,a.label]}),(0,z.jsx)(`code`,{className:`min-w-0 flex-1 truncate rounded-lg bg-surface-2 px-2.5 py-1 font-mono text-xs`,title:t.remoteUrl,children:t.remoteUrl})]}),i===`none`&&(0,z.jsx)(hy,{onDone:()=>{r(),e()}})]})}function hy({onDone:e}){let{cloud:t}=Bv(),[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)([]),c=t?.mode===`cloud`&&t.steps.claim,l=async()=>{r(!0),a(``);try{let t=await A.request(`git.setupSync`,{body:{}});t.ok&&t.data.ok?(s(t.data.done),e()):(t.data&&typeof t.data==`object`&&`done`in t.data&&Array.isArray(t.data.done)&&s(t.data.done),a(P(t)||`setting up kraftwerk sync failed`),e())}catch(e){a(e.message||`setting up kraftwerk sync failed`)}finally{r(!1)}};return(0,z.jsxs)(`div`,{className:`sync-setup flex flex-col gap-2 border-t border-line bg-surface-2 px-[18px] py-3.5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,z.jsx)(`strong`,{className:`text-sm`,children:`Sync with kraftwerk cloud`}),(0,z.jsx)(`div`,{className:sy,children:c?`One click: the workspace gets its repository in kraftwerk cloud and kraftwerk sync turns on — every minute what changed here goes up and the others' changes come in. This machine signs in with its own key — no token, no git provider.`:`kraftwerk sync comes with cloud mode: switch the workspace to cloud (below), then set it up here in one click. Or turn git sync on and use a remote of your own (expert mode).`})]}),c?(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`cloud_upload`,busy:n,disabled:n,onClick:()=>void l(),children:`set up kraftwerk sync`}):(0,z.jsx)(`a`,{className:`text-sm font-semibold`,href:`#/settings/cloud`,children:`what cloud mode is →`})]}),o.length>0&&(0,z.jsx)(`ul`,{className:I(`text-xs text-fg-2`,`m-0 list-none p-0`),children:o.map(e=>(0,z.jsxs)(`li`,{className:`inline-flex items-center gap-1 pr-3 text-ok`,children:[(0,z.jsx)(B,{name:`check`,className:`ms-sm`}),` `,e]},e))}),i&&(0,z.jsx)(rt,{tone:`bad`,children:i})]})}var gy=`flex flex-wrap items-center gap-2.5 py-2 [&+&]:border-t [&+&]:border-line`,_y=`truncate font-mono text-[12.5px]`,vy=e=>e.replace(/^https?:\/\//,``).replace(/^git@([^:]+):/,`$1/`).replace(/\.git$/,``),yy=e=>e.error?{label:`unreadable`,state:`unreadable`}:e.dirty?{label:`${e.dirty} changed`,state:`changed`}:e.ahead?{label:`${e.ahead} to push`,state:`clean`}:e.behind?{label:`${e.behind} behind`,state:`behind`}:{label:`clean`,state:`clean`};function by({label:e,state:t}){return(0,z.jsx)(`span`,{className:I(`inline-flex items-center text-2xs font-semibold tracking-[0.4px] uppercase`,t===`clean`?`text-ok`:t===`changed`?`text-ask`:t===`unreadable`?`text-bad`:`text-fg-2`),children:e})}var xy=`rounded-full border border-line px-[7px] py-px font-mono text-xs text-fg-2`,Sy=`border-line px-[18px] py-2 [&+&]:border-t`,Cy=`group/item flex w-full cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,wy=`min-w-0 truncate font-mono text-[12.5px] group-hover/item:underline`;function Ty({title:e,embedded:t,children:n}){return(0,z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-3`,children:[!t&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`arrow_back`,href:`/repos`,title:`all repositories`,children:`repositories`}),!t&&(0,z.jsx)(B,{name:`folder_data`,className:`text-[26px] text-fg-2`}),!t&&(0,z.jsx)(ot,{children:e}),n]})}var Ey=e=>!!(e.error||e.dirty||e.ahead===void 0||e.ahead);function Dy({slug:e}){return e?(0,z.jsx)(Oy,{slug:e}):(0,z.jsx)(ky,{})}function Oy({slug:e,embedded:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(0),g=(0,v.useCallback)(async()=>{try{let t=await A.request(`repos.get`,{slug:e});if(!t.ok)throw Error(P(t));r(t.data),a(``)}catch(e){a(e.message||`could not load the repository`)}},[e]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await g(),e&&(t=setTimeout(n,5e3))};return n(),()=>{e=!1,clearTimeout(t)}},[g,m]);let _=async()=>{d(`update`),p(``);try{let t=await A.request(`repos.update`,{slug:e});if(!t.ok||!t.data.ok)throw Error(t.error||`failed`);t.data.error&&p(t.data.error)}catch(e){p(e.message)}finally{d(``),h(e=>e+1)}};if(i&&!n)return(0,z.jsxs)(ct,{className:`repo-page`,children:[(0,z.jsx)(Ty,{title:e,embedded:t}),(0,z.jsx)(rt,{tone:`bad`,children:i})]});if(!n)return(0,z.jsx)(Y,{children:`loading…`});let y=yy(n),b=n.commits.filter(e=>e.local).length;return(0,z.jsxs)(ct,{className:`repo-page`,children:[(0,z.jsxs)(Ty,{title:n.slug,embedded:t,children:[n.branch&&(0,z.jsx)(`span`,{className:xy,children:n.branch}),n.upstream&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,title:`upstream`,children:[`→ `,n.upstream]}),(0,z.jsx)(by,{...y}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(K,{size:`sm`,icon:`sync`,busy:u===`update`,disabled:!!u,onClick:()=>void _(),title:`git fetch, then fast-forward when clean`,children:u===`update`?`updating…`:`update`})]}),(0,z.jsxs)(`div`,{className:I(sy,`flex flex-wrap gap-x-3.5 gap-y-1`),children:[n.url&&(0,z.jsx)(`span`,{title:n.url,children:vy(n.url)}),(0,z.jsx)(`span`,{title:n.path,children:n.path}),n.head&&(0,z.jsxs)(`span`,{children:[`at `,(0,z.jsx)(`code`,{children:n.head}),n.committedAt?` · ${G(n.committedAt)}`:``]}),!!n.ahead&&(0,z.jsxs)(`span`,{children:[n.ahead,` to push`]}),!!n.behind&&(0,z.jsxs)(`span`,{children:[n.behind,` behind`]}),n.updatedAt&&(0,z.jsxs)(`span`,{children:[`changed `,G(n.updatedAt)]})]}),(n.error||f||i)&&(0,z.jsx)(rt,{tone:`bad`,children:n.error||f||i}),(0,z.jsxs)(X,{title:`changes · working tree against HEAD`,actions:(0,z.jsxs)(`span`,{className:sy,children:[n.files.length,` file`,n.files.length===1?``:`s`,n.insertions||n.deletions?(0,z.jsxs)(z.Fragment,{children:[` · `,(0,z.jsxs)(`span`,{className:`text-ok`,children:[`+`,n.insertions]}),` `,(0,z.jsxs)(`span`,{className:`text-bad`,children:[`−`,n.deletions]})]}):null]}),children:[n.files.length===0&&(0,z.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Clean — nothing changed since the last commit.`}),n.files.map(t=>(0,z.jsxs)(`div`,{className:I(`repo-file`,Sy),"data-file":t.path,children:[(0,z.jsxs)(`button`,{type:`button`,className:Cy,onClick:()=>s(o===t.path?null:t.path),children:[(0,z.jsx)(B,{name:o===t.path?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,z.jsx)(oy,{status:t.status}),(0,z.jsx)(`span`,{className:wy,children:t.path})]}),o===t.path&&(0,z.jsx)(ry,{source:{route:`repos.diff`,input:{slug:e,query:{path:t.path}}},refresh:n.updatedAt})]},t.path))]}),(0,z.jsxs)(X,{title:`commits · newest first`,actions:(0,z.jsx)(`span`,{className:sy,children:b?`${b} not pushed`:n.commits.length?`all pushed`:``}),children:[n.commits.length===0&&(0,z.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`No commits yet.`}),n.commits.map(t=>(0,z.jsxs)(`div`,{className:I(`repo-commit`,Sy),"data-commit":t.short,children:[(0,z.jsxs)(`button`,{type:`button`,className:Cy,onClick:()=>l(c===t.hash?null:t.hash),title:t.hash,children:[(0,z.jsx)(B,{name:c===t.hash?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,z.jsx)(`code`,{className:`text-xs`,children:t.short}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm group-hover/item:underline`,children:t.subject}),t.local&&(0,z.jsx)(J,{tone:`accent`,children:`not pushed`}),(0,z.jsxs)(`span`,{className:I(sy,`ml-auto flex-none`),children:[t.author,` · `,G(t.committedAt)]})]}),c===t.hash&&(0,z.jsx)(ry,{source:{route:`repos.commit`,input:{slug:e,hash:t.hash}}})]},t.hash))]})]})}function ky(){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,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(``),x=(0,v.useCallback)(async()=>{try{let e=await A.request(`repos.list`);if(!e.ok)throw Error(`HTTP ${e.status}`);t(e.data),r(``)}catch(e){r(e.message||`could not load repositories`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await x(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[x]);let S=async(e,t,n=!1)=>{a(n=>({...n,[e]:t})),s(t=>({...t,[e]:``})),l(null);try{let r=t===`update`?await A.request(`repos.update`,{slug:e}):await A.request(`repos.remove`,{slug:e,query:{force:n}});if(!r.ok||!r.data.ok)throw Error(r.error||`failed`);let i=r.data.error;i&&s(t=>({...t,[e]:i}))}catch(t){s(n=>({...n,[e]:t.message}))}finally{a(t=>{let n={...t};return delete n[e],n}),x()}},C=async e=>{if(e.preventDefault(),u.trim()&&!g){_(!0),b(``);try{let e=await A.request(`repos.add`,{body:{url:u.trim(),name:f.trim()||void 0,branch:m.trim()||void 0}});if(!e.ok)throw Error(e.error||`clone failed`);d(``),p(``),h(``),await x()}catch(e){b(e.message)}finally{_(!1)}}},w=[...e?.repos??[]].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``));return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:`source`,title:`Repositories`,actions:(0,z.jsxs)(z.Fragment,{children:[e?.enabled&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[w.length,` cloned`]}),n&&(0,z.jsx)(rt,{tone:`bad`,children:n})]})}),e&&!e.enabled&&(0,z.jsx)(X,{children:(0,z.jsx)(`div`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:e.error&&!/are off/.test(e.error)?(0,z.jsx)(rt,{tone:`bad`,children:e.error}):(0,z.jsxs)(z.Fragment,{children:[`Repositories are off. Turn them on in `,(0,z.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,z.jsx)(`code`,{children:`repos:`}),` block to kraftwerk.yml.`]})})}),e?.enabled&&(0,z.jsx)(X,{title:`add a repository`,actions:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`clones into `,(0,z.jsx)(`code`,{title:e.root,children:e.root})]}),children:(0,z.jsxs)(`form`,{className:`flex flex-col gap-2.5 p-[18px]`,onSubmit:e=>void C(e),children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2.5`,children:[(0,z.jsx)(Q,{label:`url`,className:`min-w-[240px] flex-[2]`,children:(0,z.jsx)(Z,{value:u,placeholder:`https://github.com/org/repo.git, git@host:org/repo.git or github:org/repo`,onChange:e=>d(e.target.value),autoFocus:!0})}),(0,z.jsx)(Q,{label:`name`,className:`min-w-[140px] flex-1`,children:(0,z.jsx)(Z,{value:f,placeholder:`from the url`,onChange:e=>p(e.target.value)})}),(0,z.jsx)(Q,{label:`branch`,className:`w-[140px]`,children:(0,z.jsx)(Z,{value:m,placeholder:`default`,onChange:e=>h(e.target.value)})}),(0,z.jsx)(K,{type:`submit`,variant:`primary`,icon:`download`,busy:g,disabled:!u.trim(),children:g?`cloning…`:`clone`})]}),y&&(0,z.jsx)(rt,{tone:`bad`,children:y}),(0,z.jsxs)(`p`,{className:I(`text-xs text-fg-2`,`m-0`),children:[`Uses your own git credentials and never prompts: a private remote must already work from a terminal. Agents see every clone here and can add more with `,(0,z.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})}),e?.enabled&&(0,z.jsxs)(X,{title:`cloned repositories · newest change first`,children:[w.length===0&&(0,z.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Nothing cloned yet.`}),w.map(e=>{let t=i[e.slug],n=yy(e);return(0,z.jsxs)(`div`,{className:I(`repo-row grid grid-cols-[40px_minmax(0,1fr)_auto] items-start gap-3.5 border-line px-[18px] py-3.5 [&+&]:border-t`,n.state===`changed`&&`bg-ask-soft/40`),"data-repo":e.slug,children:[(0,z.jsx)(`span`,{className:I(`grid size-10 place-items-center rounded-full bg-surface-2 text-fg-2`,n.state===`unreadable`&&`opacity-45 grayscale`),children:(0,z.jsx)(B,{name:`folder_data`,className:`text-[22px]`})}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,z.jsx)(U,{href:`/repos/${encodeURIComponent(e.slug)}`,className:`text-md font-semibold text-fg no-underline hover:underline`,title:`changes and commits`,children:e.slug}),e.branch&&(0,z.jsx)(`span`,{className:xy,children:e.branch}),(0,z.jsx)(by,{...n}),e.updatedAt&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.updatedAt,children:[`changed `,G(e.updatedAt)]})]}),e.url&&(0,z.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.url,children:vy(e.url)}),(0,z.jsx)(`div`,{className:`text-xs [overflow-wrap:anywhere] text-fg-2 opacity-70`,title:e.path,children:e.path}),(0,z.jsxs)(`div`,{className:I(`text-xs text-fg-2`,`flex flex-wrap gap-x-3.5 gap-y-1 [&_code]:text-[11.5px]`),children:[e.head&&(0,z.jsxs)(`span`,{title:e.committedAt,children:[(0,z.jsx)(`code`,{children:e.head}),` `,e.subject,e.committedAt?` · ${G(e.committedAt)}`:``]}),!!e.behind&&!!e.dirty&&(0,z.jsxs)(`span`,{children:[`behind by `,e.behind]}),e.error&&(0,z.jsx)(`span`,{className:`text-bad`,children:e.error})]}),o[e.slug]&&(0,z.jsx)(rt,{tone:`bad`,children:o[e.slug]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,z.jsx)(K,{size:`sm`,icon:`difference`,href:`/repos/${encodeURIComponent(e.slug)}`,title:`changed files with diffs, recent commits`,children:`changes`}),(0,z.jsx)(K,{size:`sm`,icon:`sync`,busy:t===`update`,disabled:!!t,onClick:()=>void S(e.slug,`update`),title:`git fetch, then fast-forward when clean`,children:t===`update`?`updating…`:`update`}),c!==e.slug&&(0,z.jsx)(K,{size:`sm`,icon:`delete`,disabled:!!t,onClick:()=>l(e.slug),title:`Move the clone to the trash`,children:`remove`}),c===e.slug&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void S(e.slug,`remove`,Ey(e)),children:e.dirty||e.ahead?`delete with local changes`:Ey(e)?`delete anyway`:`confirm remove`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},e.slug)})]})]})}var Ay={workspace:`workspace`,project:`.claude`,user:`global`,agent:`agent`};function jy(e){return(0,z.jsx)(J,{tone:e===`workspace`?`ok`:e===`agent`?`accent`:`neutral`,children:Ay[e]})}function My({name:e}){let t=F(`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&&H(`/skills/${encodeURIComponent(a.name)}`,{replace:!0})},[e,a?.name]);let o=t=>(0,z.jsx)(gt,{href:`/skills/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,z.jsx)(et,{tone:t.source===`workspace`?`ok`:`idle`}),title:`/${t.name}`,titleExtra:t.source!==`workspace`&&jy(t.source),sub:t.description||`no description`},`${t.source}:${t.name}`);return(0,z.jsxs)(`div`,{className:`runs-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`workspace skills`}),(0,z.jsxs)(jt,{children:[r.map(o),t&&r.length===0&&(0,z.jsx)(Mt,{children:`no workspace skills yet`}),i.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(kt,{title:`local (this machine / repo)`,divided:!0}),i.map(o)]})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:e?(0,z.jsx)(Py,{name:e},e):t&&!a?(0,z.jsx)(Ny,{root:t.root}):(0,z.jsx)(Y,{children:`loading…`})})]})}function Ny({root:e}){return(0,z.jsx)(`div`,{className:`empty-action py-6`,children:(0,z.jsxs)(Y,{icon:`extension`,children:[`Create `,(0,z.jsxs)(`code`,{children:[e,`/<name>/SKILL.md`]}),` and it appears here and in every session's `,(0,z.jsx)(`code`,{children:`/`}),` menu.`]})})}function Py({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?fo.sanitize(Mi.parse(s,{async:!1})):``,[s]);return(0,v.useEffect)(()=>{A.call(`skills.get`,{name:e}).then(n,()=>i(!0))},[e]),r?(0,z.jsx)(Y,{icon:`extension`,children:`skill not found`}):t?(0,z.jsxs)(`div`,{className:`agent-view flex flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,z.jsxs)(ot,{size:`lg`,children:[`/`,t.name]}),jy(t.source)]}),t.description&&(0,z.jsx)(`p`,{className:`-mt-2 mb-0 mx-0.5 text-sm leading-[1.6] text-fg-2`,children:t.description}),(0,z.jsx)(Fy,{name:t.name}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_320px] items-start gap-4 max-[1020px]:grid-cols-1`,children:[(0,z.jsx)(X,{className:`min-w-0`,title:`SKILL.md`,actions:(0,z.jsx)(_t,{bare:!0,label:`SKILL.md view`,value:a,onChange:o,items:[{id:`rendered`,label:`rendered`},{id:`source`,label:`source`}]}),children:a===`rendered`?(0,z.jsx)(`div`,{className:`md-body h-auto overflow-visible [&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2`,dangerouslySetInnerHTML:{__html:c}}):(0,z.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,z.jsx)(`aside`,{className:`flex min-w-0 flex-col gap-4`,children:(0,z.jsx)(X,{title:`about`,children:(0,z.jsxs)(mt,{children:[(0,z.jsx)(ht,{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,z.jsx)(ht,{label:`path`,mono:!0,children:(0,z.jsx)(`span`,{title:t.path,children:t.path})}),(0,z.jsx)(ht,{label:`invoke`,children:(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`code`,{children:[`/`,t.name]}),` in any session`]})}),t.files.length>0&&(0,z.jsx)(ht,{label:`bundled files`,mono:!0,children:t.files.map(e=>(0,z.jsx)(`span`,{className:`block w-full`,children:e},e))})]})})})]})]}):(0,z.jsx)(Y,{children:`loading…`})}function Fy({name:e}){let t=F(`agents.list`,{},{interval:3e4}),n=Yt(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=(t?.agents??[]).filter(t=>!t.archived&&(t.skills===void 0||t.skills.includes(e)));return(0,z.jsx)(Rt,{label:`use this skill`,className:`skill-run`,chip:`/${e}`,chipTitle:`the skill's command: the message starts with it`,value:a,onChange:o,inputLabel:`what to do with the skill`,placeholder:`Add what it should work on (optional)`,onSend:async t=>{c(!0),u(``);let i=await Kt({who:r||void 0,text:`/${e}${a.trim()?` ${a.trim()}`:``}`,files:t});if(c(!1),`error`in i)return u(i.error),!1;o(``),n(i.href)},sendLabel:`send to a new chat`,busy:s,error:l,who:r,onWho:e=>d.some(t=>t.slug===e)&&i(e),attach:!0,controls:(0,z.jsx)(Bt,{value:r,onChange:i,agents:d}),hint:`starts a new chat`})}var Iy=encodeURIComponent,Ly=new Set([`chats`,`workflows`,`skills`,`runs`,`tasks`,`boards`,`knowledge`,`contacts`,`places`,`events`]),Ry={chats:`New chat`,workflows:`New workflow`,skills:`New skill`,runs:`Run a workflow`,tasks:`New task`,boards:`New board`,knowledge:`New knowledge bundle`,contacts:`New contact`,places:`New place`,events:`New event`};function zy({label:e,title:t,onClose:n,children:r}){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)},[n]),(0,b.createPortal)((0,z.jsx)(`div`,{className:`fixed inset-0 z-40 flex animate-fade items-start justify-center bg-black/38 px-4 pt-[12vh] pb-4`,onMouseDown:n,children:(0,z.jsxs)(`div`,{role:`dialog`,"aria-label":e,className:`relative flex w-[min(600px,100%)] animate-modal flex-col gap-4 rounded-card border border-line bg-surface p-5 shadow-modal`,onMouseDown:e=>e.stopPropagation(),children:[(0,z.jsx)(q,{icon:`close`,label:`close (esc)`,className:`absolute top-3 right-3 rounded-full`,onClick:n}),(0,z.jsx)(`h2`,{className:`m-0 text-base font-semibold text-fg`,children:t}),r]})}),document.body)}function By({kind:e,project:t,onClose:n,onMade:r}){let i=Yt();return(0,z.jsx)(zy,{label:Ry[e].toLowerCase(),title:Ry[e],onClose:n,children:(0,z.jsxs)(Jt.Provider,{value:e=>(n(),i(e),!0),children:[e===`chats`&&(0,z.jsx)(Vy,{project:t}),e===`workflows`&&(0,z.jsx)(Hy,{what:`workflow`}),e===`skills`&&(0,z.jsx)(Hy,{what:`skill`}),e===`runs`&&(0,z.jsx)(Uy,{}),e===`tasks`&&(0,z.jsx)(Wy,{project:t,onMade:e=>(n(),r(`tasks:${e.project??``}:${e.board}:${e.slug}`,e.href))}),e===`boards`&&(0,z.jsx)(Gy,{project:t,onCancel:n,onMade:e=>(n(),r(`boards:${t??``}:${e}`,`${t?`/projects/${Iy(t)}`:``}/boards/${Iy(e)}`))}),e===`knowledge`&&(0,z.jsx)(Ky,{onCancel:n,onMade:e=>(n(),r(`knowledge:${e}`,`/knowledge/${Iy(e)}`))}),(e===`contacts`||e===`places`||e===`events`)&&(0,z.jsx)(bg,{kind:e,onCancel:n,onCreated:t=>(n(),r(`${e}:${t}`,`/${e}/${Iy(t)}`))})]})})}function Vy({project:e}){let t=F(`agents.list`,{}),n=Vt(),r=Yt(),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(e??``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),m=(t?.agents??[]).filter(e=>!e.archived);return(0,z.jsx)(Rt,{label:`new chat`,value:c,onChange:l,autoFocus:!0,inputLabel:`message`,placeholder:`Ask anything — / for skills, @ for an agent`,sendLabel:`start chat`,busy:u,error:f,skills:!0,who:i,onWho:a,attach:!0,controls:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Bt,{value:i,onChange:a,agents:m,byDefault:o?`🧭 Assistant (default)`:void 0}),(0,z.jsx)(Ht,{value:o,onChange:s,projects:n})]}),hint:o&&o===e?`a chat in this project`:void 0,onSend:async e=>{d(!0),p(``);let t=await Kt({who:i||void 0,project:o||void 0,harness:n.find(e=>e.slug===o)?.harness,text:c,files:e});if(d(!1),`error`in t)return p(t.error),!1;r(t.href)}})}function Hy({what:e}){let t=Yt(),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);return(0,z.jsx)(Rt,{label:`new ${e}`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:e===`workflow`?`account_tree`:`extension`,className:`ms-sm`}),` new `,e]}),chipTitle:`Ralv builds the ${e} from what you describe`,value:n,onChange:r,autoFocus:!0,inputLabel:`what the ${e} should do`,placeholder:e===`workflow`?`Describe what it should do, step by step if you know`:`Describe what the skill is for and when to use it`,sendLabel:`ask Ralv to make the ${e}`,busy:i,disabled:!n.trim(),error:o,attach:!0,hint:`Ralv makes it in a chat`,onSend:async r=>{a(!0),s(``);let i=await Kt({text:e===`workflow`?`Create a new workflow in this workspace. What it should do:\n\n${n.trim()}`:`Create a new skill in this workspace's skills folder. What it is for:\n\n${n.trim()}`,files:r});if(a(!1),`error`in i)return s(i.error),!1;t(i.href)}})}function Uy(){let e=F(`workflows.list`,{}),t=(e?.workflows??[]).filter(e=>!e.error),[n,r]=(0,v.useState)(``),i=t.find(e=>e.slug===n)??t[0];return e&&t.length===0?(0,z.jsx)(`p`,{className:`m-0 text-sm text-fg-2`,children:`There is no workflow to run yet.`}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsx)(Q,{label:`workflow`,children:(0,z.jsx)(St,{"aria-label":`workflow`,value:i?.slug??``,onChange:e=>r(e.target.value),children:t.map(e=>(0,z.jsx)(`option`,{value:e.slug,children:e.name||e.slug},e.slug))})}),i&&(0,z.jsx)(Eg,{slug:i.slug,usesRequest:i.usesRequest},i.slug)]})}function Wy({project:e,onMade:t}){let n=F(`boards.list`,{query:{all:`1`}}),r=Yt(),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),f=(n?.boards??[]).filter(t=>!e||t.project===e),p=e=>`${e.project??``}/${e.board}`,m=f.find(e=>p(e)===o)??f[0];return(0,z.jsx)(Rt,{label:`new task`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`task_alt`,className:`ms-sm`}),` task`]}),value:i,onChange:e=>a(e.replace(/\n/g,` `)),autoFocus:!0,minRows:1,inputLabel:`task title`,placeholder:`What needs doing?`,sendLabel:`add task`,sendIcon:`add`,busy:c,disabled:!i.trim()||!m,error:u||(n&&f.length===0?`There is no board yet: make one first (New board).`:``),controls:f.length>0&&(0,z.jsx)(St,{"aria-label":`board`,value:m?p(m):``,onChange:e=>s(e.target.value),className:`h-8 w-auto max-w-[260px] rounded-full border-0 bg-transparent text-sm font-medium hover:bg-surface-2`,children:f.map(t=>(0,z.jsxs)(`option`,{value:p(t),children:[t.project&&!e?`${t.project} · `:``,t.title]},p(t)))}),hint:`lands in the board's todo column`,onSend:async()=>{if(!m)return!1;l(!0),d(``);let e=await A.request(`tasks.create`,{board:m.board,query:m.project?{project:m.project}:{},body:{title:i.trim()}});if(l(!1),!e.ok)return d(P(e)),!1;let n=`${m.project?`/projects/${Iy(m.project)}`:``}/boards/${Iy(m.board)}/${Iy(e.data.slug)}`;t?t({project:m.project,board:m.board,slug:e.data.slug,href:n}):r(n)}})}function Gy({project:e,onMade:t,onCancel:n}){let[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=Bv().cloud?.mode===`local`,[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(qy,{label:`title`,inputLabel:`board title`,placeholder:`e.g. Marketing`,value:r,onChange:i,submit:`create board`,busy:c,error:u,onSubmit:async()=>{let n=r.trim();if(!n||c)return;l(!0),d(``);let i=await A.request(`boards.create`,{body:{title:n,...e?{project:e}:{},...a?{cloud:!0}:{}}});if(l(!1),!i.ok)return d(P(i));t(i.data.board)},onCancel:n,hint:a?`Kept in kraftwerk cloud: everyone on the workspace sees and edits it; tasks go to people or agents.`:`Starts with the columns Draft, Todo, In progress, Review and Done; change them in the board's settings.`}),!e&&!s&&(0,z.jsx)(Tt,{checked:a,onChange:o,className:`mt-3 text-sm`,children:`in kraftwerk cloud — shared with everyone on the workspace`}),!e&&s&&(0,z.jsxs)(`p`,{className:`m-0 mt-3 text-xs text-fg-2`,children:[(0,z.jsx)(B,{name:`cloud`,className:`ms-sm align-[-3px] text-accent`}),` Shared with others? Cloud boards need cloud mode —`,` `,(0,z.jsx)(`a`,{href:`#/settings/cloud`,className:`text-accent`,children:`switch to cloud`}),`.`]})]})}function Ky({onMade:e,onCancel:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);return(0,z.jsx)(qy,{label:`name`,inputLabel:`bundle name`,placeholder:`e.g. customer-support`,value:n,onChange:r,submit:`create bundle`,busy:i,error:o,onSubmit:async()=>{let t=n.trim();if(!t||i)return;a(!0),s(``);let r=await A.request(`knowledge.create`,{body:{name:t}});if(a(!1),!r.ok)return s(P(r));e(t)},onCancel:t,hint:`A folder of pages agents read and keep up to date.`})}function qy(e){return(0,z.jsx)(`form`,{onSubmit:t=>{t.preventDefault(),e.onSubmit()},children:(0,z.jsxs)(Ct,{children:[(0,z.jsx)(Q,{label:e.label,hint:e.hint,children:(0,z.jsx)(Z,{autoFocus:!0,value:e.value,"aria-label":e.inputLabel,placeholder:e.placeholder,disabled:e.busy,onChange:t=>e.onChange(t.target.value)})}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(K,{variant:`primary`,type:`submit`,icon:`add`,busy:e.busy,disabled:!e.value.trim()||e.busy,children:e.submit}),(0,z.jsx)(K,{variant:`quiet`,onClick:e.onCancel,children:`cancel`}),e.error&&(0,z.jsx)(`span`,{className:`text-sm text-bad`,children:e.error})]})]})})}var Jy=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,Yy=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function Xy(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 Zy(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 Qy(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function $y(){let e=F(`runs.list`,{}),t=F(`chats.list`,{}),n=F(`knowledge.list`,{}),r=F(`agents.list`,{}),i=F(`workflows.list`,{}),a=F(`skills.list`,{}),[o,s]=(0,v.useState)(`all`),c=F(`projects.list`,{},{interval:3e4}),l=e=>c?.projects.find(t=>t.slug===e)?.title??e,u=e?.runs??[],d=t?.chats??[],f=n?.bundles??[],p=(a?.skills??[]).filter(e=>e.source===`workspace`),m=[[i?.workflows.length,`workflows`,`/workflows`],[e?u.length:void 0,`runs`,`/runs`],[n?f.length:void 0,`bundles`,`/knowledge`],[a?p.length:void 0,`skills`,`/skills`],[t?d.length:void 0,`chats`,`/agents/chats`]],h=u.filter(e=>e.status===`failed`&&Date.now()-Date.parse(e.updatedAt)<864e5);return(0,z.jsxs)(`div`,{className:`w-full px-7 pt-6 pb-10 max-[800px]:px-3 max-[800px]:pt-3`,children:[(0,z.jsx)(sb,{runs:u,chats:d,bundles:f,agents:r?.agents??[],workflows:i?.workflows??[],projectTitle:l,loaded:!!e&&!!t}),(0,z.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:m.map(([e,t,n])=>(0,z.jsxs)(U,{href:n,className:`group/mini text-inherit no-underline hover:text-accent hover:underline`,children:[(0,z.jsx)(`b`,{className:`font-semibold tabular-nums text-fg group-hover/mini:text-accent`,children:e??`…`}),` `,t]},t))}),h.length>0&&o!==`failed`&&(0,z.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:[`⚠ `,h.length,` run`,h.length===1?``:`s`,` failed in the last 24 h — review`]}),(0,z.jsx)(nb,{projectTitle:l,runs:u,chats:d,bundles:f,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function eb(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 tb=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function nb({projectTitle:e,runs:t,chats:n,bundles:r,agents:i,workflows:a,filter:o,setFilter:s}){let c=(0,v.useMemo)(()=>{let s=[],c=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:c(e.workflow)??e.id,sub:e.request??``,href:`/runs/${e.id}`,lamp:Jy(e.status),status:Yy(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`:Zy(t,i,e),href:Xy(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,o]),l=``,u=(e,t)=>I(`inline-flex cursor-pointer items-center gap-0.5 rounded-lg border px-2.5 py-0.5 text-2xs transition-colors`,e?I(`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,z.jsx)(X,{className:`animate-rise`,title:`all activity`,actions:(0,z.jsxs)(`span`,{className:`flex flex-wrap gap-1.5`,children:[tb.map(([e,t])=>(0,z.jsx)(`button`,{type:`button`,className:u(o===e),"aria-pressed":o===e,onClick:()=>s(e),children:t},e)),o===`failed`&&(0,z.jsxs)(`button`,{type:`button`,className:u(!0,!0),onClick:()=>s(`all`),children:[`failed `,(0,z.jsx)(B,{name:`close`,className:`ms-sm`})]})]}),children:c.length===0?(0,z.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,z.jsx)(`div`,{className:`flex flex-col p-1.5`,children:c.map(e=>{let t=eb(e),n=t===l?null:t;return l=t,(0,z.jsxs)(`div`,{children:[n&&(0,z.jsx)(it,{className:`block px-2.5 pt-3 pb-1`,children:n}),(0,z.jsx)(gt,{href:e.href,leading:(0,z.jsxs)(`span`,{className:`relative text-[18px] leading-none`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),e.lamp===`running`&&(0,z.jsx)(`span`,{className:`absolute -right-1 -bottom-1 grid rounded-full bg-surface p-px`,children:(0,z.jsx)(et,{tone:`working`})})]}),title:Qy(e.title),titleExtra:(0,z.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,z.jsx)(J,{tone:rb[e.kind],children:e.kind===`session`?`chat`:e.kind})}),sub:e.sub&&Qy(e.sub),meta:(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.status&&(0,z.jsx)(J,{tone:ib[e.lamp]??`neutral`,children:e.status}),(0,z.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:G(e.at)}),(0,z.jsx)(B,{name:`chevron_right`,className:`ms-sm max-[800px]:hidden`})]})})]},`${e.kind}:${e.href}:${e.at}`)})})})}var rb={run:`accent`,session:`ask`,knowledge:`ok`},ib={ok:`ok`,failed:`bad`,blocked:`bad`,running:`accent`,aborted:`neutral`};function ab(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 ob=e=>new Date(e).toDateString()===new Date().toDateString();function sb({runs:e,chats:t,bundles:n,agents:r,workflows:i,projectTitle:a,loaded:o}){let s=rs()??[],c=ne(),l=F(`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:Zy(e,r,a),title:Qy(e.title||`new chat`),meta:`working${d.get(e.id)?` · ${ab(d.get(e.id))}`:``}`,href:Xy(e),tone:`working`})),...e.filter(e=>e.status===`running`).map(e=>({key:`r:${e.id}`,owner:`⚙️ ${u(e.workflow)}`,title:Qy(e.request??``),meta:`running`,href:`/runs/${e.id}`,tone:`working`}))],p=[...t.filter(e=>!e.busy&&!e.awaitingApproval&&ob(e.updatedAt)&&e.title).map(e=>({key:`c:${e.id}`,at:e.updatedAt,owner:Zy(e,r,a),title:Qy(e.title),meta:G(e.updatedAt),href:Xy(e)})),...e.filter(e=>e.status!==`running`&&ob(e.updatedAt)).map(e=>({key:`r:${e.id}`,at:e.updatedAt,owner:`⚙️ ${u(e.workflow)}`,title:Qy(e.request??``),meta:`${e.status===`ok`?`done`:e.status===`aborted`?`stopped`:`failed`} · ${G(e.updatedAt)}`,href:`/runs/${e.id}`})),...n.filter(e=>e.updatedAt&&ob(e.updatedAt)).map(e=>({key:`k:${e.name}`,at:e.updatedAt,owner:`📚 ${e.name}`,title:`knowledge updated`,meta:G(e.updatedAt),href:`/knowledge/${encodeURIComponent(e.name)}`}))].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,12),m=us(s,c),h=o&&s.length===0&&f.length===0;return(0,z.jsxs)(`div`,{className:`today flex flex-col gap-3.5`,children:[(0,z.jsxs)(X,{className:`today-section`,title:`needs you`,count:s.length,actions:m&&(0,z.jsxs)(K,{variant:`primary`,size:`sm`,onClick:()=>ds(m),className:`bg-bad text-on-bad hover:bg-bad`,children:[`start `,(0,z.jsx)(B,{name:`arrow_forward`,className:`ms-sm`})]}),children:[s.length===0?(0,z.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,z.jsx)(`div`,{className:`p-1.5`,children:s.map(e=>(0,z.jsx)(gt,{className:`today-row waiting`,onClick:()=>ds(e),over:ss(e.owner),title:e.title,meta:(0,z.jsxs)(`span`,{className:`font-semibold text-bad`,children:[os(e.kind),` · `,G(e.since)]})},e.id))}),h&&(0,z.jsx)(`div`,{className:`px-[18px] pb-4`,children:(0,z.jsx)(K,{variant:`primary`,icon:`chat`,href:`/agents/chats`,children:`chat with Ralv`})})]}),f.length>0&&(0,z.jsx)(X,{className:`today-section`,title:`in progress`,children:(0,z.jsx)(`div`,{className:`p-1.5`,children:f.map(e=>(0,z.jsx)(cb,{r:e},e.key))})}),(0,z.jsx)(X,{className:`today-section`,title:`done today`,children:p.length===0?(0,z.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:`Nothing finished yet today.`}):(0,z.jsx)(`div`,{className:`p-1.5`,children:p.map(e=>(0,z.jsx)(cb,{r:e},e.key))})})]})}function cb({r:e}){return(0,z.jsx)(gt,{className:`today-row`,href:e.href,over:e.owner,title:e.title,meta:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e.tone===`working`&&(0,z.jsx)(et,{tone:`working`}),e.meta]})})}var lb=e=>e.agent?`${e.agent.emoji?`${e.agent.emoji} `:``}${e.agent.name}`:e.project?`🧭 Assistant`:`🎩 Ralv`,ub=e=>e.enabled?e.nextRunAt?`next ${Ke(e.nextRunAt)}`:e.runner===`unassigned`?`no runner`:e.runner===`elsewhere`?`runs on ${e.runsOn}`:e.schedule:`paused`,db=(e,t)=>e.project?`/projects/${encodeURIComponent(e.project)}/chat/${t}`:e.agent?`/agents/${encodeURIComponent(e.agent.slug)}/chat/${t}`:`/agents/chats/${t}`,fb={name:``,schedule:`0 9 * * 1-5`,prompt:``,enabled:!0,project:``,agent:``,private:!1},pb=e=>({id:e.id,name:e.name,schedule:e.schedule,prompt:e.prompt,enabled:e.enabled,project:e.project??``,agent:e.agent?.slug??``,runsOn:e.runsOn??``,private:e.private??!1});function mb({r:e,error:t}){return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-2`,children:[(0,z.jsx)(`code`,{children:e.schedule}),(0,z.jsxs)(`span`,{children:[`· `,ub(e)]}),e.runner===`here`?(0,z.jsx)(J,{title:`runs_on: ${e.runsOn} — this machine fires it`,children:`runs here`}):e.runner===`unassigned`?(0,z.jsx)(J,{tone:e.enabled?`ask`:`neutral`,title:`no runs_on — it fires on no machine until one adopts it`,children:`no runner`}):(0,z.jsxs)(J,{tone:e.retired?`ask`:`neutral`,title:e.retired?`a retired identity of this machine — it fires nowhere until reassigned`:`another machine fires it, not this one`,children:[`runs on `,e.runsOn]}),e.lastChatId?(0,z.jsxs)(U,{href:db(e,e.lastChatId),children:[`last run `,Ke(e.lastRunAt)]}):(0,z.jsx)(`span`,{children:`never ran`}),e.awaitingApproval&&e.lastChatId&&(0,z.jsx)(J,{href:db(e,e.lastChatId),tone:`bad`,title:`the last run asked for a permission nobody has answered yet`,children:`needs approval`}),(t||e.lastError)&&(0,z.jsx)(`span`,{title:t||e.lastError,children:(0,z.jsx)(J,{tone:`bad`,children:`error`})})]})}function hb({owner:e,id:t,onOpen:n}){let r=De(),i=F(`routines.list`,{},{interval:3e4}),a=F(`agents.list`,{},{interval:6e4}),o=F(`projects.list`,r.projects?{}:null,{interval:6e4}),s=F(`identity.get`,{},{interval:6e4}),c=e===`_`&&t===`new`,l=c?void 0:i?.routines.find(n=>n.owner===e&&n.id===t),[u,d]=(0,v.useState)(c?fb:null),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(null),C=Yt();if((0,v.useEffect)(()=>{d(c?fb:l?pb(l):null),h(``),_(``)},[e,t,!!l]),!c&&!l)return(0,z.jsx)(Y,{className:`my-auto`,children:i?`That routine is gone.`:`loading…`});async function w(e,t){p(e),h(``),_(``);try{await t()}catch(e){h(e.message)}finally{p(``)}}let T=()=>w(`run`,async()=>{let n=e===`_`?await A.request(`routines.run`,{id:t}):await A.request(`agents.runRoutine`,{slug:e,id:t});if(!n.ok)throw Error(P(n));l&&n.data.chatId&&H(db(l,n.data.chatId))});if(!u)return(0,z.jsx)(Y,{className:`my-auto`,children:`loading…`});let E=e=>d({...u,...e}),D=e!==`_`,O=(a?.agents??[]).filter(e=>!e.archived||e.slug===u.agent),k=()=>w(`save`,async()=>{let{runsOn:t,project:r,agent:i,...a}=u,o=t===void 0?{}:{runsOn:t.trim()||null},s=D?await A.request(`agents.saveRoutine`,{slug:e,body:{...a,...o}}):await A.request(`routines.save`,{body:{...a,project:r||null,agent:i||null,...o}});if(!s.ok)throw Error(P(s));_(`saved`),c&&n(`routines:_:${s.data.id}`)}),ee=()=>w(`adopt`,async()=>{let n=D?await A.request(`agents.adoptRoutine`,{slug:e,id:t}):await A.request(`routines.adoptOne`,{id:t});if(!n.ok)throw Error(P(n));let r=n.data.commit;if(r&&!r.ok)throw Error(`runs on ${n.data.runsOn} — routines.yml written, but not committed: ${r.error??`git failed`}`);_(`runs on ${n.data.runsOn} now${r?` — committed`:``}`),E({runsOn:n.data.runsOn}),ns()}),j=()=>{window.confirm(`Delete the routine "${u.name}"?`)&&w(`delete`,async()=>{let r=D?await A.request(`agents.deleteRoutine`,{slug:e,id:t}):await A.request(`routines.delete`,{id:t});if(!r.ok)throw Error(P(r));n(void 0)})},M=()=>w(`chat`,async()=>{if(!l||!x?.trim())return;let t=await Kt({who:D?e:void 0,project:l.project??void 0,text:gb(l,x.trim())});if(`error`in t)throw Error(t.error);S(null),C(t.href)}),N=vb(u.schedule),I=y?{...N,kind:`custom`}:N,te=e=>{if(e.kind===`custom`)return b(!0);e.kind&&b(!1),E({schedule:yb({...N,...e,kind:e.kind??(N.kind===`custom`?`weekdays`:N.kind)})})},R=`h-8 w-auto max-w-[220px] rounded-full border-0 bg-transparent text-sm font-medium hover:bg-surface-2`;return(0,z.jsxs)(`div`,{className:`routine-form flex flex-col gap-3 p-3`,children:[(0,z.jsx)(`input`,{value:u.name,"aria-label":`name`,placeholder:`Name the routine, e.g. Morning report`,className:`w-full border-0 bg-transparent p-0 font-[inherit] text-xl font-semibold text-fg shadow-none outline-none placeholder:font-normal placeholder:text-fg-2 focus:shadow-none focus:outline-none`,onChange:e=>E({name:e.target.value})}),l&&(0,z.jsx)(mb,{r:l}),(0,z.jsx)(Rt,{label:`what the routine asks`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`schedule`,className:`ms-sm`}),` `,bb(u.schedule)]}),chipTitle:`cron: ${u.schedule}`,value:u.prompt,onChange:e=>E({prompt:e}),inputLabel:`prompt — what to ask on each run`,placeholder:`What to ask on each run, e.g. Check … and summarize what changed.`,onSend:()=>void k(),sendLabel:c?`add the routine`:`save`,sendIcon:`check`,busy:f===`save`,disabled:!u.name.trim()||!u.prompt.trim()||!!f,skills:!0,who:u.agent,hint:g||(u.agent?`in a new session each time`:u.project?`asks the project's assistant`:`asks Ralv`),controls:D?(0,z.jsx)(U,{href:`/agents/${encodeURIComponent(e)}/info`,className:`inline-flex h-8 items-center px-2 text-sm font-medium text-fg no-underline hover:text-accent`,title:`an agent's own routine always asks its agent — it lives on the agent's profile`,children:l?.agent?lb(l):e}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(St,{"aria-label":`who`,value:u.agent,onChange:e=>E({agent:e.target.value}),className:R,children:[(0,z.jsx)(`option`,{value:``,children:u.project?`🧭 the project's assistant`:`🎩 Ralv`}),O.map(e=>(0,z.jsxs)(`option`,{value:e.slug,children:[e.emoji,` `,e.name]},e.slug))]}),r.projects&&(0,z.jsxs)(St,{"aria-label":`runs in`,value:u.project,onChange:e=>E({project:e.target.value}),className:R,title:u.project?`its runs are filed under the project`:`not tied to a project`,children:[(0,z.jsx)(`option`,{value:``,children:`the whole workspace`}),(o?.projects??[]).map(e=>(0,z.jsxs)(`option`,{value:e.slug,children:[`📁 `,e.title]},e.slug)),u.project&&!o?.projects.some(e=>e.slug===u.project)&&(0,z.jsxs)(`option`,{value:u.project,children:[`📁 `,u.project]})]})]}),children:(0,z.jsxs)(`div`,{className:`routine-when flex flex-wrap items-center gap-x-1 gap-y-1 border-t border-line px-2.5 py-1.5 text-sm text-fg-2`,children:[(0,z.jsxs)(St,{"aria-label":`repeats`,value:I.kind,onChange:e=>te({kind:e.target.value}),className:R,children:[(0,z.jsx)(`option`,{value:`weekdays`,children:`every weekday`}),(0,z.jsx)(`option`,{value:`daily`,children:`every day`}),(0,z.jsx)(`option`,{value:`weekly`,children:`every week`}),(0,z.jsx)(`option`,{value:`hourly`,children:`every hour`}),(0,z.jsx)(`option`,{value:`custom`,children:`custom (cron)`})]}),I.kind===`weekly`&&(0,z.jsx)(St,{"aria-label":`weekday`,value:I.day,onChange:e=>te({day:e.target.value}),className:R,children:_b.map((e,t)=>(0,z.jsxs)(`option`,{value:String(t),children:[`on `,e]},e))}),(I.kind===`weekdays`||I.kind===`daily`||I.kind===`weekly`)&&(0,z.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 px-1`,children:[`at`,(0,z.jsx)(`input`,{type:`time`,"aria-label":`time`,value:I.time,className:`h-8 rounded-control border border-line bg-surface px-2 font-[inherit] text-sm text-fg`,onChange:e=>e.target.value&&te({time:e.target.value})})]}),I.kind===`hourly`&&(0,z.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 px-1`,children:[`at minute`,(0,z.jsx)(`input`,{type:`number`,min:0,max:59,"aria-label":`minute`,value:I.minute,className:`h-8 w-16 rounded-control border border-line bg-surface px-2 font-[inherit] text-sm text-fg`,onChange:e=>te({minute:String(Math.min(59,Math.max(0,Number(e.target.value)||0)))})})]}),I.kind===`custom`&&(0,z.jsx)(Z,{className:`h-8 w-[180px] font-mono text-sm`,"aria-label":`schedule (cron)`,value:u.schedule,placeholder:`0 9 * * 1-5`,title:`minute hour day month weekday, this machine's time`,onChange:e=>E({schedule:e.target.value})}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5 px-1 text-fg`,title:`a paused routine keeps its schedule and fires nowhere`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:u.enabled,onChange:e=>E({enabled:e.target.checked})}),`enabled`]}),(0,z.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5 px-1 text-fg`,title:`its runs stay off what remote members and paired devices see`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:u.private,onChange:e=>E({private:e.target.checked})}),`private`]})]})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5 text-xs text-fg-2`,children:[(0,z.jsxs)(`label`,{className:`inline-flex min-w-0 items-center gap-1.5`,title:`the one machine that fires it${s?` — this machine is ${s.identity}`:``}; empty: no runner, it fires nowhere`,children:[`runs on`,(0,z.jsx)(Z,{className:`h-7 w-[200px] font-mono text-xs`,"aria-label":`runs on`,value:u.runsOn??s?.identity??``,placeholder:`<handle>@<machine>`,onChange:e=>E({runsOn:e.target.value})})]}),(0,z.jsx)(`span`,{className:`flex-1`}),l&&(0,z.jsxs)(z.Fragment,{children:[l.runner!==`here`&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,busy:f===`adopt`,disabled:!!f,onClick:()=>void ee(),title:`make ${s?.identity??`this machine`} its runner and commit routines.yml`,children:`run here`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`forum`,disabled:!!f,onClick:()=>S(x===null?``:null),title:`describe the change; ${D?lb(l):`an assistant`} makes it in a new chat`,children:`change in a chat`}),(0,z.jsx)(K,{size:`sm`,icon:`play_arrow`,busy:f===`run`,disabled:!!f,onClick:()=>void T(),title:`start a run with the saved prompt, now`,children:f===`run`?`starting…`:`run now`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`delete`,disabled:!!f,onClick:j,children:`delete`})]})]}),l&&x!==null&&(0,z.jsxs)(`div`,{className:`routine-chat flex flex-col gap-2 rounded-card border border-line bg-surface p-2.5`,children:[(0,z.jsx)(xt,{autoFocus:!0,rows:2,"aria-label":`what should change`,placeholder:`What should change? ${D?lb(l):`The assistant`} updates the routine in a new chat, e.g. "run it at 7:00 and add Avia to the providers"`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&M(),e.key===`Escape`&&S(null)},className:`text-sm`}),(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>S(null),children:`cancel`}),(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`send`,busy:f===`chat`,disabled:!x.trim()||!!f,onClick:()=>void M(),children:`open the chat`})]})]}),m&&(0,z.jsx)(rt,{tone:`bad`,children:m})]})}function gb(e,t){let n=e.owner!==`_`;return[`Change the routine "${e.name}" (id \`${e.id}\`, ${n?`${e.agent?.name??e.owner}'s own routine`:`a workspace routine`}): ${t}`,``,`As it is now: schedule \`${e.schedule}\` (${bb(e.schedule)}), ${e.enabled?`enabled`:`paused`}${e.project?`, runs in project ${e.project}`:``}${n?``:`, asks ${lb(e)}`}. Its prompt:`,``,e.prompt.split(`
473
+ `]})]}):(0,z.jsx)(`div`,{className:sy,children:`no textual diff (binary or empty)`})}var sy=`git-diff mt-1.5 mb-0.5 max-h-[420px] basis-full overflow-auto rounded-xl bg-surface-2 px-3 py-2.5 font-mono text-[11.5px] leading-[1.5] whitespace-pre`,cy={modified:`text-accent`,added:`text-ok`,untracked:`text-ok`,deleted:`text-bad`,conflicted:`text-bad`};function ly({status:e,muted:t}){return(0,z.jsx)(`span`,{className:I(`flex-none rounded-full border border-line px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.4px] uppercase`,t?`text-fg-2`:cy[e]??`text-fg-2`),children:e})}var uy=`text-xs text-fg-2`,dy=`m-0 p-[18px] text-sm text-fg-2`;function fy(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(new Set),[i,a]=(0,v.useState)(new Set),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),m=(0,v.useRef)(!0),h=(0,v.useCallback)(async()=>{try{let e=await A.request(`git.status`,{query:{fresh:m.current}});m.current=!1,e.ok&&t(e.data)}catch{}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await h(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[h]),(0,v.useEffect)(()=>{if(!e?.files)return;let t=new Set(e.files.filter(e=>e.syncable).map(e=>e.path));r(e=>{let n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[e]);let g=async(e,t)=>{l(e),d(``),p(``);try{let n=await A.request(`git.${e}`,{body:t??{}});n.ok&&n.data.ok?p(e===`push`?`pushed`:e===`pull`?`pulled`:`fetched`):d(P(n)||`${e} failed`)}catch(t){d(t.message||`${e} failed`)}finally{l(``)}h()},_=async()=>{l(`commit`),d(``),p(``);try{let e=await A.request(`git.commit`,{body:{paths:[...n],message:o}});e.ok&&e.data.ok?(p(`committed ${n.size} file${n.size===1?``:`s`}`),r(new Set),s(``)):d(P(e)||`commit failed`)}catch(e){d(e.message||`commit failed`)}finally{l(``)}h()};if(!e)return(0,z.jsx)(Y,{children:`loading…`});if(!e.enabled)return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:`cloud_sync`,title:`Git sync`}),(0,z.jsx)(X,{children:(0,z.jsxs)(`p`,{className:dy,children:[`Git sync is off. Turn it on in `,(0,z.jsx)(`a`,{href:`#/settings`,children:`settings → git sync`}),` — in cloud mode with kraftwerk sync in one click — or add a `,(0,z.jsx)(`code`,{children:`git:`}),` block to kraftwerk.yml.`]})})]});let y=(e.files??[]).filter(e=>e.syncable),b=(e.files??[]).filter(e=>!e.syncable),x=(e,t)=>r(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:`cloud_sync`,title:`Git sync`,actions:(0,z.jsxs)(z.Fragment,{children:[f&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-sm text-ok`,children:[(0,z.jsx)(B,{name:`check`,className:`ms-sm`}),` `,f]}),u&&(0,z.jsx)(rt,{tone:`bad`,children:u})]})}),!e.error&&(0,z.jsx)(my,{st:e}),(0,z.jsx)(X,{title:`branch`,actions:(0,z.jsxs)(z.Fragment,{children:[e.lastFetch&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.lastFetch,children:[`fetched `,G(e.lastFetch)]}),e.lastError&&(0,z.jsxs)(`span`,{className:`inline-flex max-w-[46ch] items-center gap-1 truncate text-xs text-bad`,title:e.lastError,children:[(0,z.jsx)(B,{name:`cloud_off`,className:`ms-sm`}),` `,e.lastError.split(`
474
+ `)[0]]})]}),children:e.error?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 p-[18px] text-sm text-bad`,children:[(0,z.jsx)(B,{name:`error`,className:`ms-sm`}),` `,e.error]}):(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-[18px] py-3.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-base`,children:[(0,z.jsx)(B,{name:`account_tree`,className:`ms-sm`}),(0,z.jsx)(`strong`,{className:`font-mono`,children:e.branch}),(0,z.jsx)(`span`,{className:uy,children:e.upstream?`tracking ${e.upstream}`:`no upstream yet, push sets one`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[12.5px] font-semibold`,children:[e.diverged&&(0,z.jsx)(`span`,{className:`text-bad`,children:`diverged, resolve in a terminal`}),!!e.behind&&(0,z.jsxs)(`span`,{className:`text-accent`,children:[e.behind,` behind`]}),!!e.ahead&&(0,z.jsxs)(`span`,{className:`text-ok`,children:[e.ahead,` ahead`]}),!e.ahead&&!e.behind&&(0,z.jsx)(`span`,{className:I(`text-xs text-fg-2`,`font-normal`),children:`up to date`})]}),(0,z.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(K,{size:`sm`,icon:`refresh`,busy:c===`fetch`,disabled:!!c,onClick:()=>void g(`fetch`),children:`fetch`}),(0,z.jsx)(K,{size:`sm`,icon:`download`,busy:c===`pull`,disabled:!!c||!e.behind||e.diverged,title:e.diverged?`Diverged. Resolve in a terminal.`:`Fast-forward to the remote`,onClick:()=>void g(`pull`),children:`pull`}),(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`upload`,busy:c===`push`,disabled:!!c||!e.ahead&&!!e.upstream,title:e.upstream?`Push to the upstream`:`Push and set the upstream`,onClick:()=>void g(`push`),children:`push`})]})]})}),!!e.conflicts?.length&&(0,z.jsxs)(X,{title:`conflicts kept beside`,actions:(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`two people changed these at once — the version that reached the cloud first stays, the other is next to it`}),children:[e.conflicts.map(e=>(0,z.jsxs)(`div`,{className:I(`git-conflict px-[18px]`,yy),children:[(0,z.jsx)(B,{name:`call_split`,className:`ms-sm text-accent`}),(0,z.jsx)(`span`,{className:by,children:e.path}),(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[e.by,`'s version:`]}),(0,z.jsx)(`span`,{className:I(by,`text-accent`),children:e.copy}),(0,z.jsx)(`span`,{className:I(`text-xs text-fg-2`,`ml-auto`),title:e.at,children:G(e.at)})]},e.copy+e.at)),(0,z.jsx)(`p`,{className:I(`text-xs text-fg-2`,`m-0 border-t border-line px-[18px] py-2.5`),children:`Compare the two, keep what is right in the original, and delete the copy — the deletion syncs like any change.`})]}),(0,z.jsxs)(X,{title:`changes`,actions:(0,z.jsx)(`span`,{className:uy,children:y.length===0?`workspace clean`:`${n.size} of ${y.length} selected`}),children:[y.length===0&&b.length===0&&(0,z.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Nothing changed under the workspace paths.`}),y.map(e=>(0,z.jsxs)(`div`,{className:I(`git-row px-[18px]`,yy),children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,"aria-label":`select ${e.path}`,checked:n.has(e.path),onChange:t=>x(e.path,t.target.checked)}),(0,z.jsxs)(`button`,{type:`button`,className:`group/file flex min-w-0 flex-1 cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),children:[(0,z.jsx)(B,{name:i.has(e.path)?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,z.jsx)(ly,{status:e.status}),(0,z.jsx)(`span`,{className:I(by,`group-hover/file:underline`),children:e.path})]}),i.has(e.path)&&(0,z.jsx)(iy,{file:e.path})]},e.path)),y.length>0&&(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5 border-t border-line bg-surface-2 px-[18px] py-3`,children:[(0,z.jsx)(Z,{className:`min-w-[220px] flex-1 text-sm`,placeholder:`Commit message`,"aria-label":`commit message`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!c&&o.trim()&&n.size>0&&_()}}),(0,z.jsx)(K,{size:`sm`,disabled:n.size===y.length,onClick:()=>r(new Set(y.map(e=>e.path))),children:`select all`}),(0,z.jsxs)(K,{size:`sm`,variant:`primary`,icon:`check`,busy:c===`commit`,disabled:!!c||n.size===0||!o.trim(),onClick:()=>void _(),children:[`commit `,n.size||``]})]}),b.length>0&&(0,z.jsxs)(`details`,{className:`border-t border-line px-[18px] py-2.5`,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer text-[12.5px] text-fg-2`,children:[b.length,e.blockedHidden?`+`:``,` change`,b.length===1&&!e.blockedHidden?``:`s`,` outside the workspace paths`]}),b.map(e=>(0,z.jsxs)(`div`,{className:I(`git-row blocked opacity-60`,yy),children:[(0,z.jsx)(ly,{status:e.status,muted:!0}),(0,z.jsx)(`span`,{className:by,children:e.path}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:e.reason})]},e.path)),!!e.blockedHidden&&(0,z.jsx)(`div`,{className:I(`git-row blocked opacity-60`,yy),children:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`and `,e.blockedHidden,` more, not listed`]})})]})]}),!e.error&&(0,z.jsx)(hy,{refresh:`${e.branch}/${e.ahead}/${e.behind}/${e.lastPull}/${e.lastPush}/${e.lastAutoCommit}/${e.files?.length}`}),!e.error&&(0,z.jsx)(gy,{st:e}),(0,z.jsxs)(`p`,{className:I(uy,`m-0`),children:[`Synced paths: `,(e.scope??[]).map((e,t)=>(0,z.jsxs)(`span`,{children:[t>0&&`, `,(0,z.jsx)(`code`,{children:e})]},e)),`. Run artifacts and files like `,(0,z.jsx)(`code`,{children:`.env`}),` are never staged.`,` `,e.interval&&e.autosync===`sync`?`kraftwerk sync every ${ty(e.interval)}: commits what changed under these paths, takes the remote's changes in and pushes. Where both sides changed a file, the remote's version wins and yours is kept beside it.${e.lastAutoCommit?` Last automatic commit ${G(e.lastAutoCommit)}.`:``} `:e.interval?`Fetches every ${ty(e.interval)}${e.autosync===`push`?`, fast-forwards when the working tree is clean and pushes what is committed`:e.autosync===`pull`?` and fast-forwards when the working tree is clean`:``}. `:`Background fetching is off. `,e.interval&&e.autosync===`sync`?`A commit by hand goes up at once.`:e.interval&&e.autosync===`push`?`Committing is always manual.`:`Commit and push are always manual.`]})]})}var py={kraftwerk:{icon:`cloud_done`,label:`managed by kraftwerk`,text:`kraftwerk sync: this workspace's own repository in kraftwerk cloud. Everyone on the workspace pulls and pushes here, with their cloud account — access follows the workspace's members, no git provider to set up.`},custom:{icon:`construction`,label:`own git provider · expert mode`,text:`This workspace syncs through a git server of your own (GitHub, GitLab, Bitbucket, a server in-house). Hosting, access and credentials are yours to manage there; kraftwerk only fetches, pulls and pushes.`},none:{icon:`cloud_off`,label:`no remote yet`,text:"History stays on this machine. In cloud mode, kraftwerk sync gives the workspace a repository in kraftwerk cloud and keeps it in step with everyone's; or add a remote of your own with `git remote add`."}};function my({st:e}){let{cloud:t}=Bv(),[n,r]=(0,v.useState)(!1),i=e.hosting??(e.remoteUrl?`custom`:`none`),a=py[i],o=``;try{o=e.remoteUrl?new URL(e.remoteUrl).host:``}catch{o=e.remoteUrl?.match(/@([^:]+):/)?.[1]??``}return(0,z.jsx)(X,{title:`repository`,actions:(0,z.jsxs)(`span`,{className:I(`git-hosting inline-flex items-center gap-1 text-xs font-semibold`,i===`kraftwerk`?`text-ok`:i===`custom`?`text-accent`:`text-fg-2`),children:[(0,z.jsx)(B,{name:a.icon,className:`ms-sm`}),` `,a.label]}),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-[18px] py-3.5`,children:[e.remoteUrl?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:uy,children:e.remote??`origin`}),(0,z.jsx)(`code`,{className:`git-remote-url min-w-0 flex-1 truncate rounded-lg bg-surface-2 px-2.5 py-1.5 font-mono text-[12.5px]`,title:e.remoteUrl,children:e.remoteUrl}),(0,z.jsx)(K,{size:`sm`,icon:n?`check`:`content_copy`,onClick:()=>{navigator.clipboard?.writeText(e.remoteUrl).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})},children:n?`copied`:`copy`})]}):null,(0,z.jsxs)(`div`,{className:I(uy,`flex flex-wrap items-center gap-x-1.5`),children:[(0,z.jsx)(`span`,{children:a.text}),e.repoRoot&&(0,z.jsxs)(`span`,{children:[`Local folder `,(0,z.jsx)(`code`,{children:e.repoRoot}),`.`]}),i===`kraftwerk`&&t?.workspaceUrl&&(0,z.jsx)(`a`,{href:t.workspaceUrl,target:`_blank`,rel:`noreferrer`,children:`the workspace in kraftwerk cloud ↗`}),i===`custom`&&o&&(0,z.jsxs)(`span`,{children:[`Provider: `,(0,z.jsx)(`strong`,{children:o}),`.`]}),i===`none`&&(0,z.jsx)(`a`,{href:`#/settings`,children:`set up kraftwerk sync in settings → git sync`}),i===`custom`&&(0,z.jsx)(`a`,{href:`#/settings/cloud`,children:`what kraftwerk sync is`})]})]})})}function hy({refresh:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=!0;return A.request(`git.log`,{}).then(t=>e&&t.ok&&n(t.data.commits)).catch(()=>{}),()=>{e=!1}},[e]),!t)return null;let a=t.filter(e=>e.local).length;return(0,z.jsxs)(X,{title:`history · newest first`,actions:(0,z.jsx)(`span`,{className:uy,children:a?`${a} not pushed`:t.length?`all pushed`:``}),children:[t.length===0&&(0,z.jsx)(`p`,{className:I(`text-xs text-fg-2`,`m-0 px-[18px] py-3.5`),children:`No commits under the workspace paths yet.`}),t.map(e=>(0,z.jsxs)(`div`,{className:`git-commit border-line px-[18px] py-2 [&+&]:border-t`,"data-commit":e.short,children:[(0,z.jsxs)(`button`,{type:`button`,className:`group/item flex w-full cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,onClick:()=>i(r===e.hash?null:e.hash),title:e.hash,children:[(0,z.jsx)(B,{name:r===e.hash?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,z.jsx)(`code`,{className:`text-xs`,children:e.short}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm group-hover/item:underline`,children:e.subject}),e.local&&(0,z.jsx)(`span`,{className:`flex-none rounded-md border border-accent px-1.5 text-[10.5px] font-semibold tracking-wide text-accent uppercase`,children:`not pushed`}),(0,z.jsxs)(`span`,{className:I(uy,`ml-auto flex-none`),children:[e.author,` · `,G(e.committedAt)]})]}),r===e.hash&&(0,z.jsx)(oy,{source:{route:`git.commitDiff`,input:{hash:e.hash}}})]},e.hash))]})}function gy({st:e}){let t=e.ignores??[],n=t.reduce((e,t)=>e+t.rules.length+(t.more??0),0);return(0,z.jsx)(X,{title:`ignored`,actions:(0,z.jsx)(`span`,{className:uy,children:t.length?`${n} rule${n===1?``:`s`} in ${t.length} file${t.length===1?``:`s`}`:`no .gitignore`}),children:(0,z.jsxs)(`div`,{className:`git-ignored flex flex-col gap-2 px-[18px] py-3.5`,children:[(0,z.jsxs)(`div`,{className:uy,children:[`Files matching these rules never reach git: they are not listed above, not committed and not synced. Edit a `,(0,z.jsx)(`code`,{children:`.gitignore`}),` to change that.`]}),t.map((e,t)=>(0,z.jsxs)(`details`,{open:t===0,className:`git-ignore-file rounded-lg border border-line`,children:[(0,z.jsxs)(`summary`,{className:`flex cursor-pointer items-center gap-2 px-2.5 py-1.5 text-[12.5px]`,children:[(0,z.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.path}),(0,z.jsx)(`span`,{className:uy,children:e.rules.length+(e.more??0)})]}),(0,z.jsxs)(`pre`,{className:`m-0 overflow-x-auto border-t border-line bg-surface-2 px-2.5 py-2 font-mono text-[12.5px] leading-relaxed`,children:[e.rules.length?e.rules.join(`
475
+ `):`(no rules)`,e.more?`\n… ${e.more} more`:``]})]},e.path))]})})}function _y({onSetup:e}){let[t,n]=(0,v.useState)(null),r=(0,v.useCallback)(async()=>{try{let e=await A.request(`git.status`,{query:{fresh:!0}});e.ok&&n(e.data)}catch{}},[]);if((0,v.useEffect)(()=>void r(),[r]),!t)return null;let i=t.enabled?t.hosting??(t.remoteUrl?`custom`:`none`):`none`,a=py[i];return(0,z.jsxs)(z.Fragment,{children:[t.remoteUrl&&(0,z.jsxs)(`div`,{className:`git-remote-summary flex flex-wrap items-center gap-2 border-t border-line px-[18px] py-3`,children:[(0,z.jsxs)(`span`,{className:I(`inline-flex items-center gap-1 text-xs font-semibold`,i===`kraftwerk`?`text-ok`:`text-accent`),children:[(0,z.jsx)(B,{name:a.icon,className:`ms-sm`}),` `,a.label]}),(0,z.jsx)(`code`,{className:`min-w-0 flex-1 truncate rounded-lg bg-surface-2 px-2.5 py-1 font-mono text-xs`,title:t.remoteUrl,children:t.remoteUrl})]}),i===`none`&&(0,z.jsx)(vy,{onDone:()=>{r(),e()}})]})}function vy({onDone:e}){let{cloud:t}=Bv(),[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)([]),c=t?.mode===`cloud`&&t.steps.claim,l=async()=>{r(!0),a(``);try{let t=await A.request(`git.setupSync`,{body:{}});t.ok&&t.data.ok?(s(t.data.done),e()):(t.data&&typeof t.data==`object`&&`done`in t.data&&Array.isArray(t.data.done)&&s(t.data.done),a(P(t)||`setting up kraftwerk sync failed`),e())}catch(e){a(e.message||`setting up kraftwerk sync failed`)}finally{r(!1)}};return(0,z.jsxs)(`div`,{className:`sync-setup flex flex-col gap-2 border-t border-line bg-surface-2 px-[18px] py-3.5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,z.jsx)(`strong`,{className:`text-sm`,children:`Sync with kraftwerk cloud`}),(0,z.jsx)(`div`,{className:uy,children:c?`One click: the workspace gets its repository in kraftwerk cloud and kraftwerk sync turns on — every minute what changed here goes up and the others' changes come in. This machine signs in with its own key — no token, no git provider.`:`kraftwerk sync comes with cloud mode: switch the workspace to cloud (below), then set it up here in one click. Or turn git sync on and use a remote of your own (expert mode).`})]}),c?(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`cloud_upload`,busy:n,disabled:n,onClick:()=>void l(),children:`set up kraftwerk sync`}):(0,z.jsx)(`a`,{className:`text-sm font-semibold`,href:`#/settings/cloud`,children:`what cloud mode is →`})]}),o.length>0&&(0,z.jsx)(`ul`,{className:I(`text-xs text-fg-2`,`m-0 list-none p-0`),children:o.map(e=>(0,z.jsxs)(`li`,{className:`inline-flex items-center gap-1 pr-3 text-ok`,children:[(0,z.jsx)(B,{name:`check`,className:`ms-sm`}),` `,e]},e))}),i&&(0,z.jsx)(rt,{tone:`bad`,children:i})]})}var yy=`flex flex-wrap items-center gap-2.5 py-2 [&+&]:border-t [&+&]:border-line`,by=`truncate font-mono text-[12.5px]`,xy=e=>e.replace(/^https?:\/\//,``).replace(/^git@([^:]+):/,`$1/`).replace(/\.git$/,``),Sy=e=>e.error?{label:`unreadable`,state:`unreadable`}:e.dirty?{label:`${e.dirty} changed`,state:`changed`}:e.ahead?{label:`${e.ahead} to push`,state:`clean`}:e.behind?{label:`${e.behind} behind`,state:`behind`}:{label:`clean`,state:`clean`};function Cy({label:e,state:t}){return(0,z.jsx)(`span`,{className:I(`inline-flex items-center text-2xs font-semibold tracking-[0.4px] uppercase`,t===`clean`?`text-ok`:t===`changed`?`text-ask`:t===`unreadable`?`text-bad`:`text-fg-2`),children:e})}var wy=`rounded-full border border-line px-[7px] py-px font-mono text-xs text-fg-2`,Ty=`border-line px-[18px] py-2 [&+&]:border-t`,Ey=`group/item flex w-full cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,Dy=`min-w-0 truncate font-mono text-[12.5px] group-hover/item:underline`;function Oy({title:e,embedded:t,children:n}){return(0,z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-3`,children:[!t&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`arrow_back`,href:`/repos`,title:`all repositories`,children:`repositories`}),!t&&(0,z.jsx)(B,{name:`folder_data`,className:`text-[26px] text-fg-2`}),!t&&(0,z.jsx)(ot,{children:e}),n]})}var ky=e=>!!(e.error||e.dirty||e.ahead===void 0||e.ahead);function Ay({slug:e}){return e?(0,z.jsx)(jy,{slug:e}):(0,z.jsx)(My,{})}function jy({slug:e,embedded:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(0),g=(0,v.useCallback)(async()=>{try{let t=await A.request(`repos.get`,{slug:e});if(!t.ok)throw Error(P(t));r(t.data),a(``)}catch(e){a(e.message||`could not load the repository`)}},[e]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await g(),e&&(t=setTimeout(n,5e3))};return n(),()=>{e=!1,clearTimeout(t)}},[g,m]);let _=async()=>{d(`update`),p(``);try{let t=await A.request(`repos.update`,{slug:e});if(!t.ok||!t.data.ok)throw Error(t.error||`failed`);t.data.error&&p(t.data.error)}catch(e){p(e.message)}finally{d(``),h(e=>e+1)}};if(i&&!n)return(0,z.jsxs)(ct,{className:`repo-page`,children:[(0,z.jsx)(Oy,{title:e,embedded:t}),(0,z.jsx)(rt,{tone:`bad`,children:i})]});if(!n)return(0,z.jsx)(Y,{children:`loading…`});let y=Sy(n),b=n.commits.filter(e=>e.local).length;return(0,z.jsxs)(ct,{className:`repo-page`,children:[(0,z.jsxs)(Oy,{title:n.slug,embedded:t,children:[n.branch&&(0,z.jsx)(`span`,{className:wy,children:n.branch}),n.upstream&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,title:`upstream`,children:[`→ `,n.upstream]}),(0,z.jsx)(Cy,{...y}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(K,{size:`sm`,icon:`sync`,busy:u===`update`,disabled:!!u,onClick:()=>void _(),title:`git fetch, then fast-forward when clean`,children:u===`update`?`updating…`:`update`})]}),(0,z.jsxs)(`div`,{className:I(uy,`flex flex-wrap gap-x-3.5 gap-y-1`),children:[n.url&&(0,z.jsx)(`span`,{title:n.url,children:xy(n.url)}),(0,z.jsx)(`span`,{title:n.path,children:n.path}),n.head&&(0,z.jsxs)(`span`,{children:[`at `,(0,z.jsx)(`code`,{children:n.head}),n.committedAt?` · ${G(n.committedAt)}`:``]}),!!n.ahead&&(0,z.jsxs)(`span`,{children:[n.ahead,` to push`]}),!!n.behind&&(0,z.jsxs)(`span`,{children:[n.behind,` behind`]}),n.updatedAt&&(0,z.jsxs)(`span`,{children:[`changed `,G(n.updatedAt)]})]}),(n.error||f||i)&&(0,z.jsx)(rt,{tone:`bad`,children:n.error||f||i}),(0,z.jsxs)(X,{title:`changes · working tree against HEAD`,actions:(0,z.jsxs)(`span`,{className:uy,children:[n.files.length,` file`,n.files.length===1?``:`s`,n.insertions||n.deletions?(0,z.jsxs)(z.Fragment,{children:[` · `,(0,z.jsxs)(`span`,{className:`text-ok`,children:[`+`,n.insertions]}),` `,(0,z.jsxs)(`span`,{className:`text-bad`,children:[`−`,n.deletions]})]}):null]}),children:[n.files.length===0&&(0,z.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Clean — nothing changed since the last commit.`}),n.files.map(t=>(0,z.jsxs)(`div`,{className:I(`repo-file`,Ty),"data-file":t.path,children:[(0,z.jsxs)(`button`,{type:`button`,className:Ey,onClick:()=>s(o===t.path?null:t.path),children:[(0,z.jsx)(B,{name:o===t.path?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,z.jsx)(ly,{status:t.status}),(0,z.jsx)(`span`,{className:Dy,children:t.path})]}),o===t.path&&(0,z.jsx)(oy,{source:{route:`repos.diff`,input:{slug:e,query:{path:t.path}}},refresh:n.updatedAt})]},t.path))]}),(0,z.jsxs)(X,{title:`commits · newest first`,actions:(0,z.jsx)(`span`,{className:uy,children:b?`${b} not pushed`:n.commits.length?`all pushed`:``}),children:[n.commits.length===0&&(0,z.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`No commits yet.`}),n.commits.map(t=>(0,z.jsxs)(`div`,{className:I(`repo-commit`,Ty),"data-commit":t.short,children:[(0,z.jsxs)(`button`,{type:`button`,className:Ey,onClick:()=>l(c===t.hash?null:t.hash),title:t.hash,children:[(0,z.jsx)(B,{name:c===t.hash?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,z.jsx)(`code`,{className:`text-xs`,children:t.short}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm group-hover/item:underline`,children:t.subject}),t.local&&(0,z.jsx)(J,{tone:`accent`,children:`not pushed`}),(0,z.jsxs)(`span`,{className:I(uy,`ml-auto flex-none`),children:[t.author,` · `,G(t.committedAt)]})]}),c===t.hash&&(0,z.jsx)(oy,{source:{route:`repos.commit`,input:{slug:e,hash:t.hash}}})]},t.hash))]})]})}function My(){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,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(``),x=(0,v.useCallback)(async()=>{try{let e=await A.request(`repos.list`);if(!e.ok)throw Error(`HTTP ${e.status}`);t(e.data),r(``)}catch(e){r(e.message||`could not load repositories`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await x(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[x]);let S=async(e,t,n=!1)=>{a(n=>({...n,[e]:t})),s(t=>({...t,[e]:``})),l(null);try{let r=t===`update`?await A.request(`repos.update`,{slug:e}):await A.request(`repos.remove`,{slug:e,query:{force:n}});if(!r.ok||!r.data.ok)throw Error(r.error||`failed`);let i=r.data.error;i&&s(t=>({...t,[e]:i}))}catch(t){s(n=>({...n,[e]:t.message}))}finally{a(t=>{let n={...t};return delete n[e],n}),x()}},C=async e=>{if(e.preventDefault(),u.trim()&&!g){_(!0),b(``);try{let e=await A.request(`repos.add`,{body:{url:u.trim(),name:f.trim()||void 0,branch:m.trim()||void 0}});if(!e.ok)throw Error(e.error||`clone failed`);d(``),p(``),h(``),await x()}catch(e){b(e.message)}finally{_(!1)}}},w=[...e?.repos??[]].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``));return(0,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:`source`,title:`Repositories`,actions:(0,z.jsxs)(z.Fragment,{children:[e?.enabled&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[w.length,` cloned`]}),n&&(0,z.jsx)(rt,{tone:`bad`,children:n})]})}),e&&!e.enabled&&(0,z.jsx)(X,{children:(0,z.jsx)(`div`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:e.error&&!/are off/.test(e.error)?(0,z.jsx)(rt,{tone:`bad`,children:e.error}):(0,z.jsxs)(z.Fragment,{children:[`Repositories are off. Turn them on in `,(0,z.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,z.jsx)(`code`,{children:`repos:`}),` block to kraftwerk.yml.`]})})}),e?.enabled&&(0,z.jsx)(X,{title:`add a repository`,actions:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`clones into `,(0,z.jsx)(`code`,{title:e.root,children:e.root})]}),children:(0,z.jsxs)(`form`,{className:`flex flex-col gap-2.5 p-[18px]`,onSubmit:e=>void C(e),children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2.5`,children:[(0,z.jsx)(Q,{label:`url`,className:`min-w-[240px] flex-[2]`,children:(0,z.jsx)(Z,{value:u,placeholder:`https://github.com/org/repo.git, git@host:org/repo.git or github:org/repo`,onChange:e=>d(e.target.value),autoFocus:!0})}),(0,z.jsx)(Q,{label:`name`,className:`min-w-[140px] flex-1`,children:(0,z.jsx)(Z,{value:f,placeholder:`from the url`,onChange:e=>p(e.target.value)})}),(0,z.jsx)(Q,{label:`branch`,className:`w-[140px]`,children:(0,z.jsx)(Z,{value:m,placeholder:`default`,onChange:e=>h(e.target.value)})}),(0,z.jsx)(K,{type:`submit`,variant:`primary`,icon:`download`,busy:g,disabled:!u.trim(),children:g?`cloning…`:`clone`})]}),y&&(0,z.jsx)(rt,{tone:`bad`,children:y}),(0,z.jsxs)(`p`,{className:I(`text-xs text-fg-2`,`m-0`),children:[`Uses your own git credentials and never prompts: a private remote must already work from a terminal. Agents see every clone here and can add more with `,(0,z.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})}),e?.enabled&&(0,z.jsxs)(X,{title:`cloned repositories · newest change first`,children:[w.length===0&&(0,z.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Nothing cloned yet.`}),w.map(e=>{let t=i[e.slug],n=Sy(e);return(0,z.jsxs)(`div`,{className:I(`repo-row grid grid-cols-[40px_minmax(0,1fr)_auto] items-start gap-3.5 border-line px-[18px] py-3.5 [&+&]:border-t`,n.state===`changed`&&`bg-ask-soft/40`),"data-repo":e.slug,children:[(0,z.jsx)(`span`,{className:I(`grid size-10 place-items-center rounded-full bg-surface-2 text-fg-2`,n.state===`unreadable`&&`opacity-45 grayscale`),children:(0,z.jsx)(B,{name:`folder_data`,className:`text-[22px]`})}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,z.jsx)(U,{href:`/repos/${encodeURIComponent(e.slug)}`,className:`text-md font-semibold text-fg no-underline hover:underline`,title:`changes and commits`,children:e.slug}),e.branch&&(0,z.jsx)(`span`,{className:wy,children:e.branch}),(0,z.jsx)(Cy,{...n}),e.updatedAt&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.updatedAt,children:[`changed `,G(e.updatedAt)]})]}),e.url&&(0,z.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.url,children:xy(e.url)}),(0,z.jsx)(`div`,{className:`text-xs [overflow-wrap:anywhere] text-fg-2 opacity-70`,title:e.path,children:e.path}),(0,z.jsxs)(`div`,{className:I(`text-xs text-fg-2`,`flex flex-wrap gap-x-3.5 gap-y-1 [&_code]:text-[11.5px]`),children:[e.head&&(0,z.jsxs)(`span`,{title:e.committedAt,children:[(0,z.jsx)(`code`,{children:e.head}),` `,e.subject,e.committedAt?` · ${G(e.committedAt)}`:``]}),!!e.behind&&!!e.dirty&&(0,z.jsxs)(`span`,{children:[`behind by `,e.behind]}),e.error&&(0,z.jsx)(`span`,{className:`text-bad`,children:e.error})]}),o[e.slug]&&(0,z.jsx)(rt,{tone:`bad`,children:o[e.slug]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,z.jsx)(K,{size:`sm`,icon:`difference`,href:`/repos/${encodeURIComponent(e.slug)}`,title:`changed files with diffs, recent commits`,children:`changes`}),(0,z.jsx)(K,{size:`sm`,icon:`sync`,busy:t===`update`,disabled:!!t,onClick:()=>void S(e.slug,`update`),title:`git fetch, then fast-forward when clean`,children:t===`update`?`updating…`:`update`}),c!==e.slug&&(0,z.jsx)(K,{size:`sm`,icon:`delete`,disabled:!!t,onClick:()=>l(e.slug),title:`Move the clone to the trash`,children:`remove`}),c===e.slug&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void S(e.slug,`remove`,ky(e)),children:e.dirty||e.ahead?`delete with local changes`:ky(e)?`delete anyway`:`confirm remove`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},e.slug)})]})]})}var Ny={workspace:`workspace`,project:`.claude`,user:`global`,agent:`agent`};function Py(e){return(0,z.jsx)(J,{tone:e===`workspace`?`ok`:e===`agent`?`accent`:`neutral`,children:Ny[e]})}function Fy({name:e}){let t=F(`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&&H(`/skills/${encodeURIComponent(a.name)}`,{replace:!0})},[e,a?.name]);let o=t=>(0,z.jsx)(gt,{href:`/skills/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,z.jsx)(et,{tone:t.source===`workspace`?`ok`:`idle`}),title:`/${t.name}`,titleExtra:t.source!==`workspace`&&Py(t.source),sub:t.description||`no description`},`${t.source}:${t.name}`);return(0,z.jsxs)(`div`,{className:`runs-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`workspace skills`}),(0,z.jsxs)(jt,{children:[r.map(o),t&&r.length===0&&(0,z.jsx)(Mt,{children:`no workspace skills yet`}),i.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(kt,{title:`local (this machine / repo)`,divided:!0}),i.map(o)]})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:e?(0,z.jsx)(Ly,{name:e},e):t&&!a?(0,z.jsx)(Iy,{root:t.root}):(0,z.jsx)(Y,{children:`loading…`})})]})}function Iy({root:e}){return(0,z.jsx)(`div`,{className:`empty-action py-6`,children:(0,z.jsxs)(Y,{icon:`extension`,children:[`Create `,(0,z.jsxs)(`code`,{children:[e,`/<name>/SKILL.md`]}),` and it appears here and in every session's `,(0,z.jsx)(`code`,{children:`/`}),` menu.`]})})}function Ly({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?fo.sanitize(Mi.parse(s,{async:!1})):``,[s]);return(0,v.useEffect)(()=>{A.call(`skills.get`,{name:e}).then(n,()=>i(!0))},[e]),r?(0,z.jsx)(Y,{icon:`extension`,children:`skill not found`}):t?(0,z.jsxs)(`div`,{className:`agent-view flex flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,z.jsxs)(ot,{size:`lg`,children:[`/`,t.name]}),Py(t.source)]}),t.description&&(0,z.jsx)(`p`,{className:`-mt-2 mb-0 mx-0.5 text-sm leading-[1.6] text-fg-2`,children:t.description}),(0,z.jsx)(Ry,{name:t.name}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_320px] items-start gap-4 max-[1020px]:grid-cols-1`,children:[(0,z.jsx)(X,{className:`min-w-0`,title:`SKILL.md`,actions:(0,z.jsx)(_t,{bare:!0,label:`SKILL.md view`,value:a,onChange:o,items:[{id:`rendered`,label:`rendered`},{id:`source`,label:`source`}]}),children:a===`rendered`?(0,z.jsx)(`div`,{className:`md-body h-auto overflow-visible [&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2`,dangerouslySetInnerHTML:{__html:c}}):(0,z.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,z.jsx)(`aside`,{className:`flex min-w-0 flex-col gap-4`,children:(0,z.jsx)(X,{title:`about`,children:(0,z.jsxs)(mt,{children:[(0,z.jsx)(ht,{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,z.jsx)(ht,{label:`path`,mono:!0,children:(0,z.jsx)(`span`,{title:t.path,children:t.path})}),(0,z.jsx)(ht,{label:`invoke`,children:(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`code`,{children:[`/`,t.name]}),` in any session`]})}),t.files.length>0&&(0,z.jsx)(ht,{label:`bundled files`,mono:!0,children:t.files.map(e=>(0,z.jsx)(`span`,{className:`block w-full`,children:e},e))})]})})})]})]}):(0,z.jsx)(Y,{children:`loading…`})}function Ry({name:e}){let t=F(`agents.list`,{},{interval:3e4}),n=Yt(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=(t?.agents??[]).filter(t=>!t.archived&&(t.skills===void 0||t.skills.includes(e)));return(0,z.jsx)(Rt,{label:`use this skill`,className:`skill-run`,chip:`/${e}`,chipTitle:`the skill's command: the message starts with it`,value:a,onChange:o,inputLabel:`what to do with the skill`,placeholder:`Add what it should work on (optional)`,onSend:async t=>{c(!0),u(``);let i=await Kt({who:r||void 0,text:`/${e}${a.trim()?` ${a.trim()}`:``}`,files:t});if(c(!1),`error`in i)return u(i.error),!1;o(``),n(i.href)},sendLabel:`send to a new chat`,busy:s,error:l,who:r,onWho:e=>d.some(t=>t.slug===e)&&i(e),attach:!0,controls:(0,z.jsx)(Bt,{value:r,onChange:i,agents:d}),hint:`starts a new chat`})}var zy=encodeURIComponent,By=new Set([`chats`,`workflows`,`skills`,`runs`,`tasks`,`boards`,`knowledge`,`contacts`,`places`,`events`]),Vy={chats:`New chat`,workflows:`New workflow`,skills:`New skill`,runs:`Run a workflow`,tasks:`New task`,boards:`New board`,knowledge:`New knowledge bundle`,contacts:`New contact`,places:`New place`,events:`New event`};function Hy({label:e,title:t,onClose:n,children:r}){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)},[n]),(0,b.createPortal)((0,z.jsx)(`div`,{className:`fixed inset-0 z-40 flex animate-fade items-start justify-center bg-black/38 px-4 pt-[12vh] pb-4`,onMouseDown:n,children:(0,z.jsxs)(`div`,{role:`dialog`,"aria-label":e,className:`relative flex w-[min(600px,100%)] animate-modal flex-col gap-4 rounded-card border border-line bg-surface p-5 shadow-modal`,onMouseDown:e=>e.stopPropagation(),children:[(0,z.jsx)(q,{icon:`close`,label:`close (esc)`,className:`absolute top-3 right-3 rounded-full`,onClick:n}),(0,z.jsx)(`h2`,{className:`m-0 text-base font-semibold text-fg`,children:t}),r]})}),document.body)}function Uy({kind:e,project:t,onClose:n,onMade:r}){let i=Yt();return(0,z.jsx)(Hy,{label:Vy[e].toLowerCase(),title:Vy[e],onClose:n,children:(0,z.jsxs)(Jt.Provider,{value:e=>(n(),i(e),!0),children:[e===`chats`&&(0,z.jsx)(Wy,{project:t}),e===`workflows`&&(0,z.jsx)(Gy,{what:`workflow`}),e===`skills`&&(0,z.jsx)(Gy,{what:`skill`}),e===`runs`&&(0,z.jsx)(Ky,{}),e===`tasks`&&(0,z.jsx)(qy,{project:t,onMade:e=>(n(),r(`tasks:${e.project??``}:${e.board}:${e.slug}`,e.href))}),e===`boards`&&(0,z.jsx)(Jy,{project:t,onCancel:n,onMade:e=>(n(),r(`boards:${t??``}:${e}`,`${t?`/projects/${zy(t)}`:``}/boards/${zy(e)}`))}),e===`knowledge`&&(0,z.jsx)(Yy,{onCancel:n,onMade:e=>(n(),r(`knowledge:${e}`,`/knowledge/${zy(e)}`))}),(e===`contacts`||e===`places`||e===`events`)&&(0,z.jsx)(bg,{kind:e,onCancel:n,onCreated:t=>(n(),r(`${e}:${t}`,`/${e}/${zy(t)}`))})]})})}function Wy({project:e}){let t=F(`agents.list`,{}),n=Vt(),r=Yt(),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(e??``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),m=(t?.agents??[]).filter(e=>!e.archived);return(0,z.jsx)(Rt,{label:`new chat`,value:c,onChange:l,autoFocus:!0,inputLabel:`message`,placeholder:`Ask anything — / for skills, @ for an agent`,sendLabel:`start chat`,busy:u,error:f,skills:!0,who:i,onWho:a,attach:!0,controls:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Bt,{value:i,onChange:a,agents:m,byDefault:o?`🧭 Assistant (default)`:void 0}),(0,z.jsx)(Ht,{value:o,onChange:s,projects:n})]}),hint:o&&o===e?`a chat in this project`:void 0,onSend:async e=>{d(!0),p(``);let t=await Kt({who:i||void 0,project:o||void 0,harness:n.find(e=>e.slug===o)?.harness,text:c,files:e});if(d(!1),`error`in t)return p(t.error),!1;r(t.href)}})}function Gy({what:e}){let t=Yt(),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);return(0,z.jsx)(Rt,{label:`new ${e}`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:e===`workflow`?`account_tree`:`extension`,className:`ms-sm`}),` new `,e]}),chipTitle:`Ralv builds the ${e} from what you describe`,value:n,onChange:r,autoFocus:!0,inputLabel:`what the ${e} should do`,placeholder:e===`workflow`?`Describe what it should do, step by step if you know`:`Describe what the skill is for and when to use it`,sendLabel:`ask Ralv to make the ${e}`,busy:i,disabled:!n.trim(),error:o,attach:!0,hint:`Ralv makes it in a chat`,onSend:async r=>{a(!0),s(``);let i=await Kt({text:e===`workflow`?`Create a new workflow in this workspace. What it should do:\n\n${n.trim()}`:`Create a new skill in this workspace's skills folder. What it is for:\n\n${n.trim()}`,files:r});if(a(!1),`error`in i)return s(i.error),!1;t(i.href)}})}function Ky(){let e=F(`workflows.list`,{}),t=(e?.workflows??[]).filter(e=>!e.error),[n,r]=(0,v.useState)(``),i=t.find(e=>e.slug===n)??t[0];return e&&t.length===0?(0,z.jsx)(`p`,{className:`m-0 text-sm text-fg-2`,children:`There is no workflow to run yet.`}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsx)(Q,{label:`workflow`,children:(0,z.jsx)(St,{"aria-label":`workflow`,value:i?.slug??``,onChange:e=>r(e.target.value),children:t.map(e=>(0,z.jsx)(`option`,{value:e.slug,children:e.name||e.slug},e.slug))})}),i&&(0,z.jsx)(Eg,{slug:i.slug,usesRequest:i.usesRequest},i.slug)]})}function qy({project:e,onMade:t}){let n=F(`boards.list`,{query:{all:`1`}}),r=Yt(),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),f=(n?.boards??[]).filter(t=>!e||t.project===e),p=e=>`${e.project??``}/${e.board}`,m=f.find(e=>p(e)===o)??f[0];return(0,z.jsx)(Rt,{label:`new task`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`task_alt`,className:`ms-sm`}),` task`]}),value:i,onChange:e=>a(e.replace(/\n/g,` `)),autoFocus:!0,minRows:1,inputLabel:`task title`,placeholder:`What needs doing?`,sendLabel:`add task`,sendIcon:`add`,busy:c,disabled:!i.trim()||!m,error:u||(n&&f.length===0?`There is no board yet: make one first (New board).`:``),controls:f.length>0&&(0,z.jsx)(St,{"aria-label":`board`,value:m?p(m):``,onChange:e=>s(e.target.value),className:`h-8 w-auto max-w-[260px] rounded-full border-0 bg-transparent text-sm font-medium hover:bg-surface-2`,children:f.map(t=>(0,z.jsxs)(`option`,{value:p(t),children:[t.project&&!e?`${t.project} · `:``,t.title]},p(t)))}),hint:`lands in the board's todo column`,onSend:async()=>{if(!m)return!1;l(!0),d(``);let e=await A.request(`tasks.create`,{board:m.board,query:m.project?{project:m.project}:{},body:{title:i.trim()}});if(l(!1),!e.ok)return d(P(e)),!1;let n=`${m.project?`/projects/${zy(m.project)}`:``}/boards/${zy(m.board)}/${zy(e.data.slug)}`;t?t({project:m.project,board:m.board,slug:e.data.slug,href:n}):r(n)}})}function Jy({project:e,onMade:t,onCancel:n}){let[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=Bv().cloud?.mode===`local`,[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Xy,{label:`title`,inputLabel:`board title`,placeholder:`e.g. Marketing`,value:r,onChange:i,submit:`create board`,busy:c,error:u,onSubmit:async()=>{let n=r.trim();if(!n||c)return;l(!0),d(``);let i=await A.request(`boards.create`,{body:{title:n,...e?{project:e}:{},...a?{cloud:!0}:{}}});if(l(!1),!i.ok)return d(P(i));t(i.data.board)},onCancel:n,hint:a?`Kept in kraftwerk cloud: everyone on the workspace sees and edits it; tasks go to people or agents.`:`Starts with the columns Draft, Todo, In progress, Review and Done; change them in the board's settings.`}),!e&&!s&&(0,z.jsx)(Tt,{checked:a,onChange:o,className:`mt-3 text-sm`,children:`in kraftwerk cloud — shared with everyone on the workspace`}),!e&&s&&(0,z.jsxs)(`p`,{className:`m-0 mt-3 text-xs text-fg-2`,children:[(0,z.jsx)(B,{name:`cloud`,className:`ms-sm align-[-3px] text-accent`}),` Shared with others? Cloud boards need cloud mode —`,` `,(0,z.jsx)(`a`,{href:`#/settings/cloud`,className:`text-accent`,children:`switch to cloud`}),`.`]})]})}function Yy({onMade:e,onCancel:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);return(0,z.jsx)(Xy,{label:`name`,inputLabel:`bundle name`,placeholder:`e.g. customer-support`,value:n,onChange:r,submit:`create bundle`,busy:i,error:o,onSubmit:async()=>{let t=n.trim();if(!t||i)return;a(!0),s(``);let r=await A.request(`knowledge.create`,{body:{name:t}});if(a(!1),!r.ok)return s(P(r));e(t)},onCancel:t,hint:`A folder of pages agents read and keep up to date.`})}function Xy(e){return(0,z.jsx)(`form`,{onSubmit:t=>{t.preventDefault(),e.onSubmit()},children:(0,z.jsxs)(Ct,{children:[(0,z.jsx)(Q,{label:e.label,hint:e.hint,children:(0,z.jsx)(Z,{autoFocus:!0,value:e.value,"aria-label":e.inputLabel,placeholder:e.placeholder,disabled:e.busy,onChange:t=>e.onChange(t.target.value)})}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(K,{variant:`primary`,type:`submit`,icon:`add`,busy:e.busy,disabled:!e.value.trim()||e.busy,children:e.submit}),(0,z.jsx)(K,{variant:`quiet`,onClick:e.onCancel,children:`cancel`}),e.error&&(0,z.jsx)(`span`,{className:`text-sm text-bad`,children:e.error})]})]})})}var Zy=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,Qy=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function $y(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 eb(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 tb(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function nb(){let e=F(`runs.list`,{}),t=F(`chats.list`,{}),n=F(`knowledge.list`,{}),r=F(`agents.list`,{}),i=F(`workflows.list`,{}),a=F(`skills.list`,{}),[o,s]=(0,v.useState)(`all`),c=F(`projects.list`,{},{interval:3e4}),l=e=>c?.projects.find(t=>t.slug===e)?.title??e,u=e?.runs??[],d=t?.chats??[],f=n?.bundles??[],p=(a?.skills??[]).filter(e=>e.source===`workspace`),m=[[i?.workflows.length,`workflows`,`/workflows`],[e?u.length:void 0,`runs`,`/runs`],[n?f.length:void 0,`bundles`,`/knowledge`],[a?p.length:void 0,`skills`,`/skills`],[t?d.length:void 0,`chats`,`/agents/chats`]],h=u.filter(e=>e.status===`failed`&&Date.now()-Date.parse(e.updatedAt)<864e5);return(0,z.jsxs)(`div`,{className:`w-full px-7 pt-6 pb-10 max-[800px]:px-3 max-[800px]:pt-3`,children:[(0,z.jsx)(ub,{runs:u,chats:d,bundles:f,agents:r?.agents??[],workflows:i?.workflows??[],projectTitle:l,loaded:!!e&&!!t}),(0,z.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:m.map(([e,t,n])=>(0,z.jsxs)(U,{href:n,className:`group/mini text-inherit no-underline hover:text-accent hover:underline`,children:[(0,z.jsx)(`b`,{className:`font-semibold tabular-nums text-fg group-hover/mini:text-accent`,children:e??`…`}),` `,t]},t))}),h.length>0&&o!==`failed`&&(0,z.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:[`⚠ `,h.length,` run`,h.length===1?``:`s`,` failed in the last 24 h — review`]}),(0,z.jsx)(ab,{projectTitle:l,runs:u,chats:d,bundles:f,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function rb(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 ib=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function ab({projectTitle:e,runs:t,chats:n,bundles:r,agents:i,workflows:a,filter:o,setFilter:s}){let c=(0,v.useMemo)(()=>{let s=[],c=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:c(e.workflow)??e.id,sub:e.request??``,href:`/runs/${e.id}`,lamp:Zy(e.status),status:Qy(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`:eb(t,i,e),href:$y(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,o]),l=``,u=(e,t)=>I(`inline-flex cursor-pointer items-center gap-0.5 rounded-lg border px-2.5 py-0.5 text-2xs transition-colors`,e?I(`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,z.jsx)(X,{className:`animate-rise`,title:`all activity`,actions:(0,z.jsxs)(`span`,{className:`flex flex-wrap gap-1.5`,children:[ib.map(([e,t])=>(0,z.jsx)(`button`,{type:`button`,className:u(o===e),"aria-pressed":o===e,onClick:()=>s(e),children:t},e)),o===`failed`&&(0,z.jsxs)(`button`,{type:`button`,className:u(!0,!0),onClick:()=>s(`all`),children:[`failed `,(0,z.jsx)(B,{name:`close`,className:`ms-sm`})]})]}),children:c.length===0?(0,z.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,z.jsx)(`div`,{className:`flex flex-col p-1.5`,children:c.map(e=>{let t=rb(e),n=t===l?null:t;return l=t,(0,z.jsxs)(`div`,{children:[n&&(0,z.jsx)(it,{className:`block px-2.5 pt-3 pb-1`,children:n}),(0,z.jsx)(gt,{href:e.href,leading:(0,z.jsxs)(`span`,{className:`relative text-[18px] leading-none`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),e.lamp===`running`&&(0,z.jsx)(`span`,{className:`absolute -right-1 -bottom-1 grid rounded-full bg-surface p-px`,children:(0,z.jsx)(et,{tone:`working`})})]}),title:tb(e.title),titleExtra:(0,z.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,z.jsx)(J,{tone:ob[e.kind],children:e.kind===`session`?`chat`:e.kind})}),sub:e.sub&&tb(e.sub),meta:(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.status&&(0,z.jsx)(J,{tone:sb[e.lamp]??`neutral`,children:e.status}),(0,z.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:G(e.at)}),(0,z.jsx)(B,{name:`chevron_right`,className:`ms-sm max-[800px]:hidden`})]})})]},`${e.kind}:${e.href}:${e.at}`)})})})}var ob={run:`accent`,session:`ask`,knowledge:`ok`},sb={ok:`ok`,failed:`bad`,blocked:`bad`,running:`accent`,aborted:`neutral`};function cb(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 lb=e=>new Date(e).toDateString()===new Date().toDateString();function ub({runs:e,chats:t,bundles:n,agents:r,workflows:i,projectTitle:a,loaded:o}){let s=rs()??[],c=ne(),l=F(`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:eb(e,r,a),title:tb(e.title||`new chat`),meta:`working${d.get(e.id)?` · ${cb(d.get(e.id))}`:``}`,href:$y(e),tone:`working`})),...e.filter(e=>e.status===`running`).map(e=>({key:`r:${e.id}`,owner:`⚙️ ${u(e.workflow)}`,title:tb(e.request??``),meta:`running`,href:`/runs/${e.id}`,tone:`working`}))],p=[...t.filter(e=>!e.busy&&!e.awaitingApproval&&lb(e.updatedAt)&&e.title).map(e=>({key:`c:${e.id}`,at:e.updatedAt,owner:eb(e,r,a),title:tb(e.title),meta:G(e.updatedAt),href:$y(e)})),...e.filter(e=>e.status!==`running`&&lb(e.updatedAt)).map(e=>({key:`r:${e.id}`,at:e.updatedAt,owner:`⚙️ ${u(e.workflow)}`,title:tb(e.request??``),meta:`${e.status===`ok`?`done`:e.status===`aborted`?`stopped`:`failed`} · ${G(e.updatedAt)}`,href:`/runs/${e.id}`})),...n.filter(e=>e.updatedAt&&lb(e.updatedAt)).map(e=>({key:`k:${e.name}`,at:e.updatedAt,owner:`📚 ${e.name}`,title:`knowledge updated`,meta:G(e.updatedAt),href:`/knowledge/${encodeURIComponent(e.name)}`}))].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,12),m=us(s,c),h=o&&s.length===0&&f.length===0;return(0,z.jsxs)(`div`,{className:`today flex flex-col gap-3.5`,children:[(0,z.jsxs)(X,{className:`today-section`,title:`needs you`,count:s.length,actions:m&&(0,z.jsxs)(K,{variant:`primary`,size:`sm`,onClick:()=>ds(m),className:`bg-bad text-on-bad hover:bg-bad`,children:[`start `,(0,z.jsx)(B,{name:`arrow_forward`,className:`ms-sm`})]}),children:[s.length===0?(0,z.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,z.jsx)(`div`,{className:`p-1.5`,children:s.map(e=>(0,z.jsx)(gt,{className:`today-row waiting`,onClick:()=>ds(e),over:ss(e.owner),title:e.title,meta:(0,z.jsxs)(`span`,{className:`font-semibold text-bad`,children:[os(e.kind),` · `,G(e.since)]})},e.id))}),h&&(0,z.jsx)(`div`,{className:`px-[18px] pb-4`,children:(0,z.jsx)(K,{variant:`primary`,icon:`chat`,href:`/agents/chats`,children:`chat with Ralv`})})]}),f.length>0&&(0,z.jsx)(X,{className:`today-section`,title:`in progress`,children:(0,z.jsx)(`div`,{className:`p-1.5`,children:f.map(e=>(0,z.jsx)(db,{r:e},e.key))})}),(0,z.jsx)(X,{className:`today-section`,title:`done today`,children:p.length===0?(0,z.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:`Nothing finished yet today.`}):(0,z.jsx)(`div`,{className:`p-1.5`,children:p.map(e=>(0,z.jsx)(db,{r:e},e.key))})})]})}function db({r:e}){return(0,z.jsx)(gt,{className:`today-row`,href:e.href,over:e.owner,title:e.title,meta:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e.tone===`working`&&(0,z.jsx)(et,{tone:`working`}),e.meta]})})}var fb=e=>e.agent?`${e.agent.emoji?`${e.agent.emoji} `:``}${e.agent.name}`:e.project?`🧭 Assistant`:`🎩 Ralv`,pb=e=>e.enabled?e.nextRunAt?`next ${Ke(e.nextRunAt)}`:e.runner===`unassigned`?`no runner`:e.runner===`elsewhere`?`runs on ${e.runsOn}`:e.schedule:`paused`,mb=(e,t)=>e.project?`/projects/${encodeURIComponent(e.project)}/chat/${t}`:e.agent?`/agents/${encodeURIComponent(e.agent.slug)}/chat/${t}`:`/agents/chats/${t}`,hb={name:``,schedule:`0 9 * * 1-5`,prompt:``,enabled:!0,project:``,agent:``,private:!1},gb=e=>({id:e.id,name:e.name,schedule:e.schedule,prompt:e.prompt,enabled:e.enabled,project:e.project??``,agent:e.agent?.slug??``,runsOn:e.runsOn??``,private:e.private??!1});function _b({r:e,error:t}){return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-2`,children:[(0,z.jsx)(`code`,{children:e.schedule}),(0,z.jsxs)(`span`,{children:[`· `,pb(e)]}),e.runner===`here`?(0,z.jsx)(J,{title:`runs_on: ${e.runsOn} — this machine fires it`,children:`runs here`}):e.runner===`unassigned`?(0,z.jsx)(J,{tone:e.enabled?`ask`:`neutral`,title:`no runs_on — it fires on no machine until one adopts it`,children:`no runner`}):(0,z.jsxs)(J,{tone:e.retired?`ask`:`neutral`,title:e.retired?`a retired identity of this machine — it fires nowhere until reassigned`:`another machine fires it, not this one`,children:[`runs on `,e.runsOn]}),e.lastChatId?(0,z.jsxs)(U,{href:mb(e,e.lastChatId),children:[`last run `,Ke(e.lastRunAt)]}):(0,z.jsx)(`span`,{children:`never ran`}),e.awaitingApproval&&e.lastChatId&&(0,z.jsx)(J,{href:mb(e,e.lastChatId),tone:`bad`,title:`the last run asked for a permission nobody has answered yet`,children:`needs approval`}),(t||e.lastError)&&(0,z.jsx)(`span`,{title:t||e.lastError,children:(0,z.jsx)(J,{tone:`bad`,children:`error`})})]})}function vb({owner:e,id:t,onOpen:n}){let r=De(),i=F(`routines.list`,{},{interval:3e4}),a=F(`agents.list`,{},{interval:6e4}),o=F(`projects.list`,r.projects?{}:null,{interval:6e4}),s=F(`identity.get`,{},{interval:6e4}),c=e===`_`&&t===`new`,l=c?void 0:i?.routines.find(n=>n.owner===e&&n.id===t),[u,d]=(0,v.useState)(c?hb:null),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(null),C=Yt();if((0,v.useEffect)(()=>{d(c?hb:l?gb(l):null),h(``),_(``)},[e,t,!!l]),!c&&!l)return(0,z.jsx)(Y,{className:`my-auto`,children:i?`That routine is gone.`:`loading…`});async function w(e,t){p(e),h(``),_(``);try{await t()}catch(e){h(e.message)}finally{p(``)}}let T=()=>w(`run`,async()=>{let n=e===`_`?await A.request(`routines.run`,{id:t}):await A.request(`agents.runRoutine`,{slug:e,id:t});if(!n.ok)throw Error(P(n));l&&n.data.chatId&&H(mb(l,n.data.chatId))});if(!u)return(0,z.jsx)(Y,{className:`my-auto`,children:`loading…`});let E=e=>d({...u,...e}),D=e!==`_`,O=(a?.agents??[]).filter(e=>!e.archived||e.slug===u.agent),k=()=>w(`save`,async()=>{let{runsOn:t,project:r,agent:i,...a}=u,o=t===void 0?{}:{runsOn:t.trim()||null},s=D?await A.request(`agents.saveRoutine`,{slug:e,body:{...a,...o}}):await A.request(`routines.save`,{body:{...a,project:r||null,agent:i||null,...o}});if(!s.ok)throw Error(P(s));_(`saved`),c&&n(`routines:_:${s.data.id}`)}),ee=()=>w(`adopt`,async()=>{let n=D?await A.request(`agents.adoptRoutine`,{slug:e,id:t}):await A.request(`routines.adoptOne`,{id:t});if(!n.ok)throw Error(P(n));let r=n.data.commit;if(r&&!r.ok)throw Error(`runs on ${n.data.runsOn} — routines.yml written, but not committed: ${r.error??`git failed`}`);_(`runs on ${n.data.runsOn} now${r?` — committed`:``}`),E({runsOn:n.data.runsOn}),ns()}),j=()=>{window.confirm(`Delete the routine "${u.name}"?`)&&w(`delete`,async()=>{let r=D?await A.request(`agents.deleteRoutine`,{slug:e,id:t}):await A.request(`routines.delete`,{id:t});if(!r.ok)throw Error(P(r));n(void 0)})},M=()=>w(`chat`,async()=>{if(!l||!x?.trim())return;let t=await Kt({who:D?e:void 0,project:l.project??void 0,text:yb(l,x.trim())});if(`error`in t)throw Error(t.error);S(null),C(t.href)}),N=xb(u.schedule),I=y?{...N,kind:`custom`}:N,te=e=>{if(e.kind===`custom`)return b(!0);e.kind&&b(!1),E({schedule:Sb({...N,...e,kind:e.kind??(N.kind===`custom`?`weekdays`:N.kind)})})},R=`h-8 w-auto max-w-[220px] rounded-full border-0 bg-transparent text-sm font-medium hover:bg-surface-2`;return(0,z.jsxs)(`div`,{className:`routine-form flex flex-col gap-3 p-3`,children:[(0,z.jsx)(`input`,{value:u.name,"aria-label":`name`,placeholder:`Name the routine, e.g. Morning report`,className:`w-full border-0 bg-transparent p-0 font-[inherit] text-xl font-semibold text-fg shadow-none outline-none placeholder:font-normal placeholder:text-fg-2 focus:shadow-none focus:outline-none`,onChange:e=>E({name:e.target.value})}),l&&(0,z.jsx)(_b,{r:l}),(0,z.jsx)(Rt,{label:`what the routine asks`,chip:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`schedule`,className:`ms-sm`}),` `,Cb(u.schedule)]}),chipTitle:`cron: ${u.schedule}`,value:u.prompt,onChange:e=>E({prompt:e}),inputLabel:`prompt — what to ask on each run`,placeholder:`What to ask on each run, e.g. Check … and summarize what changed.`,onSend:()=>void k(),sendLabel:c?`add the routine`:`save`,sendIcon:`check`,busy:f===`save`,disabled:!u.name.trim()||!u.prompt.trim()||!!f,skills:!0,who:u.agent,hint:g||(u.agent?`in a new session each time`:u.project?`asks the project's assistant`:`asks Ralv`),controls:D?(0,z.jsx)(U,{href:`/agents/${encodeURIComponent(e)}/info`,className:`inline-flex h-8 items-center px-2 text-sm font-medium text-fg no-underline hover:text-accent`,title:`an agent's own routine always asks its agent — it lives on the agent's profile`,children:l?.agent?fb(l):e}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(St,{"aria-label":`who`,value:u.agent,onChange:e=>E({agent:e.target.value}),className:R,children:[(0,z.jsx)(`option`,{value:``,children:u.project?`🧭 the project's assistant`:`🎩 Ralv`}),O.map(e=>(0,z.jsxs)(`option`,{value:e.slug,children:[e.emoji,` `,e.name]},e.slug))]}),r.projects&&(0,z.jsxs)(St,{"aria-label":`runs in`,value:u.project,onChange:e=>E({project:e.target.value}),className:R,title:u.project?`its runs are filed under the project`:`not tied to a project`,children:[(0,z.jsx)(`option`,{value:``,children:`the whole workspace`}),(o?.projects??[]).map(e=>(0,z.jsxs)(`option`,{value:e.slug,children:[`📁 `,e.title]},e.slug)),u.project&&!o?.projects.some(e=>e.slug===u.project)&&(0,z.jsxs)(`option`,{value:u.project,children:[`📁 `,u.project]})]})]}),children:(0,z.jsxs)(`div`,{className:`routine-when flex flex-wrap items-center gap-x-1 gap-y-1 border-t border-line px-2.5 py-1.5 text-sm text-fg-2`,children:[(0,z.jsxs)(St,{"aria-label":`repeats`,value:I.kind,onChange:e=>te({kind:e.target.value}),className:R,children:[(0,z.jsx)(`option`,{value:`weekdays`,children:`every weekday`}),(0,z.jsx)(`option`,{value:`daily`,children:`every day`}),(0,z.jsx)(`option`,{value:`weekly`,children:`every week`}),(0,z.jsx)(`option`,{value:`hourly`,children:`every hour`}),(0,z.jsx)(`option`,{value:`custom`,children:`custom (cron)`})]}),I.kind===`weekly`&&(0,z.jsx)(St,{"aria-label":`weekday`,value:I.day,onChange:e=>te({day:e.target.value}),className:R,children:bb.map((e,t)=>(0,z.jsxs)(`option`,{value:String(t),children:[`on `,e]},e))}),(I.kind===`weekdays`||I.kind===`daily`||I.kind===`weekly`)&&(0,z.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 px-1`,children:[`at`,(0,z.jsx)(`input`,{type:`time`,"aria-label":`time`,value:I.time,className:`h-8 rounded-control border border-line bg-surface px-2 font-[inherit] text-sm text-fg`,onChange:e=>e.target.value&&te({time:e.target.value})})]}),I.kind===`hourly`&&(0,z.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 px-1`,children:[`at minute`,(0,z.jsx)(`input`,{type:`number`,min:0,max:59,"aria-label":`minute`,value:I.minute,className:`h-8 w-16 rounded-control border border-line bg-surface px-2 font-[inherit] text-sm text-fg`,onChange:e=>te({minute:String(Math.min(59,Math.max(0,Number(e.target.value)||0)))})})]}),I.kind===`custom`&&(0,z.jsx)(Z,{className:`h-8 w-[180px] font-mono text-sm`,"aria-label":`schedule (cron)`,value:u.schedule,placeholder:`0 9 * * 1-5`,title:`minute hour day month weekday, this machine's time`,onChange:e=>E({schedule:e.target.value})}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5 px-1 text-fg`,title:`a paused routine keeps its schedule and fires nowhere`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:u.enabled,onChange:e=>E({enabled:e.target.checked})}),`enabled`]}),(0,z.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5 px-1 text-fg`,title:`its runs stay off what remote members and paired devices see`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:u.private,onChange:e=>E({private:e.target.checked})}),`private`]})]})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5 text-xs text-fg-2`,children:[(0,z.jsxs)(`label`,{className:`inline-flex min-w-0 items-center gap-1.5`,title:`the one machine that fires it${s?` — this machine is ${s.identity}`:``}; empty: no runner, it fires nowhere`,children:[`runs on`,(0,z.jsx)(Z,{className:`h-7 w-[200px] font-mono text-xs`,"aria-label":`runs on`,value:u.runsOn??s?.identity??``,placeholder:`<handle>@<machine>`,onChange:e=>E({runsOn:e.target.value})})]}),(0,z.jsx)(`span`,{className:`flex-1`}),l&&(0,z.jsxs)(z.Fragment,{children:[l.runner!==`here`&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,busy:f===`adopt`,disabled:!!f,onClick:()=>void ee(),title:`make ${s?.identity??`this machine`} its runner and commit routines.yml`,children:`run here`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`forum`,disabled:!!f,onClick:()=>S(x===null?``:null),title:`describe the change; ${D?fb(l):`an assistant`} makes it in a new chat`,children:`change in a chat`}),(0,z.jsx)(K,{size:`sm`,icon:`play_arrow`,busy:f===`run`,disabled:!!f,onClick:()=>void T(),title:`start a run with the saved prompt, now`,children:f===`run`?`starting…`:`run now`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`delete`,disabled:!!f,onClick:j,children:`delete`})]})]}),l&&x!==null&&(0,z.jsxs)(`div`,{className:`routine-chat flex flex-col gap-2 rounded-card border border-line bg-surface p-2.5`,children:[(0,z.jsx)(xt,{autoFocus:!0,rows:2,"aria-label":`what should change`,placeholder:`What should change? ${D?fb(l):`The assistant`} updates the routine in a new chat, e.g. "run it at 7:00 and add Avia to the providers"`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&M(),e.key===`Escape`&&S(null)},className:`text-sm`}),(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>S(null),children:`cancel`}),(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`send`,busy:f===`chat`,disabled:!x.trim()||!!f,onClick:()=>void M(),children:`open the chat`})]})]}),m&&(0,z.jsx)(rt,{tone:`bad`,children:m})]})}function yb(e,t){let n=e.owner!==`_`;return[`Change the routine "${e.name}" (id \`${e.id}\`, ${n?`${e.agent?.name??e.owner}'s own routine`:`a workspace routine`}): ${t}`,``,`As it is now: schedule \`${e.schedule}\` (${Cb(e.schedule)}), ${e.enabled?`enabled`:`paused`}${e.project?`, runs in project ${e.project}`:``}${n?``:`, asks ${fb(e)}`}. Its prompt:`,``,e.prompt.split(`
476
476
  `).map(e=>`> ${e}`).join(`
477
477
  `),``,`Update it in place with \`npx kraftwerk routines add ${e.owner} --id ${e.id} --name "…" --schedule "…" --prompt "…"\` — the same id updates it (name, schedule and the whole prompt as they should be; project, agent and runner stay unless you pass them${e.enabled?``:`; --disabled keeps it paused`}); \`npx kraftwerk routines list ${e.owner}\` shows the result. If the request is unclear, ask me first. Then say in one or two sentences what changed.`].join(`
478
- `)}var _b=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function vb(e){let t={kind:`custom`,time:`09:00`,day:`1`,minute:`0`},n=e.trim().split(/\s+/);if(n.length!==5)return t;let[r,i,a,o,s]=n,c=(e,t)=>/^\d{1,2}$/.test(e)&&Number(e)<=t;if(a!==`*`||o!==`*`||!c(r,59))return t;if(i===`*`&&s===`*`)return{...t,kind:`hourly`,minute:String(Number(r))};if(!c(i,23))return t;let l=`${i.padStart(2,`0`)}:${r.padStart(2,`0`)}`;return s===`1-5`?{...t,kind:`weekdays`,time:l}:s===`*`?{...t,kind:`daily`,time:l}:/^[0-7]$/.test(s)?{...t,kind:`weekly`,time:l,day:String(Number(s)%7)}:t}function yb(e){let[t,n]=e.time.split(`:`).map(e=>String(Number(e)||0));return e.kind===`hourly`?`${Number(e.minute)||0} * * * *`:e.kind===`daily`?`${n} ${t} * * *`:e.kind===`weekly`?`${n} ${t} * * ${e.day}`:`${n} ${t} * * 1-5`}function bb(e){let t=vb(e);return t.kind===`weekdays`?`weekdays ${t.time}`:t.kind===`daily`?`daily ${t.time}`:t.kind===`weekly`?`${_b[Number(t.day)]}s ${t.time}`:t.kind===`hourly`?`hourly at :${t.minute.padStart(2,`0`)}`:e.trim()||`no schedule`}var xb=[{id:`create`,label:`Create`},{id:`results`,label:`Results`},{id:`context`,label:`Context`}],Sb=new Set,Cb={workflows:`describe a workflow and Ralv makes it`,skills:`describe a skill and Ralv makes it`,runs:`run a workflow`,tasks:`add a task to a board`},wb=[{id:`chats`,group:`create`,label:`Chats`,one:`Chat`,icon:`chat`,hue:`#4f46e5`,newHref:`/agents/chats`,newTitle:`new chat`},{id:`workflows`,group:`create`,label:`Workflows`,one:`Workflow`,icon:`account_tree`,hue:`#0e7490`,newHref:`/agents/chats`,newTitle:`ask Ralv to make a workflow`},{id:`skills`,group:`create`,label:`Skills`,one:`Skill`,icon:`extension`,hue:`#9333ea`,newHref:`/agents/chats`,newTitle:`ask Ralv to make a skill`},{id:`routines`,group:`create`,label:`Routines`,one:`Routine`,icon:`schedule`,hue:`#b45309`,newHref:`/?kind=routines&open=routines%3A_%3Anew`},{id:`boards`,group:`create`,label:`Boards`,one:`Board`,icon:`view_kanban`,hue:`#15803d`,newHref:`/boards/new`},{id:`runs`,group:`results`,label:`Workflow runs`,one:`Workflow run`,icon:`play_circle`,hue:`#0f766e`,newHref:`/?kind=workflows`,newTitle:`pick a workflow to run`},{id:`tasks`,group:`results`,label:`Tasks`,one:`Task`,icon:`task_alt`,hue:`#166534`,newHref:`/?kind=boards`,newTitle:`pick a board to add a task`},{id:`presentations`,group:`results`,label:`Presentations`,one:`Slides`,icon:`slideshow`,hue:`#c2410c`,newHref:`/presentations/new`},{id:`vibeables`,group:`results`,label:`Apps`,one:`App`,icon:`web`,hue:`#2563eb`,newHref:`/vibeables`},{id:`knowledge`,group:`context`,label:`Knowledge`,one:`Knowledge bundle`,icon:`menu_book`,hue:`#4d7c0f`,newHref:`/knowledge/new`},{id:`repos`,group:`context`,label:`Repos`,one:`Repository`,icon:`source`,hue:`#475569`,newHref:`/repos`,newTitle:`clone a repository`},{id:`contacts`,group:`context`,label:`Contacts`,one:`Contact`,icon:`person`,hue:`#7c3aed`,newHref:`/contacts/new`},{id:`places`,group:`context`,label:`Places`,one:`Place`,icon:`location_on`,hue:`#be123c`,newHref:`/places/new`},{id:`events`,group:`context`,label:`Events`,one:`Event`,icon:`event`,hue:`#a16207`,newHref:`/events/new`}],Tb=encodeURIComponent,Eb=(e,t)=>t===`chats`||t===`workflows`||t===`runs`||t===`routines`||t===`knowledge`||t===`skills`||!!e[t===`tasks`?`boards`:t],Db=e=>wb.find(t=>t.id===e);function Ob(){let[e,t]=ne().split(`?`),n=e.split(`/`).filter(Boolean),r=n[0]===`projects`&&n.length===2&&n[1]!==`new`?decodeURIComponent(n[1]):void 0,i=r?`/projects/${Tb(r)}`:`/`,a=new URLSearchParams(t??``),o=a.get(`kind`);return{kind:wb.some(e=>e.id===o)?o:`all`,open:a.get(`open`)??void 0,project:r,href:({kind:e,open:t})=>{let n=new URLSearchParams;e&&e!==`all`&&n.set(`kind`,e),t&&n.set(`open`,t);let r=n.toString();return r?`${i}?${r}`:i}}}var kb=new Set([`chats`,`routines`,`boards`,`tasks`,`presentations`,`runs`,`workflows`,`knowledge`,`vibeables`,`repos`,`contacts`,`places`,`events`]),Ab={knowledge:`knowledge`,vibeables:`vibeables`,repos:`repos`,workflows:`workflows`,contacts:`contacts`,places:`places`,events:`events`};function jb(e){let t=De(),n=F(`chats.list`,{}),r=F(`agents.list`,{},{interval:3e4})?.agents??[],i=F(`workflows.list`,{},{interval:3e4}),a=F(`runs.list`,{},{fast:!0}),o=F(`knowledge.list`,{},{interval:3e4}),s=F(`routines.list`,{},{interval:3e4}),c=F(`skills.list`,{},{interval:3e4}),l=F(`repos.list`,t.repos?{}:null,{interval:3e4}),u=F(`vibeables.list`,t.vibeables?{}:null,{interval:3e4}),d=F(`presentations.list`,t.presentations?{query:{all:`1`}}:null,{interval:3e4}),f=F(`boards.list`,t.boards?{query:{all:`1`}}:null,{interval:3e4}),p=F(`tasks.list`,t.boards?{}:null,{interval:3e4}),m=F(`contacts.list`,t.contacts?{}:null,{interval:3e4}),h=F(`places.list`,t.places?{}:null,{interval:3e4}),g=F(`events.list`,t.events?{}:null,{interval:3e4}),_=F(`projects.list`,t.projects?{}:null,{interval:6e4}),v=e=>e?_?.projects.find(t=>t.slug===e)?.title??e:void 0,y=[...(n?.chats??[]).map(e=>({key:`chats:${e.id}`,kind:`chats`,title:e.title||`New chat`,href:Xy(e),project:e.scope.kind===`project`?e.scope.slug:e.project,updatedAt:e.updatedAt,live:e.awaitingApproval?`waiting`:e.busy?`working`:void 0,when:e.awaitingApproval?`needs approval`:e.busy?`working`:void 0,sub:e.scope.kind===`project`?`assistant`:Zy({...e,project:void 0},r,e=>e)})),...(i?.workflows??[]).map(e=>({key:`workflows:${e.slug}`,kind:`workflows`,title:e.name||e.slug,href:`/workflows/${Tb(e.slug)}`,updatedAt:e.updatedAt,broken:!!e.error})),...(a?.runs??[]).map(e=>{let t=!!e.awaitingDecision&&e.status!==`ok`&&e.status!==`aborted`,n=e.status===`running`;return{key:`runs:${e.id}`,kind:`runs`,title:e.workflow??`unknown workflow`,href:`/runs/${Tb(e.id)}`,updatedAt:e.updatedAt,live:t?`waiting`:n?`working`:void 0,since:n&&!t?e.startedAt:void 0,when:t?`decision needed`:n?e.currentPhase??`running`:e.status===`ok`?`Ran ${G(e.updatedAt)}`:`${e.status===`aborted`?`Stopped`:`Failed`} ${G(e.updatedAt)}`,broken:e.status===`failed`,sub:e.request||void 0}}),...(o?.bundles??[]).map(e=>({key:`knowledge:${e.name}`,kind:`knowledge`,title:e.name,href:`/knowledge/${Tb(e.name)}`,updatedAt:e.updatedAt,sub:`${e.concepts} concept${e.concepts===1?``:`s`}`})),...(s?.routines??[]).map(e=>({key:`routines:${e.owner}:${e.id}`,kind:`routines`,title:e.name,...e.owner===`_`?{}:{href:`/agents/${Tb(e.owner)}/info`},project:e.project,updatedAt:e.lastRunAt,when:ub(e),broken:!!e.lastError,sub:lb(e)})),...(c?.skills??[]).filter(e=>e.source===`workspace`||e.source===`project`).map(e=>({key:`skills:${e.name}`,kind:`skills`,title:`/${e.name}`,href:`/skills/${Tb(e.name)}`,updatedAt:e.updatedAt,sub:e.description||void 0})),...(l?.repos??[]).map(e=>({key:`repos:${e.slug}`,kind:`repos`,title:e.slug,href:`/repos/${Tb(e.slug)}`,updatedAt:e.updatedAt??e.committedAt,broken:!!e.error,sub:[e.branch,e.dirty?`${e.dirty} changed`:e.ahead?`${e.ahead} to push`:e.behind?`${e.behind} behind`:e.error?``:`clean`].filter(Boolean).join(` · `)})),...(u?.vibeables??[]).map(e=>({key:`vibeables:${e.slug}`,kind:`vibeables`,title:e.slug,href:`/vibeables/${Tb(e.slug)}`,updatedAt:e.updatedAt,broken:!!e.configError})),...(d?.presentations??[]).map(e=>({key:`presentations:${e.project??``}:${e.name}`,kind:`presentations`,title:e.title,href:e.project?`/projects/${Tb(e.project)}/presentations/${Tb(e.name)}`:`/presentations/${Tb(e.name)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.error})),...(f?.boards??[]).map(e=>({key:`boards:${e.project??``}:${e.board}`,kind:`boards`,title:e.title,href:e.project?`/projects/${Tb(e.project)}/boards/${Tb(e.board)}`:`/boards/${Tb(e.board)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.configError})),...(p?.tasks??[]).map(e=>({key:`tasks:${e.project??``}:${e.board}:${e.slug}`,kind:`tasks`,title:e.title,href:`${Us({project:e.project,board:e.board})}/${Tb(e.slug)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.configError,sub:[`#${e.number}`,e.boardTitle,e.column].filter(Boolean).join(` · `)})),...[[`contacts`,m],[`places`,h],[`events`,g]].flatMap(([e,t])=>(t?.items??[]).map(t=>{let n=t;return{key:`${e}:${t.slug}`,kind:e,title:t.title||t.slug,href:`/${e}/${Tb(t.slug)}`,updatedAt:t.updatedAt,broken:!!t.configError,lat:n.lat,lng:n.lng,start:n.start,end:n.end}}))].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``)),b=F(`projects.get`,e?{slug:e}:null,{interval:3e4})?.links,x=(e,t)=>{let n=Ab[e];return!!n&&!!b?.[n]?.some(e=>e.slug===t)};return e?{items:y.filter(t=>{if(t.project===e)return!0;if(t.project)return!1;let n=t.key.slice(t.kind.length+1);return t.kind===`runs`?!!b?.workflows.some(e=>t.title===e.slug||n.endsWith(`-${e.slug}`)):x(t.kind,n)}),loading:!n&&!p&&!d&&!f&&!b,projectTitle:()=>void 0}:{items:y,loading:!n&&!i&&!a&&!s&&!o&&!c&&!l&&!u&&!d&&!f&&!m&&!h&&!g,projectTitle:v}}function Mb({title:e=`Home`}){let t=De(),{kind:n,open:r,project:i,href:a}=Ob(),o=wb.filter(e=>Eb(t,e.id)&&(!i||kb.has(e.id))),s=i?`/projects/${Tb(i)}`:``,c=e=>i?e.id===`chats`?`${s}/chat/new`:e.id===`boards`||e.id===`presentations`?`${s}/${e.id}/new`:e.id===`routines`?a({kind:`routines`,open:`routines:_:new`}):e.id===`runs`?a({kind:`workflows`}):e.id===`tasks`?a({kind:`boards`}):e.newHref:e.newHref,l=e=>H(a({kind:e,open:e===`all`||r?.startsWith(`${e}:`)?r:void 0}),{replace:!0}),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),g=e=>{let t=Gt(e),r=/^\/runs\/([^/?]+)$/.exec(e)?.[1];return!t&&!r?!1:(H(a({kind:n,open:t?`chats:${t}`:`runs:${decodeURIComponent(r)}`})),!0)},{items:_,loading:y,projectTitle:b}=jb(i),x=u.trim().toLowerCase(),S=_.filter(e=>(n===`all`||e.kind===n)&&(!x||`${e.title} ${b(e.project)??``}`.toLowerCase().includes(x))),C=o.length>0&&y,w=e=>e.live===`waiting`?0:e.live===`working`?1:2,T=[...S].sort((e,t)=>w(e)-w(t)),E=T.filter(e=>e.live).length;return(0,z.jsxs)(`div`,{className:`artifacts-screen mx-auto flex w-full max-w-[920px] flex-col gap-6 px-6 pt-8 pb-12 max-[800px]:px-4`,children:[(0,z.jsx)(`h1`,{className:`m-0 text-3xl font-semibold tracking-[-0.02em] text-fg`,children:e}),m&&(0,z.jsx)(Jt.Provider,{value:g,children:(0,z.jsx)(By,{kind:m,project:i,onClose:()=>h(null),onMade:e=>(Sb.add(e),H(a({kind:n,open:e})))})}),o.length>0&&(0,z.jsx)(`section`,{className:`flex flex-col gap-4`,"aria-label":`kinds`,children:xb.filter(e=>o.some(t=>t.group===e.id)).map(e=>(0,z.jsxs)(`div`,{role:`group`,"aria-label":e.label,className:`flex flex-col gap-2`,children:[(0,z.jsx)(it,{children:e.label}),(0,z.jsx)(`div`,{className:`grid grid-cols-6 gap-3 max-[900px]:grid-cols-4 max-[600px]:grid-cols-3`,children:o.filter(t=>t.group===e.id).map(e=>{let t=n===e.id;return(0,z.jsxs)(`div`,{className:`relative flex flex-col gap-1.5 text-fg`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-pressed":t,"aria-label":`show only ${e.label.toLowerCase()}`,title:t?`show everything`:`show only ${e.label.toLowerCase()}`,className:I(`grid h-[60px] cursor-pointer place-items-center rounded-2xl outline-offset-2 transition-[filter,box-shadow] hover:brightness-95`,t&&`shadow-[0_0_0_2px_currentColor]`,n!==`all`&&!t&&`opacity-55`),style:{background:`color-mix(in srgb, ${e.hue} 20%, var(--color-surface))`,color:e.hue},onClick:()=>l(t?`all`:e.id),children:(0,z.jsx)(B,{name:e.icon,className:`text-[28px]`})}),Ly.has(e.id)?(0,z.jsx)(`button`,{type:`button`,"aria-label":`new ${e.one.toLowerCase()}`,title:Cb[e.id]??`new ${e.one.toLowerCase()}`,className:`absolute top-1 right-1 grid size-6 cursor-pointer place-items-center rounded-full border-0 bg-transparent p-0 opacity-70 hover:bg-surface hover:opacity-100`,style:{color:e.hue},onClick:()=>h(e.id),children:(0,z.jsx)(B,{name:`add`,className:`ms-sm`})}):(0,z.jsx)(U,{href:c(e),"aria-label":`new ${e.one.toLowerCase()}`,title:e.newTitle??`new ${e.one.toLowerCase()}`,className:`absolute top-1 right-1 grid size-6 place-items-center rounded-full no-underline opacity-70 hover:bg-surface hover:opacity-100`,style:{color:e.hue},children:(0,z.jsx)(B,{name:`add`,className:`ms-sm`})}),(0,z.jsx)(`span`,{className:I(`line-clamp-2 text-center text-xs leading-tight [overflow-wrap:anywhere]`,t&&`font-medium`),children:e.label})]},e.id)})})]},e.id))}),(0,z.jsxs)(`div`,{className:`-mb-3 flex items-center gap-2`,children:[(0,z.jsx)(`h2`,{className:`m-0 flex-1 text-sm font-normal text-fg-2`,children:n===`all`?`Everything`:Db(n).label}),f?(0,z.jsx)(`input`,{autoFocus:!0,type:`search`,"aria-label":`search home`,placeholder:`Search`,value:u,onChange:e=>d(e.target.value),onBlur:()=>!u&&p(!1),className:`w-56 rounded-full border border-line bg-surface px-3 py-1.5 text-sm text-fg outline-none focus:border-accent`}):(0,z.jsx)(`button`,{type:`button`,"aria-label":`search home`,className:`grid size-8 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>p(!0),children:(0,z.jsx)(B,{name:`search`})})]}),(0,z.jsxs)(`section`,{className:`flex flex-col`,"aria-label":`everything`,children:[o.length===0&&(0,z.jsxs)(`p`,{className:`m-0 py-3 text-sm text-fg-2`,children:[`Nothing to list yet: turn on apps, presentations, boards, contacts, places or events in `,(0,z.jsx)(U,{href:`/settings`,className:`text-accent`,children:`settings`}),`.`]}),!C&&o.length>0&&S.length===0&&(0,z.jsx)(`p`,{className:`m-0 py-3 text-sm text-fg-2`,children:x?`Nothing matches “${u.trim()}”.`:`Nothing here yet — make something above.`}),T.map((e,t)=>{let i=Db(e.kind),o=b(e.project),s=E===0?void 0:t===0?`Now`:t===E?`Earlier`:void 0;return(0,z.jsxs)(v.Fragment,{children:[s&&(0,z.jsx)(it,{className:I(`block px-2 pb-1`,t>0&&`pt-4`),children:s}),(0,z.jsxs)(U,{"data-live":e.live,href:a({kind:n,open:e.key}),"data-artifact":e.kind,"data-key":e.key,"aria-current":r===e.key?`true`:void 0,className:`artifact-row flex items-center gap-3 rounded-xl px-2 py-2.5 text-fg no-underline hover:bg-surface-2 aria-[current=true]:bg-surface-2`,children:[(0,z.jsx)(`span`,{className:`grid size-9 flex-none place-items-center rounded-lg`,style:{background:`color-mix(in srgb, ${i.hue} 16%, var(--color-surface))`,color:i.hue},title:i.one,children:(0,z.jsx)(B,{name:i.icon,className:`ms-sm`})}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(`span`,{className:I(`truncate text-[15px]`,e.broken&&`text-on-bad-soft`),children:e.title}),(0,z.jsxs)(`span`,{className:`truncate text-xs text-fg-2`,children:[i.one,e.sub?` · ${e.sub}`:``,o?` · 📁 ${o}`:``,e.broken&&e.kind!==`runs`?e.kind===`routines`?` · last run failed`:` · unreadable`:``]})]}),e.live?(0,z.jsxs)(`span`,{className:I(`flex flex-none items-center gap-1.5 text-sm tabular-nums`,e.live===`waiting`?`text-accent`:`text-fg-2`),children:[(0,z.jsx)(et,{tone:e.live===`waiting`?`ask`:`working`}),e.when,e.since&&(0,z.jsx)(qe,{since:e.since})]}):e.when?(0,z.jsx)(`span`,{className:`flex-none text-sm text-fg-2 tabular-nums`,title:e.kind===`routines`?e.updatedAt?`last run ${e.updatedAt}`:`never ran`:e.updatedAt,children:e.when}):e.updatedAt&&(0,z.jsxs)(`span`,{className:`flex-none text-sm text-fg-2 tabular-nums`,title:e.updatedAt,children:[`Edited `,G(e.updatedAt)]})]})]},e.key)})]})]})}function Nb(){let{kind:e,open:t,project:n,href:r}=Ob(),{items:i,loading:a}=jb(n),o=`routines:_:new`,s=t===o?{key:o,kind:`routines`,title:`New routine`}:t?i.find(e=>e.key===t)??(()=>{if(!t)return;if(t.startsWith(`chats:`))return{key:t,kind:`chats`,title:`New chat`};if(t.startsWith(`runs:`))return{key:t,kind:`runs`,title:`Workflow run`};let e=Sb.has(t)?wb.find(e=>t.startsWith(`${e.id}:`)):void 0;return e?{key:t,kind:e.id,title:`New ${e.one.toLowerCase()}`}:void 0})():void 0,c=t=>{let n=Gt(t),i=/^\/runs\/([^/?]+)$/.exec(t)?.[1];return!n&&!i?!1:(H(r({kind:e,open:n?`chats:${n}`:`runs:${decodeURIComponent(i)}`})),!0)},l=s?Db(s.kind):void 0,[,u=``,d=``,f=``]=(t??``).split(`:`),p=e===`places`||s?.kind===`places`,m=i.filter(e=>e.kind===`places`),h=m.flatMap(e=>e.lat!==void 0&&e.lng!==void 0?[{slug:e.key.slice(7),title:e.title,lat:e.lat,lng:e.lng}]:[]),g=m.length-h.length,_=r({kind:e}),v=e===`events`||s?.kind===`events`,y=i.flatMap(e=>e.kind===`events`&&e.start?[{slug:e.key.slice(7),title:e.title,start:String(e.start),end:e.end?String(e.end):void 0}]:[]),b=s&&l&&(0,z.jsxs)(`div`,{className:`flex flex-none items-center gap-2.5 border-b border-line px-3 py-2.5`,children:[(0,z.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-lg`,style:{background:`color-mix(in srgb, ${l.hue} 16%, var(--color-surface))`,color:l.hue},title:l.one,children:(0,z.jsx)(B,{name:l.icon,className:`ms-sm`})}),(0,z.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 truncate text-base font-semibold text-fg`,title:s.title,children:s.title}),s.href&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`open_in_new`,href:s.href,title:`open the ${l.one.toLowerCase()} where it lives`,children:`open`}),(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`close`,href:_,"aria-label":`close the preview`})]});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`space-title flex min-w-0 items-center gap-2 px-1`}),(0,z.jsx)(`aside`,{className:`ctx artifact-preview`,"aria-label":`Preview`,"data-open":s?.key,children:v?(0,z.jsxs)(z.Fragment,{children:[b,(0,z.jsx)(`div`,{className:I(`flex min-h-0 flex-col p-3`,s?`h-[52%] flex-none`:`flex-1`),children:(0,z.jsx)(xs,{events:y,selected:s?u:void 0,onPick:t=>H(r({kind:e,open:`events:${t}`}))})}),s?(0,z.jsx)(`div`,{className:`ctx-body ctx-embed border-t border-line`,children:(0,z.jsx)(vg,{kind:`events`,slug:u})},s.key):(0,z.jsx)(`p`,{className:`m-0 flex-none px-3 pb-3 text-sm text-fg-2`,children:`Pick an event on the left or in the calendar to see its details.`})]}):p?(0,z.jsxs)(z.Fragment,{children:[b,(0,z.jsxs)(`div`,{className:I(`flex min-h-0 flex-col gap-1.5 p-3`,s?`h-[48%] flex-none`:`flex-1`),children:[(0,z.jsx)(gs,{places:h,selected:s?u:void 0,onPick:t=>H(r({kind:e,open:`places:${t}`}))}),(g>0||s&&s.lat===void 0)&&(0,z.jsx)(`p`,{className:`m-0 text-xs text-fg-2`,children:s&&s.lat===void 0?`This place has no coordinates yet: add latitude and longitude below to put it on the map.`:`${g} of ${m.length} places have no coordinates and are not on the map.`})]}),s?(0,z.jsx)(`div`,{className:`ctx-body ctx-embed border-t border-line`,children:(0,z.jsx)(vg,{kind:`places`,slug:u})},s.key):(0,z.jsx)(`p`,{className:`m-0 flex-none px-3 pb-3 text-sm text-fg-2`,children:`Pick a place on the left or a dot on the map to zoom in and see its details.`})]}):!s||!l?(0,z.jsx)(Y,{icon:`preview`,className:`my-auto`,children:t&&!a?`That one is gone.`:`Pick something on the left to see it here.`}):(0,z.jsxs)(z.Fragment,{children:[b,s.kind===`chats`?(0,z.jsx)(`div`,{className:`artifact-chat flex min-h-0 flex-1 flex-col overflow-hidden px-5 pb-3`,children:(0,z.jsx)(Ko,{id:u},s.key)}):s.kind===`vibeables`?(0,z.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,z.jsx)(en,{slug:u},s.key)}):(0,z.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,z.jsxs)(Jt.Provider,{value:c,children:[s.kind===`workflows`&&(0,z.jsx)(Pb,{slug:u}),s.kind===`runs`&&(0,z.jsx)(`div`,{className:`p-3`,children:(0,z.jsx)(Rg,{id:u})}),s.kind===`routines`&&(0,z.jsx)(hb,{owner:u,id:d,onOpen:t=>H(r({kind:e,open:t}),{replace:!0})}),s.kind===`knowledge`&&(0,z.jsx)(Ib,{name:u}),s.kind===`skills`&&(0,z.jsx)(Py,{name:u}),s.kind===`repos`&&(0,z.jsx)(Oy,{slug:u,embedded:!0}),s.kind===`presentations`&&(0,z.jsx)(ag,{project:u||void 0,name:d}),s.kind===`boards`&&(0,z.jsx)(Fb,{project:u||void 0,board:d,kind:e,href:r}),s.kind===`tasks`&&(0,z.jsx)(`div`,{className:`p-3`,children:(0,z.jsx)(ic,{project:u||void 0,board:d,task:f})}),s.kind===`contacts`&&(0,z.jsx)(vg,{kind:s.kind,slug:u})]})},s.key)]})})]})}function Pb({slug:e}){let[t,n]=(0,v.useState)(`overview`),r=`/workflows/${Tb(e)}`;return(0,z.jsx)(_e.Provider,{value:e=>{if(e!==r&&!e.startsWith(`${r}/`))return!1;let t=e.slice(r.length+1);return n(t===`details`||t===`runs`?t:`overview`),!0},children:(0,z.jsx)(p_,{slug:e,tab:t},e)})}function Fb({project:e,board:t,kind:n,href:r}){let i=`${Us({project:e,board:t})}/`;return(0,z.jsx)(_e.Provider,{value:a=>{let o=a.startsWith(i)?a.slice(i.length):``;return!o||o.includes(`/`)||o===`settings`?!1:(H(r({kind:n===`boards`?`all`:n,open:`tasks:${e??``}:${t}:${decodeURIComponent(o)}`})),!0)},children:(0,z.jsx)(fc,{project:e,board:t})})}function Ib({name:e}){let[t,n]=(0,v.useState)(void 0),r=`/knowledge/${Tb(e)}`;return(0,z.jsx)(_e.Provider,{value:e=>{if(e!==r&&!e.startsWith(`${r}/`))return!1;let t=e.slice(r.length+1);return n(t?t.split(`/`).map(decodeURIComponent).join(`/`):void 0),!0},children:(0,z.jsx)(F_,{name:e,conceptId:t},e)})}function Lb({placeholder:e,byDefault:t,firstGroup:n,agentHint:r,exclude:i,placeOf:a,sessions:o,hrefOf:s,create:c,pickProject:l,defaultControls:u,children:d}){let f=F(`agents.list`,{},{interval:3e4}),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),_=Vt(),y=l?_.find(e=>e.slug===h):void 0;y&&l===`assistant`&&(t={...He,sub:`the assistant of ${y.title}`,hint:`in ${y.title}`});let[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(``),E=(0,v.useRef)(null);(0,v.useEffect)(()=>{document.querySelector(`[role=dialog]`)||E.current?.focus()},[]);let D=(f?.agents??[]).filter(e=>!e.archived),O=D.filter(e=>e.slug!==i),k=n?O.filter(e=>n.slugs.has(e.slug)):[],ee=n?O.filter(e=>!n.slugs.has(e.slug)):O,A=p?O.find(e=>e.slug===p):void 0,j=e=>{let t=D.find(t=>t.slug===e);return t?`${t.emoji||`🤖`} ${t.name}`:e},M=async e=>{if(S)return;C(!0),T(``);let t=await c(p||void 0,y);if(`error`in t)return C(!1),T(t.error),!1;let n=await qt(t.id,b,e);if(n)return C(!1),T(n),!1;H(t.href)},N=A?`${A.emoji||`🤖`} ${A.name}`:`${t.emoji} ${t.name}`,P=(e,t)=>(0,z.jsx)(Bb,{emoji:e.emoji||`🤖`,name:e.name,sub:e.description,on:p===e.slug,onClick:()=>{m(e.slug),t()}},e.slug);return(0,z.jsxs)(`div`,{className:`session-home mx-auto flex w-full max-w-[760px] animate-rise flex-col gap-7 px-6 pt-8 pb-12 max-[800px]:px-3 max-[800px]:pt-4`,children:[(0,z.jsx)(Rt,{label:`start a session`,value:b,onChange:x,inputRef:E,inputLabel:`new session`,placeholder:e,onSend:M,sendLabel:`start session`,busy:S,error:w,skills:!0,who:p,onWho:e=>O.some(t=>t.slug===e)&&m(e),attach:!0,hint:A?r??``:t.hint??``,controls:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Nt,{className:`max-h-[50vh] overflow-y-auto`,trigger:({open:e,toggle:t})=>(0,z.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":e,"aria-label":`session with`,className:`inline-flex cursor-pointer items-center gap-1 rounded-full border-0 bg-transparent px-2.5 py-1 text-sm font-medium text-fg transition-colors hover:bg-surface-2`,onClick:t,children:[N,(0,z.jsx)(B,{name:`expand_more`,className:`ms-sm text-fg-2`})]}),children:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Bb,{emoji:t.emoji,name:`${t.name} (default)`,sub:t.sub,on:!p,onClick:()=>{m(``),e()}}),k.length>0&&n&&(0,z.jsx)(zb,{children:n.label}),k.map(t=>P(t,e)),ee.length>0&&(0,z.jsx)(zb,{children:k.length>0?`other agents`:`agents`}),ee.map(t=>P(t,e))]})}),l&&(0,z.jsx)(Ht,{value:h,onChange:g,projects:_}),!A&&!y&&u]})}),d,(0,z.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`recent sessions`,children:[(0,z.jsx)(`h2`,{className:`m-0 px-3 pb-1 text-sm font-medium text-fg-2`,children:`Recents`}),o&&o.length===0&&(0,z.jsx)(`p`,{className:`m-0 px-3 text-sm text-fg-2`,children:`No sessions yet — start one above.`}),(o??[]).map(e=>(0,z.jsx)(Vb,{chat:e,href:s(e),place:a?.(e),who:e.scope.kind===`channel`?`👥 coworkers · #${e.scope.slug}`:e.scope.kind===`agent`?j(e.scope.slug):e.scope.kind===`project`?`${He.emoji} ${He.name}`:`${t.emoji} ${t.name}`},e.id))]})]})}async function Rb(e,t){let n=await A.request(`chats.create`,{body:e});return n.ok?{id:n.data.id,href:t(n.data.id)}:{error:P(n)}}function zb({children:e}){return(0,z.jsx)(`div`,{className:`mt-1.5 border-t border-line px-2 pt-2 pb-1 text-2xs font-semibold tracking-[0.06em] text-fg-2 uppercase`,children:e})}function Bb({emoji:e,name:t,sub:n,on:r,onClick:i}){return(0,z.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,className:`flex w-full cursor-pointer items-start gap-2.5 rounded-md px-2 py-1.5 text-left hover:bg-surface-2`,onClick:i,children:[(0,z.jsx)(`span`,{className:`w-5 flex-none text-center text-base leading-5`,children:e}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(`span`,{className:`text-sm text-fg`,children:t}),n&&(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:n})]}),r&&(0,z.jsx)(B,{name:`check`,className:`ms-sm mt-0.5 text-accent`})]})}function Vb({chat:e,href:t,who:n,place:r}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),c=xn(e,`new session`);return i?(0,z.jsx)(`div`,{className:`px-1.5 py-1`,children:(0,z.jsx)(yn,{name:c,className:`w-full text-base`,onDone:t=>{a(!1),t&&A.request(`chats.rename`,{id:e.id,body:{title:t}}).catch(()=>null)}})}):(0,z.jsxs)(`div`,{className:`recent-session group/recent relative flex items-center rounded-card transition-colors hover:bg-surface-2 has-[[aria-expanded=true]]:bg-surface-2`,"data-chat":e.id,children:[(0,z.jsxs)(U,{href:t,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-2.5 text-[15px] text-fg no-underline`,children:[(e.busy||e.awaitingApproval)&&(0,z.jsx)(et,{tone:e.awaitingApproval?`bad`:`working`,title:e.awaitingApproval?`waiting for your approval`:`working`}),e.scope.kind===`channel`&&(0,z.jsx)(B,{name:`forum`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`truncate`,children:c}),r&&(0,z.jsx)(`span`,{className:`recent-place flex-none truncate text-xs text-fg-2`,children:r})]}),(0,z.jsx)(`span`,{className:`recent-agent flex-none truncate rounded-full bg-surface-2 px-2 py-0.5 text-xs text-fg-2 max-w-[40%]`,title:`session with ${n}`,children:n}),(0,z.jsx)(`span`,{className:`flex-none px-3 text-sm text-fg-2 tabular-nums group-hover/recent:hidden group-has-[[aria-expanded=true]]/recent:hidden`,title:e.updatedAt,children:G(e.updatedAt)}),(0,z.jsx)(`span`,{className:`hidden flex-none pr-1.5 group-hover/recent:inline-flex group-has-[[aria-expanded=true]]/recent:inline-flex pointer-coarse:inline-flex`,children:(0,z.jsx)(Nt,{align:`end`,trigger:({open:e,toggle:t})=>(0,z.jsx)(q,{icon:`more_horiz`,size:`sm`,label:`more for ${c}`,"aria-haspopup":`menu`,"aria-expanded":e,onClick:()=>{s(!1),t()}}),children:t=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(bn,{icon:`edit`,label:`rename`,onClick:()=>{t(),a(!0)}}),(0,z.jsx)(bn,{icon:`delete`,label:o?`confirm delete`:`delete`,danger:!0,onClick:()=>{if(!o)return s(!0);t(),A.request(`chats.delete`,{id:e.id}).catch(()=>null)}})]})})})]})}var Hb=[`active`,`paused`,`done`,`archived`],Ub={active:`working`,paused:`idle`,done:`ok`,archived:`idle`},Wb={"my-netnode":`my.netnode.ch`,"google-drive":`Google Drive`,github:`GitHub`,bitbucket:`Bitbucket`,notion:`Notion`,slack:`Slack`,crm:`CRM`,newsletter:`Newsletter tool`,calendar:`Calendar`,"google-maps":`Google Maps`,url:`Link`},Gb=e=>Wb[e]??e,Kb=[{id:`claude`,label:`claude`,hint:`Claude Code via ACP`},{id:`codex`,label:`codex`,hint:`Codex (ChatGPT) via ACP`},{id:`pi`,label:`pi`,hint:`pi coding agent`},{id:`antigravity`,label:`antigravity`,hint:`Google Antigravity (agy) via ACP`}],qb=e=>[e.harness,e.model,e.effort?`effort ${e.effort}`:``].filter(Boolean).join(` · `),Jb=(e,t)=>(e??[]).filter(e=>e.scope.kind===`project`&&e.scope.slug===t||e.project===t),Yb=(e,t)=>`/projects/${encodeURIComponent(t)}/chat/${e.id}`;async function Xb(e,t,n=!1){let r=await A.request(`projects.save`,{slug:e,body:t,keepalive:n});if(!r.ok)throw Error(P(r));return r.data}function Zb({seg:e}){let t=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`project`:`home`,r=n===`chat`?e[2]:void 0,[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),c=(0,v.useCallback)(async()=>{try{let e=await A.request(`projects.list`);if(!e.ok)throw Error(`HTTP ${e.status}`);a(e.data),s(``)}catch(e){s(e.message||`could not load projects`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await c(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[c]),(0,v.useEffect)(()=>{c()},[t,n,c]);let l=i?.projects??[],u=t?l.find(e=>e.slug===t):void 0,d=[...l].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))[0]?.slug;(0,v.useEffect)(()=>{n===`home`&&d&&H(`/projects/${encodeURIComponent(d)}`,{replace:!0})},[n,d]);let f;return f=i&&!i.enabled?(0,z.jsx)(Y,{icon:`folder_off`,children:i.error&&!/are off/.test(i.error)?(0,z.jsx)(`span`,{className:`text-bad`,children:i.error}):(0,z.jsxs)(z.Fragment,{children:[`Projects are off. Turn them on in `,(0,z.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,z.jsx)(`code`,{children:`projects:`}),` block to kraftwerk.yml.`]})}):i?n===`new`||n===`home`&&l.length===0?(0,z.jsx)($b,{root:i.root,onCreated:c}):n===`home`?(0,z.jsx)(Y,{children:`loading…`}):t&&!u?(0,z.jsxs)(Y,{icon:`folder_off`,children:[`no project named `,t]}):n===`chat`&&t&&r===`new`?(0,z.jsx)(ex,{slug:t,title:u?.title??t},t):n===`chat`&&t&&r?(0,z.jsx)(`div`,{className:`chat-main`,children:(0,z.jsx)(tx,{chatId:r,title:u?.title??t,goal:u?.goal},r)}):n===`info`&&t?(0,z.jsx)(ax,{slug:t,onChanged:c},t):t?(0,z.jsx)(Mb,{title:u?.title??t},t):(0,z.jsx)(Y,{children:`loading…`}):(0,z.jsx)(Y,{children:`loading…`}),(0,z.jsxs)(`div`,{className:`runs-screen agents-screen projects-screen ${t&&u?`in-project`:``}`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`projects`,count:i?.enabled?l.length:void 0,action:i?.enabled&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,href:`/projects/new`,children:`new`})}),(0,z.jsxs)(jt,{children:[l.map(e=>(0,z.jsx)(gt,{href:`/projects/${encodeURIComponent(e.slug)}`,active:e.slug===t,size:`sm`,innerProps:{"data-project":e.slug},leading:(0,z.jsx)(et,{tone:e.configError?`bad`:Ub[e.status],title:e.status}),title:e.title,sub:e.configError?e.configError:e.goal||e.status,subTone:e.configError?`bad`:`plain`,meta:e.updatedAt&&(0,z.jsx)(`span`,{title:e.updatedAt,children:G(e.updatedAt)})},e.slug)),i&&i.enabled&&l.length===0&&(0,z.jsx)(Mt,{children:`no projects yet`}),o&&(0,z.jsx)(rt,{tone:`bad`,children:o})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:f})]})}function Qb(){let e=F(`projects.list`,{},{interval:6e4});return e&&!e.enabled?(0,z.jsxs)(Y,{icon:`folder_off`,children:[`Projects are off. Turn them on in `,(0,z.jsx)(`a`,{href:`#/settings`,children:`settings`}),`.`]}):(0,z.jsx)($b,{root:e?.root,onCreated:async()=>{}})}function $b({root:e,onCreated:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),u=async e=>{e.preventDefault();let r=n.trim();if(r&&!o){s(!0),l(``);try{let e=await A.request(`projects.create`,{body:{title:r,goal:i.trim()}});if(!e.ok)throw Error(P(e));let n=e.data;H(`/projects/${encodeURIComponent(n.slug)}/info`),t()}catch(e){l(e.message)}finally{s(!1)}}};return(0,z.jsxs)(`form`,{className:`new-chat mx-auto flex w-full max-w-[640px] animate-rise flex-col gap-4`,onSubmit:e=>void u(e),children:[(0,z.jsx)(ot,{size:`lg`,children:`new project`}),(0,z.jsx)(X,{children:(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsx)(Q,{label:`title`,children:(0,z.jsx)(Z,{value:n,placeholder:`e.g. Relaunch netnode.ch`,"aria-label":`project title`,autoFocus:!0,onChange:e=>r(e.target.value)})}),(0,z.jsx)(Q,{label:`goal (one line)`,children:(0,z.jsx)(Z,{value:i,placeholder:`e.g. Ship the new site on NodeHive by November`,"aria-label":`project goal`,onChange:e=>a(e.target.value)})}),(0,z.jsx)(`div`,{children:(0,z.jsx)(K,{variant:`primary`,type:`submit`,icon:`add`,busy:o,disabled:!n.trim(),children:o?`creating…`:`create project`})}),c&&(0,z.jsx)(rt,{tone:`bad`,children:c}),(0,z.jsxs)(nt,{children:[`One folder each under `,(0,z.jsx)(`code`,{title:e,children:e}),` with project.yml, brief.md, state.md and log.md; part of the workspace, commit it from the git screen. Chats opened in the project carry all of it as context.`]})]})})]})}function ex({slug:e,title:t}){let n=De(),r=F(`projects.get`,{slug:e}),i=F(`chats.list`,{}),a=Kb.find(e=>e.id===r?.harness)??Kb[0],o=n.vibeables?(r?.links.vibeables??[]).filter(e=>e.found).map(e=>e.slug):[],s=t=>`/projects/${encodeURIComponent(e)}/chat/${t}`;return(0,z.jsx)(Lb,{placeholder:`New session in ${t}`,byDefault:{...He,sub:r?`the project's assistant · ${qb(r)}`:`the project's assistant`,hint:r?qb(r):``},firstGroup:{label:`agents of the project`,slugs:new Set((r?.links.agents??[]).map(e=>e.slug))},agentHint:`works with the project's context`,sessions:i?Jb(i.chats,e):null,hrefOf:t=>Yb(t,e),create:t=>Rb(t?{agent:`claude`,scope:{kind:`agent`,slug:t},project:e}:{agent:a.id,scope:{kind:`project`,slug:e}},s),children:o.length>0&&(0,z.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`pinned apps`,children:[(0,z.jsx)(`h2`,{className:`m-0 px-3 pb-1 text-sm font-medium text-fg-2`,children:`Apps`}),(0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2 px-1`,children:o.map(t=>(0,z.jsxs)(U,{href:`/projects/${encodeURIComponent(e)}?app=${encodeURIComponent(t)}`,className:`pinned-app flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-2.5 text-sm text-fg no-underline hover:bg-surface-2`,title:`open ${t} beside the project's chat`,"data-app":t,children:[(0,z.jsx)(B,{name:`web`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:t})]},t))})]})})}function tx({chatId:e,title:t,goal:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let t=!0;return A.call(`chats.get`,{id:e}).then(e=>t&&i(e.meta.scope)).catch(()=>t&&o(!0)),()=>{t=!1}},[e,s]);let l=r?.kind===`channel`?r.slug:void 0,u=r?.kind===`agent`?r.slug:void 0,d=F(`channels.list`,l?{}:null,{interval:4e3}),f=F(`agents.list`,l||u?{}:null,{interval:8e3});if(a)return(0,z.jsx)(Y,{icon:`chat_error`,children:`chat not found`});if(!r)return(0,z.jsx)(Y,{children:`loading…`});if(l){let t=d?.channels.find(e=>e.slug===l);return d?t?(0,z.jsx)(Ko,{id:e,channel:t,agents:f?.agents??[]},`${e}:channel`):(0,z.jsxs)(Y,{icon:`forum`,children:[`channel #`,l,` is gone — its definition under channels/ was removed`]}):(0,z.jsx)(Y,{children:`loading…`})}if(u){let t=f?.agents.find(e=>e.slug===u);return f?(0,z.jsx)(Ko,{id:e,agentName:t?`${t.emoji||`🤖`} ${t.name}`:u,agentDescription:t?.description,onConverted:()=>c(e=>e+1)},`${e}:${s}`):(0,z.jsx)(Y,{children:`loading…`})}return(0,z.jsx)(Ko,{id:e,agentName:t,agentDescription:n,onConverted:()=>c(e=>e+1)},`${e}:${s}`)}var nx=[{kind:`knowledge`,label:`knowledge`,icon:`menu_book`,href:e=>`/knowledge/${encodeURIComponent(e)}`},{kind:`vibeables`,label:`apps`,icon:`web`,href:e=>`/vibeables/${encodeURIComponent(e)}`},{kind:`repos`,label:`repositories`,icon:`source`},{kind:`workflows`,label:`workflows`,icon:`account_tree`,href:e=>`/workflows/${encodeURIComponent(e)}`},{kind:`agents`,label:`agents`,icon:`groups`,href:e=>`/agents/${encodeURIComponent(e)}`},{kind:`contacts`,label:`contacts`,icon:`person`,href:e=>`/contacts/${encodeURIComponent(e)}`},{kind:`places`,label:`places`,icon:`location_on`,href:e=>`/places/${encodeURIComponent(e)}`},{kind:`events`,label:`events`,icon:`event`,href:e=>`/events/${encodeURIComponent(e)}`}],rx=[`title`,`goal`,`model`,`brief`,`state`],ix=(e,t,n)=>e===`brief`||e===`state`?t!==n[e]:e===`title`?!!t.trim()&&t.trim()!==n.title:t.trim()!==(n[e]??``);function ax({slug:e,onChanged:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(``),g=De(),_=(0,v.useRef)(null),y=(0,v.useRef)({}),b=(0,v.useRef)(Promise.resolve()),x=(0,v.useRef)(0),S=(0,v.useRef)(null),C=(0,v.useRef)(!1),w=e=>{_.current=e,r(e)},T=e=>{y.current=e,p(e)};(0,v.useEffect)(()=>{let t=!0;return A.call(`projects.get`,{slug:e}).then(e=>t&&w(e)).catch(()=>t&&a(!0)),()=>{t=!1}},[e]);let E=(n,r=!1)=>{x.current++,l(!0);let i=b.current.then(async()=>{let i=typeof n==`function`?n():n;if(i&&!C.current){s(``);try{w(await Xb(e,i,r)),await t()}catch(t){s(t.message);let n=await A.call(`projects.get`,{slug:e}).catch(()=>null);n&&w(n)}}x.current--,x.current===0&&l(!1)});return b.current=i,i},D=e=>{_.current&&w({..._.current,...e}),E(e)},O=()=>{let e=_.current;if(!e)return null;let t={};for(let n of rx){let r=y.current[n];r!==void 0&&ix(n,r,e)&&(t[n]=r)}return Object.keys(t).length?t:null},k=(e=!1)=>(S.current&&clearTimeout(S.current),S.current=null,O()?E(O,e):Promise.resolve()),ee=(e,t)=>{T({...y.current,[e]:t}),(e===`brief`||e===`state`)&&(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>void k(),1e3))},j=async e=>{let t=y.current[e];if(t===void 0)return;await k();let n=_.current;if(y.current[e]!==t||!n||ix(e,t,n))return;let{[e]:r,...i}=y.current;T(i)};(0,v.useEffect)(()=>{let e=()=>void k(!0);return window.addEventListener(`beforeunload`,e),window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`beforeunload`,e),window.removeEventListener(`pagehide`,e),k(!0)}},[]);let M=async()=>{l(!0);try{let n=await A.request(`projects.delete`,{slug:e});if(!n.ok)throw Error(n.error||`failed`);C.current=!0,await t(),H(`/`,{replace:!0})}catch(e){s(e.message),l(!1)}},N=async()=>{let t=m.trim();if(t){l(!0),s(``);try{let n=await A.request(`projects.log`,{slug:e,body:{entry:t}});if(!n.ok)throw Error(n.error||`failed`);let r=n.data;h(``),_.current&&w({..._.current,log:r.log??_.current.log})}catch(e){s(e.message)}finally{x.current===0&&l(!1)}}};if(i)return(0,z.jsx)(Y,{icon:`folder_off`,children:`project not found`});if(!n)return(0,z.jsx)(Y,{children:`loading…`});let P=e=>f[e]??n[e]??``,F=rx.some(e=>f[e]!==void 0&&ix(e,f[e],n)),I=e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},te=`h-8 border-transparent bg-transparent px-2 text-sm shadow-none hover:bg-surface-2 focus:bg-surface`;return(0,z.jsx)(`div`,{className:`chat-main project-page @container flex flex-col`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[1120px] flex-none flex-col gap-5`,children:[(0,z.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex min-h-7 items-center gap-2 text-sm text-fg-2 [.edit-modal_&]:pr-9`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,title:n.path,children:n.path}),(c||F)&&(0,z.jsx)(`span`,{className:`flex-none text-xs`,children:c?`saving…`:`unsaved`}),(0,z.jsx)(`span`,{className:`flex-1`}),u?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,disabled:c,onClick:()=>void M(),title:`Move the project, its files and log to the trash; #/trash puts it back`,children:`confirm delete`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>d(!1),children:`cancel`})]}):(0,z.jsx)(q,{icon:`delete`,label:`delete project`,size:`sm`,disabled:c,onClick:()=>d(!0)})]}),(0,z.jsx)(`h1`,{className:`sr-only`,children:n.title}),(0,z.jsx)(`textarea`,{rows:1,value:P(`title`),"aria-label":`title`,className:`block w-full resize-none border-0 bg-transparent p-0 font-[inherit] text-2xl leading-tight font-semibold text-fg shadow-none outline-none focus:shadow-none focus:outline-none focus-visible:outline-none [field-sizing:content]`,onChange:e=>ee(`title`,e.target.value.replace(/\n/g,` `)),onBlur:()=>void j(`title`),onKeyDown:I}),(0,z.jsx)(`div`,{className:`-mx-2`,children:(0,z.jsx)(Z,{value:P(`goal`),"aria-label":`goal`,placeholder:`what the project is for`,className:`h-8 border-transparent bg-transparent px-2 text-base text-fg-2 shadow-none hover:bg-surface-2 focus:bg-surface focus:text-fg`,onChange:e=>ee(`goal`,e.target.value),onBlur:()=>void j(`goal`),onKeyDown:I})})]}),n.configError&&(0,z.jsxs)(rt,{tone:`bad`,children:[`project.yml: `,n.configError]}),o&&(0,z.jsx)(rt,{tone:`bad`,children:o}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-x-8 gap-y-6 @[880px]:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6`,children:[(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Brief`}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`brief.md — what done looks like, constraints, stakeholders`})]}),(0,z.jsx)(xt,{rows:10,className:`resize-y font-mono text-sm`,value:P(`brief`),"aria-label":`brief`,onChange:e=>ee(`brief`,e.target.value),onBlur:()=>void j(`brief`)})]}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`State`}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`state.md — current state, rewritten at the end of a session`})]}),(0,z.jsx)(xt,{rows:6,className:`resize-y font-mono text-sm`,value:P(`state`),"aria-label":`state`,onChange:e=>ee(`state`,e.target.value),onBlur:()=>void j(`state`)})]}),(0,z.jsx)(ux,{records:n.records,saving:c,onSave:e=>E({records:e})}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Links`}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`by name; a target that is missing in this workspace is marked`})]}),(0,z.jsx)(`div`,{className:`overflow-hidden rounded-card border border-line bg-surface`,children:(0,z.jsx)(ft,{children:nx.filter(e=>e.kind!==`contacts`&&e.kind!==`places`&&e.kind!==`events`||g[e.kind]).map(r=>(0,z.jsx)(cx,{kind:r.kind,label:r.label,icon:r.icon,href:r.href,links:n.links[r.kind],saving:c,onChange:(n,i)=>void ox(e,r.kind,n,i,e=>{w(e),t()},s)},r.kind))})})]}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Log`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Z,{value:m,"aria-label":`log entry`,placeholder:`Add an entry — a decision, a milestone…`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),N())}}),(0,z.jsx)(K,{icon:`add`,disabled:c||!m.trim(),onClick:()=>void N(),children:`log`})]}),(0,z.jsx)(`div`,{className:`md-body h-auto overflow-visible pt-1 text-sm [&_h1]:hidden [&_h2]:mt-3 [&_h2]:mb-1 [&_h2]:text-xs [&_ul]:m-0 [&_ul]:pl-[18px]`,dangerouslySetInnerHTML:{__html:fo.sanitize(Mi.parse(n.log||`_no entries yet_`,{async:!1}))}})]})]}),(0,z.jsxs)(`aside`,{className:`order-first flex min-w-0 flex-col gap-2 @[880px]:order-none`,"aria-label":`details`,children:[(0,z.jsxs)(`dl`,{className:`m-0 grid grid-cols-[76px_minmax(0,1fr)] items-center gap-x-2 gap-y-1 text-sm @min-[520px]:@max-[879px]:grid-cols-[76px_minmax(0,1fr)_76px_minmax(0,1fr)]`,children:[(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Status`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(St,{value:n.status,"aria-label":`status`,className:te,onChange:e=>D({status:e.target.value}),children:Hb.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Harness`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(St,{value:n.harness,"aria-label":`harness`,className:te,onChange:e=>D({harness:e.target.value}),children:Kb.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Model`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(Z,{value:P(`model`),"aria-label":`model`,placeholder:`harness default`,title:`e.g. sonnet, gpt-5.6-sol — empty for the harness default`,className:te,onChange:e=>ee(`model`,e.target.value),onBlur:()=>void j(`model`),onKeyDown:I})}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Effort`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(St,{value:n.effort??``,"aria-label":`effort`,className:te,onChange:e=>D({effort:e.target.value}),children:Je.map(e=>(0,z.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,z.jsx)(`span`,{className:`px-2 text-xs text-fg-2`,children:`harness, model and effort: what every chat in this project runs on`})]})]})]})})}async function ox(e,t,n,r,i,a){try{let a=await A.request(`projects.link`,{slug:e,body:{kind:t,target:n,remove:r}});if(!a.ok)throw Error(P(a));i(a.data)}catch(e){a(e.message)}}async function sx(e){switch(e){case`knowledge`:return(await A.call(`knowledge.list`)).bundles.map(e=>({slug:e.name,hint:`${e.concepts} concepts`}));case`vibeables`:return(await A.call(`vibeables.list`)).vibeables.map(e=>({slug:e.slug,hint:e.dev?`dev`:`static`}));case`repos`:return(await A.call(`repos.list`)).repos.map(e=>({slug:e.slug,hint:e.branch}));case`workflows`:return(await A.call(`workflows.list`)).workflows.map(e=>({slug:e.slug,hint:e.description??e.name}));case`agents`:return(await A.call(`agents.list`)).agents.filter(e=>!e.archived).map(e=>({slug:e.slug,hint:`${e.emoji} ${e.name}`}));case`contacts`:return(await A.call(`contacts.list`)).items.map(e=>({slug:e.slug,hint:[e.role,e.org].filter(Boolean).join(`, `)||void 0}));case`places`:return(await A.call(`places.list`)).items.map(e=>({slug:e.slug,hint:e.address}));case`events`:return(await A.call(`events.list`)).items.map(e=>({slug:e.slug,hint:e.start}))}}function cx({kind:e,label:t,icon:n,href:r,links:i,saving:a,onChange:o}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!s||l)return;let t=!0;return sx(e).then(e=>t&&u(e)).catch(()=>t&&u([])),()=>{t=!1}},[s,l,e]);let p=new Set(i.map(e=>e.slug)),m=(l??[]).filter(e=>!p.has(e.slug));return(0,z.jsxs)(dt,{icon:n,title:t,"data-link-kind":e,action:!s&&(0,z.jsx)(K,{size:`sm`,icon:`add`,onClick:()=>c(!0),children:`link`}),children:[i.length===0&&!s&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none linked`}),i.length>0&&(0,z.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,z.jsxs)(J,{tone:e.found?`neutral`:`bad`,title:e.found?e.label:`configured but not found in this workspace`,children:[r&&e.found?(0,z.jsx)(U,{href:r(e.slug),className:`text-inherit no-underline hover:underline`,children:e.slug}):e.slug,!e.found&&` · not found`,(0,z.jsx)(`button`,{type:`button`,className:`-mr-1 ml-1 inline-grid size-4 cursor-pointer place-items-center rounded-full border-0 bg-transparent p-0 text-inherit opacity-70 hover:bg-surface hover:opacity-100 disabled:cursor-default [&_.ms]:text-[13px]`,"aria-label":`unlink ${e.slug}`,disabled:a,onClick:()=>o(e.slug,!0),children:(0,z.jsx)(B,{name:`close`})})]},e.slug))}),s&&(0,z.jsx)(`span`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:l===null?(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`loading…`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(St,{className:`w-auto max-w-full min-w-48 flex-1`,"aria-label":`link ${t}`,value:d,onChange:e=>f(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:m.length?`pick ${t}…`:`nothing to link`}),m.map(e=>(0,z.jsxs)(`option`,{value:e.slug,children:[e.slug,e.hint?` — ${e.hint}`:``]},e.slug))]}),(0,z.jsx)(K,{disabled:a||!d,onClick:()=>{o(d,!1),f(``),c(!1)},children:`link`}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>c(!1),children:`cancel`})]})})]})}var lx={kind:`url`};function ux({records:e,saving:t,onSave:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=e=>i(t=>({...t??lx,...e})),c=e=>{let t={kind:e.kind.trim().toLowerCase()||`url`};for(let n of[`title`,`url`,`workspace`,`note`]){let r=(e[n]??``).trim();r&&(t[n]=r)}return t};return(0,z.jsx)(X,{title:`systems of record`,className:`flex-none`,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`where the truth is managed outside kraftwerk — context for the agent, not a credential`}),!r&&(0,z.jsx)(K,{size:`sm`,icon:`add`,onClick:()=>i({...lx}),children:`add`})]}),children:(0,z.jsxs)(ft,{children:[e.map((r,i)=>(0,z.jsx)(dt,{"data-record-kind":r.kind,icon:`database`,title:(0,z.jsxs)(z.Fragment,{children:[Gb(r.kind),r.title&&(0,z.jsx)(`span`,{className:`text-xs font-normal text-fg-2`,children:r.title}),r.workspace&&(0,z.jsxs)(J,{children:[`workspace `,r.workspace]})]}),action:(0,z.jsx)(q,{icon:`close`,size:`sm`,label:`remove record ${r.title??r.kind}`,disabled:t,onClick:()=>void n(e.filter((e,t)=>t!==i))}),children:(r.url||r.note)&&(0,z.jsxs)(`span`,{className:`text-xs leading-normal text-fg-2`,children:[r.url&&(0,z.jsx)(`a`,{href:r.url,target:`_blank`,rel:`noreferrer`,children:r.url}),r.url&&r.note&&` — `,r.note]})},i)),e.length===0&&!r&&(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`none yet — e.g. a my.netnode.ch workspace, a Google Drive folder, a board`}),r&&(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`kind`,children:a?(0,z.jsx)(Z,{value:r.kind,"aria-label":`record kind`,placeholder:`e.g. jira`,onChange:e=>s({kind:e.target.value})}):(0,z.jsxs)(St,{value:r.kind,"aria-label":`record kind`,onChange:e=>{e.target.value===`__other`?(o(!0),s({kind:``})):s({kind:e.target.value})},children:[Object.entries(Wb).map(([e,t])=>(0,z.jsx)(`option`,{value:e,children:t},e)),(0,z.jsx)(`option`,{value:`__other`,children:`other…`})]})}),(0,z.jsx)(Q,{label:`title`,className:`flex-1`,children:(0,z.jsx)(Z,{value:r.title??``,"aria-label":`record title`,placeholder:`e.g. Contracts folder`,onChange:e=>s({title:e.target.value})})}),(0,z.jsx)(Q,{label:`workspace / id`,children:(0,z.jsx)(Z,{value:r.workspace??``,"aria-label":`record workspace`,placeholder:`e.g. 22`,onChange:e=>s({workspace:e.target.value})})})]}),(0,z.jsx)(Q,{label:`url`,children:(0,z.jsx)(Z,{value:r.url??``,"aria-label":`record url`,placeholder:`https://…`,onChange:e=>s({url:e.target.value})})}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`note — what lives there and how it is usually reached`,className:`flex-1`,children:(0,z.jsx)(Z,{value:r.note??``,"aria-label":`record note`,placeholder:`e.g. tickets and roadmap; the my CLI`,onChange:e=>s({note:e.target.value})})}),(0,z.jsx)(K,{disabled:t||!r.kind.trim(),onClick:async()=>{await n([...e,c(r)]),i(null),o(!1)},children:`add record`}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>{i(null),o(!1)},children:`cancel`})]})]})]})})}var dx=`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`;function fx({children:e}){return(0,z.jsx)(`span`,{className:`mt-[3px] flex flex-wrap gap-1.5`,children:e})}function px({children:e}){return(0,z.jsx)(`div`,{className:`flex flex-col gap-[7px] py-1`,children:e})}var mx=`resize-y font-mono text-[12.5px] leading-[1.65]`;function hx({bundles:e,onHide:t,onResize:n}){let[r,i]=(0,v.useState)({}),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``);(0,v.useEffect)(()=>{i({});let t=!0,n,r=async()=>{await Promise.all(e.map(async e=>{try{let n=await A.request(`knowledge.get`,{bundle:e}),r=n.ok?n.data:null;t&&i(t=>JSON.stringify(t[e])===JSON.stringify(r)?t:{...t,[e]:r})}catch{t&&i(t=>e in t?t:{...t,[e]:null})}})),t&&(n=setTimeout(r,6e3))};return r(),()=>{t=!1,clearTimeout(n)}},[e.join(`,`)]),(0,v.useEffect)(()=>{if(!a||d===a)return;let e=a.indexOf(`::`),t=a.slice(0,e),n=a.slice(e+2),r=!0,i,o=async()=>{try{let e=await A.request(`knowledge.concept`,{bundle:t,query:{id:n}}),i=e.ok?e.data:null;r&&c(e=>JSON.stringify(e[a])===JSON.stringify(i)?e:{...e,[a]:i})}catch{r&&c(e=>a in e?e:{...e,[a]:null})}r&&(i=setTimeout(o,6e3))};return o(),()=>{r=!1,clearTimeout(i)}},[a,d]);function b(e,t){let n=`${e}::${t}`;o(a===n?null:n)}async function x(e,t){let n=`${e}::${t}`;g(!0),y(``);try{let r=await A.request(`knowledge.putConcept`,{bundle:e,body:{id:t,content:p}});if(!r.ok)y(P(r));else if(r.data.error)y(r.data.error);else{let e=r.data;c(t=>({...t,[n]:e})),f(null)}}catch(e){y(e.message)}g(!1)}return(0,z.jsxs)(`aside`,{className:`runs-side knowledge-side`,children:[(0,z.jsx)(`div`,{className:`absolute inset-y-0 -left-[3px] z-4 w-[7px] cursor-col-resize hover:bg-accent/25`,title:`Drag to resize`,onMouseDown:e=>{e.preventDefault();let t=e.clientX,r=e.currentTarget.parentElement.offsetWidth,i=e=>n(Math.min(900,Math.max(280,r+(t-e.clientX)))),a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)}}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4 py-3.5`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,z.jsx)(it,{children:`knowledge`}),(0,z.jsx)(`span`,{className:`truncate text-[10.5px] text-fg-2`,children:`read & kept current by this agent`})]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(K,{size:`sm`,variant:`quiet`,onClick:t,title:`Hide knowledge sidebar`,children:[`hide `,(0,z.jsx)(B,{name:`close`,className:`ms-sm`})]})]}),(0,z.jsx)(`div`,{className:`flex-1 divide-y divide-line overflow-y-auto p-1.5`,children:e.map(e=>{let t=r[e],n=l[e]===!0;return(0,z.jsxs)(`div`,{className:`px-2 pt-1.5 pb-2.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-0.5 py-0.5`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-[7px] rounded-xl border-0 bg-transparent px-2 py-1.5 text-left hover:bg-surface-2`,"aria-expanded":!n,onClick:()=>u({...l,[e]:!n}),children:[(0,z.jsx)(gx,{open:!n}),(0,z.jsx)(`span`,{className:`truncate text-xs font-semibold text-fg`,children:e}),t&&(0,z.jsx)(`span`,{className:`flex-none rounded-full bg-surface-2 px-[7px] text-[10.5px] leading-[17px] tabular-nums text-fg-2`,children:t.concepts.length})]}),(0,z.jsx)(q,{icon:`picture_as_pdf`,label:`Export this bundle as PDF`,size:`sm`,onClick:()=>void b_(e)}),(0,z.jsx)(q,{icon:`arrow_outward`,label:`Open this bundle on the knowledge screen`,size:`sm`,href:`/knowledge/${encodeURIComponent(e)}`})]}),!n&&t===null&&(0,z.jsx)(nt,{className:`px-[18px] py-1.5`,children:`bundle not found`}),!n&&t?.concepts.map(t=>{let n=`${e}::${t.id}`,r=a===n,i=`/knowledge/${encodeURIComponent(e)}/${t.id.split(`/`).map(encodeURIComponent).join(`/`)}`;return(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`button`,{type:`button`,className:I(`flex w-full cursor-pointer items-center gap-[7px] rounded-xl border-0 py-1.5 pr-2 pl-[18px] text-left text-xs`,r?`bg-accent-soft font-medium text-on-accent-soft`:`bg-transparent text-fg-2 hover:bg-surface-2 hover:text-fg`),"aria-expanded":r,title:t.description||void 0,onClick:()=>b(e,t.id),children:[(0,z.jsx)(gx,{open:r}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title||t.id}),t.stale&&(0,z.jsx)(`span`,{className:`cursor-help`,title:`Past its stale-after date — ask the agent to re-verify it`,children:(0,z.jsx)(J,{tone:`bad`,children:`stale`})})]}),r&&(0,z.jsx)(`div`,{className:`mt-1 mb-2.5 ml-[18px] overflow-hidden rounded-xl border border-line bg-surface-2`,ref:e=>e?.scrollIntoView({block:`nearest`}),children:s[n]===void 0?(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`loading…`}):s[n]===null?(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`could not load concept`}):d===n?(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,z.jsx)(xt,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,"aria-label":`concept`,value:p,rows:Math.min(28,Math.max(10,p.split(`
479
- `).length+2)),onChange:e=>m(e.target.value),spellCheck:!1}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(K,{size:`sm`,variant:`quiet`,disabled:h,onClick:()=>f(null),children:`cancel`}),(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`check`,busy:h,onClick:()=>x(e,t.id),children:h?`saving…`:`save`})]}),_&&(0,z.jsx)(rt,{tone:`bad`,children:_})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-[7px]`,children:[t.type&&(0,z.jsx)(J,{children:t.type}),_x(t)&&(0,z.jsxs)(`span`,{className:`text-[10.5px] tabular-nums text-fg-2`,children:[`updated `,Ke(_x(t))]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`edit`,onClick:()=>{m(s[n].raw),f(n),y(``)},children:`edit`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`open_in_new`,href:`/knowledge/${encodeURIComponent(e)}/${t.id}`,title:`The page in the knowledge section`,children:`page`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,href:i,children:`open ↗`})]}),(0,z.jsx)(`div`,{className:`md-body h-auto overflow-visible px-3.5 pt-3 pb-3.5 text-xs`,dangerouslySetInnerHTML:{__html:fo.sanitize(Mi.parse(s[n].body??``,{async:!1}))}})]})})]},t.id)}),!n&&t&&t.concepts.length===0&&(0,z.jsx)(nt,{className:`px-[18px] py-1.5`,children:`no concepts yet`})]},e)})})]})}function gx({open:e}){return(0,z.jsx)(`span`,{className:I(`inline-grid w-[15px] flex-none text-fg-2 transition-transform`,e&&`rotate-90`),"aria-hidden":!0,children:(0,z.jsx)(B,{name:`chevron_right`,className:`text-[15px]`})})}function _x(e){return[e.generated?.at,...e.verified.map(e=>e.at)].filter(e=>typeof e==`string`&&e.length>0).sort().pop()}function vx({slug:e}){let t=F(`agents.list`,{},{interval:3e4}),n=F(`chats.list`,{}),r=F(`projects.list`,{},{interval:6e4}),i=e=>r?.projects.find(t=>t.slug===e)?.title??e,a=t?.agents.find(t=>t.slug===e),o=a?.name??e,s=(e,t)=>`/agents/${encodeURIComponent(e)}/chat/${t}`;return(0,z.jsx)(Lb,{placeholder:`New session with ${o}`,byDefault:{emoji:a?.emoji||`🤖`,name:o,sub:a?.description,hint:`${a?.harness??`claude`} · its role, knowledge and skills`},agentHint:`opens in that agent's sessions`,exclude:e,placeOf:e=>e.project?`📁 ${i(e.project)}`:void 0,sessions:n?n.chats.filter(t=>t.scope.kind===`agent`&&t.scope.slug===e):null,hrefOf:t=>s(e,t.id),pickProject:`filed`,create:(t,n)=>Rb({agent:`claude`,scope:{kind:`agent`,slug:t??e},...n?{project:n.slug}:{}},r=>n?`/projects/${encodeURIComponent(n.slug)}/chat/${r}`:s(t??e,r))},e)}function yx(){let e=Cx(),t=F(`chats.list`,{}),n=F(`projects.list`,{},{interval:6e4}),r=e=>n?.projects.find(t=>t.slug===e)?.title??e;return(0,z.jsx)(Lb,{placeholder:`New chat with Ralv`,byDefault:{emoji:`🎩`,name:`Ralv`,sub:`chief of staff: knows the workspace, advises, launches things`,hint:`knows the workspace`},defaultControls:(0,z.jsx)(Tx,{...e}),agentHint:`opens in the agent's sessions`,placeOf:e=>Ex(e)?`📁 ${r(Ex(e))}`:void 0,sessions:t?Dx(t.chats):null,hrefOf:Ox,pickProject:`assistant`,create:(t,n)=>{let r=e=>`/projects/${encodeURIComponent(n.slug)}/chat/${e}`;return t?Rb({agent:`claude`,scope:{kind:`agent`,slug:t},...n?{project:n.slug}:{}},n?r:e=>`/agents/${encodeURIComponent(t)}/chat/${e}`):n?Rb({agent:n.harness,scope:{kind:`project`,slug:n.slug}},r):Rb({agent:e.agent,scope:{kind:`kraftwerk`},...e.config?{config:e.config}:{}},e=>`/agents/chats/${e}`)}})}var bx=[`claude`,`codex`,`antigravity`,`pi`],xx=`kw-ralv-start`;function Sx(){try{let e=JSON.parse(localStorage.getItem(xx)??`null`);if(e&&bx.includes(e.agent))return{agent:e.agent,picks:e.picks??{}}}catch{}return{agent:`claude`,picks:{}}}function Cx(){let[e,t]=(0,v.useState)(Sx),[n,r]=(0,v.useState)(null);(0,v.useEffect)(()=>{let t=!0;return A.request(`agents.options`,{query:{agent:e.agent}}).then(n=>{t&&r(n.ok?{agent:e.agent,options:n.data.options}:{agent:e.agent,options:[],error:P(n)})}),()=>{t=!1}},[e.agent]);let i=n?.agent===e.agent?n:null,a=i?.options??[],o=e=>{t(e);try{localStorage.setItem(xx,JSON.stringify(e))}catch{}},s=Object.entries(e.picks).filter(([e,t])=>a.some(n=>n.id===e&&n.type===`select`&&n.choices.some(e=>e.value===t)));return{agent:e.agent,picks:e.picks,options:a,loading:!i,error:i?.error,config:s.length?Object.fromEntries(s):void 0,setAgent:e=>o({agent:e,picks:{}}),pick:(t,n)=>{let r={...e.picks};n?r[t]=n:delete r[t],o({...e,picks:r})}}}var wx=`h-8 w-auto max-w-[220px] rounded-full border-0 bg-transparent text-sm font-medium hover:bg-surface-2`;function Tx({agent:e,picks:t,options:n,loading:r,error:i,setAgent:a,pick:o}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(St,{"aria-label":`agent`,value:e,onChange:e=>a(e.target.value),className:wx,children:bx.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))}),r&&(0,z.jsxs)(`span`,{className:`px-2 text-xs text-fg-2`,children:[`asking `,e,` for its models…`]}),i&&(0,z.jsxs)(`span`,{className:`max-w-[260px] truncate px-2 text-xs text-bad`,title:i,children:[e,` did not answer — its default model`]}),n.map(e=>e.type===`select`?(0,z.jsxs)(St,{"aria-label":e.category===`model`?`model`:`thinking`,value:t[e.id]??``,onChange:t=>o(e.id,t.target.value),className:wx,children:[(0,z.jsxs)(`option`,{value:``,children:[e.category===`model`?`model`:`thinking`,`: default`,e.value==="default"?``:` (${e.choices.find(t=>t.value===e.value)?.name??e.value})`]}),e.choices.filter(e=>e.value!=="default").map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.name},e.value))]},e.id):null)]})}var Ex=e=>e.scope.kind===`project`?e.scope.slug:e.project||void 0,Dx=e=>e.filter(e=>Ex(e)||e.scope.kind!==`agent`&&e.scope.kind!==`channel`),Ox=e=>{let t=Ex(e);return t?`/projects/${encodeURIComponent(t)}/chat/${e.id}`:`/agents/chats/${e.id}`};function kx({agents:e}){return(0,v.useEffect)(()=>{let t=!0,n=()=>H(`/agents/${encodeURIComponent(e[0].slug)}`,{replace:!0});return A.call(`chats.list`).then(r=>{if(!t)return;let i=new Set(e.map(e=>e.slug)),a=r.chats.find(e=>e.scope.kind===`agent`&&i.has(e.scope.slug));a&&a.scope.kind===`agent`?H(`/agents/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`,{replace:!0}):n()}).catch(()=>t&&n()),()=>{t=!1}},[e.map(e=>e.slug).join(`,`)]),(0,z.jsx)(Y,{children:`loading…`})}function Ax(){return(0,z.jsx)(`div`,{className:`empty-action flex justify-center py-16 text-center text-sm text-fg-2`,children:(0,z.jsx)(K,{variant:`primary`,icon:`add`,onClick:()=>H(`/agents/new`),children:`create your first agent`})})}var jx=`---
478
+ `)}var bb=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function xb(e){let t={kind:`custom`,time:`09:00`,day:`1`,minute:`0`},n=e.trim().split(/\s+/);if(n.length!==5)return t;let[r,i,a,o,s]=n,c=(e,t)=>/^\d{1,2}$/.test(e)&&Number(e)<=t;if(a!==`*`||o!==`*`||!c(r,59))return t;if(i===`*`&&s===`*`)return{...t,kind:`hourly`,minute:String(Number(r))};if(!c(i,23))return t;let l=`${i.padStart(2,`0`)}:${r.padStart(2,`0`)}`;return s===`1-5`?{...t,kind:`weekdays`,time:l}:s===`*`?{...t,kind:`daily`,time:l}:/^[0-7]$/.test(s)?{...t,kind:`weekly`,time:l,day:String(Number(s)%7)}:t}function Sb(e){let[t,n]=e.time.split(`:`).map(e=>String(Number(e)||0));return e.kind===`hourly`?`${Number(e.minute)||0} * * * *`:e.kind===`daily`?`${n} ${t} * * *`:e.kind===`weekly`?`${n} ${t} * * ${e.day}`:`${n} ${t} * * 1-5`}function Cb(e){let t=xb(e);return t.kind===`weekdays`?`weekdays ${t.time}`:t.kind===`daily`?`daily ${t.time}`:t.kind===`weekly`?`${bb[Number(t.day)]}s ${t.time}`:t.kind===`hourly`?`hourly at :${t.minute.padStart(2,`0`)}`:e.trim()||`no schedule`}var wb=[{id:`create`,label:`Create`},{id:`results`,label:`Results`},{id:`context`,label:`Context`}],Tb=new Set,Eb={workflows:`describe a workflow and Ralv makes it`,skills:`describe a skill and Ralv makes it`,runs:`run a workflow`,tasks:`add a task to a board`},Db=[{id:`chats`,group:`create`,label:`Chats`,one:`Chat`,icon:`chat`,hue:`#4f46e5`,newHref:`/agents/chats`,newTitle:`new chat`},{id:`workflows`,group:`create`,label:`Workflows`,one:`Workflow`,icon:`account_tree`,hue:`#0e7490`,newHref:`/agents/chats`,newTitle:`ask Ralv to make a workflow`},{id:`skills`,group:`create`,label:`Skills`,one:`Skill`,icon:`extension`,hue:`#9333ea`,newHref:`/agents/chats`,newTitle:`ask Ralv to make a skill`},{id:`routines`,group:`create`,label:`Routines`,one:`Routine`,icon:`schedule`,hue:`#b45309`,newHref:`/?kind=routines&open=routines%3A_%3Anew`},{id:`boards`,group:`create`,label:`Boards`,one:`Board`,icon:`view_kanban`,hue:`#15803d`,newHref:`/boards/new`},{id:`runs`,group:`results`,label:`Workflow runs`,one:`Workflow run`,icon:`play_circle`,hue:`#0f766e`,newHref:`/?kind=workflows`,newTitle:`pick a workflow to run`},{id:`tasks`,group:`results`,label:`Tasks`,one:`Task`,icon:`task_alt`,hue:`#166534`,newHref:`/?kind=boards`,newTitle:`pick a board to add a task`},{id:`presentations`,group:`results`,label:`Presentations`,one:`Slides`,icon:`slideshow`,hue:`#c2410c`,newHref:`/presentations/new`},{id:`vibeables`,group:`results`,label:`Apps`,one:`App`,icon:`web`,hue:`#2563eb`,newHref:`/vibeables`},{id:`knowledge`,group:`context`,label:`Knowledge`,one:`Knowledge bundle`,icon:`menu_book`,hue:`#4d7c0f`,newHref:`/knowledge/new`},{id:`repos`,group:`context`,label:`Repos`,one:`Repository`,icon:`source`,hue:`#475569`,newHref:`/repos`,newTitle:`clone a repository`},{id:`contacts`,group:`context`,label:`Contacts`,one:`Contact`,icon:`person`,hue:`#7c3aed`,newHref:`/contacts/new`},{id:`places`,group:`context`,label:`Places`,one:`Place`,icon:`location_on`,hue:`#be123c`,newHref:`/places/new`},{id:`events`,group:`context`,label:`Events`,one:`Event`,icon:`event`,hue:`#a16207`,newHref:`/events/new`}],Ob=encodeURIComponent,kb=(e,t)=>t===`chats`||t===`workflows`||t===`runs`||t===`routines`||t===`knowledge`||t===`skills`||!!e[t===`tasks`?`boards`:t],Ab=e=>Db.find(t=>t.id===e);function jb(){let[e,t]=ne().split(`?`),n=e.split(`/`).filter(Boolean),r=n[0]===`projects`&&n.length===2&&n[1]!==`new`?decodeURIComponent(n[1]):void 0,i=r?`/projects/${Ob(r)}`:`/`,a=new URLSearchParams(t??``),o=a.get(`kind`);return{kind:Db.some(e=>e.id===o)?o:`all`,open:a.get(`open`)??void 0,project:r,href:({kind:e,open:t})=>{let n=new URLSearchParams;e&&e!==`all`&&n.set(`kind`,e),t&&n.set(`open`,t);let r=n.toString();return r?`${i}?${r}`:i}}}var Mb=new Set([`chats`,`routines`,`boards`,`tasks`,`presentations`,`runs`,`workflows`,`knowledge`,`vibeables`,`repos`,`contacts`,`places`,`events`]),Nb={knowledge:`knowledge`,vibeables:`vibeables`,repos:`repos`,workflows:`workflows`,contacts:`contacts`,places:`places`,events:`events`};function Pb(e){let t=De(),n=F(`chats.list`,{}),r=F(`agents.list`,{},{interval:3e4})?.agents??[],i=F(`workflows.list`,{},{interval:3e4}),a=F(`runs.list`,{},{fast:!0}),o=F(`knowledge.list`,{},{interval:3e4}),s=F(`routines.list`,{},{interval:3e4}),c=F(`skills.list`,{},{interval:3e4}),l=F(`repos.list`,t.repos?{}:null,{interval:3e4}),u=F(`vibeables.list`,t.vibeables?{}:null,{interval:3e4}),d=F(`presentations.list`,t.presentations?{query:{all:`1`}}:null,{interval:3e4}),f=F(`boards.list`,t.boards?{query:{all:`1`}}:null,{interval:3e4}),p=F(`tasks.list`,t.boards?{}:null,{interval:3e4}),m=F(`contacts.list`,t.contacts?{}:null,{interval:3e4}),h=F(`places.list`,t.places?{}:null,{interval:3e4}),g=F(`events.list`,t.events?{}:null,{interval:3e4}),_=F(`projects.list`,t.projects?{}:null,{interval:6e4}),v=e=>e?_?.projects.find(t=>t.slug===e)?.title??e:void 0,y=[...(n?.chats??[]).map(e=>({key:`chats:${e.id}`,kind:`chats`,title:e.title||`New chat`,href:$y(e),project:e.scope.kind===`project`?e.scope.slug:e.project,updatedAt:e.updatedAt,live:e.awaitingApproval?`waiting`:e.busy?`working`:void 0,when:e.awaitingApproval?`needs approval`:e.busy?`working`:void 0,sub:e.scope.kind===`project`?`assistant`:eb({...e,project:void 0},r,e=>e)})),...(i?.workflows??[]).map(e=>({key:`workflows:${e.slug}`,kind:`workflows`,title:e.name||e.slug,href:`/workflows/${Ob(e.slug)}`,updatedAt:e.updatedAt,broken:!!e.error})),...(a?.runs??[]).map(e=>{let t=!!e.awaitingDecision&&e.status!==`ok`&&e.status!==`aborted`,n=e.status===`running`;return{key:`runs:${e.id}`,kind:`runs`,title:e.workflow??`unknown workflow`,href:`/runs/${Ob(e.id)}`,updatedAt:e.updatedAt,live:t?`waiting`:n?`working`:void 0,since:n&&!t?e.startedAt:void 0,when:t?`decision needed`:n?e.currentPhase??`running`:e.status===`ok`?`Ran ${G(e.updatedAt)}`:`${e.status===`aborted`?`Stopped`:`Failed`} ${G(e.updatedAt)}`,broken:e.status===`failed`,sub:e.request||void 0}}),...(o?.bundles??[]).map(e=>({key:`knowledge:${e.name}`,kind:`knowledge`,title:e.name,href:`/knowledge/${Ob(e.name)}`,updatedAt:e.updatedAt,sub:`${e.concepts} concept${e.concepts===1?``:`s`}`})),...(s?.routines??[]).map(e=>({key:`routines:${e.owner}:${e.id}`,kind:`routines`,title:e.name,...e.owner===`_`?{}:{href:`/agents/${Ob(e.owner)}/info`},project:e.project,updatedAt:e.lastRunAt,when:pb(e),broken:!!e.lastError,sub:fb(e)})),...(c?.skills??[]).filter(e=>e.source===`workspace`||e.source===`project`).map(e=>({key:`skills:${e.name}`,kind:`skills`,title:`/${e.name}`,href:`/skills/${Ob(e.name)}`,updatedAt:e.updatedAt,sub:e.description||void 0})),...(l?.repos??[]).map(e=>({key:`repos:${e.slug}`,kind:`repos`,title:e.slug,href:`/repos/${Ob(e.slug)}`,updatedAt:e.updatedAt??e.committedAt,broken:!!e.error,sub:[e.branch,e.dirty?`${e.dirty} changed`:e.ahead?`${e.ahead} to push`:e.behind?`${e.behind} behind`:e.error?``:`clean`].filter(Boolean).join(` · `)})),...(u?.vibeables??[]).map(e=>({key:`vibeables:${e.slug}`,kind:`vibeables`,title:e.slug,href:`/vibeables/${Ob(e.slug)}`,updatedAt:e.updatedAt,broken:!!e.configError})),...(d?.presentations??[]).map(e=>({key:`presentations:${e.project??``}:${e.name}`,kind:`presentations`,title:e.title,href:e.project?`/projects/${Ob(e.project)}/presentations/${Ob(e.name)}`:`/presentations/${Ob(e.name)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.error})),...(f?.boards??[]).map(e=>({key:`boards:${e.project??``}:${e.board}`,kind:`boards`,title:e.title,href:e.project?`/projects/${Ob(e.project)}/boards/${Ob(e.board)}`:`/boards/${Ob(e.board)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.configError})),...(p?.tasks??[]).map(e=>({key:`tasks:${e.project??``}:${e.board}:${e.slug}`,kind:`tasks`,title:e.title,href:`${Us({project:e.project,board:e.board})}/${Ob(e.slug)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.configError,sub:[`#${e.number}`,e.boardTitle,e.column].filter(Boolean).join(` · `)})),...[[`contacts`,m],[`places`,h],[`events`,g]].flatMap(([e,t])=>(t?.items??[]).map(t=>{let n=t;return{key:`${e}:${t.slug}`,kind:e,title:t.title||t.slug,href:`/${e}/${Ob(t.slug)}`,updatedAt:t.updatedAt,broken:!!t.configError,lat:n.lat,lng:n.lng,start:n.start,end:n.end}}))].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``)),b=F(`projects.get`,e?{slug:e}:null,{interval:3e4})?.links,x=(e,t)=>{let n=Nb[e];return!!n&&!!b?.[n]?.some(e=>e.slug===t)};return e?{items:y.filter(t=>{if(t.project===e)return!0;if(t.project)return!1;let n=t.key.slice(t.kind.length+1);return t.kind===`runs`?!!b?.workflows.some(e=>t.title===e.slug||n.endsWith(`-${e.slug}`)):x(t.kind,n)}),loading:!n&&!p&&!d&&!f&&!b,projectTitle:()=>void 0}:{items:y,loading:!n&&!i&&!a&&!s&&!o&&!c&&!l&&!u&&!d&&!f&&!m&&!h&&!g,projectTitle:v}}function Fb({title:e=`Home`}){let t=De(),{kind:n,open:r,project:i,href:a}=jb(),o=Db.filter(e=>kb(t,e.id)&&(!i||Mb.has(e.id))),s=i?`/projects/${Ob(i)}`:``,c=e=>i?e.id===`chats`?`${s}/chat/new`:e.id===`boards`||e.id===`presentations`?`${s}/${e.id}/new`:e.id===`routines`?a({kind:`routines`,open:`routines:_:new`}):e.id===`runs`?a({kind:`workflows`}):e.id===`tasks`?a({kind:`boards`}):e.newHref:e.newHref,l=e=>H(a({kind:e,open:e===`all`||r?.startsWith(`${e}:`)?r:void 0}),{replace:!0}),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),g=e=>{let t=Gt(e),r=/^\/runs\/([^/?]+)$/.exec(e)?.[1];return!t&&!r?!1:(H(a({kind:n,open:t?`chats:${t}`:`runs:${decodeURIComponent(r)}`})),!0)},{items:_,loading:y,projectTitle:b}=Pb(i),x=u.trim().toLowerCase(),S=_.filter(e=>(n===`all`||e.kind===n)&&(!x||`${e.title} ${b(e.project)??``}`.toLowerCase().includes(x))),C=o.length>0&&y,w=e=>e.live===`waiting`?0:e.live===`working`?1:2,T=[...S].sort((e,t)=>w(e)-w(t)),E=T.filter(e=>e.live).length;return(0,z.jsxs)(`div`,{className:`artifacts-screen mx-auto flex w-full max-w-[920px] flex-col gap-6 px-6 pt-8 pb-12 max-[800px]:px-4`,children:[(0,z.jsx)(`h1`,{className:`m-0 text-3xl font-semibold tracking-[-0.02em] text-fg`,children:e}),m&&(0,z.jsx)(Jt.Provider,{value:g,children:(0,z.jsx)(Uy,{kind:m,project:i,onClose:()=>h(null),onMade:e=>(Tb.add(e),H(a({kind:n,open:e})))})}),o.length>0&&(0,z.jsx)(`section`,{className:`flex flex-col gap-4`,"aria-label":`kinds`,children:wb.filter(e=>o.some(t=>t.group===e.id)).map(e=>(0,z.jsxs)(`div`,{role:`group`,"aria-label":e.label,className:`flex flex-col gap-2`,children:[(0,z.jsx)(it,{children:e.label}),(0,z.jsx)(`div`,{className:`grid grid-cols-6 gap-3 max-[900px]:grid-cols-4 max-[600px]:grid-cols-3`,children:o.filter(t=>t.group===e.id).map(e=>{let t=n===e.id;return(0,z.jsxs)(`div`,{className:`relative flex flex-col gap-1.5 text-fg`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-pressed":t,"aria-label":`show only ${e.label.toLowerCase()}`,title:t?`show everything`:`show only ${e.label.toLowerCase()}`,className:I(`grid h-[60px] cursor-pointer place-items-center rounded-2xl outline-offset-2 transition-[filter,box-shadow] hover:brightness-95`,t&&`shadow-[0_0_0_2px_currentColor]`,n!==`all`&&!t&&`opacity-55`),style:{background:`color-mix(in srgb, ${e.hue} 20%, var(--color-surface))`,color:e.hue},onClick:()=>l(t?`all`:e.id),children:(0,z.jsx)(B,{name:e.icon,className:`text-[28px]`})}),By.has(e.id)?(0,z.jsx)(`button`,{type:`button`,"aria-label":`new ${e.one.toLowerCase()}`,title:Eb[e.id]??`new ${e.one.toLowerCase()}`,className:`absolute top-1 right-1 grid size-6 cursor-pointer place-items-center rounded-full border-0 bg-transparent p-0 opacity-70 hover:bg-surface hover:opacity-100`,style:{color:e.hue},onClick:()=>h(e.id),children:(0,z.jsx)(B,{name:`add`,className:`ms-sm`})}):(0,z.jsx)(U,{href:c(e),"aria-label":`new ${e.one.toLowerCase()}`,title:e.newTitle??`new ${e.one.toLowerCase()}`,className:`absolute top-1 right-1 grid size-6 place-items-center rounded-full no-underline opacity-70 hover:bg-surface hover:opacity-100`,style:{color:e.hue},children:(0,z.jsx)(B,{name:`add`,className:`ms-sm`})}),(0,z.jsx)(`span`,{className:I(`line-clamp-2 text-center text-xs leading-tight [overflow-wrap:anywhere]`,t&&`font-medium`),children:e.label})]},e.id)})})]},e.id))}),(0,z.jsxs)(`div`,{className:`-mb-3 flex items-center gap-2`,children:[(0,z.jsx)(`h2`,{className:`m-0 flex-1 text-sm font-normal text-fg-2`,children:n===`all`?`Everything`:Ab(n).label}),f?(0,z.jsx)(`input`,{autoFocus:!0,type:`search`,"aria-label":`search home`,placeholder:`Search`,value:u,onChange:e=>d(e.target.value),onBlur:()=>!u&&p(!1),className:`w-56 rounded-full border border-line bg-surface px-3 py-1.5 text-sm text-fg outline-none focus:border-accent`}):(0,z.jsx)(`button`,{type:`button`,"aria-label":`search home`,className:`grid size-8 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>p(!0),children:(0,z.jsx)(B,{name:`search`})})]}),(0,z.jsxs)(`section`,{className:`flex flex-col`,"aria-label":`everything`,children:[o.length===0&&(0,z.jsxs)(`p`,{className:`m-0 py-3 text-sm text-fg-2`,children:[`Nothing to list yet: turn on apps, presentations, boards, contacts, places or events in `,(0,z.jsx)(U,{href:`/settings`,className:`text-accent`,children:`settings`}),`.`]}),!C&&o.length>0&&S.length===0&&(0,z.jsx)(`p`,{className:`m-0 py-3 text-sm text-fg-2`,children:x?`Nothing matches “${u.trim()}”.`:`Nothing here yet — make something above.`}),T.map((e,t)=>{let i=Ab(e.kind),o=b(e.project),s=E===0?void 0:t===0?`Now`:t===E?`Earlier`:void 0;return(0,z.jsxs)(v.Fragment,{children:[s&&(0,z.jsx)(it,{className:I(`block px-2 pb-1`,t>0&&`pt-4`),children:s}),(0,z.jsxs)(U,{"data-live":e.live,href:a({kind:n,open:e.key}),"data-artifact":e.kind,"data-key":e.key,"aria-current":r===e.key?`true`:void 0,className:`artifact-row flex items-center gap-3 rounded-xl px-2 py-2.5 text-fg no-underline hover:bg-surface-2 aria-[current=true]:bg-surface-2`,children:[(0,z.jsx)(`span`,{className:`grid size-9 flex-none place-items-center rounded-lg`,style:{background:`color-mix(in srgb, ${i.hue} 16%, var(--color-surface))`,color:i.hue},title:i.one,children:(0,z.jsx)(B,{name:i.icon,className:`ms-sm`})}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(`span`,{className:I(`truncate text-[15px]`,e.broken&&`text-on-bad-soft`),children:e.title}),(0,z.jsxs)(`span`,{className:`truncate text-xs text-fg-2`,children:[i.one,e.sub?` · ${e.sub}`:``,o?` · 📁 ${o}`:``,e.broken&&e.kind!==`runs`?e.kind===`routines`?` · last run failed`:` · unreadable`:``]})]}),e.live?(0,z.jsxs)(`span`,{className:I(`flex flex-none items-center gap-1.5 text-sm tabular-nums`,e.live===`waiting`?`text-accent`:`text-fg-2`),children:[(0,z.jsx)(et,{tone:e.live===`waiting`?`ask`:`working`}),e.when,e.since&&(0,z.jsx)(qe,{since:e.since})]}):e.when?(0,z.jsx)(`span`,{className:`flex-none text-sm text-fg-2 tabular-nums`,title:e.kind===`routines`?e.updatedAt?`last run ${e.updatedAt}`:`never ran`:e.updatedAt,children:e.when}):e.updatedAt&&(0,z.jsxs)(`span`,{className:`flex-none text-sm text-fg-2 tabular-nums`,title:e.updatedAt,children:[`Edited `,G(e.updatedAt)]})]})]},e.key)})]})]})}function Ib(){let{kind:e,open:t,project:n,href:r}=jb(),{items:i,loading:a}=Pb(n),o=`routines:_:new`,s=t===o?{key:o,kind:`routines`,title:`New routine`}:t?i.find(e=>e.key===t)??(()=>{if(!t)return;if(t.startsWith(`chats:`))return{key:t,kind:`chats`,title:`New chat`};if(t.startsWith(`runs:`))return{key:t,kind:`runs`,title:`Workflow run`};let e=Tb.has(t)?Db.find(e=>t.startsWith(`${e.id}:`)):void 0;return e?{key:t,kind:e.id,title:`New ${e.one.toLowerCase()}`}:void 0})():void 0,c=t=>{let n=Gt(t),i=/^\/runs\/([^/?]+)$/.exec(t)?.[1];return!n&&!i?!1:(H(r({kind:e,open:n?`chats:${n}`:`runs:${decodeURIComponent(i)}`})),!0)},l=s?Ab(s.kind):void 0,[,u=``,d=``,f=``]=(t??``).split(`:`),p=e===`places`||s?.kind===`places`,m=i.filter(e=>e.kind===`places`),h=m.flatMap(e=>e.lat!==void 0&&e.lng!==void 0?[{slug:e.key.slice(7),title:e.title,lat:e.lat,lng:e.lng}]:[]),g=m.length-h.length,_=r({kind:e}),v=e===`events`||s?.kind===`events`,y=i.flatMap(e=>e.kind===`events`&&e.start?[{slug:e.key.slice(7),title:e.title,start:String(e.start),end:e.end?String(e.end):void 0}]:[]),b=s&&l&&(0,z.jsxs)(`div`,{className:`flex flex-none items-center gap-2.5 border-b border-line px-3 py-2.5`,children:[(0,z.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-lg`,style:{background:`color-mix(in srgb, ${l.hue} 16%, var(--color-surface))`,color:l.hue},title:l.one,children:(0,z.jsx)(B,{name:l.icon,className:`ms-sm`})}),(0,z.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 truncate text-base font-semibold text-fg`,title:s.title,children:s.title}),s.href&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`open_in_new`,href:s.href,title:`open the ${l.one.toLowerCase()} where it lives`,children:`open`}),(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`close`,href:_,"aria-label":`close the preview`})]});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`space-title flex min-w-0 items-center gap-2 px-1`}),(0,z.jsx)(`aside`,{className:`ctx artifact-preview`,"aria-label":`Preview`,"data-open":s?.key,children:v?(0,z.jsxs)(z.Fragment,{children:[b,(0,z.jsx)(`div`,{className:I(`flex min-h-0 flex-col p-3`,s?`h-[52%] flex-none`:`flex-1`),children:(0,z.jsx)(xs,{events:y,selected:s?u:void 0,onPick:t=>H(r({kind:e,open:`events:${t}`}))})}),s?(0,z.jsx)(`div`,{className:`ctx-body ctx-embed border-t border-line`,children:(0,z.jsx)(vg,{kind:`events`,slug:u})},s.key):(0,z.jsx)(`p`,{className:`m-0 flex-none px-3 pb-3 text-sm text-fg-2`,children:`Pick an event on the left or in the calendar to see its details.`})]}):p?(0,z.jsxs)(z.Fragment,{children:[b,(0,z.jsxs)(`div`,{className:I(`flex min-h-0 flex-col gap-1.5 p-3`,s?`h-[48%] flex-none`:`flex-1`),children:[(0,z.jsx)(gs,{places:h,selected:s?u:void 0,onPick:t=>H(r({kind:e,open:`places:${t}`}))}),(g>0||s&&s.lat===void 0)&&(0,z.jsx)(`p`,{className:`m-0 text-xs text-fg-2`,children:s&&s.lat===void 0?`This place has no coordinates yet: add latitude and longitude below to put it on the map.`:`${g} of ${m.length} places have no coordinates and are not on the map.`})]}),s?(0,z.jsx)(`div`,{className:`ctx-body ctx-embed border-t border-line`,children:(0,z.jsx)(vg,{kind:`places`,slug:u})},s.key):(0,z.jsx)(`p`,{className:`m-0 flex-none px-3 pb-3 text-sm text-fg-2`,children:`Pick a place on the left or a dot on the map to zoom in and see its details.`})]}):!s||!l?(0,z.jsx)(Y,{icon:`preview`,className:`my-auto`,children:t&&!a?`That one is gone.`:`Pick something on the left to see it here.`}):(0,z.jsxs)(z.Fragment,{children:[b,s.kind===`chats`?(0,z.jsx)(`div`,{className:`artifact-chat flex min-h-0 flex-1 flex-col overflow-hidden px-5 pb-3`,children:(0,z.jsx)(Ko,{id:u},s.key)}):s.kind===`vibeables`?(0,z.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,z.jsx)(en,{slug:u},s.key)}):(0,z.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,z.jsxs)(Jt.Provider,{value:c,children:[s.kind===`workflows`&&(0,z.jsx)(Lb,{slug:u}),s.kind===`runs`&&(0,z.jsx)(`div`,{className:`p-3`,children:(0,z.jsx)(Rg,{id:u})}),s.kind===`routines`&&(0,z.jsx)(vb,{owner:u,id:d,onOpen:t=>H(r({kind:e,open:t}),{replace:!0})}),s.kind===`knowledge`&&(0,z.jsx)(zb,{name:u}),s.kind===`skills`&&(0,z.jsx)(Ly,{name:u}),s.kind===`repos`&&(0,z.jsx)(jy,{slug:u,embedded:!0}),s.kind===`presentations`&&(0,z.jsx)(ag,{project:u||void 0,name:d}),s.kind===`boards`&&(0,z.jsx)(Rb,{project:u||void 0,board:d,kind:e,href:r}),s.kind===`tasks`&&(0,z.jsx)(`div`,{className:`p-3`,children:(0,z.jsx)(ic,{project:u||void 0,board:d,task:f})}),s.kind===`contacts`&&(0,z.jsx)(vg,{kind:s.kind,slug:u})]})},s.key)]})})]})}function Lb({slug:e}){let[t,n]=(0,v.useState)(`overview`),r=`/workflows/${Ob(e)}`;return(0,z.jsx)(_e.Provider,{value:e=>{if(e!==r&&!e.startsWith(`${r}/`))return!1;let t=e.slice(r.length+1);return n(t===`details`||t===`runs`?t:`overview`),!0},children:(0,z.jsx)(p_,{slug:e,tab:t},e)})}function Rb({project:e,board:t,kind:n,href:r}){let i=`${Us({project:e,board:t})}/`;return(0,z.jsx)(_e.Provider,{value:a=>{let o=a.startsWith(i)?a.slice(i.length):``;return!o||o.includes(`/`)||o===`settings`?!1:(H(r({kind:n===`boards`?`all`:n,open:`tasks:${e??``}:${t}:${decodeURIComponent(o)}`})),!0)},children:(0,z.jsx)(fc,{project:e,board:t})})}function zb({name:e}){let[t,n]=(0,v.useState)(void 0),r=`/knowledge/${Ob(e)}`;return(0,z.jsx)(_e.Provider,{value:e=>{if(e!==r&&!e.startsWith(`${r}/`))return!1;let t=e.slice(r.length+1);return n(t?t.split(`/`).map(decodeURIComponent).join(`/`):void 0),!0},children:(0,z.jsx)(F_,{name:e,conceptId:t},e)})}function Bb({placeholder:e,byDefault:t,firstGroup:n,agentHint:r,exclude:i,placeOf:a,sessions:o,hrefOf:s,create:c,pickProject:l,defaultControls:u,children:d}){let f=F(`agents.list`,{},{interval:3e4}),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),_=Vt(),y=l?_.find(e=>e.slug===h):void 0;y&&l===`assistant`&&(t={...He,sub:`the assistant of ${y.title}`,hint:`in ${y.title}`});let[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(``),E=(0,v.useRef)(null);(0,v.useEffect)(()=>{document.querySelector(`[role=dialog]`)||E.current?.focus()},[]);let D=(f?.agents??[]).filter(e=>!e.archived),O=D.filter(e=>e.slug!==i),k=n?O.filter(e=>n.slugs.has(e.slug)):[],ee=n?O.filter(e=>!n.slugs.has(e.slug)):O,A=p?O.find(e=>e.slug===p):void 0,j=e=>{let t=D.find(t=>t.slug===e);return t?`${t.emoji||`🤖`} ${t.name}`:e},M=async e=>{if(S)return;C(!0),T(``);let t=await c(p||void 0,y);if(`error`in t)return C(!1),T(t.error),!1;let n=await qt(t.id,b,e);if(n)return C(!1),T(n),!1;H(t.href)},N=A?`${A.emoji||`🤖`} ${A.name}`:`${t.emoji} ${t.name}`,P=(e,t)=>(0,z.jsx)(Ub,{emoji:e.emoji||`🤖`,name:e.name,sub:e.description,on:p===e.slug,onClick:()=>{m(e.slug),t()}},e.slug);return(0,z.jsxs)(`div`,{className:`session-home mx-auto flex w-full max-w-[760px] animate-rise flex-col gap-7 px-6 pt-8 pb-12 max-[800px]:px-3 max-[800px]:pt-4`,children:[(0,z.jsx)(Rt,{label:`start a session`,value:b,onChange:x,inputRef:E,inputLabel:`new session`,placeholder:e,onSend:M,sendLabel:`start session`,busy:S,error:w,skills:!0,who:p,onWho:e=>O.some(t=>t.slug===e)&&m(e),attach:!0,hint:A?r??``:t.hint??``,controls:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Nt,{className:`max-h-[50vh] overflow-y-auto`,trigger:({open:e,toggle:t})=>(0,z.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":e,"aria-label":`session with`,className:`inline-flex cursor-pointer items-center gap-1 rounded-full border-0 bg-transparent px-2.5 py-1 text-sm font-medium text-fg transition-colors hover:bg-surface-2`,onClick:t,children:[N,(0,z.jsx)(B,{name:`expand_more`,className:`ms-sm text-fg-2`})]}),children:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Ub,{emoji:t.emoji,name:`${t.name} (default)`,sub:t.sub,on:!p,onClick:()=>{m(``),e()}}),k.length>0&&n&&(0,z.jsx)(Hb,{children:n.label}),k.map(t=>P(t,e)),ee.length>0&&(0,z.jsx)(Hb,{children:k.length>0?`other agents`:`agents`}),ee.map(t=>P(t,e))]})}),l&&(0,z.jsx)(Ht,{value:h,onChange:g,projects:_}),!A&&!y&&u]})}),d,(0,z.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`recent sessions`,children:[(0,z.jsx)(`h2`,{className:`m-0 px-3 pb-1 text-sm font-medium text-fg-2`,children:`Recents`}),o&&o.length===0&&(0,z.jsx)(`p`,{className:`m-0 px-3 text-sm text-fg-2`,children:`No sessions yet — start one above.`}),(o??[]).map(e=>(0,z.jsx)(Wb,{chat:e,href:s(e),place:a?.(e),who:e.scope.kind===`channel`?`👥 coworkers · #${e.scope.slug}`:e.scope.kind===`agent`?j(e.scope.slug):e.scope.kind===`project`?`${He.emoji} ${He.name}`:`${t.emoji} ${t.name}`},e.id))]})]})}async function Vb(e,t){let n=await A.request(`chats.create`,{body:e});return n.ok?{id:n.data.id,href:t(n.data.id)}:{error:P(n)}}function Hb({children:e}){return(0,z.jsx)(`div`,{className:`mt-1.5 border-t border-line px-2 pt-2 pb-1 text-2xs font-semibold tracking-[0.06em] text-fg-2 uppercase`,children:e})}function Ub({emoji:e,name:t,sub:n,on:r,onClick:i}){return(0,z.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,className:`flex w-full cursor-pointer items-start gap-2.5 rounded-md px-2 py-1.5 text-left hover:bg-surface-2`,onClick:i,children:[(0,z.jsx)(`span`,{className:`w-5 flex-none text-center text-base leading-5`,children:e}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(`span`,{className:`text-sm text-fg`,children:t}),n&&(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:n})]}),r&&(0,z.jsx)(B,{name:`check`,className:`ms-sm mt-0.5 text-accent`})]})}function Wb({chat:e,href:t,who:n,place:r}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),c=xn(e,`new session`);return i?(0,z.jsx)(`div`,{className:`px-1.5 py-1`,children:(0,z.jsx)(yn,{name:c,className:`w-full text-base`,onDone:t=>{a(!1),t&&A.request(`chats.rename`,{id:e.id,body:{title:t}}).catch(()=>null)}})}):(0,z.jsxs)(`div`,{className:`recent-session group/recent relative flex items-center rounded-card transition-colors hover:bg-surface-2 has-[[aria-expanded=true]]:bg-surface-2`,"data-chat":e.id,children:[(0,z.jsxs)(U,{href:t,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-2.5 text-[15px] text-fg no-underline`,children:[(e.busy||e.awaitingApproval)&&(0,z.jsx)(et,{tone:e.awaitingApproval?`bad`:`working`,title:e.awaitingApproval?`waiting for your approval`:`working`}),e.scope.kind===`channel`&&(0,z.jsx)(B,{name:`forum`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`truncate`,children:c}),r&&(0,z.jsx)(`span`,{className:`recent-place flex-none truncate text-xs text-fg-2`,children:r})]}),(0,z.jsx)(`span`,{className:`recent-agent flex-none truncate rounded-full bg-surface-2 px-2 py-0.5 text-xs text-fg-2 max-w-[40%]`,title:`session with ${n}`,children:n}),(0,z.jsx)(`span`,{className:`flex-none px-3 text-sm text-fg-2 tabular-nums group-hover/recent:hidden group-has-[[aria-expanded=true]]/recent:hidden`,title:e.updatedAt,children:G(e.updatedAt)}),(0,z.jsx)(`span`,{className:`hidden flex-none pr-1.5 group-hover/recent:inline-flex group-has-[[aria-expanded=true]]/recent:inline-flex pointer-coarse:inline-flex`,children:(0,z.jsx)(Nt,{align:`end`,trigger:({open:e,toggle:t})=>(0,z.jsx)(q,{icon:`more_horiz`,size:`sm`,label:`more for ${c}`,"aria-haspopup":`menu`,"aria-expanded":e,onClick:()=>{s(!1),t()}}),children:t=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(bn,{icon:`edit`,label:`rename`,onClick:()=>{t(),a(!0)}}),(0,z.jsx)(bn,{icon:`delete`,label:o?`confirm delete`:`delete`,danger:!0,onClick:()=>{if(!o)return s(!0);t(),A.request(`chats.delete`,{id:e.id}).catch(()=>null)}})]})})})]})}var Gb=[`active`,`paused`,`done`,`archived`],Kb={active:`working`,paused:`idle`,done:`ok`,archived:`idle`},qb={"my-netnode":`my.netnode.ch`,"google-drive":`Google Drive`,github:`GitHub`,bitbucket:`Bitbucket`,notion:`Notion`,slack:`Slack`,crm:`CRM`,newsletter:`Newsletter tool`,calendar:`Calendar`,"google-maps":`Google Maps`,url:`Link`},Jb=e=>qb[e]??e,Yb=[{id:`claude`,label:`claude`,hint:`Claude Code via ACP`},{id:`codex`,label:`codex`,hint:`Codex (ChatGPT) via ACP`},{id:`pi`,label:`pi`,hint:`pi coding agent`},{id:`antigravity`,label:`antigravity`,hint:`Google Antigravity (agy) via ACP`}],Xb=e=>[e.harness,e.model,e.effort?`effort ${e.effort}`:``].filter(Boolean).join(` · `),Zb=(e,t)=>(e??[]).filter(e=>e.scope.kind===`project`&&e.scope.slug===t||e.project===t),Qb=(e,t)=>`/projects/${encodeURIComponent(t)}/chat/${e.id}`;async function $b(e,t,n=!1){let r=await A.request(`projects.save`,{slug:e,body:t,keepalive:n});if(!r.ok)throw Error(P(r));return r.data}function ex({seg:e}){let t=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`project`:`home`,r=n===`chat`?e[2]:void 0,[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),c=(0,v.useCallback)(async()=>{try{let e=await A.request(`projects.list`);if(!e.ok)throw Error(`HTTP ${e.status}`);a(e.data),s(``)}catch(e){s(e.message||`could not load projects`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await c(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[c]),(0,v.useEffect)(()=>{c()},[t,n,c]);let l=i?.projects??[],u=t?l.find(e=>e.slug===t):void 0,d=[...l].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))[0]?.slug;(0,v.useEffect)(()=>{n===`home`&&d&&H(`/projects/${encodeURIComponent(d)}`,{replace:!0})},[n,d]);let f;return f=i&&!i.enabled?(0,z.jsx)(Y,{icon:`folder_off`,children:i.error&&!/are off/.test(i.error)?(0,z.jsx)(`span`,{className:`text-bad`,children:i.error}):(0,z.jsxs)(z.Fragment,{children:[`Projects are off. Turn them on in `,(0,z.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,z.jsx)(`code`,{children:`projects:`}),` block to kraftwerk.yml.`]})}):i?n===`new`||n===`home`&&l.length===0?(0,z.jsx)(nx,{root:i.root,onCreated:c}):n===`home`?(0,z.jsx)(Y,{children:`loading…`}):t&&!u?(0,z.jsxs)(Y,{icon:`folder_off`,children:[`no project named `,t]}):n===`chat`&&t&&r===`new`?(0,z.jsx)(rx,{slug:t,title:u?.title??t},t):n===`chat`&&t&&r?(0,z.jsx)(`div`,{className:`chat-main`,children:(0,z.jsx)(ix,{chatId:r,title:u?.title??t,goal:u?.goal},r)}):n===`info`&&t?(0,z.jsx)(cx,{slug:t,onChanged:c},t):t?(0,z.jsx)(Fb,{title:u?.title??t},t):(0,z.jsx)(Y,{children:`loading…`}):(0,z.jsx)(Y,{children:`loading…`}),(0,z.jsxs)(`div`,{className:`runs-screen agents-screen projects-screen ${t&&u?`in-project`:``}`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`projects`,count:i?.enabled?l.length:void 0,action:i?.enabled&&(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,href:`/projects/new`,children:`new`})}),(0,z.jsxs)(jt,{children:[l.map(e=>(0,z.jsx)(gt,{href:`/projects/${encodeURIComponent(e.slug)}`,active:e.slug===t,size:`sm`,innerProps:{"data-project":e.slug},leading:(0,z.jsx)(et,{tone:e.configError?`bad`:Kb[e.status],title:e.status}),title:e.title,sub:e.configError?e.configError:e.goal||e.status,subTone:e.configError?`bad`:`plain`,meta:e.updatedAt&&(0,z.jsx)(`span`,{title:e.updatedAt,children:G(e.updatedAt)})},e.slug)),i&&i.enabled&&l.length===0&&(0,z.jsx)(Mt,{children:`no projects yet`}),o&&(0,z.jsx)(rt,{tone:`bad`,children:o})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:f})]})}function tx(){let e=F(`projects.list`,{},{interval:6e4});return e&&!e.enabled?(0,z.jsxs)(Y,{icon:`folder_off`,children:[`Projects are off. Turn them on in `,(0,z.jsx)(`a`,{href:`#/settings`,children:`settings`}),`.`]}):(0,z.jsx)(nx,{root:e?.root,onCreated:async()=>{}})}function nx({root:e,onCreated:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),u=async e=>{e.preventDefault();let r=n.trim();if(r&&!o){s(!0),l(``);try{let e=await A.request(`projects.create`,{body:{title:r,goal:i.trim()}});if(!e.ok)throw Error(P(e));let n=e.data;H(`/projects/${encodeURIComponent(n.slug)}/info`),t()}catch(e){l(e.message)}finally{s(!1)}}};return(0,z.jsxs)(`form`,{className:`new-chat mx-auto flex w-full max-w-[640px] animate-rise flex-col gap-4`,onSubmit:e=>void u(e),children:[(0,z.jsx)(ot,{size:`lg`,children:`new project`}),(0,z.jsx)(X,{children:(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsx)(Q,{label:`title`,children:(0,z.jsx)(Z,{value:n,placeholder:`e.g. Relaunch netnode.ch`,"aria-label":`project title`,autoFocus:!0,onChange:e=>r(e.target.value)})}),(0,z.jsx)(Q,{label:`goal (one line)`,children:(0,z.jsx)(Z,{value:i,placeholder:`e.g. Ship the new site on NodeHive by November`,"aria-label":`project goal`,onChange:e=>a(e.target.value)})}),(0,z.jsx)(`div`,{children:(0,z.jsx)(K,{variant:`primary`,type:`submit`,icon:`add`,busy:o,disabled:!n.trim(),children:o?`creating…`:`create project`})}),c&&(0,z.jsx)(rt,{tone:`bad`,children:c}),(0,z.jsxs)(nt,{children:[`One folder each under `,(0,z.jsx)(`code`,{title:e,children:e}),` with project.yml, brief.md, state.md and log.md; part of the workspace, commit it from the git screen. Chats opened in the project carry all of it as context.`]})]})})]})}function rx({slug:e,title:t}){let n=De(),r=F(`projects.get`,{slug:e}),i=F(`chats.list`,{}),a=Yb.find(e=>e.id===r?.harness)??Yb[0],o=n.vibeables?(r?.links.vibeables??[]).filter(e=>e.found).map(e=>e.slug):[],s=t=>`/projects/${encodeURIComponent(e)}/chat/${t}`;return(0,z.jsx)(Bb,{placeholder:`New session in ${t}`,byDefault:{...He,sub:r?`the project's assistant · ${Xb(r)}`:`the project's assistant`,hint:r?Xb(r):``},firstGroup:{label:`agents of the project`,slugs:new Set((r?.links.agents??[]).map(e=>e.slug))},agentHint:`works with the project's context`,sessions:i?Zb(i.chats,e):null,hrefOf:t=>Qb(t,e),create:t=>Vb(t?{agent:`claude`,scope:{kind:`agent`,slug:t},project:e}:{agent:a.id,scope:{kind:`project`,slug:e}},s),children:o.length>0&&(0,z.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`pinned apps`,children:[(0,z.jsx)(`h2`,{className:`m-0 px-3 pb-1 text-sm font-medium text-fg-2`,children:`Apps`}),(0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2 px-1`,children:o.map(t=>(0,z.jsxs)(U,{href:`/projects/${encodeURIComponent(e)}?app=${encodeURIComponent(t)}`,className:`pinned-app flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-2.5 text-sm text-fg no-underline hover:bg-surface-2`,title:`open ${t} beside the project's chat`,"data-app":t,children:[(0,z.jsx)(B,{name:`web`,className:`ms-sm text-fg-2`}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:t})]},t))})]})})}function ix({chatId:e,title:t,goal:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let t=!0;return A.call(`chats.get`,{id:e}).then(e=>t&&i(e.meta.scope)).catch(()=>t&&o(!0)),()=>{t=!1}},[e,s]);let l=r?.kind===`channel`?r.slug:void 0,u=r?.kind===`agent`?r.slug:void 0,d=F(`channels.list`,l?{}:null,{interval:4e3}),f=F(`agents.list`,l||u?{}:null,{interval:8e3});if(a)return(0,z.jsx)(Y,{icon:`chat_error`,children:`chat not found`});if(!r)return(0,z.jsx)(Y,{children:`loading…`});if(l){let t=d?.channels.find(e=>e.slug===l);return d?t?(0,z.jsx)(Ko,{id:e,channel:t,agents:f?.agents??[]},`${e}:channel`):(0,z.jsxs)(Y,{icon:`forum`,children:[`channel #`,l,` is gone — its definition under channels/ was removed`]}):(0,z.jsx)(Y,{children:`loading…`})}if(u){let t=f?.agents.find(e=>e.slug===u);return f?(0,z.jsx)(Ko,{id:e,agentName:t?`${t.emoji||`🤖`} ${t.name}`:u,agentDescription:t?.description,onConverted:()=>c(e=>e+1)},`${e}:${s}`):(0,z.jsx)(Y,{children:`loading…`})}return(0,z.jsx)(Ko,{id:e,agentName:t,agentDescription:n,onConverted:()=>c(e=>e+1)},`${e}:${s}`)}var ax=[{kind:`knowledge`,label:`knowledge`,icon:`menu_book`,href:e=>`/knowledge/${encodeURIComponent(e)}`},{kind:`vibeables`,label:`apps`,icon:`web`,href:e=>`/vibeables/${encodeURIComponent(e)}`},{kind:`repos`,label:`repositories`,icon:`source`},{kind:`workflows`,label:`workflows`,icon:`account_tree`,href:e=>`/workflows/${encodeURIComponent(e)}`},{kind:`agents`,label:`agents`,icon:`groups`,href:e=>`/agents/${encodeURIComponent(e)}`},{kind:`contacts`,label:`contacts`,icon:`person`,href:e=>`/contacts/${encodeURIComponent(e)}`},{kind:`places`,label:`places`,icon:`location_on`,href:e=>`/places/${encodeURIComponent(e)}`},{kind:`events`,label:`events`,icon:`event`,href:e=>`/events/${encodeURIComponent(e)}`}],ox=[`title`,`goal`,`model`,`brief`,`state`],sx=(e,t,n)=>e===`brief`||e===`state`?t!==n[e]:e===`title`?!!t.trim()&&t.trim()!==n.title:t.trim()!==(n[e]??``);function cx({slug:e,onChanged:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(``),g=De(),_=(0,v.useRef)(null),y=(0,v.useRef)({}),b=(0,v.useRef)(Promise.resolve()),x=(0,v.useRef)(0),S=(0,v.useRef)(null),C=(0,v.useRef)(!1),w=e=>{_.current=e,r(e)},T=e=>{y.current=e,p(e)};(0,v.useEffect)(()=>{let t=!0;return A.call(`projects.get`,{slug:e}).then(e=>t&&w(e)).catch(()=>t&&a(!0)),()=>{t=!1}},[e]);let E=(n,r=!1)=>{x.current++,l(!0);let i=b.current.then(async()=>{let i=typeof n==`function`?n():n;if(i&&!C.current){s(``);try{w(await $b(e,i,r)),await t()}catch(t){s(t.message);let n=await A.call(`projects.get`,{slug:e}).catch(()=>null);n&&w(n)}}x.current--,x.current===0&&l(!1)});return b.current=i,i},D=e=>{_.current&&w({..._.current,...e}),E(e)},O=()=>{let e=_.current;if(!e)return null;let t={};for(let n of ox){let r=y.current[n];r!==void 0&&sx(n,r,e)&&(t[n]=r)}return Object.keys(t).length?t:null},k=(e=!1)=>(S.current&&clearTimeout(S.current),S.current=null,O()?E(O,e):Promise.resolve()),ee=(e,t)=>{T({...y.current,[e]:t}),(e===`brief`||e===`state`)&&(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>void k(),1e3))},j=async e=>{let t=y.current[e];if(t===void 0)return;await k();let n=_.current;if(y.current[e]!==t||!n||sx(e,t,n))return;let{[e]:r,...i}=y.current;T(i)};(0,v.useEffect)(()=>{let e=()=>void k(!0);return window.addEventListener(`beforeunload`,e),window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`beforeunload`,e),window.removeEventListener(`pagehide`,e),k(!0)}},[]);let M=async()=>{l(!0);try{let n=await A.request(`projects.delete`,{slug:e});if(!n.ok)throw Error(n.error||`failed`);C.current=!0,await t(),H(`/`,{replace:!0})}catch(e){s(e.message),l(!1)}},N=async()=>{let t=m.trim();if(t){l(!0),s(``);try{let n=await A.request(`projects.log`,{slug:e,body:{entry:t}});if(!n.ok)throw Error(n.error||`failed`);let r=n.data;h(``),_.current&&w({..._.current,log:r.log??_.current.log})}catch(e){s(e.message)}finally{x.current===0&&l(!1)}}};if(i)return(0,z.jsx)(Y,{icon:`folder_off`,children:`project not found`});if(!n)return(0,z.jsx)(Y,{children:`loading…`});let P=e=>f[e]??n[e]??``,F=ox.some(e=>f[e]!==void 0&&sx(e,f[e],n)),I=e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},te=`h-8 border-transparent bg-transparent px-2 text-sm shadow-none hover:bg-surface-2 focus:bg-surface`;return(0,z.jsx)(`div`,{className:`chat-main project-page @container flex flex-col`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[1120px] flex-none flex-col gap-5`,children:[(0,z.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex min-h-7 items-center gap-2 text-sm text-fg-2 [.edit-modal_&]:pr-9`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,title:n.path,children:n.path}),(c||F)&&(0,z.jsx)(`span`,{className:`flex-none text-xs`,children:c?`saving…`:`unsaved`}),(0,z.jsx)(`span`,{className:`flex-1`}),u?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,disabled:c,onClick:()=>void M(),title:`Move the project, its files and log to the trash; #/trash puts it back`,children:`confirm delete`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>d(!1),children:`cancel`})]}):(0,z.jsx)(q,{icon:`delete`,label:`delete project`,size:`sm`,disabled:c,onClick:()=>d(!0)})]}),(0,z.jsx)(`h1`,{className:`sr-only`,children:n.title}),(0,z.jsx)(`textarea`,{rows:1,value:P(`title`),"aria-label":`title`,className:`block w-full resize-none border-0 bg-transparent p-0 font-[inherit] text-2xl leading-tight font-semibold text-fg shadow-none outline-none focus:shadow-none focus:outline-none focus-visible:outline-none [field-sizing:content]`,onChange:e=>ee(`title`,e.target.value.replace(/\n/g,` `)),onBlur:()=>void j(`title`),onKeyDown:I}),(0,z.jsx)(`div`,{className:`-mx-2`,children:(0,z.jsx)(Z,{value:P(`goal`),"aria-label":`goal`,placeholder:`what the project is for`,className:`h-8 border-transparent bg-transparent px-2 text-base text-fg-2 shadow-none hover:bg-surface-2 focus:bg-surface focus:text-fg`,onChange:e=>ee(`goal`,e.target.value),onBlur:()=>void j(`goal`),onKeyDown:I})})]}),n.configError&&(0,z.jsxs)(rt,{tone:`bad`,children:[`project.yml: `,n.configError]}),o&&(0,z.jsx)(rt,{tone:`bad`,children:o}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-x-8 gap-y-6 @[880px]:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6`,children:[(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Brief`}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`brief.md — what done looks like, constraints, stakeholders`})]}),(0,z.jsx)(xt,{rows:10,className:`resize-y font-mono text-sm`,value:P(`brief`),"aria-label":`brief`,onChange:e=>ee(`brief`,e.target.value),onBlur:()=>void j(`brief`)})]}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`State`}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`state.md — current state, rewritten at the end of a session`})]}),(0,z.jsx)(xt,{rows:6,className:`resize-y font-mono text-sm`,value:P(`state`),"aria-label":`state`,onChange:e=>ee(`state`,e.target.value),onBlur:()=>void j(`state`)})]}),(0,z.jsx)(px,{records:n.records,saving:c,onSave:e=>E({records:e})}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Links`}),(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`by name; a target that is missing in this workspace is marked`})]}),(0,z.jsx)(`div`,{className:`overflow-hidden rounded-card border border-line bg-surface`,children:(0,z.jsx)(ft,{children:ax.filter(e=>e.kind!==`contacts`&&e.kind!==`places`&&e.kind!==`events`||g[e.kind]).map(r=>(0,z.jsx)(dx,{kind:r.kind,label:r.label,icon:r.icon,href:r.href,links:n.links[r.kind],saving:c,onChange:(n,i)=>void lx(e,r.kind,n,i,e=>{w(e),t()},s)},r.kind))})})]}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Log`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Z,{value:m,"aria-label":`log entry`,placeholder:`Add an entry — a decision, a milestone…`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),N())}}),(0,z.jsx)(K,{icon:`add`,disabled:c||!m.trim(),onClick:()=>void N(),children:`log`})]}),(0,z.jsx)(`div`,{className:`md-body h-auto overflow-visible pt-1 text-sm [&_h1]:hidden [&_h2]:mt-3 [&_h2]:mb-1 [&_h2]:text-xs [&_ul]:m-0 [&_ul]:pl-[18px]`,dangerouslySetInnerHTML:{__html:fo.sanitize(Mi.parse(n.log||`_no entries yet_`,{async:!1}))}})]})]}),(0,z.jsxs)(`aside`,{className:`order-first flex min-w-0 flex-col gap-2 @[880px]:order-none`,"aria-label":`details`,children:[(0,z.jsxs)(`dl`,{className:`m-0 grid grid-cols-[76px_minmax(0,1fr)] items-center gap-x-2 gap-y-1 text-sm @min-[520px]:@max-[879px]:grid-cols-[76px_minmax(0,1fr)_76px_minmax(0,1fr)]`,children:[(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Status`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(St,{value:n.status,"aria-label":`status`,className:te,onChange:e=>D({status:e.target.value}),children:Gb.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Harness`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(St,{value:n.harness,"aria-label":`harness`,className:te,onChange:e=>D({harness:e.target.value}),children:Yb.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Model`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(Z,{value:P(`model`),"aria-label":`model`,placeholder:`harness default`,title:`e.g. sonnet, gpt-5.6-sol — empty for the harness default`,className:te,onChange:e=>ee(`model`,e.target.value),onBlur:()=>void j(`model`),onKeyDown:I})}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Effort`}),(0,z.jsx)(`dd`,{className:`m-0`,children:(0,z.jsx)(St,{value:n.effort??``,"aria-label":`effort`,className:te,onChange:e=>D({effort:e.target.value}),children:Je.map(e=>(0,z.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,z.jsx)(`span`,{className:`px-2 text-xs text-fg-2`,children:`harness, model and effort: what every chat in this project runs on`})]})]})]})})}async function lx(e,t,n,r,i,a){try{let a=await A.request(`projects.link`,{slug:e,body:{kind:t,target:n,remove:r}});if(!a.ok)throw Error(P(a));i(a.data)}catch(e){a(e.message)}}async function ux(e){switch(e){case`knowledge`:return(await A.call(`knowledge.list`)).bundles.map(e=>({slug:e.name,hint:`${e.concepts} concepts`}));case`vibeables`:return(await A.call(`vibeables.list`)).vibeables.map(e=>({slug:e.slug,hint:e.dev?`dev`:`static`}));case`repos`:return(await A.call(`repos.list`)).repos.map(e=>({slug:e.slug,hint:e.branch}));case`workflows`:return(await A.call(`workflows.list`)).workflows.map(e=>({slug:e.slug,hint:e.description??e.name}));case`agents`:return(await A.call(`agents.list`)).agents.filter(e=>!e.archived).map(e=>({slug:e.slug,hint:`${e.emoji} ${e.name}`}));case`contacts`:return(await A.call(`contacts.list`)).items.map(e=>({slug:e.slug,hint:[e.role,e.org].filter(Boolean).join(`, `)||void 0}));case`places`:return(await A.call(`places.list`)).items.map(e=>({slug:e.slug,hint:e.address}));case`events`:return(await A.call(`events.list`)).items.map(e=>({slug:e.slug,hint:e.start}))}}function dx({kind:e,label:t,icon:n,href:r,links:i,saving:a,onChange:o}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!s||l)return;let t=!0;return ux(e).then(e=>t&&u(e)).catch(()=>t&&u([])),()=>{t=!1}},[s,l,e]);let p=new Set(i.map(e=>e.slug)),m=(l??[]).filter(e=>!p.has(e.slug));return(0,z.jsxs)(dt,{icon:n,title:t,"data-link-kind":e,action:!s&&(0,z.jsx)(K,{size:`sm`,icon:`add`,onClick:()=>c(!0),children:`link`}),children:[i.length===0&&!s&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none linked`}),i.length>0&&(0,z.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,z.jsxs)(J,{tone:e.found?`neutral`:`bad`,title:e.found?e.label:`configured but not found in this workspace`,children:[r&&e.found?(0,z.jsx)(U,{href:r(e.slug),className:`text-inherit no-underline hover:underline`,children:e.slug}):e.slug,!e.found&&` · not found`,(0,z.jsx)(`button`,{type:`button`,className:`-mr-1 ml-1 inline-grid size-4 cursor-pointer place-items-center rounded-full border-0 bg-transparent p-0 text-inherit opacity-70 hover:bg-surface hover:opacity-100 disabled:cursor-default [&_.ms]:text-[13px]`,"aria-label":`unlink ${e.slug}`,disabled:a,onClick:()=>o(e.slug,!0),children:(0,z.jsx)(B,{name:`close`})})]},e.slug))}),s&&(0,z.jsx)(`span`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:l===null?(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`loading…`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(St,{className:`w-auto max-w-full min-w-48 flex-1`,"aria-label":`link ${t}`,value:d,onChange:e=>f(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:m.length?`pick ${t}…`:`nothing to link`}),m.map(e=>(0,z.jsxs)(`option`,{value:e.slug,children:[e.slug,e.hint?` — ${e.hint}`:``]},e.slug))]}),(0,z.jsx)(K,{disabled:a||!d,onClick:()=>{o(d,!1),f(``),c(!1)},children:`link`}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>c(!1),children:`cancel`})]})})]})}var fx={kind:`url`};function px({records:e,saving:t,onSave:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=e=>i(t=>({...t??fx,...e})),c=e=>{let t={kind:e.kind.trim().toLowerCase()||`url`};for(let n of[`title`,`url`,`workspace`,`note`]){let r=(e[n]??``).trim();r&&(t[n]=r)}return t};return(0,z.jsx)(X,{title:`systems of record`,className:`flex-none`,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`where the truth is managed outside kraftwerk — context for the agent, not a credential`}),!r&&(0,z.jsx)(K,{size:`sm`,icon:`add`,onClick:()=>i({...fx}),children:`add`})]}),children:(0,z.jsxs)(ft,{children:[e.map((r,i)=>(0,z.jsx)(dt,{"data-record-kind":r.kind,icon:`database`,title:(0,z.jsxs)(z.Fragment,{children:[Jb(r.kind),r.title&&(0,z.jsx)(`span`,{className:`text-xs font-normal text-fg-2`,children:r.title}),r.workspace&&(0,z.jsxs)(J,{children:[`workspace `,r.workspace]})]}),action:(0,z.jsx)(q,{icon:`close`,size:`sm`,label:`remove record ${r.title??r.kind}`,disabled:t,onClick:()=>void n(e.filter((e,t)=>t!==i))}),children:(r.url||r.note)&&(0,z.jsxs)(`span`,{className:`text-xs leading-normal text-fg-2`,children:[r.url&&(0,z.jsx)(`a`,{href:r.url,target:`_blank`,rel:`noreferrer`,children:r.url}),r.url&&r.note&&` — `,r.note]})},i)),e.length===0&&!r&&(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`none yet — e.g. a my.netnode.ch workspace, a Google Drive folder, a board`}),r&&(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`kind`,children:a?(0,z.jsx)(Z,{value:r.kind,"aria-label":`record kind`,placeholder:`e.g. jira`,onChange:e=>s({kind:e.target.value})}):(0,z.jsxs)(St,{value:r.kind,"aria-label":`record kind`,onChange:e=>{e.target.value===`__other`?(o(!0),s({kind:``})):s({kind:e.target.value})},children:[Object.entries(qb).map(([e,t])=>(0,z.jsx)(`option`,{value:e,children:t},e)),(0,z.jsx)(`option`,{value:`__other`,children:`other…`})]})}),(0,z.jsx)(Q,{label:`title`,className:`flex-1`,children:(0,z.jsx)(Z,{value:r.title??``,"aria-label":`record title`,placeholder:`e.g. Contracts folder`,onChange:e=>s({title:e.target.value})})}),(0,z.jsx)(Q,{label:`workspace / id`,children:(0,z.jsx)(Z,{value:r.workspace??``,"aria-label":`record workspace`,placeholder:`e.g. 22`,onChange:e=>s({workspace:e.target.value})})})]}),(0,z.jsx)(Q,{label:`url`,children:(0,z.jsx)(Z,{value:r.url??``,"aria-label":`record url`,placeholder:`https://…`,onChange:e=>s({url:e.target.value})})}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`note — what lives there and how it is usually reached`,className:`flex-1`,children:(0,z.jsx)(Z,{value:r.note??``,"aria-label":`record note`,placeholder:`e.g. tickets and roadmap; the my CLI`,onChange:e=>s({note:e.target.value})})}),(0,z.jsx)(K,{disabled:t||!r.kind.trim(),onClick:async()=>{await n([...e,c(r)]),i(null),o(!1)},children:`add record`}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>{i(null),o(!1)},children:`cancel`})]})]})]})})}var mx=`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`;function hx({children:e}){return(0,z.jsx)(`span`,{className:`mt-[3px] flex flex-wrap gap-1.5`,children:e})}function gx({children:e}){return(0,z.jsx)(`div`,{className:`flex flex-col gap-[7px] py-1`,children:e})}var _x=`resize-y font-mono text-[12.5px] leading-[1.65]`;function vx({bundles:e,onHide:t,onResize:n}){let[r,i]=(0,v.useState)({}),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``);(0,v.useEffect)(()=>{i({});let t=!0,n,r=async()=>{await Promise.all(e.map(async e=>{try{let n=await A.request(`knowledge.get`,{bundle:e}),r=n.ok?n.data:null;t&&i(t=>JSON.stringify(t[e])===JSON.stringify(r)?t:{...t,[e]:r})}catch{t&&i(t=>e in t?t:{...t,[e]:null})}})),t&&(n=setTimeout(r,6e3))};return r(),()=>{t=!1,clearTimeout(n)}},[e.join(`,`)]),(0,v.useEffect)(()=>{if(!a||d===a)return;let e=a.indexOf(`::`),t=a.slice(0,e),n=a.slice(e+2),r=!0,i,o=async()=>{try{let e=await A.request(`knowledge.concept`,{bundle:t,query:{id:n}}),i=e.ok?e.data:null;r&&c(e=>JSON.stringify(e[a])===JSON.stringify(i)?e:{...e,[a]:i})}catch{r&&c(e=>a in e?e:{...e,[a]:null})}r&&(i=setTimeout(o,6e3))};return o(),()=>{r=!1,clearTimeout(i)}},[a,d]);function b(e,t){let n=`${e}::${t}`;o(a===n?null:n)}async function x(e,t){let n=`${e}::${t}`;g(!0),y(``);try{let r=await A.request(`knowledge.putConcept`,{bundle:e,body:{id:t,content:p}});if(!r.ok)y(P(r));else if(r.data.error)y(r.data.error);else{let e=r.data;c(t=>({...t,[n]:e})),f(null)}}catch(e){y(e.message)}g(!1)}return(0,z.jsxs)(`aside`,{className:`runs-side knowledge-side`,children:[(0,z.jsx)(`div`,{className:`absolute inset-y-0 -left-[3px] z-4 w-[7px] cursor-col-resize hover:bg-accent/25`,title:`Drag to resize`,onMouseDown:e=>{e.preventDefault();let t=e.clientX,r=e.currentTarget.parentElement.offsetWidth,i=e=>n(Math.min(900,Math.max(280,r+(t-e.clientX)))),a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)}}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4 py-3.5`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,z.jsx)(it,{children:`knowledge`}),(0,z.jsx)(`span`,{className:`truncate text-[10.5px] text-fg-2`,children:`read & kept current by this agent`})]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(K,{size:`sm`,variant:`quiet`,onClick:t,title:`Hide knowledge sidebar`,children:[`hide `,(0,z.jsx)(B,{name:`close`,className:`ms-sm`})]})]}),(0,z.jsx)(`div`,{className:`flex-1 divide-y divide-line overflow-y-auto p-1.5`,children:e.map(e=>{let t=r[e],n=l[e]===!0;return(0,z.jsxs)(`div`,{className:`px-2 pt-1.5 pb-2.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-0.5 py-0.5`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-[7px] rounded-xl border-0 bg-transparent px-2 py-1.5 text-left hover:bg-surface-2`,"aria-expanded":!n,onClick:()=>u({...l,[e]:!n}),children:[(0,z.jsx)(yx,{open:!n}),(0,z.jsx)(`span`,{className:`truncate text-xs font-semibold text-fg`,children:e}),t&&(0,z.jsx)(`span`,{className:`flex-none rounded-full bg-surface-2 px-[7px] text-[10.5px] leading-[17px] tabular-nums text-fg-2`,children:t.concepts.length})]}),(0,z.jsx)(q,{icon:`picture_as_pdf`,label:`Export this bundle as PDF`,size:`sm`,onClick:()=>void b_(e)}),(0,z.jsx)(q,{icon:`arrow_outward`,label:`Open this bundle on the knowledge screen`,size:`sm`,href:`/knowledge/${encodeURIComponent(e)}`})]}),!n&&t===null&&(0,z.jsx)(nt,{className:`px-[18px] py-1.5`,children:`bundle not found`}),!n&&t?.concepts.map(t=>{let n=`${e}::${t.id}`,r=a===n,i=`/knowledge/${encodeURIComponent(e)}/${t.id.split(`/`).map(encodeURIComponent).join(`/`)}`;return(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`button`,{type:`button`,className:I(`flex w-full cursor-pointer items-center gap-[7px] rounded-xl border-0 py-1.5 pr-2 pl-[18px] text-left text-xs`,r?`bg-accent-soft font-medium text-on-accent-soft`:`bg-transparent text-fg-2 hover:bg-surface-2 hover:text-fg`),"aria-expanded":r,title:t.description||void 0,onClick:()=>b(e,t.id),children:[(0,z.jsx)(yx,{open:r}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title||t.id}),t.stale&&(0,z.jsx)(`span`,{className:`cursor-help`,title:`Past its stale-after date — ask the agent to re-verify it`,children:(0,z.jsx)(J,{tone:`bad`,children:`stale`})})]}),r&&(0,z.jsx)(`div`,{className:`mt-1 mb-2.5 ml-[18px] overflow-hidden rounded-xl border border-line bg-surface-2`,ref:e=>e?.scrollIntoView({block:`nearest`}),children:s[n]===void 0?(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`loading…`}):s[n]===null?(0,z.jsx)(nt,{className:`px-[18px] py-3`,children:`could not load concept`}):d===n?(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,z.jsx)(xt,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,"aria-label":`concept`,value:p,rows:Math.min(28,Math.max(10,p.split(`
479
+ `).length+2)),onChange:e=>m(e.target.value),spellCheck:!1}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(K,{size:`sm`,variant:`quiet`,disabled:h,onClick:()=>f(null),children:`cancel`}),(0,z.jsx)(K,{size:`sm`,variant:`primary`,icon:`check`,busy:h,onClick:()=>x(e,t.id),children:h?`saving…`:`save`})]}),_&&(0,z.jsx)(rt,{tone:`bad`,children:_})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-[7px]`,children:[t.type&&(0,z.jsx)(J,{children:t.type}),bx(t)&&(0,z.jsxs)(`span`,{className:`text-[10.5px] tabular-nums text-fg-2`,children:[`updated `,Ke(bx(t))]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`edit`,onClick:()=>{m(s[n].raw),f(n),y(``)},children:`edit`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`open_in_new`,href:`/knowledge/${encodeURIComponent(e)}/${t.id}`,title:`The page in the knowledge section`,children:`page`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,href:i,children:`open ↗`})]}),(0,z.jsx)(`div`,{className:`md-body h-auto overflow-visible px-3.5 pt-3 pb-3.5 text-xs`,dangerouslySetInnerHTML:{__html:fo.sanitize(Mi.parse(s[n].body??``,{async:!1}))}})]})})]},t.id)}),!n&&t&&t.concepts.length===0&&(0,z.jsx)(nt,{className:`px-[18px] py-1.5`,children:`no concepts yet`})]},e)})})]})}function yx({open:e}){return(0,z.jsx)(`span`,{className:I(`inline-grid w-[15px] flex-none text-fg-2 transition-transform`,e&&`rotate-90`),"aria-hidden":!0,children:(0,z.jsx)(B,{name:`chevron_right`,className:`text-[15px]`})})}function bx(e){return[e.generated?.at,...e.verified.map(e=>e.at)].filter(e=>typeof e==`string`&&e.length>0).sort().pop()}function xx({slug:e}){let t=F(`agents.list`,{},{interval:3e4}),n=F(`chats.list`,{}),r=F(`projects.list`,{},{interval:6e4}),i=e=>r?.projects.find(t=>t.slug===e)?.title??e,a=t?.agents.find(t=>t.slug===e),o=a?.name??e,s=(e,t)=>`/agents/${encodeURIComponent(e)}/chat/${t}`;return(0,z.jsx)(Bb,{placeholder:`New session with ${o}`,byDefault:{emoji:a?.emoji||`🤖`,name:o,sub:a?.description,hint:`${a?.harness??`claude`} · its role, knowledge and skills`},agentHint:`opens in that agent's sessions`,exclude:e,placeOf:e=>e.project?`📁 ${i(e.project)}`:void 0,sessions:n?n.chats.filter(t=>t.scope.kind===`agent`&&t.scope.slug===e):null,hrefOf:t=>s(e,t.id),pickProject:`filed`,create:(t,n)=>Vb({agent:`claude`,scope:{kind:`agent`,slug:t??e},...n?{project:n.slug}:{}},r=>n?`/projects/${encodeURIComponent(n.slug)}/chat/${r}`:s(t??e,r))},e)}function Sx(){let e=Ex(),t=F(`chats.list`,{}),n=F(`projects.list`,{},{interval:6e4}),r=e=>n?.projects.find(t=>t.slug===e)?.title??e;return(0,z.jsx)(Bb,{placeholder:`New chat with Ralv`,byDefault:{emoji:`🎩`,name:`Ralv`,sub:`chief of staff: knows the workspace, advises, launches things`,hint:`knows the workspace`},defaultControls:(0,z.jsx)(Ox,{...e}),agentHint:`opens in the agent's sessions`,placeOf:e=>kx(e)?`📁 ${r(kx(e))}`:void 0,sessions:t?Ax(t.chats):null,hrefOf:jx,pickProject:`assistant`,create:(t,n)=>{let r=e=>`/projects/${encodeURIComponent(n.slug)}/chat/${e}`;return t?Vb({agent:`claude`,scope:{kind:`agent`,slug:t},...n?{project:n.slug}:{}},n?r:e=>`/agents/${encodeURIComponent(t)}/chat/${e}`):n?Vb({agent:n.harness,scope:{kind:`project`,slug:n.slug}},r):Vb({agent:e.agent,scope:{kind:`kraftwerk`},...e.config?{config:e.config}:{}},e=>`/agents/chats/${e}`)}})}var Cx=[`claude`,`codex`,`antigravity`,`pi`],wx=`kw-ralv-start`;function Tx(){try{let e=JSON.parse(localStorage.getItem(wx)??`null`);if(e&&Cx.includes(e.agent))return{agent:e.agent,picks:e.picks??{}}}catch{}return{agent:`claude`,picks:{}}}function Ex(){let[e,t]=(0,v.useState)(Tx),[n,r]=(0,v.useState)(null);(0,v.useEffect)(()=>{let t=!0;return A.request(`agents.options`,{query:{agent:e.agent}}).then(n=>{t&&r(n.ok?{agent:e.agent,options:n.data.options}:{agent:e.agent,options:[],error:P(n)})}),()=>{t=!1}},[e.agent]);let i=n?.agent===e.agent?n:null,a=i?.options??[],o=e=>{t(e);try{localStorage.setItem(wx,JSON.stringify(e))}catch{}},s=Object.entries(e.picks).filter(([e,t])=>a.some(n=>n.id===e&&n.type===`select`&&n.choices.some(e=>e.value===t)));return{agent:e.agent,picks:e.picks,options:a,loading:!i,error:i?.error,config:s.length?Object.fromEntries(s):void 0,setAgent:e=>o({agent:e,picks:{}}),pick:(t,n)=>{let r={...e.picks};n?r[t]=n:delete r[t],o({...e,picks:r})}}}var Dx=`h-8 w-auto max-w-[220px] rounded-full border-0 bg-transparent text-sm font-medium hover:bg-surface-2`;function Ox({agent:e,picks:t,options:n,loading:r,error:i,setAgent:a,pick:o}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(St,{"aria-label":`agent`,value:e,onChange:e=>a(e.target.value),className:Dx,children:Cx.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))}),r&&(0,z.jsxs)(`span`,{className:`px-2 text-xs text-fg-2`,children:[`asking `,e,` for its models…`]}),i&&(0,z.jsxs)(`span`,{className:`max-w-[260px] truncate px-2 text-xs text-bad`,title:i,children:[e,` did not answer — its default model`]}),n.map(e=>e.type===`select`?(0,z.jsxs)(St,{"aria-label":e.category===`model`?`model`:`thinking`,value:t[e.id]??``,onChange:t=>o(e.id,t.target.value),className:Dx,children:[(0,z.jsxs)(`option`,{value:``,children:[e.category===`model`?`model`:`thinking`,`: default`,e.value==="default"?``:` (${e.choices.find(t=>t.value===e.value)?.name??e.value})`]}),e.choices.filter(e=>e.value!=="default").map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.name},e.value))]},e.id):null)]})}var kx=e=>e.scope.kind===`project`?e.scope.slug:e.project||void 0,Ax=e=>e.filter(e=>kx(e)||e.scope.kind!==`agent`&&e.scope.kind!==`channel`),jx=e=>{let t=kx(e);return t?`/projects/${encodeURIComponent(t)}/chat/${e.id}`:`/agents/chats/${e.id}`};function Mx({agents:e}){return(0,v.useEffect)(()=>{let t=!0,n=()=>H(`/agents/${encodeURIComponent(e[0].slug)}`,{replace:!0});return A.call(`chats.list`).then(r=>{if(!t)return;let i=new Set(e.map(e=>e.slug)),a=r.chats.find(e=>e.scope.kind===`agent`&&i.has(e.scope.slug));a&&a.scope.kind===`agent`?H(`/agents/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`,{replace:!0}):n()}).catch(()=>t&&n()),()=>{t=!1}},[e.map(e=>e.slug).join(`,`)]),(0,z.jsx)(Y,{children:`loading…`})}function Nx(){return(0,z.jsx)(`div`,{className:`empty-action flex justify-center py-16 text-center text-sm text-fg-2`,children:(0,z.jsx)(K,{variant:`primary`,icon:`add`,onClick:()=>H(`/agents/new`),children:`create your first agent`})})}var Px=`---
480
480
  description: What this skill is for (one line)
481
481
  ---
482
482
 
483
483
  Instructions this agent follows when the skill applies or is invoked with /<name>.
484
- `;function Mx({slug:e}){let t=F(`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,z.jsxs)(X,{title:`own skills — only this agent`,actions:!n&&(0,z.jsx)(K,{size:`sm`,icon:`add`,onClick:()=>{r({name:``,content:jx,isNew:!0}),s(``)},children:`new skill`}),children:[t.length===0&&!n&&(0,z.jsxs)(nt,{className:`px-[18px] py-3 text-xs`,children:[`none — skills in `,(0,z.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,z.jsx)(ft,{children:t.map(e=>(0,z.jsx)(dt,{icon:`extension`,title:`/${e.name}`,action:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,icon:`edit`,onClick:()=>void c(e.name),children:`edit`}),(0,z.jsx)(q,{icon:`delete`,label:`delete /${e.name}`,variant:`danger`,size:`sm`,onClick:()=>void u(e.name)})]}),children:(0,z.jsx)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:e.description||(0,z.jsx)(`code`,{children:`SKILL.md`})})},e.name))}),n&&(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsx)(Q,{label:`name — invoked as /<name>`,children:(0,z.jsx)(Z,{className:`font-mono`,value:n.name,placeholder:`e.g. report-html`,disabled:!n.isNew,onChange:e=>r({...n,name:e.target.value})})}),(0,z.jsx)(Q,{label:`SKILL.md — frontmatter (description) + the instructions`,children:(0,z.jsx)(xt,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,rows:Math.min(28,Math.max(12,n.content.split(`
485
- `).length+2)),value:n.content,spellCheck:!1,onChange:e=>r({...n,content:e.target.value})})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(K,{variant:`primary`,busy:i,disabled:!n.name.trim(),onClick:()=>void l(),children:i?`saving…`:`save`}),(0,z.jsx)(K,{variant:`quiet`,disabled:i,onClick:()=>r(null),children:`cancel`})]})]}),o&&(0,z.jsx)(`div`,{className:`px-[18px] pb-3`,children:(0,z.jsx)(rt,{tone:`bad`,children:o})})]})}function Nx(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 Px({r:e}){return e.runner===`here`?(0,z.jsx)(J,{title:`runs_on: ${e.runsOn} — this machine fires it`,children:`runs here`}):e.runner===`unassigned`?(0,z.jsx)(J,{tone:e.enabled?`ask`:`neutral`,title:`no runs_on — it fires on no machine until one adopts it`,children:`no runner`}):e.retired?(0,z.jsxs)(J,{tone:`ask`,title:`${e.runsOn} is a retired identity of this machine — it fires nowhere until reassigned`,children:[`runs on `,e.runsOn,` · retired`]}):(0,z.jsxs)(J,{title:`another machine fires it, not this one`,children:[`runs on `,e.runsOn]})}function Fx({slug:e}){let[t,n]=(0,v.useState)(0),r=F(`agents.routines`,{slug:e},{refresh:t}),i=F(`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=(rs()??[]).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(P(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&&H(`/agents/${encodeURIComponent(e)}/chat/${n.data.chatId}`):l(P(n))}function w(e){let t=Nx(e);d(t.note),l(t.error),n(e=>e+1),ns()}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(P(n))}async function E(){h(`*`),l(``),d(``);let e=await A.request(`routines.adopt`,{body:{retired:y}});h(``),e.ok?w(e.data):l(P(e))}async function D(t){window.confirm(`Delete the scheduled prompt "${t}"?`)&&await A.request(`agents.deleteRoutine`,{slug:e,id:t}).catch(()=>{})}return(0,z.jsxs)(X,{title:`schedule — prompts that run on their own`,actions:!o&&(0,z.jsx)(K,{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,z.jsx)(nt,{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,z.jsx)(dt,{icon:`event_busy`,title:`${b} routine${b===1?` fires`:`s fire`} nowhere`,action:(0,z.jsx)(K,{size:`sm`,icon:`download_done`,busy:m===`*`,onClick:()=>void E(),children:m===`*`?`adopting…`:`run these here`}),children:(0,z.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,z.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,z.jsx)(ft,{children:a.map(t=>(0,z.jsx)(dt,{icon:`schedule`,title:(0,z.jsxs)(z.Fragment,{children:[t.name,(0,z.jsx)(Px,{r:t}),t.lastError&&(0,z.jsx)(`span`,{title:t.lastError,children:(0,z.jsx)(J,{tone:`bad`,children:`error`})}),t.awaitingApproval&&t.lastChatId&&(0,z.jsx)(J,{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,z.jsxs)(z.Fragment,{children:[t.runner!==`here`&&(0,z.jsx)(K,{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,z.jsx)(K,{size:`sm`,icon:`play_arrow`,busy:f===t.id,onClick:()=>C(t.id),children:f===t.id?`starting…`:`run`}),(0,z.jsx)(K,{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,z.jsx)(K,{size:`sm`,variant:`danger`,onClick:()=>void D(t.id),children:`delete`}),(0,z.jsx)(Dt,{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,z.jsxs)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:[(0,z.jsx)(`code`,{children:t.schedule}),t.enabled?t.nextRunAt?` · next ${Ke(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,z.jsxs)(U,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,Ke(t.lastRunAt)]}):`never ran`]})},t.id))}),o&&(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`name`,className:`flex-1`,children:(0,z.jsx)(Z,{value:o.name,placeholder:`e.g. Morning report`,onChange:e=>s({...o,name:e.target.value})})}),(0,z.jsx)(Q,{label:`schedule (cron)`,className:`w-[200px] max-[900px]:w-auto`,children:(0,z.jsx)(Z,{className:`font-mono`,value:o.schedule,placeholder:`0 9 * * 1-5`,onChange:e=>s({...o,schedule:e.target.value})})}),(0,z.jsxs)(`label`,{className:`flex h-9 cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:o.enabled,onChange:e=>s({...o,enabled:e.target.checked})}),`enabled`]})]}),(0,z.jsx)(Q,{label:`prompt — what to ask this agent on each run`,children:(0,z.jsx)(xt,{rows:5,value:o.prompt,placeholder:`Check ... and summarize what changed.`,onChange:e=>s({...o,prompt:e.target.value})})}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`runs on — the one machine that fires it`,className:`flex-1`,children:(0,z.jsx)(Z,{className:`font-mono`,value:o.runsOn??i?.identity??``,placeholder:`<handle>@<machine> — empty: no runner`,onChange:e=>s({...o,runsOn:e.target.value})})}),(0,z.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,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:o.private??!1,onChange:e=>s({...o,private:e.target.checked})}),`private`]})]}),i&&(0,z.jsxs)(nt,{children:[`This machine is `,(0,z.jsx)(`code`,{children:i.identity}),`. Empty: no runner — it fires nowhere.`]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(K,{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,z.jsx)(K,{variant:`quiet`,onClick:()=>(s(null),l(``)),children:`cancel`})]})]}),(c||u)&&(0,z.jsx)(`div`,{className:`px-[18px] pb-3`,children:c?(0,z.jsx)(rt,{tone:`bad`,children:c}):(0,z.jsx)(rt,{children:u})})]})}function Ix({title:e,kind:t,editing:n,saving:r,onToggle:i,children:a}){return(0,z.jsxs)(`section`,{className:`flex flex-col gap-1`,"data-link-kind":t,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:e}),(0,z.jsx)(`span`,{className:`flex-1`}),n?(0,z.jsx)(K,{size:`sm`,variant:`quiet`,busy:r,onClick:i,children:`done`}):(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`edit`,onClick:i,children:`edit`})]}),a]})}function Lx({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=(0,v.useRef)(Promise.resolve()),g=(0,v.useRef)(0),_=De(),y=F(`workflows.list`,{}),b=F(`knowledge.list`,{}),x=F(`vibeables.list`,_.vibeables?{}:null),S=F(`skills.list`,{}),C=e=>{p.current=e,n(e)},w=e=>{m.current=e,c(e)};(0,v.useEffect)(()=>{let t=!0;return A.call(`agents.get`,{slug:e}).then(e=>t&&C(e)).catch(()=>t&&i(!0)),()=>{t=!1}},[e]);function T(t,n=!1){let r=p.current;if(!r)return Promise.resolve(!1);C({...r,...t}),g.current++,u(!0),f(``);let i=h.current.then(async()=>{let t=p.current,r=!1;try{let i=await A.request(`agents.save`,{slug:e,keepalive:n,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,i.ok?g.current===1&&C(i.data):f(P(i))}catch(e){f(e.message)}if(!r){let t=await A.call(`agents.get`,{slug:e}).catch(()=>null);t&&g.current===1&&C(t)}return g.current--,g.current===0&&u(!1),r});return h.current=i,i}async function E(e=!1){let t=m.current,n=p.current;t!==null&&n&&(t.trim()===(n.system??``).trim()||await T({system:t},e))&&m.current===t&&w(null)}(0,v.useEffect)(()=>()=>{E(!0)},[]);async function D(t){u(!0),f(``);try{let n=await A.request(`agents.archive`,{slug:e,body:{archived:t}});n.ok?C(n.data):f(P(n))}catch(e){f(e.message)}u(!1)}if(r)return(0,z.jsx)(Y,{icon:`person_off`,children:`agent not found`});if(!t)return(0,z.jsx)(Y,{children:`loading…`});let O=e=>()=>{o(a===e?``:e),f(``)},k=(e,n,r)=>{let i=t[e]??[];T({[e]:r?[...i.filter(e=>e!==n),n]:i.filter(e=>e!==n)})},ee=(e,n)=>{let r=t.skills??[];T({skills:n?[...r.filter(t=>t!==e),e]:r.filter(t=>t!==e)})},j=s??t.system??``,M=s!==null&&s.trim()!==(t.system??``).trim(),N=t.files??[],I=`m-0 flex min-h-8 min-w-0 items-center gap-1.5 px-2 [overflow-wrap:anywhere]`,te=e=>(0,z.jsx)(`span`,{className:`text-fg-2`,children:e});return(0,z.jsxs)(`div`,{className:`agent-view @container flex animate-rise flex-col gap-4`,children:[(0,z.jsxs)(`header`,{className:`flex items-center gap-3.5`,children:[(0,z.jsx)(lt,{children:(0,z.jsx)(`span`,{"aria-hidden":!0,children:t.emoji})}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(ot,{size:`lg`,children:t.name}),t.archived&&(0,z.jsxs)(J,{children:[(0,z.jsx)(B,{name:`inventory_2`,className:`ms-sm mr-1`}),` archived`]})]}),t.description&&(0,z.jsx)(`p`,{className:`m-0 text-sm text-fg-2 [overflow-wrap:anywhere]`,children:t.description})]})]}),d&&(0,z.jsx)(rt,{tone:`bad`,children:d}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-x-8 gap-y-6 @[880px]:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6`,children:[(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`What the agent is told`}),(M||l&&s!==null)&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:l?`saving…`:`unsaved`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(`span`,{className:dx,children:[`agents/`,t.slug,`/system.md`]})]}),(0,z.jsx)(xt,{className:mx,"aria-label":`role`,rows:Math.min(24,Math.max(8,j.split(`
486
- `).length+2)),value:j,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>w(e.target.value),onBlur:()=>void E(),spellCheck:!1})]}),(0,z.jsx)(Ix,{title:`Workflows`,kind:`workflows`,editing:a===`workflows`,saving:l,onToggle:O(`workflows`),children:a===`workflows`?(0,z.jsxs)(px,{children:[(y?.workflows??[]).map(e=>(0,z.jsx)(Tt,{checked:t.workflows.includes(e.slug),onChange:t=>k(`workflows`,e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),(y?.workflows??[]).length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}):t.workflows.length===0?(0,z.jsx)(`span`,{className:dx,children:`none connected — the agent can run any workflow you connect`}):(0,z.jsx)(fx,{children:t.workflows.map(e=>(0,z.jsx)(J,{href:`/workflows/${encodeURIComponent(e)}`,children:e},e))})}),(0,z.jsx)(Ix,{title:`Knowledge`,kind:`knowledge`,editing:a===`knowledge`,saving:l,onToggle:O(`knowledge`),children:a===`knowledge`?(0,z.jsxs)(px,{children:[(b?.bundles??[]).map(e=>(0,z.jsx)(Tt,{checked:t.knowledge.includes(e.name),onChange:t=>k(`knowledge`,e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),(b?.bundles??[]).length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}):t.knowledge.length===0?(0,z.jsx)(`span`,{className:dx,children:`none connected — connected bundles are read and kept current by the agent`}):(0,z.jsx)(fx,{children:t.knowledge.map(e=>(0,z.jsx)(J,{href:`/knowledge/${encodeURIComponent(e)}`,children:e},e))})}),(_.vibeables||(t.vibeables??[]).length>0)&&(0,z.jsx)(Ix,{title:`Apps`,kind:`vibeables`,editing:a===`vibeables`,saving:l,onToggle:O(`vibeables`),children:a===`vibeables`?(0,z.jsxs)(px,{children:[(x?.vibeables??[]).map(e=>(0,z.jsx)(Tt,{checked:(t.vibeables??[]).includes(e.slug),onChange:t=>k(`vibeables`,e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),(t.vibeables??[]).filter(e=>!(x?.vibeables??[]).some(t=>t.slug===e)).map(e=>(0,z.jsx)(Tt,{checked:!0,onChange:t=>k(`vibeables`,e,t),hint:`not found in this workspace`,mono:!0,children:e},e)),!_.vibeables&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),_.vibeables&&(x?.vibeables??[]).length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no apps in this workspace yet — create one on the apps page`})]}):(t.vibeables??[]).length===0?(0,z.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,z.jsx)(fx,{children:(t.vibeables??[]).map(e=>{let t=!_.vibeables||!x||x.vibeables.some(t=>t.slug===e);return(0,z.jsxs)(J,{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)})})}),N.length>0&&(0,z.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Folders`}),(0,z.jsx)(fx,{children:N.map(e=>(0,z.jsx)(J,{className:`font-mono`,children:e},e))})]}),(0,z.jsx)(Ix,{title:`Shared skills`,kind:`skills`,editing:a===`skills`,saving:l,onToggle:O(`skills`),children:a===`skills`?(0,z.jsxs)(px,{children:[(0,z.jsx)(Tt,{checked:t.skills===void 0,onChange:e=>void T({skills:e?void 0:(S?.skills??[]).map(e=>e.name)}),hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),t.skills!==void 0&&(S?.skills??[]).map(e=>(0,z.jsx)(Tt,{checked:(t.skills??[]).includes(e.name),onChange:t=>ee(e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),t.skills!==void 0&&(S?.skills??[]).length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}):t.skills===void 0?(0,z.jsx)(`span`,{className:dx,children:`all discovered skills (default) — invoke with /name in a session`}):t.skills.length===0?(0,z.jsx)(`span`,{className:dx,children:`none — this agent runs without skills`}):(0,z.jsx)(fx,{children:t.skills.map(e=>(0,z.jsxs)(J,{children:[`/`,e]},e))})}),(0,z.jsx)(Mx,{slug:e}),(0,z.jsx)(Fx,{slug:e})]}),(0,z.jsxs)(`aside`,{className:`order-first flex min-w-0 flex-col gap-3 @[880px]:order-none`,"aria-label":`details`,children:[(0,z.jsxs)(`dl`,{className:`m-0 grid grid-cols-[76px_minmax(0,1fr)] items-center gap-x-2 gap-y-1 text-sm @min-[520px]:@max-[879px]:grid-cols-[76px_minmax(0,1fr)_76px_minmax(0,1fr)]`,children:[(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Group`}),(0,z.jsx)(`dd`,{className:I,children:t.group||te(`none`)}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Harness`}),(0,z.jsx)(`dd`,{className:I,children:t.harness}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Model`}),(0,z.jsx)(`dd`,{className:I,children:t.model||te(`harness default`)}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Effort`}),(0,z.jsx)(`dd`,{className:I,children:t.effort||te(`default`)}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`State`}),(0,z.jsxs)(`dd`,{className:I,children:[t.archived?`archived`:`active`,t.archived?(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`unarchive`,busy:l,title:`Put this agent back on the roster`,onClick:()=>void D(!1),children:`unarchive`}):(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`archive`,disabled:l,title:`Hide this agent from the roster — restorable any time`,onClick:()=>void D(!0),children:`archive`})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-2`,children:[(0,z.jsx)(K,{size:`sm`,icon:`edit`,href:`/agents/${encodeURIComponent(e)}/edit`,title:`name, emoji, description, group, harness, model and effort`,children:`edit`}),(0,z.jsxs)(`code`,{className:`font-mono text-2xs text-fg-2 [overflow-wrap:anywhere]`,title:`the agent's folder`,children:[`agents/`,t.slug]})]})]})]})]})}var Rx=[`🤖`,`🧑‍💻`,`🎧`,`🛠️`,`📊`,`✍️`,`🔍`,`🧹`,`📦`,`🚀`];function zx({slug:e}){let[t,n]=(0,v.useState)(e?null:f()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=F(`workflows.list`,{})?.workflows??[],c=F(`knowledge.list`,{})?.bundles??[],l=De(),u=F(`vibeables.list`,l.vibeables?{}:null)?.vibeables??[],d=F(`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?H(`/agents/${encodeURIComponent(r.data.slug)}/info`):i(P(r))}async function m(){e&&window.confirm(`Move agent "${e}" to the trash?`)&&(await A.request(`agents.delete`,{slug:e}).catch(()=>{}),H(`/agents`))}if(!t)return(0,z.jsx)(Y,{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,z.jsxs)(ct,{width:`narrow`,children:[(0,z.jsx)(ot,{children:e?`edit ${e}`:`new agent`}),(0,z.jsx)(X,{children:(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`name`,className:`flex-1`,children:(0,z.jsx)(Z,{value:t.name,placeholder:`e.g. Max`,onChange:e=>h({name:e.target.value})})}),(0,z.jsx)(Q,{label:`emoji`,className:`w-[90px] max-[900px]:w-auto`,children:(0,z.jsx)(Z,{value:t.emoji,onChange:e=>h({emoji:e.target.value})})})]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Rx.map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":t.emoji===e,className:I(`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,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`description`,className:`flex-1`,children:(0,z.jsx)(Z,{value:t.description,placeholder:`one line: what this agent is for`,onChange:e=>h({description:e.target.value})})}),(0,z.jsx)(Q,{label:`group`,className:`w-[180px] max-[900px]:w-auto`,children:(0,z.jsx)(Z,{value:t.group,placeholder:`none`,onChange:e=>h({group:e.target.value})})})]}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`harness`,className:`w-[140px] max-[900px]:w-auto`,children:(0,z.jsxs)(St,{value:t.harness,onChange:e=>h({harness:e.target.value}),children:[(0,z.jsx)(`option`,{value:`claude`,children:`claude`}),(0,z.jsx)(`option`,{value:`codex`,children:`codex`}),(0,z.jsx)(`option`,{value:`pi`,children:`pi`}),(0,z.jsx)(`option`,{value:`antigravity`,children:`antigravity`})]})}),(0,z.jsx)(Q,{label:`model`,className:`flex-1`,children:(0,z.jsx)(Z,{className:`font-mono`,value:t.model,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>h({model:e.target.value})})}),(0,z.jsx)(Q,{label:`effort`,className:`w-[140px] max-[900px]:w-auto`,children:(0,z.jsx)(St,{value:t.effort,onChange:e=>h({effort:e.target.value}),children:Je.map(e=>(0,z.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,z.jsx)(Q,{label:`system prompt — the agent's role`,children:(0,z.jsx)(xt,{className:mx,rows:10,value:t.system,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>h({system:e.target.value})})}),(0,z.jsxs)(Bx,{label:`connected workflows — autoloaded into the agent's context; it can run them`,children:[s.map(e=>(0,z.jsx)(Tt,{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,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),(0,z.jsxs)(Bx,{label:`connected knowledge — OKF bundles the agent consults and maintains`,children:[c.map(e=>(0,z.jsx)(Tt,{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,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),(l.vibeables||t.vibeables.length>0)&&(0,z.jsxs)(Bx,{label:`apps — small apps the agent builds and maintains`,linkKind:`vibeables`,children:[u.map(e=>(0,z.jsx)(Tt,{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,z.jsx)(Tt,{checked:!0,onChange:()=>g(`vibeables`,e,!1),hint:`not found in this workspace`,mono:!0,children:e},e)),!l.vibeables&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),l.vibeables&&u.length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no vibeables in this workspace yet`})]}),(0,z.jsxs)(Bx,{label:`connected skills — workspace skill packages (see the skills tab); invoked with /name in sessions`,children:[(0,z.jsx)(Tt,{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,z.jsx)(Tt,{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,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),r&&(0,z.jsx)(rt,{tone:`bad`,children:r}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(K,{variant:`primary`,busy:a,disabled:!t.name.trim(),onClick:p,children:a?`saving…`:e?`save`:`create`}),(0,z.jsx)(`span`,{className:`flex-1`}),e&&(0,z.jsx)(K,{variant:`danger`,icon:`delete`,onClick:m,children:`delete agent`})]})]})})]})}function Bx({label:e,linkKind:t,children:n}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-link-kind":t,children:[(0,z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e}),(0,z.jsx)(px,{children:n})]})}var Vx=`bg-accent/7 outline-[1.5px] -outline-offset-[1.5px] outline-accent outline-dashed`,Hx=`px-2.5 pt-1.5 pb-2 text-2xs text-fg-2`;function Ux({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=F(`agents.list`,{}),[o,s]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`kw-agent-groups`)??`[]`);return Array.isArray(e)?e.map(String):[]}catch{return[]}}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)({}),C=(a?.agents??[]).map(e=>x[e.slug]===void 0?e:{...e,group:x[e.slug]||void 0});(0,v.useEffect)(()=>{S(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 w=C.filter(e=>!e.archived),T=C.filter(e=>e.archived),[E,D]=(0,v.useState)(!1),O=[...new Set([...w.map(e=>e.group??``).filter(Boolean),...o])].sort((e,t)=>e.localeCompare(t)),k=w.filter(e=>!e.group);function ee(e){s(e);try{localStorage.setItem(`kw-agent-groups`,JSON.stringify(e))}catch{}}function j(){let e=u.trim();l(!1),d(``),e&&!O.includes(e)&&ee([...o,e])}function M(e,t){p(null);let n=t.trim();if(n&&n!==e){for(let t of C.filter(t=>t.group===e))N(t.slug,n);o.includes(e)&&ee([...new Set(o.map(t=>t===e?n:t))])}}async function N(e,t){if((C.find(t=>t.slug===e)?.group??``)!==t){S(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{S(t=>{let n={...t};return delete n[e],n})}}}let P=e=>({onDragOver:t=>{g!=null&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,y!==e&&b(e))},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||g;n&&N(n,e),_(null),b(null)}}),te=e=>(0,z.jsx)(`div`,{className:g===e.slug?`opacity-40`:void 0,onDragStart:t=>{t.dataTransfer.setData(`text/plain`,e.slug),t.dataTransfer.effectAllowed=`move`,_(e.slug)},onDragEnd:()=>{_(null),b(null)},children:(0,z.jsx)(gt,{href:`/agents/${encodeURIComponent(e.slug)}`,active:e.slug===t,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness})},e.slug),R=e=>(0,z.jsx)(gt,{href:`/agents/${encodeURIComponent(e.slug)}/info`,active:e.slug===t,dim:e.slug!==t,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness},e.slug),ne;ne=n===`new`?(0,z.jsx)(zx,{},`new`):n===`edit`&&t?(0,z.jsx)(zx,{slug:t},t):n===`chat`&&t&&i===`new`?(0,z.jsx)(vx,{slug:t},t):n===`chat`&&t&&i?(0,z.jsx)(`div`,{className:`chat-main`,children:(0,z.jsx)(Ko,{id:i,agentName:C.find(e=>e.slug===t)?.name??t,agentDescription:C.find(e=>e.slug===t)?.description},i)}):n===`chats`?i?(0,z.jsx)(`div`,{className:`chat-main`,children:(0,z.jsx)(Ko,{id:i},i)}):(0,z.jsx)(yx,{}):n===`info`&&t?(0,z.jsx)(Lx,{slug:t},t):t?(0,z.jsx)(vx,{slug:t},t):a?w.length?(0,z.jsx)(kx,{agents:w}):(0,z.jsx)(Ax,{}):(0,z.jsx)(Y,{children:`loading…`});let re=(n===`agent`||n===`info`||n===`chat`)&&t?C.find(e=>e.slug===t)?.knowledge??[]:[],[ie,ae]=(0,v.useState)(()=>localStorage.getItem(`kw-kside`)!==`hidden`),[oe,se]=(0,v.useState)(()=>Number(localStorage.getItem(`kw-kside-w`))||460),ce=re.length>0&&ie;function le(e){ae(e),localStorage.setItem(`kw-kside`,e?`open`:`hidden`)}function ue(e){se(e),localStorage.setItem(`kw-kside-w`,String(e))}return(0,z.jsxs)(`div`,{className:`runs-screen agents-screen ${t?`in-agent`:``} ${ce?`has-knowledge`:``}`,style:ce?{"--kside-w":`${oe}px`}:void 0,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`agents`,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,href:`/agents/new`,children:`new`})}),(0,z.jsxs)(jt,{children:[(0,z.jsx)(`div`,{className:`mb-1.5 border-b border-line pb-1.5`,children:(0,z.jsx)(gt,{href:`/agents/chats`,active:n===`chats`,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:`🎩`}),title:`Ralv`,sub:`chief of staff of the workspace`})}),(0,z.jsxs)(`div`,{className:I(`rounded-xl`,g&&y===``&&Vx),...P(``),children:[k.map(te),g!=null&&k.length===0&&(0,z.jsx)(`div`,{className:Hx,children:`no group — drop here`})]}),O.map(e=>{let t=w.filter(t=>t.group===e);return(0,z.jsxs)(`div`,{className:I(`group/grp mt-3 rounded-xl`,g&&y===e&&Vx),...P(e),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pt-1.5 pb-0.5`,children:[f===e?(0,z.jsx)(Z,{className:`h-7 min-w-0 flex-1 text-2xs`,autoFocus:!0,"aria-label":`group name`,value:m,onChange:e=>h(e.target.value),onKeyDown:t=>{t.key===`Enter`&&M(e,m),t.key===`Escape`&&p(null)},onBlur:()=>M(e,m)}):(0,z.jsx)(it,{children:e}),(0,z.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-2`,children:t.length}),(0,z.jsx)(`span`,{className:`flex-1`}),f!==e&&(0,z.jsx)(q,{icon:`edit`,label:`Rename group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>{p(e),h(e)}}),t.length===0&&o.includes(e)&&(0,z.jsx)(q,{icon:`close`,label:`Remove empty group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>ee(o.filter(t=>t!==e))})]}),t.map(te),t.length===0&&(0,z.jsx)(`div`,{className:Hx,children:`drag agents here`})]},e)}),T.length>0&&(0,z.jsxs)(`div`,{className:`mt-2.5 border-t border-line pt-1`,children:[(0,z.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":E,onClick:()=>D(e=>!e),children:[(0,z.jsx)(it,{className:`group-hover/arch:text-fg`,children:`archived`}),(0,z.jsx)(`span`,{className:`text-[10px] tabular-nums`,children:T.length}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(B,{name:E?`expand_less`:`expand_more`,className:`ms-sm`})]}),E&&T.map(R)]}),a&&C.length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-2.5`,children:`no agents yet`}),c?(0,z.jsx)(`div`,{className:`px-2.5 pt-2.5 pb-1`,children:(0,z.jsx)(Z,{className:`h-8 text-sm`,autoFocus:!0,"aria-label":`new group`,value:u,placeholder:`group name, e.g. Team Content`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j(),e.key===`Escape`&&(l(!1),d(``))},onBlur:j})}):(0,z.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:()=>l(!0),children:[(0,z.jsx)(B,{name:`add`,className:`ms-sm`}),` group`]})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:ne}),ce&&(0,z.jsx)(hx,{bundles:re,onHide:()=>le(!1),onResize:ue}),re.length>0&&!ie&&(0,z.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:()=>le(!0),title:`Show knowledge sidebar`,children:[(0,z.jsx)(B,{name:`menu_book`,className:`ms-sm`}),` knowledge`]})]})}function Wx(e){if(!me(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,z.jsx)(Qb,{},`new-project`):r?(0,z.jsx)(zx,{},`new-agent`):(0,z.jsx)(dn,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,z.jsx)(ax,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,z.jsx)(Lx,{slug:n},n):r&&t[2]===`edit`?(0,z.jsx)(zx,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,z.jsx)(dn,{slug:n},n):null}function Gx({back:e,children:t}){let n=()=>H(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,z.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,z.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,z.jsx)(q,{icon:`close`,label:`close (esc)`,className:`absolute top-3 right-3 z-1 rounded-full`,onClick:n}),(0,z.jsx)(`div`,{className:`runs-main min-w-0 pt-[18px] pr-12 pb-10 pl-6`,children:t})]})})}function Kx(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function qx(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function Jx({slug:e,tab:t}){let n=F(`workflows.list`,{}),r=F(`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:Kx(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&&H(`/workflows/${encodeURIComponent(l)}`,{replace:!0})},[e,l,u]),(0,z.jsxs)(`div`,{className:`runs-screen workflows-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`workflows`,count:n?o.length:void 0,action:(0,z.jsxs)(K,{size:`sm`,variant:`quiet`,icon:`history`,href:`/runs`,title:`every run of every workflow, newest first`,children:[`runs `,(0,z.jsx)(`span`,{className:`tabular-nums`,children:s.length})]})}),o.length>0&&(0,z.jsx)(At,{icon:`search`,value:i,placeholder:`search workflows`,"aria-label":`search workflows`,onChange:e=>a(e.target.value)}),(0,z.jsxs)(jt,{children:[c.map(t=>{let n=Kx(s,t);return(0,z.jsx)(gt,{className:`wf-row`,href:`/workflows/${encodeURIComponent(t.slug)}`,active:t.slug===e,leading:(0,z.jsx)(et,{tone:jg(n.last?.status),title:n.last?.status??`no runs yet`}),title:t.name??t.slug,titleExtra:t.error&&(0,z.jsx)(J,{tone:`bad`,children:`broken`}),meta:n.last&&G(n.last.updatedAt),sub:(0,z.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,z.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:()=>H(qx(n.last,t)),children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,z.jsx)(Mg,{status:n.last.status})]}):(0,z.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,z.jsxs)(Mt,{className:`wf-nomatch`,children:[`no workflow matches “`,i,`”`]}),n&&o.length===0&&(0,z.jsx)(Mt,{children:`no workflows yet`})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:e?(0,z.jsx)(p_,{slug:e,tab:t},e):n&&o.length===0?(0,z.jsxs)(Y,{icon:`account_tree`,children:[`No workflows found — expected `,(0,z.jsx)(`code`,{children:`src/workflows/`}),` or `,(0,z.jsx)(`code`,{children:`workflows/`}),` next to the output folder.`]}):(0,z.jsx)(Y,{children:`loading…`})})]})}var Yx={agents:{label:`agents`,icon:`smart_toy`},"agent-skills":{label:`agent skills`,icon:`extension`},projects:{label:`projects`,icon:`folder`},boards:{label:`boards`,icon:`view_kanban`},tasks:{label:`tasks`,icon:`task`},presentations:{label:`presentations`,icon:`slideshow`},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 Xx(){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:P(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(Yx).indexOf(e)-Object.keys(Yx).indexOf(t));return(0,z.jsxs)(ct,{className:`px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{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,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(K,{variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`empty`,`*`),children:[`delete all `,u.length,` for good`]}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,z.jsx)(K,{variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(`*`),children:`empty trash`}))}),n&&(0,z.jsx)(rt,{tone:`bad`,children:n}),!e&&!n&&(0,z.jsx)(X,{children:(0,z.jsx)(Y,{children:`loading…`})}),e&&u.length===0&&(0,z.jsx)(X,{children:(0,z.jsx)(Y,{icon:`delete`,children:`The trash is empty. What you delete lands here first.`})}),d.map(e=>(0,z.jsx)(X,{title:Yx[e]?.label??e,actions:(0,z.jsxs)(`code`,{className:`text-xs text-fg-2`,children:[`trash/`,e,`/`]}),children:(0,z.jsx)(`div`,{className:`p-1.5`,children:u.filter(t=>t.kind===e).map(t=>(0,z.jsx)(gt,{className:`trash-row`,leading:(0,z.jsx)(B,{name:Yx[e]?.icon??`draft`,className:`ms-sm`}),title:t.name,sub:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-mono`,children:t.from}),` · `,(0,z.jsxs)(`span`,{title:t.trashedAt,children:[`deleted `,G(t.trashedAt)]})]}),meta:(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(K,{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,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`purge`,t.id),children:`delete for good`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(t.id),children:`delete`})]})},t.id))})},e)),e&&(0,z.jsxs)(`p`,{className:`m-0 text-sm text-fg-2`,children:[`The trash lives in `,(0,z.jsx)(`code`,{children:e.root}),`, kept out of the workspace git. From the terminal:`,` `,(0,z.jsx)(`code`,{children:`kraftwerk trash`}),`, `,(0,z.jsx)(`code`,{children:`kraftwerk trash restore <id>`}),`, `,(0,z.jsx)(`code`,{children:`kraftwerk trash empty`}),`.`]})]})}function Zx(){let[e,t]=(0,v.useState)(`overview`),[n,r]=(0,v.useState)(!0);return(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4 p-6`,children:[(0,z.jsx)(st,{title:`Components`,sub:`src/ui — what every screen is built from`,actions:(0,z.jsx)(K,{variant:`primary`,icon:`add`,children:`primary`})}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,z.jsxs)(X,{title:`Buttons`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 p-4`,children:[(0,z.jsx)(K,{variant:`primary`,icon:`play_arrow`,children:`Run`}),(0,z.jsx)(K,{variant:`secondary`,icon:`upload`,children:`Upload`}),(0,z.jsx)(K,{variant:`quiet`,icon:`create_new_folder`,children:`Folder`}),(0,z.jsx)(K,{variant:`danger`,icon:`delete`,children:`Move to trash`}),(0,z.jsx)(K,{variant:`primary`,busy:!0,children:`Saving`}),(0,z.jsx)(K,{variant:`secondary`,disabled:!0,children:`Disabled`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 pb-4`,children:[(0,z.jsx)(K,{size:`sm`,variant:`primary`,children:`small`}),(0,z.jsx)(K,{size:`sm`,variant:`secondary`,children:`small`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,children:`small`}),(0,z.jsx)(q,{icon:`edit`,label:`Rename`}),(0,z.jsx)(q,{icon:`download`,label:`Download`}),(0,z.jsx)(q,{icon:`delete`,label:`Delete`,variant:`danger`}),(0,z.jsx)(q,{icon:`close`,label:`Close`,size:`sm`})]})]}),(0,z.jsxs)(X,{title:`Status`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,z.jsx)($e,{n:3}),` `,(0,z.jsx)($e,{n:12,tone:`neutral`}),(0,z.jsx)(et,{tone:`ok`}),` `,(0,z.jsx)(et,{tone:`bad`}),` `,(0,z.jsx)(et,{tone:`ask`}),` `,(0,z.jsx)(et,{tone:`live`}),` `,(0,z.jsx)(et,{tone:`working`}),` `,(0,z.jsx)(et,{tone:`idle`}),(0,z.jsx)(J,{children:`static`}),` `,(0,z.jsx)(J,{tone:`ok`,children:`done`}),` `,(0,z.jsx)(J,{tone:`bad`,children:`failed`}),` `,(0,z.jsx)(J,{tone:`ask`,children:`needs approval`}),` `,(0,z.jsx)(J,{tone:`accent`,children:`running`})]}),(0,z.jsx)(rt,{tone:`bad`,children:`Could not upload brief.pdf`}),(0,z.jsx)(rt,{children:`uploading 2 of 3…`})]}),(0,z.jsx)(X,{title:`Rows`,count:1,actions:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`arrow_forward`,children:`all`}),children:(0,z.jsxs)(`div`,{className:`p-1.5`,children:[(0,z.jsx)(gt,{leading:`🐻`,title:`Max`,sub:`waiting for you · Set up the build`,subTone:`bad`,titleExtra:(0,z.jsx)($e,{n:1}),href:`/ui`}),(0,z.jsx)(gt,{leading:`🦊`,title:`Lisa`,sub:`last active 2h ago`,href:`/ui`,active:!0}),(0,z.jsx)(gt,{leading:(0,z.jsx)(`span`,{className:`ms material-symbols-rounded ms-sm`,children:`folder`}),title:`briefing`,meta:`3 files`,onClick:()=>{},actions:(0,z.jsx)(q,{icon:`edit`,label:`Rename`,size:`sm`})}),(0,z.jsx)(gt,{leading:(0,z.jsx)(et,{tone:`working`}),title:`website-check`,sub:`https://netnode.ch`,meta:`running`,size:`sm`}),(0,z.jsx)(gt,{leading:`📁`,title:`Gone project`,sub:`not in this workspace`,dim:!0})]})}),(0,z.jsxs)(X,{title:`Tabs and sections`,children:[(0,z.jsx)(_t,{items:[{id:`overview`,label:`overview`},{id:`files`,label:`files`,count:4},{id:`knowledge`,label:`knowledge`,count:0}],value:e,onChange:t}),(0,z.jsxs)(`div`,{className:`p-2`,children:[(0,z.jsx)(at,{size:`lg`,title:`needs you`,count:2,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,children:`all`}),children:(0,z.jsx)(gt,{leading:`✋`,title:`Run npm install`,sub:`🐻 Max · needs approval · 4m ago`,onClick:()=>{}})}),(0,z.jsx)(at,{title:`team`,children:(0,z.jsx)(gt,{leading:`🦊`,title:`Lisa`,sub:`Research`})})]})]}),(0,z.jsx)(X,{title:`Fields`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,z.jsx)(Q,{label:`Name`,hint:`Shown in the rail.`,children:(0,z.jsx)(Z,{placeholder:`e.g. Max`})}),(0,z.jsx)(Q,{label:`Harness`,children:(0,z.jsxs)(St,{defaultValue:`claude`,children:[(0,z.jsx)(`option`,{children:`claude`}),(0,z.jsx)(`option`,{children:`codex`}),(0,z.jsx)(`option`,{children:`pi`}),(0,z.jsx)(`option`,{children:`antigravity`})]})}),(0,z.jsx)(Q,{label:`Role`,children:(0,z.jsx)(xt,{rows:3,placeholder:`What this agent does`})})]})}),(0,z.jsxs)(X,{title:`Empty and menus`,children:[(0,z.jsx)(Y,{icon:`upload_file`,action:(0,z.jsx)(K,{variant:`secondary`,size:`sm`,icon:`upload`,children:`choose files`}),children:`Drop files here.`}),(0,z.jsx)(`div`,{className:`p-4`,children:(0,z.jsx)(Nt,{trigger:({toggle:e})=>(0,z.jsx)(K,{onClick:e,icon:`expand_more`,children:`menu`}),children:e=>(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,z.jsx)(gt,{leading:`⚙️`,title:`Settings`,onClick:e,size:`sm`}),(0,z.jsx)(gt,{leading:`🗑`,title:`Trash`,onClick:e,size:`sm`})]})})})]}),(0,z.jsx)(X,{title:`Sidebar parts`,children:(0,z.jsxs)(`div`,{className:`w-[300px] border-r border-line`,children:[(0,z.jsx)(kt,{title:`workflows`,count:3,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,children:`new`})}),(0,z.jsx)(At,{placeholder:`search workflows`,"aria-label":`search workflows`}),(0,z.jsxs)(jt,{children:[(0,z.jsx)(gt,{leading:(0,z.jsx)(et,{tone:`ok`}),title:`triage`,sub:`checks, drafts, publishes`,size:`sm`,active:!0}),(0,z.jsx)(Mt,{children:`no workflow matches “x”`})]})]})}),(0,z.jsx)(X,{title:`Choices`,children:(0,z.jsxs)(Ct,{children:[(0,z.jsx)(Tt,{checked:n,onChange:r,hint:`every discovered skill`,children:`all skills`}),(0,z.jsx)(Tt,{checked:!n,onChange:e=>r(!e),hint:`0 concepts`,mono:!0,children:`brand-guide`}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(Dt,{checked:n,onChange:r,label:`routine enabled`}),(0,z.jsxs)(nt,{children:[`Hint: a small explaining line. Keys look like `,(0,z.jsx)(tt,{children:`⌘K`}),`.`]})]}),(0,z.jsx)(Ot,{label:`Docker sandbox`,hint:`Docker is not running`,checked:n,onChange:r})]})}),(0,z.jsxs)(X,{title:`Page parts`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(lt,{children:`🐻`}),(0,z.jsx)(ot,{size:`lg`,children:`Max`}),(0,z.jsx)(J,{href:`#/ui`,children:`linked tag`})]}),(0,z.jsx)(_t,{bare:!0,label:`link tabs`,value:`pages`,items:[{id:`pages`,label:`pages`,href:`/ui`},{id:`activity`,label:`activity`,href:`/ui`}]})]}),(0,z.jsxs)(ft,{children:[(0,z.jsx)(dt,{icon:`account_tree`,title:`workflows`,action:(0,z.jsx)(K,{size:`sm`,children:`edit`}),children:(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none connected`})}),(0,z.jsx)(dt,{icon:`menu_book`,title:`knowledge`})]}),(0,z.jsxs)(mt,{children:[(0,z.jsx)(ht,{label:`source`,children:`workspace`}),(0,z.jsx)(ht,{label:`path`,mono:!0,children:`skills/release-notes/SKILL.md`})]})]})]})]})}var Qx={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`}},$x={running:`text-ok`,stopped:`text-fg-2`,died:`text-ask`,missing:`text-bad`,orphaned:`text-bad`},eS={running:``,stopped:`opacity-65 grayscale-50`,died:`opacity-80`,missing:`opacity-45 grayscale-80`,orphaned:`opacity-45 grayscale-80`};function tS(){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(P(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,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`hub`,className:`text-[28px] text-fg-2`}),title:`Workspaces`,actions:(0,z.jsxs)(z.Fragment,{children:[e&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[e.length,` known · `,p,` running`]}),e&&n&&(0,z.jsx)(rt,{tone:`bad`,children:n})]})}),(0,z.jsxs)(X,{title:`workspaces on this machine`,actions:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`registry: `,(0,z.jsx)(`code`,{className:`text-2xs`,children:`~/.kraftwerk/workspaces`})]}),children:[!e&&!n&&(0,z.jsx)(Y,{className:`py-6`,children:`loading…`}),!e&&n&&(0,z.jsx)(`div`,{className:`px-[18px] py-4`,children:(0,z.jsx)(rt,{tone:`bad`,children:n})}),e&&e.length===0&&(0,z.jsx)(Y,{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=I(`text-md font-semibold text-fg`,e.named===!1&&`italic text-fg-2`);return(0,z.jsxs)(`div`,{className:I(`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,z.jsx)(Ve,{className:I(`size-10`,eS[e.state]),icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:h(e.icon)}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[e.live&&!e.current?(0,z.jsx)(`a`,{href:he(e),className:I(a,`no-underline hover:underline`),children:e.name}):(0,z.jsx)(`span`,{className:a,children:e.name}),e.current&&(0,z.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.4px] text-fg-2 uppercase`,children:`current`}),(0,z.jsxs)(`span`,{className:I(`inline-flex items-center gap-1.5 text-2xs font-semibold tracking-[0.4px] uppercase`,$x[e.state]),children:[e.live&&(0,z.jsx)(`span`,{className:`inline-block size-2 rounded-full bg-ok`}),Qx[e.state].label]}),Qx[e.state].note&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:Qx[e.state].note})]}),(0,z.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.root,children:e.rootLabel??(0,z.jsx)(`span`,{className:`font-sans opacity-70`,children:`no root recorded (started by an older version)`})}),(0,z.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,z.jsx)(`span`,{children:e.url.replace(/^https?:\/\//,``)}),e.counts&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`span`,{children:[e.counts.agents,` agents`]}),(0,z.jsxs)(`span`,{children:[e.counts.workflows,` workflows`]}),(0,z.jsxs)(`span`,{children:[e.counts.runs,` runs`]}),(0,z.jsxs)(`span`,{children:[e.counts.chats,` chats`]})]}),e.lastStarted&&(0,z.jsxs)(`span`,{title:e.lastStarted,children:[`started `,G(e.lastStarted)]}),!e.live&&e.lastStopped&&(0,z.jsxs)(`span`,{title:e.lastStopped,children:[`stopped `,G(e.lastStopped)]}),e.startCount!=null&&(0,z.jsxs)(`span`,{children:[e.startCount,`× launched`]}),e.firstSeen&&(0,z.jsxs)(`span`,{title:e.firstSeen,children:[`first seen `,G(e.firstSeen)]})]}),o[t]&&(0,z.jsx)(rt,{tone:`bad`,children:o[t]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[e.live&&!e.current&&(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:he(e),title:`Open this workspace`,children:[(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),` open`]}),!e.live&&e.root&&e.exists!==!1&&!e.dirGone&&(0,z.jsx)(K,{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,z.jsx)(K,{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,z.jsx)(K,{size:`sm`,icon:`delete`,disabled:!!n,title:`Drop this project from the registry (files untouched)`,onClick:()=>l(t),children:`remove`}),r&&c===t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void f(e,`forget`),children:`confirm remove`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},t)})]}),(0,z.jsxs)(`p`,{className:`m-0 text-xs text-fg-2 [&_code]:text-2xs`,children:[`Start launches `,(0,z.jsx)(`code`,{children:`kraftwerk ui`}),` detached in the project root (log in `,(0,z.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,z.jsx)(`code`,{children:`kraftwerk.yml`}),` — the same from the terminal:`,` `,(0,z.jsx)(`code`,{children:`kraftwerk workspaces`}),`.`]})]})}var nS=40,rS=/Mac|iPhone|iPad/.test(navigator.platform),iS=null,aS=e=>(e?.workspaces??[]).flatMap(e=>[...e.agents.map(t=>({kind:`agent`,agent:t,ws:e,key:`${e.url}|agent|${t.slug}`})),...(e.projects??[]).map(t=>({kind:`project`,project:t,ws:e,key:`${e.url}|project|${t.slug}`})),...(e.channels??[]).map(t=>({kind:`channel`,channel:t,ws:e,key:`${e.url}|channel|${t.slug}`})),...(e.entities??[]).map(t=>({kind:`entity`,entity:t,ws:e,key:`${e.url}|${t.kind}|${t.slug}`})),...(e.current?e.tasks??[]:[]).map(t=>({kind:`task`,task:t,ws:e,key:`${e.url}|task|${t.project??``}|${t.board}|${t.slug}`})),...(e.current?e.decks??[]:[]).map(t=>({kind:`deck`,deck:t,ws:e,key:`${e.url}|deck|${t.project??``}|${t.name}`}))]),oS=e=>e.kind===`thing`?e.thing.name:e.kind===`agent`?e.agent.name:e.kind===`project`?e.project.title:e.kind===`entity`?e.entity.title:e.kind===`task`?e.task.title:e.kind===`deck`?e.deck.title:e.channel.name,sS=e=>e.kind===`thing`?e.thing.sub:e.kind===`agent`?e.agent.description:e.kind===`project`?e.project.goal||(e.project.status===`active`?void 0:e.project.status):e.kind===`entity`?e.entity.detail:e.kind===`task`?`${e.task.project?`${e.task.project} · `:``}${e.task.board} · ${e.task.status}`:e.kind===`deck`?`${e.deck.project?`${e.deck.project} · `:``}${e.deck.slides} ${e.deck.slides===1?`slide`:`slides`}`:e.channel.purpose,cS=e=>e.kind===`thing`?e.thing.href:e.kind===`agent`?`/agents/${encodeURIComponent(e.agent.slug)}`:e.kind===`project`?`/projects/${encodeURIComponent(e.project.slug)}`:e.kind===`entity`?`/${e.entity.kind}/${encodeURIComponent(e.entity.slug)}`:e.kind===`task`?e.task.href:e.kind===`deck`?e.deck.href:`/channels/${encodeURIComponent(e.channel.slug)}`,lS={contacts:`contact`,places:`place`,events:`event`},uS={contacts:`person`,places:`location_on`,events:`event`},dS={active:`📁`,paused:`⏸️`,done:`✅`,archived:`🗄️`},fS=e=>e.kind===`agent`?e.agent.emoji:e.kind===`thing`?(0,z.jsx)(B,{name:e.thing.icon,className:`text-[18px] text-fg-2`}):e.kind===`project`?dS[e.project.status]:e.kind===`entity`?(0,z.jsx)(B,{name:uS[e.entity.kind],className:`text-[18px] text-fg-2`}):e.kind===`task`?(0,z.jsx)(B,{name:`task`,className:`text-[18px] text-fg-2`}):e.kind===`deck`?(0,z.jsx)(B,{name:`slideshow`,className:`text-[18px] text-fg-2`}):(0,z.jsx)(B,{name:`forum`,className:`text-[18px] text-fg-2`}),pS=`flex-none rounded-full border border-line px-1.5 py-px text-[10px] font-semibold tracking-[0.4px] uppercase`;function mS(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;let r=[],i=new Map;for(let t of e){i.has(t.ws)||i.set(t.ws,i.size);let e=oS(t).toLowerCase(),a=[e,...t.kind===`thing`?[t.thing.id,t.thing.sub??``,t.thing.type,t.thing.words??``]:t.kind===`agent`?[t.agent.slug,t.agent.description??``,t.agent.group??``,`agent`]:t.kind===`project`?[t.project.slug,t.project.goal??``,t.project.status,`project`]:t.kind===`entity`?[t.entity.slug,t.entity.detail??``,lS[t.entity.kind],`${lS[t.entity.kind]}:${t.entity.slug}`]:t.kind===`task`?[t.task.slug,`task:${t.task.slug}`,t.task.board,t.task.project??``,t.task.status,`task`]:t.kind===`deck`?[t.deck.name,`presentation:${t.deck.name}`,t.deck.project??``,`presentation`,`deck`]:[t.channel.slug,t.channel.purpose??``,`channel`],t.ws.name].join(` `).toLowerCase();if(!n.every(e=>a.includes(e)))continue;let o=e.startsWith(n[0])?0:e.includes(n[0])?1:2;r.push({hit:t,score:o,ws:i.get(t.ws)})}return r.sort((e,t)=>e.ws-t.ws||e.score-t.score).map(e=>e.hit)}function hS(e){let t=[];for(let n of e){let e=t.find(e=>e.ws===n.ws);e?e.hits.push(n):t.push({ws:n.ws,hits:[n]})}return t}async function gS(e){let t=cS(e);if(e.ws.current)return H(t);let n=e.ws.live||!e.ws.root?he(e.ws):await ge(e.ws.root);window.location.assign(`${n.replace(/\/+$/,``)}/#${t}`)}var _S={type:`command`,id:`New chat`,name:`New chat`,href:`/agents/chats`,icon:`chat`,words:`start session message ask`,keys:`⌥C`,act:{kind:`chat`,label:`chat`}},vS={type:`command`,id:`New task`,name:`New task`,href:`/boards`,icon:`task_alt`,words:`add todo create`,keys:`⌥T`,act:{kind:`task`,label:`add`}};function yS(){let[e,t]=(0,v.useState)(!1),n=De();return(0,v.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`){e.preventDefault(),t(e=>!e);return}if(!e.altKey||e.metaKey||e.ctrlKey||e.shiftKey||e.code!==`KeyC`&&e.code!==`KeyT`)return;let r=e.target;r&&(r.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(r.tagName))||(e.code!==`KeyT`||n.boards)&&(e.preventDefault(),t(e.code===`KeyC`?_S:vS))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n.boards]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex flex-none cursor-pointer items-center gap-1.5 rounded-xl border-0 bg-transparent py-1 pr-2 pl-1.5 text-fg-2 transition-colors hover:bg-surface-2 hover:text-fg active:scale-96`,onClick:()=>t(!0),title:`jump to anything, or do something (⌥C new chat, ⌥T new task)`,"aria-label":`search`,children:[(0,z.jsx)(B,{name:`search`}),(0,z.jsx)(tt,{className:`max-[1100px]:hidden`,children:rS?`⌘K`:`Ctrl K`})]}),e&&(0,z.jsx)(bS,{start:e===!0?void 0:e,onClose:()=>t(!1)})]})}function bS({onClose:e,start:t}){let[n,r]=(0,v.useState)(iS),[i,a]=(0,v.useState)(iS===null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(0),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(``),g=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=!0;return A.call(`search.agents`).then(t=>{iS=t,e&&r(t)}).catch(()=>e&&s(!0)).finally(()=>e&&a(!1)),()=>{e=!1}},[]);let _=SS(),[y,b]=(0,v.useState)(t??null),x=(0,v.useMemo)(()=>{let e=aS(n),t=n?.workspaces.find(e=>e.current);if(!t)return e;let r=_.map(e=>({kind:`thing`,thing:e,ws:t,key:`${t.url}|${e.type}|${e.id}`})),i=e.findIndex(e=>e.ws===t),a=e.reduce((e,n,r)=>n.ws===t?r+1:e,0),o=r.filter(e=>e.kind===`thing`&&e.thing.type===`command`),s=r.filter(e=>!o.includes(e));return i<0?[...r,...e]:[...e.slice(0,i),...o,...e.slice(i,a),...s,...e.slice(a)]},[n,_]),S=(0,v.useMemo)(()=>mS(x,c).slice(0,nS),[x,c]),C=(0,v.useMemo)(()=>hS(S),[S]),w=Math.min(u,Math.max(S.length-1,0));(0,v.useEffect)(()=>{g.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[w,S]);let T=e=>e?.kind===`thing`?e.thing.act:void 0,E=t=>{if(!f){if(t.kind===`thing`&&t.thing.type===`command`&&t.thing.act)return b(t.thing);t.ws.current||t.ws.live?(e(),gS(t)):(p(t.key),h(``),gS(t).catch(e=>{p(null),h(`${t.ws.name}: ${e.message}`)}))}},D=t=>{if(y)t.key===`Escape`&&(t.preventDefault(),b(null));else if(t.key===`Tab`&&!t.shiftKey&&T(S[w]))t.preventDefault(),b(S[w].thing);else if(t.key===`ArrowDown`)t.preventDefault(),d(S.length?(w+1)%S.length:0);else if(t.key===`ArrowUp`)t.preventDefault(),d(S.length?(w-1+S.length)%S.length:0);else if(t.key===`Enter`){t.preventDefault();let e=S[w];e&&E(e)}else t.key===`Escape`&&(t.preventDefault(),e())},O=`px-4 py-7 text-center text-sm text-fg-2 [&_a]:underline`,k;if(S.length>0){let e=-1;k=(0,z.jsx)(`ul`,{className:`m-0 list-none overflow-y-auto overscroll-contain p-1.5`,role:`listbox`,"aria-label":`agents, projects and channels`,ref:g,children:C.map(t=>(0,z.jsxs)(v.Fragment,{children:[(0,z.jsxs)(`li`,{className:`palette-group flex items-center gap-1.5 px-2.5 pt-3 pb-1 text-2xs font-semibold tracking-[0.4px] text-fg-2 uppercase first:pt-1.5`,role:`presentation`,title:t.ws.current?`this workspace`:t.ws.url,children:[t.ws.icon&&(0,z.jsx)(`span`,{"aria-hidden":!0,children:t.ws.icon}),(0,z.jsx)(`span`,{className:`truncate`,children:t.ws.name}),t.ws.current?(0,z.jsx)(`span`,{className:`font-normal tracking-normal normal-case`,children:`this workspace`}):t.ws.live?(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}):(0,z.jsx)(`span`,{className:pS,children:`stopped`})]}),t.hits.map(t=>{let n=++e;return(0,z.jsxs)(`li`,{role:`option`,"aria-selected":n===w,className:I(`flex cursor-pointer items-center gap-2.5 rounded-xl px-2.5 py-2`,n===w&&`bg-surface-2`),onMouseMove:()=>n!==w&&d(n),onClick:()=>E(t),children:[(0,z.jsx)(`span`,{className:`w-6 flex-none text-center text-[18px] leading-none`,"aria-hidden":!0,children:fS(t)}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(`span`,{className:`truncate text-[13.5px] font-medium text-fg`,children:oS(t)}),sS(t)&&(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:sS(t)})]}),t.kind===`thing`&&t.thing.act&&t.thing.type!==`command`&&(0,z.jsx)(`button`,{type:`button`,className:`palette-act inline-flex flex-none cursor-pointer items-center gap-1 rounded-full border border-line bg-surface px-2 py-0.5 text-xs font-medium text-fg hover:bg-accent-soft hover:text-on-accent-soft`,title:`${t.thing.act.label} here (Tab)`,onClick:e=>{e.stopPropagation(),b(t.thing)},children:t.thing.act.label}),f===t.key?(0,z.jsx)(B,{name:`progress_activity`,className:`ms-sm`}):t.kind===`thing`&&t.thing.keys?(0,z.jsx)(tt,{children:t.thing.keys}):t.kind===`thing`?(0,z.jsx)(`span`,{className:I(pS,`text-fg-2`),children:t.thing.type}):t.kind!==`agent`&&(0,z.jsx)(`span`,{className:I(pS,`text-fg-2`),children:t.kind===`entity`?lS[t.entity.kind]:t.kind===`deck`?`presentation`:t.kind})]},t.key)})]},t.ws.url||t.ws.name))})}else k=o?(0,z.jsx)(`div`,{className:O,children:`could not load the agents, projects and channels`}):i?(0,z.jsx)(`div`,{className:O,children:`looking for agents, projects and channels…`}):x.length===0?(0,z.jsxs)(`div`,{className:O,children:[`no agents yet — `,(0,z.jsx)(`a`,{href:`#/agents/new`,onClick:e,children:`create one`})]}):(0,z.jsxs)(`div`,{className:O,children:[`no agent, project or channel matches “`,c,`”`]});return(0,z.jsx)(`div`,{className:`palette-backdrop fixed inset-0 z-50 flex animate-fade items-start justify-center bg-black/35 px-4 pt-[12vh] pb-4`,onMouseDown:e,children:(0,z.jsxs)(`div`,{className:`flex max-h-[min(70dvh,560px)] w-[min(620px,100%)] animate-modal flex-col overflow-hidden rounded-2xl border border-line bg-surface shadow-modal`,role:`dialog`,"aria-label":`jump to an agent, project or channel`,onMouseDown:e=>e.stopPropagation(),onKeyDown:D,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4 py-3 text-fg-2`,children:[(0,z.jsx)(B,{name:`search`}),(0,z.jsx)(`input`,{autoFocus:!0,className:`min-w-0 flex-1 border-0 bg-transparent p-0 font-sans text-[16px] text-fg outline-none`,value:c,onChange:e=>{l(e.target.value),d(0)},placeholder:`jump to anything, or do something: new chat, new task, a skill, a workflow…`,disabled:!!y,"aria-label":`search`,autoComplete:`off`,spellCheck:!1}),i&&n&&(0,z.jsx)(B,{name:`progress_activity`,className:`ms-sm`}),(0,z.jsx)(tt,{children:`esc`})]}),y?(0,z.jsx)(Jt.Provider,{value:()=>(e(),!1),children:(0,z.jsxs)(`div`,{className:`palette-action flex flex-col gap-2 overflow-y-auto p-3`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex cursor-pointer items-center gap-1 self-start border-0 bg-transparent p-0 text-xs text-fg-2 hover:text-fg`,onClick:()=>b(null),children:[(0,z.jsx)(B,{name:`arrow_back`,className:`ms-sm`}),` back to the list`]}),y.act?.kind===`skill`&&(0,z.jsx)(Fy,{name:y.id}),y.act?.kind===`workflow`&&(0,z.jsx)(Eg,{slug:y.id,usesRequest:y.act.usesRequest!==!1}),y.act?.kind===`chat`&&(0,z.jsx)(Vy,{}),y.act?.kind===`task`&&(0,z.jsx)(Wy,{})]})}):k,(0,z.jsxs)(`div`,{className:`flex items-center gap-3.5 border-t border-line px-3.5 py-2 text-2xs text-fg-2 [&>span]:inline-flex [&>span]:items-center [&>span]:gap-1`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(tt,{children:`↑`}),(0,z.jsx)(tt,{children:`↓`}),` move`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(tt,{children:`↵`}),` `,y?`send`:`open`]}),!y&&T(S[w])&&S[w].kind===`thing`&&S[w].thing.type!==`command`&&(0,z.jsxs)(`span`,{children:[(0,z.jsx)(tt,{children:`⇥`}),` `,T(S[w]).label,` here`]}),y&&(0,z.jsxs)(`span`,{children:[(0,z.jsx)(tt,{children:`esc`}),` back`]}),f&&(0,z.jsxs)(`span`,{className:`ml-auto`,children:[(0,z.jsx)(B,{name:`progress_activity`,className:`ms-sm`}),` starting the workspace…`]}),m&&(0,z.jsxs)(`span`,{className:`ml-auto max-w-[60%] truncate text-bad`,title:m,children:[(0,z.jsx)(B,{name:`warning`,className:`ms-sm`}),` `,m]})]})]})})}var xS=encodeURIComponent;function SS(){let e=De(),t=F(`skills.list`,{}),n=F(`workflows.list`,{}),r=F(`routines.list`,{}),i=F(`knowledge.list`,{}),a=F(`vibeables.list`,e.vibeables?{}:null),o=F(`chats.list`,{});return(0,v.useMemo)(()=>{let s=(e,t,n,r=``)=>({type:`page`,id:t,name:e,href:t,icon:n,words:`settings overview ${r}`}),c=(e,t,n,r,i)=>({type:`command`,id:e,name:e,href:t,icon:n,words:r,act:i});return[_S,...e.boards?[vS]:[],c(`New routine`,`/?kind=routines&open=${xS(`routines:_:new`)}`,`schedule`,`create schedule cron`),c(`New agent`,`/agents/new`,`smart_toy`,`create coworker`),...e.projects?[c(`New project`,`/projects/new`,`folder`,`create`)]:[],...e.boards?[c(`New board`,`/boards/new`,`view_kanban`,`create kanban`)]:[],c(`New knowledge bundle`,`/knowledge/new`,`menu_book`,`create wiki`),...(t?.skills??[]).filter(e=>e.source===`workspace`||e.source===`project`).map(e=>({type:`skill`,id:e.name,name:`/${e.name}`,sub:e.description||void 0,icon:`extension`,href:`/skills/${xS(e.name)}`,act:{kind:`skill`,label:`use`}})),...(n?.workflows??[]).map(e=>({type:`workflow`,id:e.slug,name:e.name||e.slug,sub:e.description||void 0,icon:`account_tree`,href:`/workflows/${xS(e.slug)}`,words:e.slug,act:e.error?void 0:{kind:`workflow`,label:`run`,usesRequest:e.usesRequest}})),...(r?.routines??[]).map(e=>({type:`routine`,id:`${e.owner}:${e.id}`,name:e.name,sub:e.schedule,icon:`schedule`,href:`/?kind=routines&open=${xS(`routines:${e.owner}:${e.id}`)}`})),...(i?.bundles??[]).map(e=>({type:`knowledge`,id:e.name,name:e.name,sub:`${e.concepts} pages`,icon:`menu_book`,href:`/knowledge/${xS(e.name)}`})),...(a?.vibeables??[]).map(e=>({type:`app`,id:e.slug,name:e.slug,icon:`web`,href:`/vibeables/${xS(e.slug)}`})),...(o?.chats??[]).filter(e=>e.title).slice(0,60).map(e=>({type:`chat`,id:e.id,name:e.title,icon:`chat`,href:Xy(e)})),s(`Home`,`/`,`home`,`everything stream`),s(`Today`,`/today`,`today`,`dashboard attention`),s(`Settings`,`/settings`,`settings`,`base`),s(`All agents`,`/settings/agents`,`smart_toy`,`admin`),s(`All routines`,`/settings/routines`,`schedule`,`admin`),s(`All workflows`,`/workflows`,`account_tree`),s(`All skills`,`/skills`,`extension`),s(`All knowledge`,`/knowledge`,`menu_book`),s(`Files`,`/files`,`folder_open`),...e.boards?[s(`All boards`,`/boards`,`view_kanban`)]:[],...e.presentations?[s(`All presentations`,`/presentations`,`slideshow`,`slides decks`)]:[],...e.vibeables?[s(`All apps`,`/vibeables`,`web`,`vibeables`)]:[],...e.repos?[s(`Repositories`,`/repos`,`source`,`repos`)]:[],...e.git?[s(`Git`,`/git`,`commit`,`sync changes commit`)]:[],s(`Trash`,`/trash`,`delete`,`deleted restore`),s(`Workspaces`,`/workspaces`,`workspaces`)]},[e,t,n,r,i,a,o])}var CS=1296e5;function wS(e){if(e<6e4)return`just now`;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function TS(e,t){let n=new Date(e),r=n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),i=Math.round((new Date(n).setHours(0,0,0,0)-new Date(t).setHours(0,0,0,0))/864e5);return i<=0?r:i===1?`tomorrow ${r}`:`${n.toLocaleDateString([],{weekday:`short`})} ${r}`}function ES(e,t=``,n=new Date){if(!e)return t?{text:t,tone:`plain`}:null;let r=e=>`${e[0].title||`a session`}${e.length>1?` +${e.length-1}`:``}`;if(e.waiting.length)return{text:`waiting for you · ${r(e.waiting)}`,tone:`waiting`};if(e.working.length){let t=e.working[0].since,i=t?wS(Math.max(0,n.getTime()-Date.parse(t))):``;return{text:`working · ${r(e.working)}${i&&i!==`just now`?` · ${i}`:``}`,tone:`working`}}if(e.nextRoutine&&Date.parse(e.nextRoutine.at)-n.getTime()<CS)return{text:`next: ${e.nextRoutine.name} · ${TS(e.nextRoutine.at,n)}`,tone:`plain`};if(e.lastActiveAt){let t=wS(Math.max(0,n.getTime()-Date.parse(e.lastActiveAt)));return{text:t===`just now`?`last active just now`:`last active ${t} ago`,tone:`plain`}}return{text:t||`no sessions yet`,tone:`plain`}}var DS=e=>`section`in e;function OS(e){return[...e.top.map(e=>({slug:e})),...e.sections.flatMap(e=>[{section:e.name},...e.projects.map(e=>({slug:e}))])]}function kS(e){let t={top:[],sections:[]};for(let n of e)DS(n)?t.sections.push({name:n.section,projects:[]}):(t.sections.at(-1)?.projects??t.top).push(n.slug);return t}var AS=(e,t)=>DS(e)?`section`in t&&e.section===t.section:`slug`in t&&e.slug===t.slug;function jS(e,t,n){let r=e.findIndex(e=>AS(e,t));if(r<0)return e;let i=r+1;if(`section`in t)for(;i<e.length&&!DS(e[i]);)i++;if(n>=r&&n<=i)return e;let a=e.slice(r,i),o=[...e.slice(0,r),...e.slice(i)],s=n>r?n-a.length:n;return[...o.slice(0,s),...a,...o.slice(s)]}function MS({layout:e,visible:t,render:n,onSave:r,collapsed:i,onCollapse:a,editing:o,onEdited:s}){let[c,l]=(0,v.useState)(null),u=c??OS(e);(0,v.useEffect)(()=>l(null),[JSON.stringify(e)]);let[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(o);(0,v.useEffect)(()=>g(o),[o]);let _=async e=>{l(e),await r(kS(e))||l(null)},y=()=>{f(null),m(null)},b=(e,t)=>{let n=e.currentTarget.getBoundingClientRect(),r=e.clientY>n.top+n.height/2,i=u[t];if(d&&`slug`in d&&DS(i))return t+1;if(d&&`section`in d){let e=t;for(;e>=0&&!DS(u[e]);)e--;if(e<0)return u.findIndex(DS)<0?u.length:u.findIndex(DS);if(!r&&e===t)return e;let n=e+1;for(;n<u.length&&!DS(u[n]);)n++;return n}return r?t+1:t},x=e=>({onDragOver:t=>{if(!d)return;t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`;let n=e===void 0?u.length:b(t,e);n!==p&&m(n)},onDrop:t=>{if(!d)return;t.preventDefault(),t.stopPropagation();let n=jS(u,d,e===void 0?u.length:b(t,e));y(),n!==u&&_(n)}}),S=e=>({draggable:!0,onDragStart:t=>{t.stopPropagation(),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,`slug`in e?e.slug:e.section),f(e)},onDragEnd:y}),C=e=>t=>{if(!t.altKey||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=u.findIndex(t=>!DS(t)&&t.slug===e),r=t.key===`ArrowUp`?n-1:n+2;r<0||r>u.length||_(jS(u,{slug:e},r))},w=e=>d&&p===e?(0,z.jsx)(`div`,{className:`relative h-0`,"aria-hidden":!0,children:(0,z.jsx)(`div`,{className:`absolute inset-x-2 -top-px h-0.5 rounded-full bg-accent`})}):null,T=[],E;return u.forEach((e,r)=>{if(T.push((0,z.jsx)(v.Fragment,{children:w(r)},`line:${r}`)),DS(e)){E=e.section;let t=e.section,n=i(t),o=0;for(let e=r+1;e<u.length&&!DS(u[e]);e++)o++;T.push((0,z.jsx)(`div`,{...x(r),...h===t?{}:S({section:t}),className:I(`group/sec mt-2 flex items-center gap-0.5 rounded-control pl-1 pr-1`,d&&`section`in d&&d.section===t&&`opacity-40`),"data-section":t,children:h===t?(0,z.jsx)(NS,{name:t,taken:u.filter(DS).map(e=>e.section).filter(e=>e!==t),onDone:e=>{g(void 0),s(),e&&e!==t&&_(u.map(n=>DS(n)&&n.section===t?{section:e}:n))}}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1 border-0 bg-transparent px-1 py-1 text-left font-[inherit] text-xs font-semibold text-fg-2 hover:text-fg`,"aria-expanded":!n,title:n?`show the projects in ${t}`:`fold ${t}`,onClick:()=>a(t),children:[(0,z.jsx)(B,{name:`chevron_right`,className:I(`ms-sm flex-none text-[15px] transition-transform`,!n&&`rotate-90`)}),(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,z.jsx)(`span`,{className:`font-normal tabular-nums opacity-70`,children:o})]}),(0,z.jsxs)(`span`,{className:`flex items-center opacity-0 transition-opacity group-hover/sec:opacity-100 group-focus-within/sec:opacity-100 pointer-coarse:opacity-100`,children:[(0,z.jsx)(q,{size:`sm`,icon:`edit`,label:`rename section ${t}`,onClick:()=>g(t)}),(0,z.jsx)(q,{size:`sm`,icon:`close`,label:`remove section ${t}`,title:`remove the section; its projects move up`,onClick:()=>void _(u.filter(e=>!(DS(e)&&e.section===t)))})]})]})},`section:${t}`))}else E&&i(E)&&!t(e.slug)||T.push((0,z.jsx)(`div`,{...x(r),...S({slug:e.slug}),onKeyDown:C(e.slug),className:I(`flex flex-col gap-0.5`,d&&`slug`in d&&d.slug===e.slug&&`opacity-40`),"data-sort":e.slug,children:n(e.slug)},e.slug))}),T.push((0,z.jsx)(v.Fragment,{children:w(u.length)},`line:end`)),d&&T.push((0,z.jsx)(`div`,{className:`h-4`,...x()},`drop:end`)),(0,z.jsx)(z.Fragment,{children:T})}function NS({name:e,taken:t,onDone:n}){let[r,i]=(0,v.useState)(e),a=(0,v.useRef)(null);(0,v.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]);let o=r.trim().slice(0,60),s=!!o&&!t.includes(o);return(0,z.jsx)(`input`,{ref:a,value:r,"aria-label":`section name`,maxLength:60,className:I(`min-w-0 flex-1 rounded-control border bg-surface px-2 py-1 font-[inherit] text-xs font-semibold text-fg outline-none`,s?`border-line focus:border-accent`:`border-bad`),onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n(s?o:void 0),e.key===`Escape`&&n()},onBlur:()=>n(s?o:void 0)})}function PS(e){let t=new Set(e.sections.map(e=>e.name)),n=`New section`;for(let e=2;t.has(n);e++)n=`New section ${e}`;return n}function FS({chatPath:e}){let t=De(),n=F(`agents.list`,{},{interval:15e3}),r=F(`projects.list`,t.projects?{}:null,{interval:15e3}),i=F(`agents.status`,{},{interval:5e3}),a=e.split(`/`).filter(Boolean),o=(e,t)=>a[0]===e&&(t===void 0||(a[1]?decodeURIComponent(a[1]):void 0)===t),s=a[0]===`agents`&&a[1]===`chats`,[c,l]=zS(),u=rs()??[],d=new Map((n?.agents??[]).filter(e=>!e.archived).map(e=>[e.slug,e])),f=(r?.projects??[]).filter(e=>e.status!==`archived`||o(`projects`,e.slug)),p=e=>(e.agents??[]).map(e=>d.get(e)).filter(e=>!!e),m=e=>o(`projects`,e.slug),h=new Map(f.map(e=>[e.slug,e])),g=r?.layout?[...r.layout.top,...r.layout.sections.flatMap(e=>e.projects)].map(e=>h.get(e)).filter(e=>!!e):f,_=async e=>!!(await A.request(`projects.saveLayout`,{body:e}).catch(()=>null))?.ok,[y,b]=(0,v.useState)(),x=async()=>{if(!r?.layout)return;let e=PS(r.layout);await _({...r.layout,sections:[...r.layout.sections,{name:e,projects:[]}]})&&b(e)},S=e=>{let t=p(e).map(e=>i?.[e.slug]).filter(e=>!!e).some(e=>e.working.length&&!e.waiting.length);return(0,z.jsx)(gt,{size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}`,active:o(`projects`,e.slug),innerProps:{"data-project":e.slug,title:e.goal?`${e.title}: ${e.goal}`:e.title},leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.status===`done`?`✅`:e.status===`paused`?`⏸️`:e.status===`archived`?`🗄️`:`📁`}),title:e.title,titleExtra:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($e,{n:is.project(u,e.slug,e.agents).length,title:`waiting for you`}),t&&(0,z.jsx)(et,{tone:`working`,title:`an agent is working`})]}),titleLines:2})};return(0,z.jsx)(`nav`,{className:`rail`,"aria-label":`Conversations`,children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2 pt-2 pb-4`,children:[(0,z.jsx)(gt,{href:`/`,active:e===`/`,leading:(0,z.jsx)(B,{name:`home`}),title:`Home`,innerProps:{title:`Everything here: chats, workflows, routines and what they made`}}),(0,z.jsx)(gt,{href:`/agents/chats`,active:s,leading:(0,z.jsx)(B,{name:`chat`}),title:`Chats`,titleExtra:(0,z.jsx)($e,{n:is.general(u).length,title:`waiting for you`}),innerProps:{title:`Every chat with Ralv and in the projects; start a new one with Ralv, the chief of staff`}}),(0,z.jsx)(gt,{href:`/today`,active:e===`/today`,leading:(0,z.jsx)(B,{name:`today`}),title:`Today`,innerProps:{title:`Today: what needs you, what happened`}}),t.projects&&(0,z.jsxs)(IS,{label:`projects`,href:`/projects`,add:r?.enabled?{href:`/projects/new`,label:`new project`}:void 0,badge:c.all?(0,z.jsx)($e,{n:new Set(f.filter(e=>!m(e)).flatMap(e=>is.project(u,e.slug,e.agents).map(e=>e.id))).size,title:`waiting in the projects folded away`}):void 0,fold:f.length>0?(0,z.jsxs)(z.Fragment,{children:[!c.all&&r?.layout&&(0,z.jsx)(q,{size:`sm`,icon:`create_new_folder`,label:`new section`,title:`new section: drag projects into it`,onClick:()=>void x()}),(0,z.jsx)(q,{size:`sm`,icon:c.all?`chevron_right`:`expand_more`,label:c.all?`show all projects`:`collapse projects`,"aria-expanded":!c.all,onClick:()=>l(e=>({...e,all:!e.all}))})]}):void 0,children:[c.all||!r?.layout?g.filter(e=>!c.all||m(e)).map(e=>(0,z.jsx)(v.Fragment,{children:S(e)},e.slug)):(0,z.jsx)(MS,{layout:r.layout,visible:e=>!!h.get(e)&&m(h.get(e)),render:e=>h.get(e)?S(h.get(e)):null,onSave:_,collapsed:e=>!!c.sections[e],onCollapse:e=>l(t=>({...t,sections:{...t.sections,[e]:!t.sections[e]}})),editing:y,onEdited:()=>b(void 0)}),c.all&&f.length>0&&(0,z.jsxs)(K,{variant:`quiet`,size:`sm`,icon:`expand_more`,className:`justify-start`,onClick:()=>l(e=>({...e,all:!1})),children:[f.filter(e=>!m(e)).length,` more`]})]}),(0,z.jsx)(IS,{label:`agents`,href:`/agents`,add:{href:`/agents/new`,label:`new agent`},children:(n?.agents??[]).filter(e=>!e.archived).map(e=>{let t=ES(i?.[e.slug],e.description);return(0,z.jsx)(gt,{href:`/agents/${encodeURIComponent(e.slug)}`,active:o(`agents`,e.slug)||o(`team`,e.slug),innerProps:{title:e.description||void 0},leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji||`🤖`}),title:e.name,titleExtra:(0,z.jsx)(LS,{n:is.agent(u,e.slug).length,st:i?.[e.slug]}),sub:t?(0,z.jsx)(`span`,{className:`rail-status${t.tone===`plain`?``:` ${t.tone}`}`,children:t.text}):void 0,subTone:t?.tone===`waiting`?`bad`:t?.tone===`working`?`accent`:`plain`},e.slug)})})]})})}function IS({label:e,href:t,add:n,badge:r,fold:i,children:a}){return(0,z.jsxs)(`div`,{className:`mt-3 flex flex-col gap-0.5`,role:`group`,"aria-label":e[0].toUpperCase()+e.slice(1),children:[(0,z.jsxs)(`div`,{className:`group/head flex items-center gap-1 pl-2.5 pr-1`,children:[(0,z.jsx)(U,{href:t,className:`flex-1 px-0 py-1 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-2 no-underline hover:text-fg`,children:e}),r,(0,z.jsxs)(`span`,{className:`flex items-center gap-1 opacity-0 transition-opacity group-hover/head:opacity-100 group-focus-within/head:opacity-100 pointer-coarse:opacity-100`,children:[n&&(0,z.jsx)(q,{size:`sm`,icon:`add`,label:n.label,href:n.href}),i]})]}),a]})}function LS({n:e,st:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($e,{n:e,title:`waiting for you`}),!e&&t?.working.length&&!t.waiting.length?(0,z.jsx)(et,{tone:`working`,title:`working`}):null]})}var RS=`kw-rail-fold`;function zS(){let[e,t]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(RS)??`null`),t=e=>e&&typeof e==`object`?e:{};return{all:!!e?.all,open:t(e?.open),sections:t(e?.sections)}}catch{return{all:!1,open:{},sections:{}}}});return[e,e=>t(t=>{let n=e(t);try{localStorage.setItem(RS,JSON.stringify(n))}catch{}return n})]}function BS(){let e=F(`agents.list`,{},{interval:3e4}),t=F(`agents.status`,{},{interval:15e3}),[n,r]=(0,v.useState)(``),i=e?.agents??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||[e.name,e.slug,e.description,e.group,e.harness,e.model].some(e=>e?.toLowerCase().includes(a))).sort((e,t)=>Number(!!e.archived)-Number(!!t.archived)||(e.group??``).localeCompare(t.group??``)||e.name.localeCompare(t.name)),s=i.filter(e=>!e.archived).length;return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`smart_toy`,className:`text-[28px] text-fg-2`}),title:`Agents`,sub:e?`${s} active${i.length>s?` · ${i.length-s} archived`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter agents`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/agents/new`,children:`new agent`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`smart_toy`,children:`No agents yet. Create the first one with "new agent".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No agent matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`agents-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`agent`}),(0,z.jsx)(`th`,{children:`group`}),(0,z.jsx)(`th`,{children:`runs on`}),(0,z.jsx)(`th`,{children:`linked`}),(0,z.jsx)(`th`,{children:`now`}),(0,z.jsx)(`th`,{})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(VS,{a:e,st:t?.[e.slug]},e.slug))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function VS({a:e,st:t}){let n=`/agents/${encodeURIComponent(e.slug)}`,r=[[e.workflows.length,`workflow`],[e.knowledge.length,`knowledge`],[e.vibeables.length,`app`],[e.files?.length??0,`folder`]].filter(([e])=>e);return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3 ${e.archived?`opacity-60`:``}`,"data-agent":e.slug,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:n,className:`flex items-start gap-2.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsx)(`span`,{className:`text-[18px] leading-5`,children:e.emoji||`🤖`}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.name,` `,e.archived&&(0,z.jsx)(J,{children:`archived`})]}),e.description&&(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.description})]})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2`,children:e.group??`—`}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap`,children:[e.harness,(e.model||e.effort)&&(0,z.jsx)(`div`,{className:`text-xs text-fg-2`,children:[e.model,e.effort].filter(Boolean).join(` · `)})]}),(0,z.jsxs)(`td`,{className:`text-xs text-fg-2`,children:[r.length===0&&e.skills===void 0?`—`:r.map(([e,t])=>(0,z.jsxs)(`div`,{children:[e,` `,t,e===1||t===`knowledge`?``:`s`]},t)),e.skills!==void 0&&(0,z.jsx)(`div`,{title:`its skill allowlist; agents without one may use every skill`,children:e.skills.length===0?`no skills`:`${e.skills.length} skill${e.skills.length===1?``:`s`} allowed`})]}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,children:[t?.waiting.length?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-fg`,children:[(0,z.jsx)(et,{tone:`ask`}),` waiting for you`]}):t?.working.length?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-fg`,children:[(0,z.jsx)(et,{tone:`working`}),` working`]}):t?.lastActiveAt?(0,z.jsxs)(z.Fragment,{children:[`active `,G(t.lastActiveAt)]}):`never used`,t?.nextRoutine&&(0,z.jsxs)(`div`,{title:t.nextRoutine.at,children:[`⏰ `,t.nextRoutine.name]})]}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-right`,children:(0,z.jsx)(q,{icon:`edit`,label:`edit ${e.name}`,size:`sm`,href:`${n}/edit`})})]})}var HS=`/settings/routines`,US=(e,t)=>`${HS}?open=${encodeURIComponent(`${e}:${t}`)}`;function WS(){let e=F(`routines.list`,{},{interval:3e4}),t=F(`projects.list`,{},{interval:6e4}),[n,r]=(0,v.useState)(``),[i,a]=(new URLSearchParams(ne().split(`?`)[1]??``).get(`open`)??``).split(`:`),o=e?.routines??[],s=e=>t?.projects.find(t=>t.slug===e)?.title??e,c=n.trim().toLowerCase(),l=o.filter(e=>!c||[e.name,e.prompt,e.schedule,e.agent?.name,e.project,e.runsOn].some(e=>e?.toLowerCase().includes(c))).sort((e,t)=>(e.nextRunAt??`9`).localeCompare(t.nextRunAt??`9`)||e.name.localeCompare(t.name)),u=o.filter(e=>e.enabled&&e.nextRunAt).length;return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`schedule`,className:`text-[28px] text-fg-2`}),title:`Routines`,sub:e?`${o.length} routine${o.length===1?``:`s`} · ${u} scheduled on this machine`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[o.length>0&&(0,z.jsx)(Z,{"aria-label":`filter routines`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:US(`_`,`new`),children:`new routine`})]})}),(0,z.jsx)(X,{children:e?o.length===0?(0,z.jsx)(Y,{icon:`schedule`,children:`No routines yet. Create the first one with "new routine".`}):l.length===0?(0,z.jsxs)(Y,{children:[`No routine matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`routines-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`routine`}),(0,z.jsx)(`th`,{children:`who`}),(0,z.jsx)(`th`,{children:`project`}),(0,z.jsx)(`th`,{children:`schedule`}),(0,z.jsx)(`th`,{children:`runs on`}),(0,z.jsx)(`th`,{children:`last run`})]})}),(0,z.jsx)(`tbody`,{children:l.map(e=>(0,z.jsx)(GS,{r:e,projectTitle:e.project?s(e.project):void 0},`${e.owner}:${e.id}`))})]})}):(0,z.jsx)(Y,{children:`loading…`})}),i&&a&&(0,z.jsx)(zy,{label:`routine`,title:a===`new`&&i===`_`?`New routine`:o.find(e=>e.owner===i&&e.id===a)?.name??`Routine`,onClose:()=>H(HS),children:(0,z.jsx)(`div`,{className:`-m-3`,children:(0,z.jsx)(hb,{owner:i,id:a,onOpen:e=>{let[,t,n]=(e??``).split(`:`);H(t&&n?US(t,n):HS,{replace:!0})}})})})]})}function GS({r:e,projectTitle:t}){return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3 ${e.enabled?``:`opacity-60`}`,"data-routine":`${e.owner}:${e.id}`,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:US(e.owner,e.id),className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.name,` `,!e.enabled&&(0,z.jsx)(J,{children:`paused`}),` `,e.private&&(0,z.jsx)(J,{children:`private`})]}),(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.prompt})]})}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap`,children:[lb(e),e.owner!==`_`&&(0,z.jsx)(`div`,{className:`text-xs text-fg-2`,children:`the agent's own`})]}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2`,children:e.project?(0,z.jsx)(U,{href:`/projects/${encodeURIComponent(e.project)}`,children:t}):`—`}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap`,children:[(0,z.jsx)(`code`,{className:`text-xs`,children:e.schedule}),(0,z.jsx)(`div`,{className:`text-xs text-fg-2`,children:ub(e)})]}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs`,children:e.runner===`here`?(0,z.jsx)(J,{title:`runs_on: ${e.runsOn} — this machine fires it`,children:`here`}):e.runner===`unassigned`?(0,z.jsx)(J,{tone:e.enabled?`ask`:`neutral`,title:`no runs_on — it fires on no machine until one adopts it`,children:`no runner`}):(0,z.jsx)(J,{tone:e.retired?`ask`:`neutral`,title:e.retired?`a retired identity of this machine — it fires nowhere until reassigned`:`another machine fires it, not this one`,children:e.runsOn})}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,children:[e.lastChatId?(0,z.jsx)(U,{href:db(e,e.lastChatId),children:Ke(e.lastRunAt)}):`never ran`,e.awaitingApproval&&e.lastChatId&&(0,z.jsx)(`div`,{children:(0,z.jsx)(J,{href:db(e,e.lastChatId),tone:`bad`,children:`needs approval`})}),e.lastError&&(0,z.jsx)(`div`,{title:e.lastError,children:(0,z.jsx)(J,{tone:`bad`,children:`error`})})]})]})}function KS(){let e=F(`workflows.list`,{},{interval:3e4}),t=F(`runs.list`,{},{interval:3e4}),[n,r]=(0,v.useState)(``),i=e?.workflows??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||[e.name,e.slug,e.description].some(e=>e?.toLowerCase().includes(a))).sort((e,t)=>(e.name||e.slug).localeCompare(t.name||t.slug)),s=i.filter(e=>e.error).length,c=e=>(t?.runs??[]).filter(t=>t.workflow===e.slug||!!e.name&&t.workflow===e.name).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt));return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`account_tree`,className:`text-[28px] text-fg-2`}),title:`Workflows`,sub:e?`${i.length} workflow${i.length===1?``:`s`}${s?` · ${s} unreadable`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter workflows`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/agents/chats`,title:`ask Ralv to make a workflow`,children:`new workflow`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`account_tree`,children:`No workflows yet. Ask Ralv to make the first one with "new workflow".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No workflow matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`workflows-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`workflow`}),(0,z.jsx)(`th`,{children:`steps`}),(0,z.jsx)(`th`,{children:`request`}),(0,z.jsx)(`th`,{children:`runs`}),(0,z.jsx)(`th`,{children:`last run`})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(qS,{w:e,runs:t?c(e):void 0},e.slug))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function qS({w:e,runs:t}){let n=t?.[0],r=!!n?.awaitingDecision&&n.status===`running`;return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-workflow":e.slug,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:`/workflows/${encodeURIComponent(e.slug)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.name||e.slug,` `,e.error&&(0,z.jsx)(J,{tone:`bad`,title:e.error,children:`error`})]}),(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.description||e.slug})]})}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap`,children:[e.steps,` step`,e.steps===1?``:`s`,(0,z.jsxs)(`div`,{className:`text-xs text-fg-2`,children:[e.agents,` agent`,e.agents===1?``:`s`]})]}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2`,title:e.usesRequest?`a step reads the request: it asks for one before it runs`:`no step reads a request: it runs straight away`,children:e.usesRequest?`yes`:`no`}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2 tabular-nums`,children:t?t.length||`—`:``}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,children:t?n?(0,z.jsxs)(U,{href:`/runs/${encodeURIComponent(n.id)}`,className:`inline-flex items-center gap-1.5`,children:[(0,z.jsx)(et,{tone:r?`ask`:n.status===`running`?`working`:n.status===`ok`?`ok`:n.status===`failed`?`bad`:`idle`}),r?`decision needed`:n.status===`aborted`?`stopped`:n.status,` · `,Ke(n.updatedAt)]}):`never ran`:``})]})}function JS(){let e=F(`knowledge.list`,{},{interval:3e4}),t=F(`agents.list`,{},{interval:3e4}),[n,r]=(0,v.useState)(``),i=e?.bundles??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||e.name.toLowerCase().includes(a)).sort((e,t)=>e.name.localeCompare(t.name)),s=i.reduce((e,t)=>e+t.concepts,0),c=e=>(t?.agents??[]).filter(t=>!t.archived&&t.knowledge.includes(e.name));return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`menu_book`,className:`text-[28px] text-fg-2`}),title:`Knowledge`,sub:e?`${i.length} bundle${i.length===1?``:`s`} · ${s} page${s===1?``:`s`}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter knowledge`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/knowledge/new`,children:`new bundle`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`menu_book`,children:`No knowledge yet. Create the first bundle with "new bundle".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No bundle matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`knowledge-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`bundle`}),(0,z.jsx)(`th`,{children:`pages`}),(0,z.jsx)(`th`,{children:`changed`}),(0,z.jsx)(`th`,{children:`used by`})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(YS,{b:e,usedBy:t?c(e):void 0},e.name))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function YS({b:e,usedBy:t}){return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-bundle":e.name,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:`/knowledge/${encodeURIComponent(e.name)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.name}),e.okfVersion&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`OKF `,e.okfVersion]})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2 tabular-nums`,children:e.concepts}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:G(e.updatedAt)}),(0,z.jsx)(`td`,{className:`text-xs text-fg-2`,children:t?t.length===0?`—`:t.map(e=>(0,z.jsx)(`div`,{children:(0,z.jsxs)(U,{href:`/agents/${encodeURIComponent(e.slug)}`,children:[e.emoji||`🤖`,` `,e.name]})},e.slug)):``})]})}var XS=encodeURIComponent,ZS=e=>`${e.project??``}:${e.board}`;function QS(){let e=F(`boards.list`,{query:{all:`1`}},{interval:3e4}),t=F(`tasks.list`,{},{interval:3e4}),n=F(`projects.list`,{},{interval:6e4}),[r,i]=(0,v.useState)(``),a=e?.boards??[],o=e=>n?.projects.find(t=>t.slug===e)?.title??e,s=r.trim().toLowerCase(),c=a.filter(e=>!s||[e.title,e.board,e.project,e.project&&o(e.project)].some(e=>e?.toLowerCase().includes(s))).sort((e,t)=>(e.project??``).localeCompare(t.project??``)||e.title.localeCompare(t.title)),l=a.reduce((e,t)=>e+t.tasks,0),u=new Map;for(let e of t?.tasks??[])u.set(ZS(e),[...u.get(ZS(e))??[],e]);return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`view_kanban`,className:`text-[28px] text-fg-2`}),title:`Boards`,sub:e?`${a.length} board${a.length===1?``:`s`} · ${l} task${l===1?``:`s`}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[a.length>0&&(0,z.jsx)(Z,{"aria-label":`filter boards`,placeholder:`filter`,value:r,onChange:e=>i(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/boards/new`,children:`new board`})]})}),(0,z.jsx)(X,{children:e?a.length===0?(0,z.jsx)(Y,{icon:`view_kanban`,children:`No boards yet. Create the first one with "new board".`}):c.length===0?(0,z.jsxs)(Y,{children:[`No board matches "`,r,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`boards-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`board`}),(0,z.jsx)(`th`,{children:`project`}),(0,z.jsx)(`th`,{children:`tasks`}),(0,z.jsx)(`th`,{children:`open`}),(0,z.jsx)(`th`,{children:`changed`})]})}),(0,z.jsx)(`tbody`,{children:c.map(e=>(0,z.jsx)($S,{b:e,tasks:t?u.get(ZS(e))??[]:void 0,projectTitle:e.project?o(e.project):void 0},ZS(e)))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function $S({b:e,tasks:t,projectTitle:n}){let r=e.project?`/projects/${XS(e.project)}/boards/${XS(e.board)}`:`/boards/${XS(e.board)}`,i=new Set(e.columns.filter(e=>e.done).map(e=>e.slug)),a=new Set(e.columns.filter(e=>e.review).map(e=>e.slug)),o=t?.filter(e=>!i.has(e.status)),s=t?.filter(e=>a.has(e.status)).length??0,c=t?.filter(e=>e.stale).length??0;return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-board":ZS(e),children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:r,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.title,` `,e.configError&&(0,z.jsx)(J,{tone:`bad`,title:e.configError,children:`error`})]}),(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.columns.map(e=>e.label).join(` · `)||e.board})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2`,children:e.project?(0,z.jsx)(U,{href:`/projects/${XS(e.project)}`,children:n}):`—`}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2 tabular-nums`,children:t?t.length:e.tasks}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,children:o?o.length===0?`—`:(0,z.jsxs)(z.Fragment,{children:[o.length,` open`,s>0&&(0,z.jsx)(`div`,{children:(0,z.jsxs)(J,{tone:`ask`,title:`tasks in a review column: they wait for a human`,children:[s,` in review`]})}),c>0&&(0,z.jsxs)(`div`,{title:`assigned, in a work column, and nothing logged for a while`,children:[c,` stale`]})]}):``}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:G(e.updatedAt)})]})}function eC(){let e=F(`vibeables.list`,{},{interval:3e4}),t=F(`agents.list`,{},{interval:3e4}),[n,r]=(0,v.useState)(``),i=e?.vibeables??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||[e.slug,e.dev].some(e=>e?.toLowerCase().includes(a))).sort((e,t)=>e.slug.localeCompare(t.slug)),s=i.filter(e=>e.configError).length,c=e=>(t?.agents??[]).filter(t=>!t.archived&&t.vibeables.includes(e.slug));return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`web`,className:`text-[28px] text-fg-2`}),title:`Apps`,sub:e?`${i.length} app${i.length===1?``:`s`}${s?` · ${s} unreadable`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter apps`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/vibeables/new`,children:`new app`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`web`,children:e.error??`No apps yet. Create the first one with "new app".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No app matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`apps-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`app`}),(0,z.jsx)(`th`,{children:`preview`}),(0,z.jsx)(`th`,{children:`used by`}),(0,z.jsx)(`th`,{children:`changed`})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(tC,{v:e,usedBy:t?c(e):void 0},e.slug))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function tC({v:e,usedBy:t}){return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-app":e.slug,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:`/vibeables/${encodeURIComponent(e.slug)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.slug,` `,e.configError&&(0,z.jsx)(J,{tone:`bad`,title:e.configError,children:`error`})]}),(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-2`,title:e.path,children:e.path})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap`,children:e.dev?(0,z.jsxs)(z.Fragment,{children:[`dev server`,(0,z.jsx)(`div`,{className:`text-xs text-fg-2`,children:(0,z.jsx)(`code`,{children:e.dev})})]}):e.hasIndex?`static page`:(0,z.jsx)(`span`,{className:`text-fg-2`,title:`no index.html in the served folder and no dev command`,children:`nothing to show yet`})}),(0,z.jsx)(`td`,{className:`text-xs text-fg-2`,children:t?t.length===0?`—`:t.map(e=>(0,z.jsx)(`div`,{children:(0,z.jsxs)(U,{href:`/agents/${encodeURIComponent(e.slug)}`,children:[e.emoji||`🤖`,` `,e.name]})},e.slug)):``}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:G(e.updatedAt)})]})}var nC={workspace:`this workspace`,machine:`every workspace on this machine`},rC={api_key:`API key`,subscription_token:`subscription token`};function iC(e){return e.credential?{tone:`ok`,text:`${rC[e.credential.kind]} ending in ${e.credential.ending}, for ${nC[e.credential.scope]}`}:e.env.length?{tone:`ok`,text:`${e.env.join(`, `)} from the shell or the workspace's .env`}:e.login===`present`?{tone:`ok`,text:`its own login on this machine`}:e.login===`absent`?{tone:`bad`,text:`nothing: no key, no token, and its CLI is not logged in here`}:{tone:`neutral`,text:`its own login on this machine, if there is one — a chat on it says who`}}function aC(){let[e,t]=(0,v.useState)(0),n=F(`harnesses.list`,{},{interval:15e3,refresh:e}),r=n?.harnesses??[],i=r.filter(e=>e.available).length;return(0,z.jsxs)(ct,{className:`max-w-[860px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`key`,className:`text-[28px] text-fg-2`}),title:`Harnesses`,sub:n?`${i} of ${r.length} usable here · keys stay on this machine`:void 0}),n?(0,z.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map(e=>(0,z.jsx)(oC,{h:e,onChanged:()=>t(e=>e+1)},e.id))}):(0,z.jsx)(X,{children:(0,z.jsx)(Y,{children:`loading…`})})]})}function oC({h:e,onChanged:t}){let n=iC(e);return(0,z.jsx)(X,{title:e.label,actions:(0,z.jsxs)(z.Fragment,{children:[e.adapter&&(0,z.jsxs)(J,{title:`its adapter comes with kraftwerk: chats and agents with protocol: acp`,children:[`bundled `,e.adapter.version]}),e.cli&&(0,z.jsxs)(J,{title:e.cli.path,children:[e.cli.command,` on the PATH`]}),!e.available&&(0,z.jsx)(J,{tone:`bad`,children:`not installed`})]}),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 px-[18px] py-3.5`,"data-harness":e.id,children:[!e.available&&(0,z.jsxs)(rt,{tone:`bad`,children:[`Not usable on this machine: install its CLI (`,(0,z.jsx)(`code`,{children:e.needs}),`) and log in with it.`]}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(`span`,{className:`text-2xs tracking-[0.5px] text-fg-2 uppercase`,children:`signs in with`}),(0,z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,z.jsx)(J,{tone:n.tone,children:e.credential?rC[e.credential.kind]:e.env.length?`environment`:e.login===`absent`?`not signed in`:`CLI login`}),(0,z.jsx)(`span`,{children:n.text}),e.credential&&(0,z.jsxs)(`span`,{className:`text-fg-2`,children:[`· set `,G(new Date(e.credential.setAt).toISOString())]})]}),e.seen&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`Last chat (`,G(new Date(e.seen.at).toISOString()),`): `,e.seen.kind===`none`?`not signed in`:[e.seen.email??e.seen.label,e.seen.organization,e.seen.plan].filter(Boolean).join(` · `),e.seen.detail?` — ${e.seen.detail}`:``]})]}),e.accepts.length>0?(0,z.jsx)(sC,{h:e,onChanged:t}):(0,z.jsx)(nt,{children:`It signs in with its own CLI only; there is nothing to store for it here.`})]})})}function sC({h:e,onChanged:t}){let[n,r]=(0,v.useState)(e.credential?.kind??e.accepts[0].kind),[i,a]=(0,v.useState)(e.credential?.scope??`workspace`),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),f=e.accepts.find(e=>e.kind===n)??e.accepts[0];async function p(e){l(!0),d(``);try{await e(),s(``),t()}catch(e){d(e instanceof w?e.message:`could not save`)}finally{l(!1)}}return(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 border-t border-line pt-3`,onSubmit:t=>{t.preventDefault(),o.trim()&&p(()=>A.call(`harnesses.setCredential`,{id:e.id,body:{kind:n,value:o,scope:i}}))},children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.accepts.length>1&&(0,z.jsx)(St,{"aria-label":`what to store`,value:n,onChange:e=>r(e.target.value),className:`w-auto`,children:e.accepts.map(e=>(0,z.jsx)(`option`,{value:e.kind,children:e.label},e.kind))}),(0,z.jsx)(Z,{type:`password`,autoComplete:`off`,spellCheck:!1,"aria-label":`${f.label} for ${e.label}`,placeholder:e.credential?`paste a new one`:`paste the ${f.label}`,value:o,onChange:e=>s(e.target.value),className:`min-w-[220px] flex-1 font-mono`}),(0,z.jsxs)(St,{"aria-label":`where it applies`,value:i,onChange:e=>a(e.target.value),className:`w-auto`,children:[(0,z.jsx)(`option`,{value:`workspace`,children:`this workspace`}),(0,z.jsx)(`option`,{value:`machine`,children:`every workspace here`})]}),(0,z.jsx)(K,{variant:`primary`,type:`submit`,disabled:c||!o.trim(),children:e.credential?`replace`:`save`}),e.credential&&(0,z.jsx)(K,{type:`button`,disabled:c,onClick:()=>void p(()=>A.call(`harnesses.removeCredential`,{id:e.id,query:{scope:e.credential.scope}})),title:`forget the ${rC[e.credential.kind]} stored for ${nC[e.credential.scope]}`,children:`remove`})]}),(0,z.jsxs)(nt,{children:[f.hint,` It is kept on this machine, outside the workspace's files, and used by the next chat or run.`]}),u&&(0,z.jsx)(rt,{tone:`bad`,children:u})]})}var cC=[`active`,`paused`,`done`,`archived`],lC={active:`📁`,paused:`⏸️`,done:`✅`,archived:`🗄️`};function uC(){let[e,t]=(0,v.useState)(0),n=F(`projects.list`,{},{interval:3e4,refresh:e}),r=F(`agents.list`,{},{interval:6e4}),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),f=n?.projects??[],p=i.trim().toLowerCase(),m=f.filter(e=>e.status===`archived`).length,h=f.filter(e=>o||e.status!==`archived`).filter(e=>!p||[e.title,e.slug,e.goal].some(e=>e?.toLowerCase().includes(p))).sort((e,t)=>cC.indexOf(e.status)-cC.indexOf(t.status)||e.title.localeCompare(t.title)),g=e=>{let t=r?.agents.find(t=>t.slug===e);return t?`${t.emoji||`🤖`} ${t.name}`:e},_=async(e,n)=>{l(e.slug),d(``);try{let r=await A.request(`projects.save`,{slug:e.slug,body:{status:n}});if(!r.ok)throw Error(P(r));t(e=>e+1)}catch(t){d(`${e.title}: ${t.message}`)}finally{l(``)}};return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`folder_special`,className:`text-[28px] text-fg-2`}),title:`Projects`,sub:n?`${f.length} project${f.length===1?``:`s`}${m?` · ${m} archived`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[m>0&&(0,z.jsx)(Tt,{checked:o,onChange:s,children:`show archived`}),f.length>0&&(0,z.jsx)(Z,{"aria-label":`filter projects`,placeholder:`filter`,value:i,onChange:e=>a(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/projects/new`,children:`new project`})]})}),u&&(0,z.jsx)(rt,{tone:`bad`,children:u}),(0,z.jsx)(X,{children:n?f.length===0?(0,z.jsx)(Y,{icon:`folder_special`,children:`No projects yet. Create the first one with "new project".`}):h.length===0?(0,z.jsx)(Y,{children:p?`No project matches "${i}".`:`Every project is archived.`}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`projects-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`project`}),(0,z.jsx)(`th`,{children:`status`}),(0,z.jsx)(`th`,{children:`agents`}),(0,z.jsx)(`th`,{children:`changed`}),(0,z.jsx)(`th`,{"aria-label":`actions`})]})}),(0,z.jsx)(`tbody`,{children:h.map(e=>(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3 ${e.status===`archived`?`opacity-60`:``}`,"data-project":e.slug,children:[(0,z.jsx)(`td`,{className:`max-w-[380px]`,children:(0,z.jsxs)(U,{href:`/projects/${encodeURIComponent(e.slug)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:lC[e.status]}),` `,e.title,` `,e.configError&&(0,z.jsx)(J,{tone:`bad`,title:e.configError,children:`error`})]}),(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.goal||`no goal written yet`})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,z.jsx)(St,{"aria-label":`status of ${e.title}`,value:e.status,disabled:c===e.slug,onChange:t=>void _(e,t.target.value),className:`h-8 w-[120px] text-sm`,children:cC.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})}),(0,z.jsx)(`td`,{className:`text-xs text-fg-2`,children:(e.agents??[]).length===0?`—`:(e.agents??[]).map(e=>(0,z.jsx)(`div`,{children:g(e)},e))}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:e.updatedAt?G(e.updatedAt):`—`}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-right`,children:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:e.status===`archived`?`unarchive`:`archive`,busy:c===e.slug,disabled:!!c,onClick:()=>void _(e,e.status===`archived`?`active`:`archived`),title:e.status===`archived`?`back to active: it shows in the rail again`:`archive: it leaves the rail, its folder stays`,children:e.status===`archived`?`unarchive`:`archive`})})]},e.slug))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}var dC={workspace:{label:`workspace`,title:`the workspace's skills root`},project:{label:`project`,title:`.claude/skills of the workspace`},user:{label:`personal`,title:`~/.claude/skills on this machine`},agent:{label:`agent`,title:`an agent's own skills folder`}},fC=[`workspace`,`project`,`agent`,`user`];function pC(){let e=F(`skills.list`,{},{interval:3e4}),t=F(`agents.list`,{},{interval:3e4}),[n,r]=(0,v.useState)(``),i=e?.skills??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||[e.name,e.description,dC[e.source].label,e.agent].some(e=>e?.toLowerCase().includes(a))).sort((e,t)=>fC.indexOf(e.source)-fC.indexOf(t.source)||e.name.localeCompare(t.name)),s=i.filter(e=>e.source!==`user`).length,c=e=>t?.agents.find(t=>t.slug===e)?.name??e,l=e=>(t?.agents??[]).filter(t=>!t.archived&&t.skills?.includes(e.name));return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`extension`,className:`text-[28px] text-fg-2`}),title:`Skills`,sub:e?`${s} in the workspace${i.length>s?` · ${i.length-s} personal`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter skills`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/agents/chats`,title:`ask Ralv to make a skill`,children:`new skill`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`extension`,children:`No skills yet. Ask Ralv to make the first one with "new skill".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No skill matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`skills-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`skill`}),(0,z.jsx)(`th`,{children:`source`}),(0,z.jsx)(`th`,{children:`limited to`}),(0,z.jsx)(`th`,{children:`changed`})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(mC,{s:e,owner:c(e.agent),limitedTo:t?l(e):void 0},`${e.source}:${e.agent??``}:${e.name}`))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function mC({s:e,owner:t,limitedTo:n}){let r=dC[e.source];return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-skill":e.name,children:[(0,z.jsx)(`td`,{className:`max-w-[420px]`,children:(0,z.jsxs)(U,{href:`/skills/${encodeURIComponent(e.name)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`font-medium`,children:[`/`,e.name]}),e.description&&(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.description})]})}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap text-xs`,children:[(0,z.jsx)(J,{title:`${r.title} — ${e.dir}`,children:r.label}),e.source===`agent`&&t&&(0,z.jsx)(`div`,{className:`mt-0.5 text-fg-2`,children:t})]}),(0,z.jsx)(`td`,{className:`text-xs text-fg-2`,title:`agents whose skill allowlist names it; agents without an allowlist may use every skill`,children:n?n.length===0?`—`:n.map(e=>(0,z.jsx)(`div`,{children:(0,z.jsxs)(U,{href:`/agents/${encodeURIComponent(e.slug)}`,children:[e.emoji||`🤖`,` `,e.name]})},e.slug)):``}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:G(e.updatedAt)})]})}function hC(){let e=De();return[{id:`settings`,main:!0,href:`/settings`,label:`base settings`,icon:`settings`},{id:`agents`,main:!0,href:`/settings/agents`,label:`agents`,icon:`smart_toy`},...e.projects?[{id:`projects`,main:!0,href:`/settings/projects`,label:`projects`,icon:`folder_special`}]:[],{id:`routines`,main:!0,href:`/settings/routines`,label:`routines`,icon:`schedule`},{id:`workflows`,main:!0,href:`/settings/workflows`,label:`workflows`,icon:`account_tree`},{id:`knowledge`,main:!0,href:`/settings/knowledge`,label:`knowledge`,icon:`menu_book`},{id:`files`,main:!0,href:`/files`,label:`files`,icon:`folder_open`},...e.boards?[{id:`boards`,main:!0,href:`/settings/boards`,label:`boards`,icon:`view_kanban`}]:[],...e.presentations?[{id:`presentations`,href:`/presentations`,label:`presentations`,icon:`slideshow`}]:[],...e.vibeables?[{id:`vibeables`,href:`/settings/apps`,label:`apps`,icon:`web`}]:[],{id:`skills`,main:!0,href:`/settings/skills`,label:`skills`,icon:`extension`},{id:`harnesses`,href:`/settings/harnesses`,label:`harnesses`,icon:`key`},...e.repos?[{id:`repos`,href:`/repos`,label:`repositories`,icon:`source`}]:[],...e.contacts?[{id:`contacts`,href:`/contacts`,label:`contacts`,icon:`person`}]:[],...e.places?[{id:`places`,href:`/places`,label:`places`,icon:`location_on`}]:[],...e.events?[{id:`events`,href:`/events`,label:`events`,icon:`event`}]:[],{id:`workspaces`,href:`/workspaces`,label:`workspaces`,icon:`grid_view`}]}var gC=new Set([`settings`,`workflows`,`runs`,`knowledge`,`files`,`boards`,`presentations`,`vibeables`,`skills`,`repos`,`contacts`,`places`,`events`,`workspaces`]),_C=new Set([`agents`,`routines`,`workflows`,`knowledge`,`boards`,`skills`,`harnesses`]);function vC(e){return gC.has(e.split(`?`)[0].split(`/`).filter(Boolean)[0]??``)}function yC({path:e}){let t=hC(),[n=``,r=``]=e.split(`?`)[0].split(`/`).filter(Boolean),i=n===`settings`?_C.has(r)?r:r===`apps`?`vibeables`:`settings`:n===`runs`?`workflows`:n,a=e=>i===e;return(0,z.jsx)(`nav`,{className:`settings-nav sticky top-[var(--topbar-h)] z-[9] flex h-11 items-center gap-0.5 overflow-x-auto bg-bg px-5 shadow-[inset_0_-1px_0_var(--line)] [scrollbar-width:none] max-[800px]:px-3`,"aria-label":`Settings`,children:t.map((e,t)=>{let n=a(e.id);return(0,z.jsxs)(U,{href:e.href,className:I(`inline-flex flex-none items-center gap-1.5 rounded-full px-3 py-1 text-[13.5px] font-semibold no-underline transition-colors [&_.ms]:text-[18px]`,n?`bg-surface text-accent shadow-[inset_0_0_0_1px_var(--line)]`:`text-fg-2 hover:bg-surface-2 hover:text-fg`,t===0&&`mr-2`),"aria-current":n?`page`:void 0,"aria-label":e.label,title:e.label,children:[(0,z.jsx)(B,{name:e.icon,fill:n}),` `,(0,z.jsx)(`span`,{className:I(!n&&(e.main?`max-[1100px]:hidden`:`max-[1720px]:hidden`)),children:e.label})]},e.id)})})}function bC({path:e}){let t=De(),n=e.split(`?`)[0].split(`/`).filter(Boolean)[0]??``;return(0,z.jsxs)(z.Fragment,{children:[t.git&&(0,z.jsxs)(`span`,{className:`relative inline-flex flex-none`,children:[(0,z.jsx)(q,{icon:`cloud_sync`,label:`git`,href:`/git`,className:n===`git`?`text-accent`:void 0}),(0,z.jsx)(xC,{})]}),(0,z.jsx)(q,{icon:`delete`,label:`trash`,href:`/trash`,className:n===`trash`?`text-accent`:void 0})]})}function xC(){let e=F(`git.status`,{},{interval:15e3}),t=e?.files?.filter(e=>e.syncable).length??0,n=e?.behind?`${e.behind}↓`:e?.ahead?`${e.ahead}↑`:t?String(t):``;return n?(0,z.jsx)(`span`,{className:I(`git-badge pointer-events-none absolute -top-1 -right-1.5 rounded-full bg-surface-2 px-1 text-[10px] leading-[14px] font-semibold tabular-nums`,e?.behind?`text-accent`:e?.ahead?`text-ok`:`text-fg-2`),children:n}):null}var SC=``,CC=e=>{let t=e.replace(/^# .*\n+/,``).replace(/\(human:user\)/g,`(you)`);return SC?t.split(`(${SC})`).join(`(you)`):t},wC=`flex flex-col gap-1.5 px-1.5 pb-6 pt-3`,TC=`m-0 px-2.5 pb-0.5 text-md leading-[1.45] text-fg`,EC=`m-0 px-2.5 py-0.5 text-sm text-fg-2`,DC=`md-body px-2.5 text-sm leading-normal`,OC=e=>fo.sanitize(Mi.parse(CC(e),{async:!1}));function kC(e,t){let n=[],r=``;for(let i of e.split(`
487
- `)){let e=/^## (.+)$/.exec(i.trim());if(e?r=e[1]:/^[-*] /.test(i)&&n.push({day:r,text:i.replace(/^[-*] /,``)}),n.length>=t)break}return n}function AC({items:e}){return e.length===0?null:(0,z.jsx)(at,{size:`lg`,title:`needs you`,count:e.length,children:e.map(e=>(0,z.jsx)(gt,{onClick:()=>ds(e),leading:(0,z.jsx)(B,{name:as(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${e.owner.agent?`${e.owner.agent.emoji??``} ${e.owner.agent.name} · `:``}${os(e.kind)} · ${G(e.since)}`},e.id))})}function jC({slugs:e,agents:t,status:n,title:r=`team`}){let i=e.map(e=>t.find(t=>t.slug===e)).filter(e=>!!e);return i.length===0?null:(0,z.jsx)(at,{size:`lg`,title:r,children:i.map(e=>{let t=ES(n?.[e.slug],e.description);return(0,z.jsx)(gt,{href:`/agents/${encodeURIComponent(e.slug)}`,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji||`🤖`}),title:e.name,sub:t?.text,subTone:t?.tone===`waiting`?`bad`:t?.tone===`working`?`accent`:`plain`},e.slug)})})}function MC({scope:e}){let t=F(`files.recent`,{query:{scope:e}},{interval:2e4});return!t||t.count===0?null:(0,z.jsx)(at,{size:`lg`,title:`files`,count:t.count,action:(0,z.jsxs)(K,{variant:`quiet`,size:`sm`,href:Cs(e),children:[`all `,(0,z.jsx)(B,{name:`arrow_forward`,className:`ms-sm`})]}),children:t.recent.map(t=>{let n=t.path.includes(`/`)?t.path.slice(0,t.path.lastIndexOf(`/`)):``;return(0,z.jsx)(gt,{href:Cs(e,n,t.path),leading:(0,z.jsx)(B,{name:`draft`,className:`ms-sm`}),title:t.path.split(`/`).pop(),sub:`${n?`${n}/ · `:``}${G(t.at)}`},t.path)})})}function NC({of:e}){SC=F(`me.get`,{},{interval:3e5})?.actor??``;let t=rs()??[],n=F(`agents.list`,{},{interval:15e3})?.agents??[],r=F(`agents.status`,{},{interval:5e3})??void 0;if(e.kind===`project`){let i=e.project,a=i.links.agents.map(e=>e.slug),o=kC(i.log,5);return(0,z.jsxs)(`div`,{className:wC,children:[(0,z.jsx)(at,{size:`lg`,title:`goal`,children:(0,z.jsxs)(`p`,{className:TC,children:[i.goal||(0,z.jsx)(`span`,{className:`text-fg-2`,children:`No goal written yet.`}),i.status!==`active`&&(0,z.jsxs)(`span`,{className:`text-fg-2`,children:[` · `,i.status]})]})}),o.length>0&&(0,z.jsx)(at,{size:`lg`,title:`lately`,children:o.map((e,t)=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[74px_minmax(0,1fr)] gap-2 px-2.5 py-1 text-sm`,children:[(0,z.jsx)(`span`,{className:`pt-px text-xs tabular-nums text-fg-2`,children:e.day}),(0,z.jsx)(`span`,{dangerouslySetInnerHTML:{__html:fo.sanitize(Mi.parseInline(CC(e.text),{async:!1}))}})]},t))}),(0,z.jsx)(AC,{items:is.project(t,i.slug,a)}),(0,z.jsx)(jC,{slugs:a,agents:n,status:r}),(0,z.jsx)(at,{size:`lg`,title:`where it stands`,children:i.state.trim()?(0,z.jsx)(`div`,{className:DC,dangerouslySetInnerHTML:{__html:OC(i.state)}}):(0,z.jsx)(`p`,{className:EC,children:`Nothing recorded yet: the project's chat writes this down at the end of a session that changed something.`})}),(0,z.jsx)(MC,{scope:`project:${i.slug}`}),i.records.length>0&&(0,z.jsx)(at,{size:`lg`,title:`systems of record`,children:i.records.map((e,t)=>(0,z.jsx)(gt,{onClick:()=>e.url&&window.open(e.url,`_blank`,`noopener`),leading:(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),title:e.title||e.kind,sub:e.note},t))})]})}if(e.kind===`agent`)return(0,z.jsx)(PC,{agent:e.agent,journal:e.journal,waiting:t,status:r});if(e.kind===`channel`){let i=e.channel;return(0,z.jsxs)(`div`,{className:wC,children:[(0,z.jsx)(`p`,{className:TC,children:i.purpose||(0,z.jsxs)(`span`,{className:`text-fg-2`,children:[`A group chat with `,i.members.length,` agent`,i.members.length===1?``:`s`,`.`]})}),(0,z.jsx)(AC,{items:is.channel(t,i.slug)}),(0,z.jsx)(jC,{slugs:i.members,agents:n,status:r,title:`in this channel`})]})}return(0,z.jsx)(FC,{waiting:t,agents:n,status:r})}function PC({agent:e,journal:t,waiting:n,status:r}){let i=F(`projects.list`,{},{interval:3e4})?.projects??[],a=F(`agents.routines`,{slug:e.slug},{interval:3e4})?.routines??[],[o,s]=(0,v.useState)(t);(0,v.useEffect)(()=>s(t),[t]);let c=ES(r?.[e.slug],e.description),l=i.filter(t=>t.agents.includes(e.slug));return(0,z.jsxs)(`div`,{className:wC,children:[(0,z.jsx)(`p`,{className:TC,children:e.description||(0,z.jsx)(`span`,{className:`text-fg-2`,children:`No description yet.`})}),c&&c.text!==e.description&&(0,z.jsx)(`p`,{className:`m-0 px-2.5 text-sm ${c.tone===`waiting`?`text-bad`:c.tone===`working`?`text-accent`:`text-fg-2`}`,children:c.text}),(0,z.jsx)(AC,{items:is.agent(n,e.slug)}),l.length>0&&(0,z.jsx)(at,{size:`lg`,title:`works on`,children:l.map(e=>(0,z.jsx)(gt,{href:`/projects/${encodeURIComponent(e.slug)}`,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),title:e.title,sub:e.goal||void 0},e.slug))}),a.length>0&&(0,z.jsx)(at,{size:`lg`,title:`schedule`,children:a.map(e=>(0,z.jsx)(gt,{leading:(0,z.jsx)(B,{name:`schedule`,className:`ms-sm`}),title:e.name,sub:`${e.enabled?e.nextRunAt?`next ${new Date(e.nextRunAt).toLocaleString([],{weekday:`short`,hour:`2-digit`,minute:`2-digit`})}`:e.schedule:`paused`}${e.lastRunAt?` · last ${G(e.lastRunAt)}`:``}`},e.id))}),(0,z.jsxs)(at,{size:`lg`,title:`journal`,children:[(0,z.jsx)(IC,{slug:e.slug,onAdded:s}),(0,z.jsx)(`div`,{className:DC,dangerouslySetInnerHTML:{__html:OC(CC(o)||`_Nothing yet: the agent notes what it learns, decides and promises here, and reads it back at the start of every session._`)}})]})]})}function FC({waiting:e,agents:t,status:n}){let r=F(`projects.list`,{},{interval:3e4}),i=(r?.projects??[]).filter(e=>e.status===`active`);return(0,z.jsxs)(`div`,{className:wC,children:[(0,z.jsx)(AC,{items:e}),r?.enabled&&(0,z.jsxs)(at,{size:`lg`,title:`projects`,count:i.length,children:[i.length===0&&(0,z.jsx)(`p`,{className:EC,children:`No active projects.`}),i.map(t=>{let n=is.project(e,t.slug,t.agents).length;return(0,z.jsx)(gt,{href:`/projects/${encodeURIComponent(t.slug)}`,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),title:t.title,sub:n?`${n} waiting for you`:t.goal||`no goal yet`,subTone:n?`bad`:`plain`},t.slug)})]}),(0,z.jsx)(jC,{slugs:t.filter(e=>!e.archived).map(e=>e.slug),agents:t,status:n,title:`agents`}),(0,z.jsx)(MC,{scope:`workspace`})]})}function IC({slug:e,onAdded:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=async()=>{if(!n.trim())return;a(!0),s(``);let i=await A.request(`agents.addJournal`,{slug:e,body:{entry:n,kind:`note`}}).then(e=>e.ok?{error:void 0,journal:e.data?.journal}:{error:P(e),journal:void 0}).catch(e=>({error:e.message,journal:void 0}));if(a(!1),i.error||i.journal===void 0)return s(i.error??`could not save`);r(``),t(i.journal)};return(0,z.jsxs)(`div`,{className:`px-2.5 pb-1.5 pt-0.5`,children:[(0,z.jsx)(Z,{className:`h-8 text-sm`,value:n,placeholder:`add a note for the agent to remember`,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&void c(),disabled:i}),o&&(0,z.jsx)(rt,{tone:`bad`,children:o})]})}var LC=[{id:`contacts`,icon:`person`},{id:`places`,icon:`location_on`},{id:`events`,icon:`event`}];function RC(e){let t=e.split(`/`).filter(Boolean),n=t[1]?decodeURIComponent(t[1]):``;return t[0]===`projects`&&n&&n!==`new`?{kind:`project`,slug:n}:t[0]===`channels`&&n&&n!==`new`?{kind:`channel`,slug:n}:(t[0]===`agents`||t[0]===`team`)&&n&&n!==`new`&&n!==`chats`?{kind:`agent`,slug:n}:{kind:`general`}}function zC(e){let t=new Date(e),n=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),r=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),i=Math.round((r(t)-r(new Date))/864e5);return i===0?`today ${n}`:i===1?`tomorrow ${n}`:i>1&&i<7?`${t.toLocaleDateString([],{weekday:`short`})} ${n}`:`${t.toLocaleDateString([],{day:`numeric`,month:`short`})} ${n}`}var BC=(e,t)=>e.map(e=>({slug:e,found:t.has(e)}));function VC({chatPath:e,workspace:t}){let n=RC(e),r=e.split(`/`).filter(Boolean),i=r[0]===`agents`&&r[1]===`chats`,a=r[0]===`agents`&&n.kind===`agent`,o=(r[0]===`projects`||a)&&r[2]===`chat`&&r[3]&&r[3]!==`new`?r[3]:i&&r[2]&&r[2]!==`new`?r[2]:void 0,s=n.kind===`project`?`/projects/${encodeURIComponent(n.slug)}`:a?`/agents/${encodeURIComponent(n.slug)}`:i?`/agents/chats`:void 0,c=`${n.kind}:${`slug`in n?n.slug:``}`,l=F(`chats.list`,o?{}:null,{interval:3e4}),u=o?l?.chats.find(e=>e.id===o):void 0,d=u?.task??(u?.scope.kind===`agent`?u.scope.task:void 0),f=d?rc(d):null,p=De(),[m,h]=n.kind===`project`?[`/projects/${encodeURIComponent(n.slug)}/info`,`edit the project: brief, state, records, links`]:n.kind===`agent`?[`/agents/${encodeURIComponent(n.slug)}/info`,`edit the agent: profile and settings`]:n.kind===`channel`?[`/channels/${encodeURIComponent(n.slug)}/edit`,`edit the channel`]:[`/settings`,`workspace settings`],g=F(`workflows.list`,{},{interval:15e3}),_=F(`runs.list`,{},{interval:6e3}),y=F(`routines.list`,{},{interval:3e4}),[b,x]=(0,v.useState)(null),S=F(`knowledge.list`,{},{interval:15e3}),C=F(`vibeables.list`,p.vibeables?{}:null,{interval:15e3}),w=F(`boards.list`,p.boards&&n.kind===`project`?{query:{project:n.slug}}:null,{interval:15e3}),T=n.kind===`project`?w?.boards??[]:[],E=F(`presentations.list`,p.presentations&&n.kind===`project`?{query:{project:n.slug}}:null,{interval:15e3}),D=n.kind===`project`?E?.presentations??[]:[],[O,k]=(0,v.useState)(null),[ee,j]=(0,v.useState)(0),M=()=>{try{return localStorage.getItem(`kw-ctx-tab`)||`overview`}catch{return`overview`}},[N,P]=(0,v.useState)(M),[I,te]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>R(`browser`);return window.addEventListener(po,e),()=>window.removeEventListener(po,e)},[]);let R=e=>{P(e);try{localStorage.setItem(`kw-ctx-tab`,e)}catch{}};(0,v.useEffect)(()=>{P(d?`task`:e=>e===`task`?M():e)},[o,d]);let[re,ie]=(0,v.useState)({});(0,v.useEffect)(()=>ie(ge.current?{vibeables:`/vibeables/${encodeURIComponent(ge.current.slug)}`}:{}),[c]);let[ae,oe]=(0,v.useState)(!1);(0,v.useEffect)(()=>oe(!1),[c]);let se=ne(),ce=n.kind===`project`?new URLSearchParams(se.split(`?`)[1]??``).get(`app`):null;(0,v.useEffect)(()=>{ce&&(R(`vibeables`),ie(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(ce)}`})),oe(!0))},[ce,c]);let le=e=>ie(t=>({...t,[xe]:e})),[ue,de]=(0,v.useState)({dir:``});(0,v.useEffect)(()=>de({dir:``}),[c]);let V=async(e,t,n)=>{(await A.request(`projects.link`,{slug:e,body:{kind:`vibeables`,target:t,remove:n}}).catch(()=>null))?.ok&&j(e=>e+1)},fe=()=>{oe(!1),ie(e=>({...e,[xe]:null}))},pe=e=>t=>t.startsWith(e)?(ie(e=>({...e,[xe]:t})),!0):!1,[H,he]=(0,v.useState)(null),ge=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;ge.current=t,he(t),t?(R(`vibeables`),ie(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(t.slug)}`}))):ie(e=>e.vibeables?.startsWith(`/vibeables/`)?{...e,vibeables:null}:e)};return window.addEventListener(Xt,e),()=>window.removeEventListener(Xt,e)},[]);let ve=p.repos&&!!O?.repos,ye=n.kind===`project`?`project:${n.slug}`:O?.channel?.project?`project:${O.channel.project}`:`workspace`,be=[...f?[{id:`task`,label:`task`,allHref:Ws(f,f.task)}]:[],{id:`overview`,label:`overview`},{id:`files`,label:`files`,allHref:`/files/${encodeURIComponent(ye)}`},{id:`knowledge`,label:`knowledge`,count:O?.knowledge.length,allHref:`/knowledge`},...p.vibeables?[{id:`vibeables`,label:`apps`,count:O?.all?C?.vibeables.length:O?.vibeables?.length??0,allHref:`/vibeables`}]:[],{id:`workflows`,label:`workflows`,count:O?.workflows.length,allHref:`/workflows`},...p.boards&&n.kind===`project`?[{id:`board`,label:`boards`,count:T.reduce((e,t)=>e+t.review,0)||void 0,allHref:`/projects/${encodeURIComponent(n.slug)}/boards`}]:[],...p.presentations&&n.kind===`project`?[{id:`presentations`,label:`presentations`,count:D.length,allHref:`/projects/${encodeURIComponent(n.slug)}/presentations`}]:[],...ve?[{id:`repos`,label:`repositories`,count:O?.repos?.length,allHref:`/repos`}]:[],...LC.filter(e=>p[e.id]&&O?.[e.id]).map(e=>({id:e.id,label:e.id,count:O?.[e.id]?.length,allHref:`/${e.id}`})),...I>0||N===`browser`?[{id:`browser`,label:`browser`,count:I}]:[]],xe=be.some(e=>e.id===N)?N:`overview`,Se=be.find(e=>e.id===xe),Ce=re[xe]??null,we=!!H&&xe===`vibeables`&&Ce===`/vibeables/${encodeURIComponent(H.slug)}`,Te=xe===`vibeables`&&!!Ce,Ee=ae&&Te,Oe=e=>t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),le(e))};(0,v.useEffect)(()=>{let e=setInterval(()=>j(e=>e+1),15e3);return()=>clearInterval(e)},[]);let ke=me(se),Ae=(0,v.useRef)(ke);(0,v.useEffect)(()=>{Ae.current&&!ke&&j(e=>e+1),Ae.current=ke},[ke]),(0,v.useEffect)(()=>{let e=!0,r=new Set((g?.workflows??[]).map(e=>e.slug)),i=new Set((S?.bundles??[]).map(e=>e.name)),a=new Set((C?.vibeables??[]).map(e=>e.slug));return(async()=>{let o=null;if(n.kind===`agent`){let e=await A.call(`agents.get`,{slug:n.slug}).catch(()=>null);e&&(o={title:`${e.emoji?`${e.emoji} `:``}${e.name}`,agent:e,workflows:BC(e.workflows,r),knowledge:BC(e.knowledge,i),editHref:`/agents/${encodeURIComponent(n.slug)}/edit`},(e.vibeables??[]).length>0&&(o.vibeables=BC(e.vibeables,a)),o.journal=(await A.call(`agents.journal`,{slug:n.slug}).catch(()=>null))?.journal??``)}else if(n.kind===`project`){let e=await A.call(`projects.get`,{slug:n.slug}).catch(()=>null);e&&(o={title:`📁 ${e.title}`,project:e,workflows:e.links.workflows,knowledge:e.links.knowledge,vibeables:e.links.vibeables,repos:e.links.repos,agents:e.links.agents,contacts:e.links.contacts,places:e.links.places,events:e.links.events,records:e.records,state:e.state,log:e.log,editHref:`/projects/${encodeURIComponent(n.slug)}/info`})}else if(n.kind===`channel`){let e=(await A.call(`channels.list`).catch(()=>null))?.channels.find(e=>e.slug===n.slug);if(e){let t=(await Promise.all(e.members.map(e=>A.call(`agents.get`,{slug:e}).catch(()=>null)))).filter(e=>!!e),s=e=>[...new Set(t.flatMap(e))],c=s(e=>e.vibeables??[]);o={title:`#${e.slug}`,channel:e,workflows:BC(s(e=>e.workflows),r),knowledge:BC(s(e=>e.knowledge),i),...c.length>0?{vibeables:BC(c,a)}:{},agents:e.members.map(e=>({slug:e,found:t.some(t=>t.slug===e),label:t.find(t=>t.slug===e)?.name})),editHref:`/channels/${encodeURIComponent(n.slug)}/edit`}}}else o={title:`${t.icon?`${t.icon} `:``}${t.name||`workspace`}`,workflows:BC([...r],r),knowledge:BC([...i],i),all:!0};e&&k(o)})(),()=>{e=!1}},[c,ee,g,S,C,t.name,t.icon]);let je=e=>g?.workflows.find(t=>t.slug===e),Me=e=>e?_?.runs.find(t=>t.workflow===(e.name??e.slug)||t.workflow===e.slug):void 0,Ne=e=>S?.bundles.find(t=>t.name===e),Pe=e=>C?.vibeables.find(t=>t.slug===e),Fe=e=>(0,z.jsxs)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:[O?.all?`No ${e} in this workspace yet.`:`No ${e} linked.`,O?.editHref&&!O.all&&(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(U,{href:O.editHref,className:`text-accent`,children:`Edit the links`}),`.`]})]});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`space-title flex min-w-0 items-center gap-2 px-1`,children:[s?(0,z.jsx)(U,{href:s,className:`project-home-link min-w-0 truncate rounded-control text-[22px] leading-[1.15] font-[750] tracking-[-0.015em] text-fg no-underline animate-fade hover:text-accent max-[800px]:text-lg`,title:`${O?.title??``} · all sessions`,children:O?O.title:`…`},O?.title??``):(0,z.jsx)(`span`,{className:`min-w-0 truncate text-[22px] leading-[1.15] font-[750] tracking-[-0.015em] text-fg animate-fade max-[800px]:text-lg`,title:O?.title,children:O?O.title:`…`},O?.title??``),m&&(0,z.jsx)(U,{href:m,className:`ctx-edit inline-grid size-7 flex-none place-items-center rounded-full text-fg-2 no-underline transition-colors hover:bg-surface-2 hover:text-accent active:scale-96 [&_.ms]:text-[18px]`,title:h,"aria-label":h,children:(0,z.jsx)(B,{name:`edit`,className:`ms-sm`})}),o&&s&&(0,z.jsx)(Sn,{id:o,fallbackTitle:i||a?`new chat`:`new session`,backHref:s},o)]}),(0,z.jsxs)(`aside`,{className:`ctx`,"aria-label":`Context`,"data-full":Ee||void 0,children:[(0,z.jsx)(_t,{className:`flex-none gap-y-0.5 pt-2`,label:`Categories`,items:be,value:xe,onChange:R}),Ce&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2`,children:[(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`arrow_back`,onClick:fe,"aria-label":`Back to the list`,children:Se?.label}),(0,z.jsx)(`span`,{className:`flex-1`}),Te&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:Ee?`close_fullscreen`:`open_in_full`,onClick:()=>oe(!Ee),title:Ee?`back beside the chat`:`full size, in place of the chat`,children:Ee?`beside the chat`:`full size`}),(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`open_in_new`,href:Ce,title:`Open as a page`,children:`page`})]}),Ce&&xe===`knowledge`&&(0,z.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,z.jsx)(_e.Provider,{value:pe(`/knowledge/`),children:(()=>{let e=Ce.split(`/`).filter(Boolean),t=decodeURIComponent(e[1]??``),n=e.length>2?e.slice(2).map(decodeURIComponent).join(`/`):void 0;return(0,z.jsx)(F_,{name:t,conceptId:n},t)})()})}),Ce&&xe===`workflows`&&(0,z.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,z.jsx)(_e.Provider,{value:pe(`/workflows/`),children:(()=>{let e=Ce.split(`/`).filter(Boolean),t=e[2]===`details`||e[2]===`runs`?e[2]:`overview`;return(0,z.jsx)(p_,{slug:decodeURIComponent(e[1]??``),tab:t},e[1])})()})}),Ce&&xe===`vibeables`&&!we&&(0,z.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,z.jsx)(en,{slug:decodeURIComponent(Ce.split(`/`).filter(Boolean)[1]??``)},Ce)}),(0,z.jsx)(`div`,{id:Zt,className:`ctx-body ctx-embed ctx-embed-vibe`,hidden:!we}),(0,z.jsx)(`div`,{className:`ctx-body ctx-embed ctx-browser`,hidden:xe!==`browser`,children:(0,z.jsx)(bo,{storeKey:c,onTabs:te},c)}),(0,z.jsxs)(`div`,{className:`ctx-body`,role:`tabpanel`,hidden:xe===`browser`||!!Ce&&[`knowledge`,`workflows`,`vibeables`].includes(xe),children:[Se?.allHref&&(0,z.jsx)(`div`,{className:`flex justify-end px-1 pb-1`,children:(0,z.jsxs)(K,{variant:`quiet`,size:`sm`,href:Se.allHref,children:[`all `,Se.label,` `,(0,z.jsx)(B,{name:`arrow_forward`,className:`ms-sm`})]})}),xe===`workflows`&&(0,z.jsxs)(z.Fragment,{children:[O&&O.workflows.length===0&&Fe(`workflows`),O?.workflows.map(({slug:e,found:t})=>{let n=je(e),r=Me(n),i=t&&!!n&&!n.error,a=(y?.routines??[]).filter(t=>t.workflows.includes(e));return(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,z.jsx)(gt,{href:`/workflows/${encodeURIComponent(e)}`,onClick:t?Oe(`/workflows/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,z.jsx)(et,{tone:!t||n?.error?`bad`:UC(r?.status)}),title:n?.name??e,sub:t?n?.error?`broken`:r?`${r.status} · ${G(r.updatedAt)}`:n?.description??`no runs yet`:`not in this workspace`,actionsAlways:!0,actions:i?(0,z.jsx)(q,{size:`sm`,icon:b===e?`close`:`play_arrow`,label:b===e?`close the launcher of ${n.name??e}`:`run ${n.name??e}`,"aria-expanded":b===e,onClick:()=>x(b===e?null:e)}):void 0}),a.map(e=>(0,z.jsxs)(U,{href:e.owner===`_`?`/?kind=routines&open=${encodeURIComponent(`routines:_:${e.id}`)}`:`/agents/${encodeURIComponent(e.owner)}/info`,className:`routine-line flex min-w-0 items-center gap-1.5 pt-0.5 pb-2 pl-[46px] pr-3 text-xs text-fg-2 no-underline hover:text-fg`,title:`${e.agent?`${e.agent.name}'s routine`:`The routine`} "${e.name}" (${e.schedule}) runs this workflow: ${e.prompt}`,children:[(0,z.jsx)(B,{name:`schedule`,className:`ms-sm flex-none text-[14px]`}),(0,z.jsxs)(`span`,{className:`min-w-0 truncate`,children:[lb(e),` · `,e.name,` · `,e.enabled?e.nextRunAt?`next ${zC(e.nextRunAt)}`:e.schedule:`paused`]})]},`${e.owner}/${e.id}`)),b===e&&n&&(0,z.jsx)(`div`,{className:`mx-1 mb-2`,children:(0,z.jsx)(Eg,{slug:e,usesRequest:n.usesRequest,onLaunched:()=>{x(null),le(`/workflows/${encodeURIComponent(e)}`)}})})]},e)})]}),xe===`knowledge`&&(0,z.jsxs)(z.Fragment,{children:[O&&O.knowledge.length===0&&Fe(`knowledge`),O?.knowledge.map(({slug:e,found:t})=>{let n=Ne(e);return(0,z.jsx)(gt,{href:`/knowledge/${encodeURIComponent(e)}`,onClick:t?Oe(`/knowledge/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,z.jsx)(B,{name:`menu_book`,className:`ms-sm`}),title:e,sub:t?n?`${n.concepts} ${n.concepts===1?`page`:`pages`}${n.updatedAt?` · ${G(n.updatedAt)}`:``}`:void 0:`not in this workspace`},e)})]}),xe===`vibeables`&&O&&(0,z.jsxs)(z.Fragment,{children:[(O.all?(C?.vibeables??[]).map(e=>({slug:e.slug,found:!0})):O.vibeables??[]).map(({slug:e,found:t})=>{let r=Pe(e);return(0,z.jsx)(gt,{href:`/vibeables/${encodeURIComponent(e)}`,onClick:t?Oe(`/vibeables/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,z.jsx)(B,{name:`web`,className:`ms-sm`}),title:e,sub:t?r?.updatedAt?`changed ${G(r.updatedAt)}`:void 0:`not in this workspace`,actions:n.kind===`project`?(0,z.jsx)(q,{icon:`keep_off`,size:`sm`,label:`unpin ${e}`,onClick:()=>void V(n.slug,e,!0)}):void 0},e)}),n.kind===`project`&&C&&(0,z.jsx)(HC,{options:C.vibeables.map(e=>e.slug).filter(e=>!O.vibeables?.some(t=>t.slug===e)),onPin:e=>void V(n.slug,e,!1)}),O.all&&C&&C.vibeables.length===0&&Fe(`vibeables`),!O.all&&O.vibeables?.length===0&&Fe(`vibeables`)]}),LC.map(e=>xe===e.id&&O?.[e.id]&&(0,z.jsxs)(v.Fragment,{children:[O[e.id].length===0&&Fe(e.id),O[e.id].map(({slug:t,found:n,label:r})=>(0,z.jsx)(gt,{href:`/${e.id}/${encodeURIComponent(t)}`,dim:!n,leading:(0,z.jsx)(B,{name:e.icon,className:`ms-sm`}),title:n&&r?r:t,sub:n?r?t:void 0:`not in this workspace`},t))]},e.id)),xe===`board`&&n.kind===`project`&&(0,z.jsxs)(z.Fragment,{children:[w&&w.enabled&&T.length===0&&(0,z.jsxs)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:[`No board yet. `,(0,z.jsx)(U,{href:`/projects/${encodeURIComponent(n.slug)}/boards`,className:`text-accent`,children:`Open the tasks board`}),` — it is created on first use.`]}),w&&!w.enabled&&(0,z.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:w.error}),T.map(e=>(0,z.jsx)(fc,{project:e.project,board:e.board},`${e.project??``}/${e.board}`))]}),xe===`presentations`&&n.kind===`project`&&(0,z.jsxs)(z.Fragment,{children:[E&&!E.enabled&&(0,z.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:E.error}),E?.enabled&&D.length===0&&Fe(`presentations`),D.map(e=>(0,z.jsx)(gt,{href:`/projects/${encodeURIComponent(n.slug)}/presentations/${encodeURIComponent(e.name)}`,innerProps:{"data-deck":e.name},leading:(0,z.jsx)(B,{name:`slideshow`,className:`ms-sm`}),title:e.title,sub:e.error?`unreadable deck.md`:`${e.slides} ${e.slides===1?`slide`:`slides`}${e.updatedAt?` · ${G(e.updatedAt)}`:``}`,subTone:e.error?`bad`:`plain`},e.name)),E?.enabled&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`add`,className:`justify-start`,href:`/projects/${encodeURIComponent(n.slug)}/presentations/new`,children:`new presentation`})]}),xe===`repos`&&O?.repos&&(0,z.jsxs)(z.Fragment,{children:[O.repos.length===0&&Fe(`repositories`),O.repos.map(({slug:e,found:t})=>(0,z.jsx)(gt,{href:`/repos/${encodeURIComponent(e)}`,dim:!t,leading:(0,z.jsx)(B,{name:`source`,className:`ms-sm`}),title:e,sub:t?void 0:`not in this workspace`},e))]}),xe===`task`&&f&&(0,z.jsx)(ic,{project:f.project,board:f.board,task:f.task,embedded:!0},d),xe===`overview`&&O&&(0,z.jsx)(NC,{of:O.project?{kind:`project`,project:O.project}:O.agent?{kind:`agent`,agent:O.agent,journal:O.journal??``}:O.channel?{kind:`channel`,channel:O.channel}:{kind:`workspace`}},c),xe===`files`&&(0,z.jsx)(As,{compact:!0,scope:ye,dir:ue.dir,file:ue.file,onOpen:(e,t)=>de({dir:e,file:t})},ye)]},xe)]})]})}function HC({options:e,onPin:t}){return e.length===0?null:(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-2 text-fg-2`,children:[(0,z.jsx)(B,{name:`keep`,className:`ms-sm`}),(0,z.jsxs)(St,{className:`h-8 text-sm`,value:``,onChange:e=>e.target.value&&t(e.target.value),"aria-label":`pin an app to this project`,children:[(0,z.jsx)(`option`,{value:``,children:`pin an app to this project…`}),e.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]})}function UC(e){return e===`ok`?`ok`:e===`failed`?`bad`:e===`running`?`working`:`idle`}var WC=`kw-chat-path`,GC=`kw-ctx-w`,KC=()=>{try{let e=Number(localStorage.getItem(GC));return e>0?e:null}catch{return null}};function qC({onResize:e}){let[t,n]=(0,v.useState)(!1);return(0,z.jsx)(`div`,{className:`split-handle${t?` dragging`:``}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`resize chat and context`,title:`drag to resize · double-click for one third · two thirds`,onPointerDown:t=>{if(t.button!==0)return;let r=t.currentTarget.closest(`.shell`);if(!r)return;t.preventDefault();let i=r.getBoundingClientRect().right-parseFloat(getComputedStyle(r).paddingRight),a=t=>e(Math.round(i-t.clientX)),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),document.body.classList.remove(`kw-resizing`),n(!1)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),document.body.classList.add(`kw-resizing`),n(!0)},onDoubleClick:()=>e(null)})}var JC=(e,t)=>{try{return sessionStorage.getItem(e)||t}catch{return t}},YC=(e,t)=>{try{sessionStorage.setItem(e,t)}catch{}};function XC(){let e=ne();ms();let[t]=e.split(`?`),n=t.split(`/`).filter(Boolean),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)([]),_=de(t),y=V(t),b=ue.has(n[0]??``)&&!_&&!y,x=n.length===0||n[0]===`artifacts`,S=n[0]===`today`,C=x||S,w=b&&n[0]===`projects`&&n.length===2&&n[1]!==`new`&&new URLSearchParams(e.split(`?`)[1]??``).has(`open`),[T,E]=(0,v.useState)(()=>JC(WC,`/agents/chats`)),D=b?Wx(t):null,O=b&&!D?t:T,[k,ee]=(0,v.useState)(`chat`),[A,j]=(0,v.useState)(KC),M=e=>{j(e);try{e===null?localStorage.removeItem(GC):localStorage.setItem(GC,String(e))}catch{}};(0,v.useEffect)(()=>{ee(e=>e===`side`?`chat`:e)},[e]),(0,v.useEffect)(()=>{b&&!Wx(t)&&(E(t),YC(WC,t))},[e]),(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;fe(t)===`chat`?(E(t),YC(WC,t)):window.location.replace(`#${t}`)};return window.addEventListener(pe,e),()=>window.removeEventListener(pe,e)},[]);let N=F(`meta.get`,{},{interval:3e4});(0,v.useEffect)(()=>{let e=N;e&&(i(e.workspaceName??``),o(e.workspaceIcon??``),c(e.workspaceColor??``),u(e.workspaceNamed!==!1),f(e.workspaceRootLabel??``),m(e.workspaceRoot??``),Ee({git:!!e.git,repos:!!e.repos,vibeables:!!e.vibeables,projects:!!e.projects,contacts:!!e.contacts,places:!!e.places,events:!!e.events,boards:!!e.boards,presentations:!!e.presentations}),g(Array.isArray(e.switcher)?e.switcher:[]))},[N]),(0,v.useEffect)(()=>{if(ce(r?`${r} — kraftwerk`:`kraftwerk inspector`),!a)return;let e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="0.9em" font-size="85">${a}</text></svg>`,t=document.querySelector(`link[rel="icon"]`);t||(t=document.createElement(`link`),t.rel=`icon`,document.head.appendChild(t)),t.href=`data:image/svg+xml,${encodeURIComponent(e)}`},[r,a]);let P=O.split(`/`).filter(Boolean),I=new URLSearchParams(e.split(`?`)[1]??``).get(`workflow`)??void 0,te;te=P[0]===`chats`?(0,z.jsx)(Ux,{seg:P}):P[0]===`projects`?(0,z.jsx)(Zb,{seg:P.slice(1)}):P[0]===`channels`?(0,z.jsx)(fn,{seg:P.slice(1)}):(0,z.jsx)(Ux,{seg:P.slice(1)});let R=null;_?R=(0,z.jsx)(sc,{seg:n.slice(3),project:decodeURIComponent(n[1])}):y?R=(0,z.jsx)(Lh,{seg:n.slice(3),project:decodeURIComponent(n[1])}):n[0]===`runs`&&n[1]?R=(0,z.jsx)(Ig,{id:n[1],workflow:I}):n[0]===`runs`?R=(0,z.jsx)(ow,{}):n[0]===`workflows`?R=(0,z.jsx)(Jx,{slug:n[1]?decodeURIComponent(n[1]):void 0,tab:n[2]===`details`||n[2]===`runs`?n[2]:`overview`}):n[0]===`vibeables`?R=(0,z.jsx)(un,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`knowledge`?R=(0,z.jsx)(D_,{bundle:n[1]?decodeURIComponent(n[1]):void 0,conceptId:n.length>2?n.slice(2).map(decodeURIComponent).join(`/`):void 0}):n[0]===`skills`?R=(0,z.jsx)(My,{name:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`settings`?R=n[1]===`agents`?(0,z.jsx)(BS,{}):n[1]===`routines`?(0,z.jsx)(WS,{}):n[1]===`workflows`?(0,z.jsx)(KS,{}):n[1]===`knowledge`?(0,z.jsx)(JS,{}):n[1]===`boards`?(0,z.jsx)(QS,{}):n[1]===`apps`?(0,z.jsx)(eC,{}):n[1]===`harnesses`?(0,z.jsx)(aC,{}):n[1]===`projects`?(0,z.jsx)(uC,{}):n[1]===`skills`?(0,z.jsx)(pC,{}):n[1]===`cloud`?(0,z.jsx)(Yv,{}):(0,z.jsx)(Ev,{}):n[0]===`trash`?R=(0,z.jsx)(Xx,{}):n[0]===`ui`?R=(0,z.jsx)(Zx,{}):n[0]===`files`?R=(0,z.jsx)(Os,{scope:n[1]?decodeURIComponent(n[1]):`workspace`,dir:n.slice(2).map(decodeURIComponent).join(`/`),file:new URLSearchParams(e.split(`?`)[1]??``).get(`file`)??void 0}):n[0]===`workspaces`?R=(0,z.jsx)(tS,{}):n[0]===`git`?R=(0,z.jsx)(ly,{}):n[0]===`repos`?R=(0,z.jsx)(Dy,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`contacts`||n[0]===`places`||n[0]===`events`?R=(0,z.jsx)(hg,{kind:n[0],slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`boards`?R=(0,z.jsx)(sc,{seg:n.slice(1)}):n[0]===`presentations`&&(R=(0,z.jsx)(Lh,{seg:n.slice(1)}));let re=!!R&&!_&&!y&&vC(t);return(0,v.useEffect)(()=>{let e=document.documentElement,t=p||r,n=t?ze(ke(s,t)):null;if(!n)delete e.dataset.wsAccent;else{for(let[t,r]of Object.entries(n))e.style.setProperty(t,r);e.dataset.wsAccent=``}},[s,p,r]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`header`,{className:`topbar sticky top-0 z-10 flex h-[var(--topbar-h)] items-center gap-3.5 bg-bg px-5 shadow-[inset_0_-1px_0_var(--line)] max-[1520px]:gap-2.5 max-[800px]:gap-1.5 max-[800px]:px-3`,style:{"--ws-c":ke(s,p||r)},children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-none items-center gap-2.5 max-[800px]:flex-[0_1_auto] max-[800px]:gap-1`,children:[(0,z.jsx)(`a`,{href:`#/`,className:`grid size-8 place-items-center rounded-full text-[15px] leading-none transition-shadow hover:shadow-[0_0_0_4px_color-mix(in_srgb,var(--ws-c,var(--text))_16%,transparent)]`,title:`Home`,children:r?(0,z.jsx)(Ve,{size:`sm`,icon:a,name:r,color:s,seed:p||r}):(0,z.jsx)(B,{name:`home`})}),r&&(0,z.jsx)(aw,{name:r,icon:a,color:s,named:l,root:d,seed:p||r,entries:h})]}),(0,z.jsx)(`span`,{className:`flex-[1_1_8px]`}),(0,z.jsx)(yS,{}),(0,z.jsx)(bC,{path:t}),(0,z.jsx)(qv,{}),(0,z.jsx)(q,{icon:`settings`,label:`settings`,href:`/settings`,"aria-current":n[0]===`settings`?`page`:void 0}),(0,z.jsx)(uw,{}),(0,z.jsx)(ps,{}),(0,z.jsx)(pw,{}),(0,z.jsx)(lw,{}),(0,z.jsx)(cw,{})]}),re&&(0,z.jsx)(yC,{path:t}),R&&(0,z.jsx)(`main`,{className:`shell shell-global`,style:re?{"--topbar-h":`108px`}:void 0,children:(0,z.jsx)(Xo,{children:R})}),(0,z.jsxs)(`main`,{className:`shell three${C?` home`:``}`,"data-focus":k,hidden:!!R,style:A?{"--ctx-w":`${A}px`}:void 0,children:[(0,z.jsx)(FS,{chatPath:x?`/`:S?`/today`:O}),(0,z.jsxs)(`section`,{className:`col-chat`,"aria-label":x?`Home`:S?`Today`:`Conversation`,children:[x?(0,z.jsx)(Mb,{}):S?(0,z.jsx)($y,{}):te,(0,z.jsx)(qC,{onResize:M})]}),x||w?(0,z.jsx)(Nb,{}):(0,z.jsx)(VC,{chatPath:C?`/`:O,workspace:{name:r,icon:a}}),D&&(0,z.jsx)(Gx,{back:O,children:D})]}),!R&&(0,z.jsxs)(`nav`,{className:`places`,"aria-label":`Sections`,children:[(0,z.jsxs)(`button`,{className:k===`side`?`active`:``,onClick:()=>ee(`side`),children:[(0,z.jsx)(B,{name:`menu`}),` list`]}),(0,z.jsxs)(`button`,{className:k===`chat`?`active`:``,onClick:()=>ee(`chat`),children:[(0,z.jsx)(B,{name:`forum`}),` chat`]}),(0,z.jsxs)(`button`,{className:k===`context`?`active`:``,onClick:()=>ee(`context`),children:[(0,z.jsx)(B,{name:`account_tree`}),` context`]})]})]})}function ZC(e){try{let t=new URL(e);return t.hostname===`localhost`||t.hostname===`127.0.0.1`?`:${t.port||(t.protocol===`https:`?443:80)}`:t.host}catch{return e.replace(/^https?:\/\//,``)}}var QC=`truncate text-sm text-fg-2 group-aria-[current=true]/ws:text-on-accent-soft group-aria-[current=true]/ws:opacity-80`,$C=`group/ws relative flex min-h-[60px] items-center gap-3.5 px-4 py-2.5 text-fg no-underline transition-colors`;function ew({label:e}){return e?(0,z.jsx)(`span`,{className:I(QC,`[direction:rtl] text-left`),title:e,children:(0,z.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})}):null}function tw({name:e,named:t}){let n=t===!1;return(0,z.jsx)(`span`,{className:I(`truncate text-md tracking-[0.2px]`,n&&`italic text-fg-2`,`group-data-[missing]/ws:line-through group-data-[stopped]/ws:text-fg-2`),title:n?`${e} — folder name; set name: in kraftwerk.yml`:e,children:e})}function nw({entry:e,ambiguous:t}){let[n,r]=(0,v.useState)(`idle`),[i,a]=(0,v.useState)(``),o=e.exists===!1,s=async()=>{r(`starting`),a(``);try{window.location.assign(await ge(e.root))}catch(e){r(`error`),a(e.message)}};return(0,z.jsxs)(`span`,{className:I($C,`cursor-default`),role:`menuitem`,"data-stopped":``,"data-missing":o?``:void 0,style:{"--ws-c":ke(e.color,e.root??e.url)},children:[(0,z.jsx)(Ve,{className:`opacity-60 grayscale-50`,icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:t}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(tw,{name:e.name,named:e.named}),n===`error`?(0,z.jsx)(`span`,{className:I(QC,`text-bad`),title:i,children:i}):o?(0,z.jsx)(`span`,{className:QC,children:`folder missing`}):(0,z.jsx)(ew,{label:e.rootLabel})]}),(0,z.jsxs)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:[(0,z.jsx)(rw,{entry:e}),(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`play_arrow`,busy:n===`starting`,className:`text-accent hover:text-accent`,disabled:o,title:o?`The project folder no longer exists`:`Start the UI for this project`,onClick:e=>{e.stopPropagation(),s()},children:n===`starting`?`starting`:`start`})]})]})}function rw({entry:e}){return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap text-2xs font-medium tracking-[0.5px] text-fg-2`,children:[e.live&&(0,z.jsx)(et,{tone:`ok`,title:`running`}),!e.here&&(0,z.jsx)(`span`,{className:`max-[800px]:hidden`,children:ZC(e.url)})]})}function iw({entry:e,ambiguous:t}){let n=e.root??e.url;return(0,z.jsxs)(`a`,{className:I($C,`hover:bg-surface-2 active:bg-surface-2`),role:`menuitem`,href:he(e),style:{"--ws-c":ke(e.color,n)},children:[(0,z.jsx)(Ve,{icon:e.icon,name:e.name,color:e.color,seed:n,ambiguous:t}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(tw,{name:e.name,named:e.named}),(0,z.jsx)(ew,{label:e.rootLabel??(e.root?void 0:e.url.replace(/^https?:\/\//,``))})]}),(0,z.jsx)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:(0,z.jsx)(rw,{entry:e})})]})}function aw({name:e,icon:t,color:n,named:r,root:i,seed:a,entries:o}){let[s,c]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!s)return;let e=e=>{e.target.closest(`[data-switcher]`)||c(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]);let l=new Map;for(let e of[t,...o.map(e=>e.icon)])e&&l.set(e,(l.get(e)??0)+1);let u=e=>!!e&&(l.get(e)??0)>1,d=[{key:`running`,label:`running`,items:o.filter(e=>e.live===!0)},{key:`stopped`,label:`stopped`,items:o.filter(e=>e.live===!1)},{key:`linked`,label:`linked`,items:o.filter(e=>e.live===void 0)}].filter(e=>e.items.length>0),f=a||e;return(0,z.jsxs)(`span`,{className:`relative inline-flex min-w-0`,"data-switcher":``,children:[(0,z.jsxs)(`button`,{type:`button`,className:`env-switch inline-flex max-w-[220px] min-w-0 cursor-pointer items-center gap-[5px] rounded-xl border-0 bg-transparent px-2 py-1 font-[inherit] text-[15px] font-bold tracking-[0.02em] whitespace-nowrap text-fg transition-colors hover:bg-surface-2 max-[1520px]:max-w-[250px]`,title:i?`${i} — workspace menu`:`Workspace menu`,"aria-haspopup":`menu`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),(0,z.jsx)(B,{name:`expand_more`,className:`flex-none opacity-55`})]}),s&&(0,z.jsxs)(`div`,{className:`absolute top-[calc(100%+8px)] left-0 z-20 max-h-[calc(100dvh-120px)] max-w-[min(480px,92vw)] min-w-[360px] max-[800px]:fixed max-[800px]:inset-x-2 max-[800px]:top-[calc(var(--topbar-h)-4px)] max-[800px]:max-w-none max-[800px]:min-w-0 overflow-y-auto overscroll-contain rounded-card border border-line bg-surface py-2 shadow-pop`,role:`menu`,children:[o.length>0&&(0,z.jsx)(it,{className:`block px-4 pt-1 pb-2`,children:`workspaces`}),(0,z.jsxs)(`span`,{className:I($C,`cursor-default bg-accent-soft text-on-accent-soft`),"aria-current":`true`,style:{"--ws-c":ke(n,f)},children:[(0,z.jsx)(Ve,{icon:t,name:e,color:n,seed:f,ambiguous:u(t)}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(tw,{name:e,named:r}),i?(0,z.jsx)(ew,{label:i}):(0,z.jsx)(`span`,{className:QC,children:`this workspace`})]}),(0,z.jsx)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:(0,z.jsx)(B,{name:`check`,className:`text-[24px] text-on-accent-soft`})})]}),d.map(e=>(0,z.jsxs)(`div`,{className:`mt-2 border-t border-line pt-1`,role:`group`,"aria-label":e.label,children:[(0,z.jsx)(it,{className:`block px-4 pt-2 pb-1`,children:e.label}),e.items.map(e=>e.live===!1&&e.root?(0,z.jsx)(nw,{entry:e,ambiguous:u(e.icon)},e.root):(0,z.jsx)(iw,{entry:e,ambiguous:u(e.icon)},e.root??e.url))]},e.key)),o.length>0&&(0,z.jsxs)(`a`,{className:`mt-2 flex min-h-12 items-center gap-4 border-t border-line px-4 text-md text-fg no-underline transition-colors hover:bg-surface-2`,href:`#/workspaces`,role:`menuitem`,onClick:()=>c(!1),children:[(0,z.jsx)(B,{name:`hub`,className:`text-[22px] text-fg-2`}),` manage workspaces`]}),(0,z.jsx)(gw,{onClose:()=>c(!1)})]})]})}function ow(){let[e,t]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let e=!0;return A.call(`runs.list`).then(n=>{e&&(n.runs.length>0?H(`/runs/${n.runs[0].id}`,{replace:!0}):t({outputDir:n.outputDir}))}).catch(()=>{}),()=>{e=!1}},[]),e?(0,z.jsxs)(Y,{icon:`play_circle`,children:[`No runs found in `,(0,z.jsx)(`code`,{children:e.outputDir}),`. Start one from the`,` `,(0,z.jsx)(`a`,{href:`#/workflows`,className:`text-accent`,children:`workflows`}),` list or with `,(0,z.jsx)(`code`,{children:`kraftwerk run <workflow> [request]`}),`.`]}):(0,z.jsx)(Y,{children:`loading…`})}async function sw(e){await A.request(`server.restart`).catch(()=>{});for(let t=0;t<60;t++){await new Promise(e=>setTimeout(e,500));try{if((await A.call(`meta.get`)).version===e)break}catch{}}location.reload()}function cw(){let e=F(`meta.get`,{},{interval:3e4}),[t,n]=(0,v.useState)(!1),r=e?.restartable&&e.diskVersion&&e.diskVersion!==e.version?e.diskVersion:null;async function i(){r&&(n(!0),await sw(r))}return!r&&!t?null:(0,z.jsx)(`button`,{type:`button`,className:`mr-2.5 inline-flex flex-none cursor-pointer items-center gap-1 rounded-full border border-accent bg-accent/10 px-3 py-1 font-[inherit] text-xs text-accent hover:bg-accent/18 disabled:cursor-default disabled:opacity-70`,disabled:t,title:`v${r} is installed on disk, the server still runs v${e?.version}. Click to relaunch with the new version.`,onClick:()=>void i(),children:t?`relaunching…`:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`restart_alt`,className:`ms-sm`}),` v`,r,` ready — relaunch`]})})}function lw(){let e=F(`me.get`,{},{interval:6e4}),[t,n]=(0,v.useState)(!1);if(!e||e.mode!==`cloud`||!e.signedIn)return null;let r=async()=>{n(!0);let e=await fetch(`${A.baseUrl}/auth/signout`,{method:`POST`}).catch(()=>null),t=e?.ok?(await e.json()).signin:void 0;location.assign(t??`${A.baseUrl}/`)};return(0,z.jsx)(Nt,{align:`end`,trigger:({toggle:t})=>(0,z.jsx)(`button`,{type:`button`,"aria-label":`signed in as ${e.handle}`,title:`${e.handle} · ${e.email??``}`,onClick:t,className:`grid size-7 cursor-pointer place-items-center rounded-full border-0 bg-accent/15 text-xs font-semibold text-accent uppercase hover:bg-accent/25`,children:e.handle.slice(0,1)}),children:()=>(0,z.jsxs)(`div`,{className:`flex min-w-[220px] flex-col gap-1 p-3 text-sm`,children:[(0,z.jsxs)(`span`,{className:`font-medium`,children:[`@`,e.handle]}),e.email&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:e.email}),(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[e.role,` · signed in with kraftwerk cloud`]}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`logout`,busy:t,onClick:()=>void r(),className:`mt-2 self-start`,children:`sign out`})]})})}function uw(){let e=Se();return(0,z.jsxs)(`button`,{type:`button`,className:I(`expert-toggle inline-flex cursor-pointer items-center gap-[7px] rounded-full border-0 bg-transparent px-2 py-1 font-mono text-2xs tracking-[0.5px] transition-colors hover:text-fg`,e?`text-fg`:`text-fg-2`),title:e?`Expert mode on — full detail`:`Expert mode off — simplified view`,"aria-pressed":e,onClick:()=>xe(!e),children:[(0,z.jsx)(`span`,{className:I(`relative h-[15px] w-[26px] rounded-full transition-colors`,e?`bg-accent`:`bg-fg/14`),children:(0,z.jsx)(`span`,{className:I(`absolute top-0.5 size-[11px] rounded-full transition-[left,background-color]`,e?`left-[13px] bg-on-accent`:`left-0.5 bg-surface`)})}),(0,z.jsx)(`span`,{className:`max-[640px]:hidden`,children:`expert`})]})}var dw={approval:`gavel`,routine_done:`schedule`,routine_failed:`schedule`,run_done:`account_tree`,run_failed:`account_tree`,task_woken:`view_kanban`,task_wake_failed:`view_kanban`,task_assigned:`assignment_ind`},fw=`kw.notif.toast.dismissed`;function pw(){let[e,t]=(0,v.useState)(!1),n=F(`notifications.list`,{},{interval:5e3}),[r,i]=(0,v.useState)(()=>typeof Notification>`u`?`unsupported`:Notification.permission),[a,o]=(0,v.useState)(()=>{try{return localStorage.getItem(fw)===`1`}catch{return!1}}),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>l(null),[n]);let f=(c??n)?.items??[],p=rs()??[],m=new Set(p.map(e=>e.notificationId).filter(Boolean)),h=f.filter(e=>e.kind!==`approval`&&!m.has(e.id)),g=h.filter(e=>!e.readAt).length,_=p.length;(0,v.useEffect)(()=>se(p.length),[p.length]),(0,v.useEffect)(()=>{if(n){if(!s.current)s.current=new Set(f.map(e=>e.id));else for(let e of f)if(!s.current.has(e.id)&&(s.current.add(e.id),!(e.readAt||r!==`granted`)&&(document.hidden||location.hash!==`#${e.href}`)))try{let t=new Notification(e.title,{body:e.body,tag:e.id});t.onclick=()=>{window.focus(),S(e),t.close()}}catch{}}},[n]),(0,v.useEffect)(()=>{if(!e)return;let n=e=>{e.target.closest(`[data-bell]`)||t(!1)};return window.addEventListener(`mousedown`,n),()=>window.removeEventListener(`mousedown`,n)},[e]);async function y(e){try{let t=await e;if(!t.ok)return;let n=t.data;l(`items`in n?n:{items:[],unread:0})}catch{}}let b=e=>y(A.request(`notifications.read`,{body:{ids:e}})),x=()=>y(A.request(`notifications.clear`));function S(e){t(!1),e.readAt||b([e.id]),H(e.href)}async function C(e){d(e.id);try{let n=await A.request(`notifications.diagnose`,{id:e.id});n.ok?(t(!1),H(n.data.href)):n.error&&alert(n.error)}catch{}d(null)}async function w(){typeof Notification<`u`&&i(await Notification.requestPermission())}function T(){o(!0);try{localStorage.setItem(fw,`1`)}catch{}}let E=r==="default"&&!a;return(0,z.jsxs)(`span`,{className:`relative inline-flex`,"data-bell":``,children:[(0,z.jsxs)(`button`,{type:`button`,className:I(`relative grid size-8 cursor-pointer place-items-center rounded-full border-0 bg-transparent transition-colors hover:bg-surface-2 hover:text-fg`,_?`text-fg`:`text-fg-2`),title:_?`${_} thing${_===1?``:`s`} waiting for you`:g?`${g} update${g===1?``:`s`}`:`Notifications`,"aria-label":`Notifications`,onClick:()=>t(e=>!e),children:[(0,z.jsx)(B,{name:_?`notifications_active`:`notifications`}),g>0&&(0,z.jsx)(`span`,{className:`absolute top-1.5 right-1.5 size-[7px] rounded-full bg-accent`})]}),e&&(0,z.jsxs)(`div`,{className:`notif-pop absolute right-0 top-[calc(100%+8px)] z-50 flex max-h-[min(80dvh,640px)] w-[min(460px,92vw)] flex-col overflow-hidden rounded-card border border-line bg-surface shadow-pop`,role:`menu`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-line px-4 py-2`,children:[(0,z.jsx)(it,{className:`text-fg`,children:`notifications`}),(0,z.jsx)(`span`,{className:`flex-1`}),g>0&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,onClick:()=>void b(h.filter(e=>!e.readAt).map(e=>e.id)),children:`mark updates read`}),f.length>0&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,onClick:()=>void x(),children:`clear`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain pb-1.5`,children:[E&&(0,z.jsxs)(`div`,{className:`m-2 flex flex-col gap-2 rounded-control bg-surface-2 p-3 text-sm`,children:[(0,z.jsx)(`span`,{children:`Get a system notification when something needs you, even with this tab in the background.`}),(0,z.jsxs)(`span`,{className:`flex gap-2`,children:[(0,z.jsx)(K,{variant:`primary`,size:`sm`,onClick:()=>void w(),children:`enable`}),(0,z.jsx)(K,{variant:`quiet`,size:`sm`,onClick:T,children:`not now`})]})]}),r===`denied`&&(0,z.jsx)(`p`,{className:`m-0 px-4 pt-2 text-xs text-fg-2`,children:`Browser notifications are blocked for this site — allow them in the address bar to get system alerts.`}),(0,z.jsx)(at,{title:`needs you`,count:p.length||void 0,className:`px-1.5 pt-1.5`,children:p.length===0?(0,z.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-fg-2`,children:`nothing is waiting for you`}):hw(p).map(([e,n])=>(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`notif-owner px-2.5 pb-0.5 pt-2 text-xs font-semibold text-fg`,children:e}),n.map(e=>{let n=e.notificationId?f.find(t=>t.id===e.notificationId):void 0;return(0,z.jsx)(gt,{className:`notif-row need`,onClick:()=>{t(!1),ds(e)},leading:(0,z.jsx)(B,{name:as(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${os(e.kind)}${e.chatTitle?` · in ${e.chatTitle}`:``}`,meta:G(e.since),actionsAlways:!0,actions:n?.diagnose?(0,z.jsx)(mw,{busy:u===n.id,onClick:()=>void C(n)}):void 0},e.id)})]},e))}),(0,z.jsx)(at,{title:`updates`,className:`px-1.5 pt-1.5`,children:h.length===0?(0,z.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-fg-2`,children:`no updates`}):h.slice(0,50).map(e=>(0,z.jsx)(gt,{className:I(`notif-row`,!e.readAt&&`bg-accent/5`),onClick:()=>S(e),leading:(0,z.jsx)(B,{name:dw[e.kind],className:I(`ms-sm`,e.kind.endsWith(`failed`)?`text-bad`:e.kind.endsWith(`done`)?`text-ok`:``)}),title:e.title,sub:e.body,meta:G(e.at),actionsAlways:!0,actions:e.diagnose?(0,z.jsx)(mw,{busy:u===e.id,onClick:()=>void C(e)}):void 0},e.id))})]})]})]})}function mw({busy:e,onClick:t}){return(0,z.jsx)(K,{variant:`secondary`,size:`sm`,icon:`troubleshoot`,busy:e,title:`Open a chat that finds the cause and proposes the fix`,onClick:e=>{e.stopPropagation(),t()},children:e?`starting…`:`diagnose`})}function hw(e){let t=new Map;for(let n of e){let e=ss(n.owner);t.set(e,[...t.get(e)??[],n])}return[...t.entries()]}function gw({onClose:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``);return(0,v.useEffect)(()=>{A.call(`meta.get`).then(e=>o(e.version)).catch(()=>{}),A.call(`runs.list`).then(n).catch(()=>{}),A.call(`workflows.list`).then(i).catch(()=>{})},[]),(0,z.jsxs)(`div`,{className:`ws-menu mt-1.5 flex flex-col gap-0.5 border-t border-line px-1.5 pb-1 pt-2`,children:[(0,z.jsx)(_w,{label:`Theme`,children:(0,z.jsx)(Sw,{})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 py-1.5 text-xs`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(it,{children:`Workflows`}),` `,r?`${r.workflows.length} discovered`:`…`,` `,(0,z.jsx)(`code`,{className:`block break-all text-2xs text-fg-2`,title:r?.root,children:r?.root??``})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(it,{children:`Runs`}),` `,t?`${t.runs.length} total`:`…`,` `,(0,z.jsx)(`code`,{className:`block break-all text-2xs text-fg-2`,title:t?.outputDir,children:t?.outputDir??``})]})]}),(0,z.jsx)(_w,{label:(0,z.jsx)(`span`,{className:`font-mono`,children:a?`kraftwerk ${a}`:`…`}),children:(0,z.jsx)(yw,{})})]})}function _w({label:e,children:t}){return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2.5 py-1.5`,children:[(0,z.jsx)(`span`,{className:`text-sm text-fg-2`,children:e}),t]})}function vw(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++)if((n[e]??0)!==(r[e]??0))return(n[e]??0)<(r[e]??0);return!1}function yw(){let[e,t]=(0,v.useState)(`idle`),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1);async function u(){t(`busy`);try{let e=await A.call(`update.check`);if(!e.latest)throw Error();r(e),t(`done`)}catch{t(`err`)}}let d=i?.state===`running`;(0,v.useEffect)(()=>{if(!d)return;let e=!0,t=setInterval(async()=>{try{let t=await A.call(`update.status`);if(!e)return;a(t)}catch{}},1e3);return()=>{e=!1,clearInterval(t)}},[d]);async function f(){if(!n)return;s(``);let e=await A.request(`update.start`,{body:{version:n.latest}});e.ok?a(e.data):s(e.error??`update refused`)}if(i&&i.state!==`idle`&&n){let e=i.log[i.log.length-1]??``;return i.state===`running`?(0,z.jsxs)(`span`,{className:I(bw,`basis-full flex-wrap`),children:[(0,z.jsx)(B,{name:`progress_activity`,className:`ms-sm`}),` installing v`,n.latest,`…`,e&&(0,z.jsx)(`code`,{className:`max-w-full truncate text-2xs text-fg-2`,title:i.log.join(`
488
- `),children:e})]}):i.state===`done`?(0,z.jsxs)(`span`,{className:I(bw,xw),children:[`v`,n.latest,` installed —`,` `,i.restartable?(0,z.jsx)(K,{size:`sm`,icon:`restart_alt`,busy:c,onClick:()=>{l(!0),sw(n.latest)},children:c?`relaunching…`:`relaunch`}):(0,z.jsxs)(z.Fragment,{children:[`restart `,(0,z.jsx)(`code`,{children:`kraftwerk ui`}),` to use it`]})]}):(0,z.jsxs)(`span`,{className:I(bw,`basis-full flex-wrap text-bad`),title:i.log.join(`
489
- `),children:[(0,z.jsx)(B,{name:`error`,className:`ms-sm`}),` install failed`,e?` — ${e}`:``,` · `,(0,z.jsxs)(`code`,{children:[`npm i -g `,n.name,`@latest`]})]})}return e===`done`&&n?vw(n.current,n.latest)?(0,z.jsxs)(`span`,{className:I(bw,xw),children:[`v`,n.latest,` available —`,` `,o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-normal text-fg-2`,title:o,children:o}),` · `,(0,z.jsxs)(`code`,{className:`text-2xs`,children:[`npm i -g `,n.name,`@latest`]})]}):(0,z.jsx)(K,{size:`sm`,icon:`download`,onClick:()=>void f(),children:`update now`})]}):(0,z.jsxs)(`span`,{className:bw,children:[(0,z.jsx)(B,{name:`check`,className:`ms-sm text-ok`}),` up to date`]}):(0,z.jsx)(K,{size:`sm`,icon:e===`busy`||e===`err`?void 0:`sync`,disabled:e===`busy`,onClick:()=>void u(),children:e===`busy`?`checking…`:e===`err`?`npm unreachable — retry`:`check for updates`})}var bw=`inline-flex items-center gap-[5px] text-xs text-fg-2`,xw=`basis-full flex-wrap font-medium text-accent`;function Sw(){return(0,z.jsx)(K,{size:`sm`,icon:`contrast`,onClick:()=>{let e=document.documentElement,t=e.dataset.theme===`light`?`dark`:`light`;e.dataset.theme=t;try{localStorage.setItem(`kw-theme`,t)}catch{}},children:`day / night`})}(0,y.createRoot)(document.getElementById(`root`)).render((0,z.jsx)(v.StrictMode,{children:(0,z.jsx)(lv,{children:(0,z.jsx)(XC,{})})}));export{o as a,d as i,R as n,s as o,h as r,l as s,Rs as t};
484
+ `;function Fx({slug:e}){let t=F(`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,z.jsxs)(X,{title:`own skills — only this agent`,actions:!n&&(0,z.jsx)(K,{size:`sm`,icon:`add`,onClick:()=>{r({name:``,content:Px,isNew:!0}),s(``)},children:`new skill`}),children:[t.length===0&&!n&&(0,z.jsxs)(nt,{className:`px-[18px] py-3 text-xs`,children:[`none — skills in `,(0,z.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,z.jsx)(ft,{children:t.map(e=>(0,z.jsx)(dt,{icon:`extension`,title:`/${e.name}`,action:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,icon:`edit`,onClick:()=>void c(e.name),children:`edit`}),(0,z.jsx)(q,{icon:`delete`,label:`delete /${e.name}`,variant:`danger`,size:`sm`,onClick:()=>void u(e.name)})]}),children:(0,z.jsx)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:e.description||(0,z.jsx)(`code`,{children:`SKILL.md`})})},e.name))}),n&&(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsx)(Q,{label:`name — invoked as /<name>`,children:(0,z.jsx)(Z,{className:`font-mono`,value:n.name,placeholder:`e.g. report-html`,disabled:!n.isNew,onChange:e=>r({...n,name:e.target.value})})}),(0,z.jsx)(Q,{label:`SKILL.md — frontmatter (description) + the instructions`,children:(0,z.jsx)(xt,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,rows:Math.min(28,Math.max(12,n.content.split(`
485
+ `).length+2)),value:n.content,spellCheck:!1,onChange:e=>r({...n,content:e.target.value})})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(K,{variant:`primary`,busy:i,disabled:!n.name.trim(),onClick:()=>void l(),children:i?`saving…`:`save`}),(0,z.jsx)(K,{variant:`quiet`,disabled:i,onClick:()=>r(null),children:`cancel`})]})]}),o&&(0,z.jsx)(`div`,{className:`px-[18px] pb-3`,children:(0,z.jsx)(rt,{tone:`bad`,children:o})})]})}function Ix(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 Lx({r:e}){return e.runner===`here`?(0,z.jsx)(J,{title:`runs_on: ${e.runsOn} — this machine fires it`,children:`runs here`}):e.runner===`unassigned`?(0,z.jsx)(J,{tone:e.enabled?`ask`:`neutral`,title:`no runs_on — it fires on no machine until one adopts it`,children:`no runner`}):e.retired?(0,z.jsxs)(J,{tone:`ask`,title:`${e.runsOn} is a retired identity of this machine — it fires nowhere until reassigned`,children:[`runs on `,e.runsOn,` · retired`]}):(0,z.jsxs)(J,{title:`another machine fires it, not this one`,children:[`runs on `,e.runsOn]})}function Rx({slug:e}){let[t,n]=(0,v.useState)(0),r=F(`agents.routines`,{slug:e},{refresh:t}),i=F(`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=(rs()??[]).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(P(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&&H(`/agents/${encodeURIComponent(e)}/chat/${n.data.chatId}`):l(P(n))}function w(e){let t=Ix(e);d(t.note),l(t.error),n(e=>e+1),ns()}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(P(n))}async function E(){h(`*`),l(``),d(``);let e=await A.request(`routines.adopt`,{body:{retired:y}});h(``),e.ok?w(e.data):l(P(e))}async function D(t){window.confirm(`Delete the scheduled prompt "${t}"?`)&&await A.request(`agents.deleteRoutine`,{slug:e,id:t}).catch(()=>{})}return(0,z.jsxs)(X,{title:`schedule — prompts that run on their own`,actions:!o&&(0,z.jsx)(K,{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,z.jsx)(nt,{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,z.jsx)(dt,{icon:`event_busy`,title:`${b} routine${b===1?` fires`:`s fire`} nowhere`,action:(0,z.jsx)(K,{size:`sm`,icon:`download_done`,busy:m===`*`,onClick:()=>void E(),children:m===`*`?`adopting…`:`run these here`}),children:(0,z.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,z.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,z.jsx)(ft,{children:a.map(t=>(0,z.jsx)(dt,{icon:`schedule`,title:(0,z.jsxs)(z.Fragment,{children:[t.name,(0,z.jsx)(Lx,{r:t}),t.lastError&&(0,z.jsx)(`span`,{title:t.lastError,children:(0,z.jsx)(J,{tone:`bad`,children:`error`})}),t.awaitingApproval&&t.lastChatId&&(0,z.jsx)(J,{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,z.jsxs)(z.Fragment,{children:[t.runner!==`here`&&(0,z.jsx)(K,{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,z.jsx)(K,{size:`sm`,icon:`play_arrow`,busy:f===t.id,onClick:()=>C(t.id),children:f===t.id?`starting…`:`run`}),(0,z.jsx)(K,{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,z.jsx)(K,{size:`sm`,variant:`danger`,onClick:()=>void D(t.id),children:`delete`}),(0,z.jsx)(Dt,{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,z.jsxs)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:[(0,z.jsx)(`code`,{children:t.schedule}),t.enabled?t.nextRunAt?` · next ${Ke(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,z.jsxs)(U,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,Ke(t.lastRunAt)]}):`never ran`]})},t.id))}),o&&(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`name`,className:`flex-1`,children:(0,z.jsx)(Z,{value:o.name,placeholder:`e.g. Morning report`,onChange:e=>s({...o,name:e.target.value})})}),(0,z.jsx)(Q,{label:`schedule (cron)`,className:`w-[200px] max-[900px]:w-auto`,children:(0,z.jsx)(Z,{className:`font-mono`,value:o.schedule,placeholder:`0 9 * * 1-5`,onChange:e=>s({...o,schedule:e.target.value})})}),(0,z.jsxs)(`label`,{className:`flex h-9 cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:o.enabled,onChange:e=>s({...o,enabled:e.target.checked})}),`enabled`]})]}),(0,z.jsx)(Q,{label:`prompt — what to ask this agent on each run`,children:(0,z.jsx)(xt,{rows:5,value:o.prompt,placeholder:`Check ... and summarize what changed.`,onChange:e=>s({...o,prompt:e.target.value})})}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`runs on — the one machine that fires it`,className:`flex-1`,children:(0,z.jsx)(Z,{className:`font-mono`,value:o.runsOn??i?.identity??``,placeholder:`<handle>@<machine> — empty: no runner`,onChange:e=>s({...o,runsOn:e.target.value})})}),(0,z.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,z.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:o.private??!1,onChange:e=>s({...o,private:e.target.checked})}),`private`]})]}),i&&(0,z.jsxs)(nt,{children:[`This machine is `,(0,z.jsx)(`code`,{children:i.identity}),`. Empty: no runner — it fires nowhere.`]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(K,{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,z.jsx)(K,{variant:`quiet`,onClick:()=>(s(null),l(``)),children:`cancel`})]})]}),(c||u)&&(0,z.jsx)(`div`,{className:`px-[18px] pb-3`,children:c?(0,z.jsx)(rt,{tone:`bad`,children:c}):(0,z.jsx)(rt,{children:u})})]})}function zx({title:e,kind:t,editing:n,saving:r,onToggle:i,children:a}){return(0,z.jsxs)(`section`,{className:`flex flex-col gap-1`,"data-link-kind":t,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:e}),(0,z.jsx)(`span`,{className:`flex-1`}),n?(0,z.jsx)(K,{size:`sm`,variant:`quiet`,busy:r,onClick:i,children:`done`}):(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`edit`,onClick:i,children:`edit`})]}),a]})}function Bx({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=(0,v.useRef)(Promise.resolve()),g=(0,v.useRef)(0),_=De(),y=F(`workflows.list`,{}),b=F(`knowledge.list`,{}),x=F(`vibeables.list`,_.vibeables?{}:null),S=F(`skills.list`,{}),C=e=>{p.current=e,n(e)},w=e=>{m.current=e,c(e)};(0,v.useEffect)(()=>{let t=!0;return A.call(`agents.get`,{slug:e}).then(e=>t&&C(e)).catch(()=>t&&i(!0)),()=>{t=!1}},[e]);function T(t,n=!1){let r=p.current;if(!r)return Promise.resolve(!1);C({...r,...t}),g.current++,u(!0),f(``);let i=h.current.then(async()=>{let t=p.current,r=!1;try{let i=await A.request(`agents.save`,{slug:e,keepalive:n,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,i.ok?g.current===1&&C(i.data):f(P(i))}catch(e){f(e.message)}if(!r){let t=await A.call(`agents.get`,{slug:e}).catch(()=>null);t&&g.current===1&&C(t)}return g.current--,g.current===0&&u(!1),r});return h.current=i,i}async function E(e=!1){let t=m.current,n=p.current;t!==null&&n&&(t.trim()===(n.system??``).trim()||await T({system:t},e))&&m.current===t&&w(null)}(0,v.useEffect)(()=>()=>{E(!0)},[]);async function D(t){u(!0),f(``);try{let n=await A.request(`agents.archive`,{slug:e,body:{archived:t}});n.ok?C(n.data):f(P(n))}catch(e){f(e.message)}u(!1)}if(r)return(0,z.jsx)(Y,{icon:`person_off`,children:`agent not found`});if(!t)return(0,z.jsx)(Y,{children:`loading…`});let O=e=>()=>{o(a===e?``:e),f(``)},k=(e,n,r)=>{let i=t[e]??[];T({[e]:r?[...i.filter(e=>e!==n),n]:i.filter(e=>e!==n)})},ee=(e,n)=>{let r=t.skills??[];T({skills:n?[...r.filter(t=>t!==e),e]:r.filter(t=>t!==e)})},j=s??t.system??``,M=s!==null&&s.trim()!==(t.system??``).trim(),N=t.files??[],I=`m-0 flex min-h-8 min-w-0 items-center gap-1.5 px-2 [overflow-wrap:anywhere]`,te=e=>(0,z.jsx)(`span`,{className:`text-fg-2`,children:e});return(0,z.jsxs)(`div`,{className:`agent-view @container flex animate-rise flex-col gap-4`,children:[(0,z.jsxs)(`header`,{className:`flex items-center gap-3.5`,children:[(0,z.jsx)(lt,{children:(0,z.jsx)(`span`,{"aria-hidden":!0,children:t.emoji})}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(ot,{size:`lg`,children:t.name}),t.archived&&(0,z.jsxs)(J,{children:[(0,z.jsx)(B,{name:`inventory_2`,className:`ms-sm mr-1`}),` archived`]})]}),t.description&&(0,z.jsx)(`p`,{className:`m-0 text-sm text-fg-2 [overflow-wrap:anywhere]`,children:t.description})]})]}),d&&(0,z.jsx)(rt,{tone:`bad`,children:d}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-x-8 gap-y-6 @[880px]:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6`,children:[(0,z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`What the agent is told`}),(M||l&&s!==null)&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:l?`saving…`:`unsaved`}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(`span`,{className:mx,children:[`agents/`,t.slug,`/system.md`]})]}),(0,z.jsx)(xt,{className:_x,"aria-label":`role`,rows:Math.min(24,Math.max(8,j.split(`
486
+ `).length+2)),value:j,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>w(e.target.value),onBlur:()=>void E(),spellCheck:!1})]}),(0,z.jsx)(zx,{title:`Workflows`,kind:`workflows`,editing:a===`workflows`,saving:l,onToggle:O(`workflows`),children:a===`workflows`?(0,z.jsxs)(gx,{children:[(y?.workflows??[]).map(e=>(0,z.jsx)(Tt,{checked:t.workflows.includes(e.slug),onChange:t=>k(`workflows`,e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),(y?.workflows??[]).length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}):t.workflows.length===0?(0,z.jsx)(`span`,{className:mx,children:`none connected — the agent can run any workflow you connect`}):(0,z.jsx)(hx,{children:t.workflows.map(e=>(0,z.jsx)(J,{href:`/workflows/${encodeURIComponent(e)}`,children:e},e))})}),(0,z.jsx)(zx,{title:`Knowledge`,kind:`knowledge`,editing:a===`knowledge`,saving:l,onToggle:O(`knowledge`),children:a===`knowledge`?(0,z.jsxs)(gx,{children:[(b?.bundles??[]).map(e=>(0,z.jsx)(Tt,{checked:t.knowledge.includes(e.name),onChange:t=>k(`knowledge`,e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),(b?.bundles??[]).length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}):t.knowledge.length===0?(0,z.jsx)(`span`,{className:mx,children:`none connected — connected bundles are read and kept current by the agent`}):(0,z.jsx)(hx,{children:t.knowledge.map(e=>(0,z.jsx)(J,{href:`/knowledge/${encodeURIComponent(e)}`,children:e},e))})}),(_.vibeables||(t.vibeables??[]).length>0)&&(0,z.jsx)(zx,{title:`Apps`,kind:`vibeables`,editing:a===`vibeables`,saving:l,onToggle:O(`vibeables`),children:a===`vibeables`?(0,z.jsxs)(gx,{children:[(x?.vibeables??[]).map(e=>(0,z.jsx)(Tt,{checked:(t.vibeables??[]).includes(e.slug),onChange:t=>k(`vibeables`,e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),(t.vibeables??[]).filter(e=>!(x?.vibeables??[]).some(t=>t.slug===e)).map(e=>(0,z.jsx)(Tt,{checked:!0,onChange:t=>k(`vibeables`,e,t),hint:`not found in this workspace`,mono:!0,children:e},e)),!_.vibeables&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),_.vibeables&&(x?.vibeables??[]).length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no apps in this workspace yet — create one on the apps page`})]}):(t.vibeables??[]).length===0?(0,z.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,z.jsx)(hx,{children:(t.vibeables??[]).map(e=>{let t=!_.vibeables||!x||x.vibeables.some(t=>t.slug===e);return(0,z.jsxs)(J,{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)})})}),N.length>0&&(0,z.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-fg`,children:`Folders`}),(0,z.jsx)(hx,{children:N.map(e=>(0,z.jsx)(J,{className:`font-mono`,children:e},e))})]}),(0,z.jsx)(zx,{title:`Shared skills`,kind:`skills`,editing:a===`skills`,saving:l,onToggle:O(`skills`),children:a===`skills`?(0,z.jsxs)(gx,{children:[(0,z.jsx)(Tt,{checked:t.skills===void 0,onChange:e=>void T({skills:e?void 0:(S?.skills??[]).map(e=>e.name)}),hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),t.skills!==void 0&&(S?.skills??[]).map(e=>(0,z.jsx)(Tt,{checked:(t.skills??[]).includes(e.name),onChange:t=>ee(e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),t.skills!==void 0&&(S?.skills??[]).length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}):t.skills===void 0?(0,z.jsx)(`span`,{className:mx,children:`all discovered skills (default) — invoke with /name in a session`}):t.skills.length===0?(0,z.jsx)(`span`,{className:mx,children:`none — this agent runs without skills`}):(0,z.jsx)(hx,{children:t.skills.map(e=>(0,z.jsxs)(J,{children:[`/`,e]},e))})}),(0,z.jsx)(Fx,{slug:e}),(0,z.jsx)(Rx,{slug:e})]}),(0,z.jsxs)(`aside`,{className:`order-first flex min-w-0 flex-col gap-3 @[880px]:order-none`,"aria-label":`details`,children:[(0,z.jsxs)(`dl`,{className:`m-0 grid grid-cols-[76px_minmax(0,1fr)] items-center gap-x-2 gap-y-1 text-sm @min-[520px]:@max-[879px]:grid-cols-[76px_minmax(0,1fr)_76px_minmax(0,1fr)]`,children:[(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Group`}),(0,z.jsx)(`dd`,{className:I,children:t.group||te(`none`)}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Harness`}),(0,z.jsx)(`dd`,{className:I,children:t.harness}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Model`}),(0,z.jsx)(`dd`,{className:I,children:t.model||te(`harness default`)}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`Effort`}),(0,z.jsx)(`dd`,{className:I,children:t.effort||te(`default`)}),(0,z.jsx)(`dt`,{className:`text-fg-2`,children:`State`}),(0,z.jsxs)(`dd`,{className:I,children:[t.archived?`archived`:`active`,t.archived?(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`unarchive`,busy:l,title:`Put this agent back on the roster`,onClick:()=>void D(!1),children:`unarchive`}):(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`archive`,disabled:l,title:`Hide this agent from the roster — restorable any time`,onClick:()=>void D(!0),children:`archive`})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-2`,children:[(0,z.jsx)(K,{size:`sm`,icon:`edit`,href:`/agents/${encodeURIComponent(e)}/edit`,title:`name, emoji, description, group, harness, model and effort`,children:`edit`}),(0,z.jsxs)(`code`,{className:`font-mono text-2xs text-fg-2 [overflow-wrap:anywhere]`,title:`the agent's folder`,children:[`agents/`,t.slug]})]})]})]})]})}var Vx=[`🤖`,`🧑‍💻`,`🎧`,`🛠️`,`📊`,`✍️`,`🔍`,`🧹`,`📦`,`🚀`];function Hx({slug:e}){let[t,n]=(0,v.useState)(e?null:f()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=F(`workflows.list`,{})?.workflows??[],c=F(`knowledge.list`,{})?.bundles??[],l=De(),u=F(`vibeables.list`,l.vibeables?{}:null)?.vibeables??[],d=F(`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?H(`/agents/${encodeURIComponent(r.data.slug)}/info`):i(P(r))}async function m(){e&&window.confirm(`Move agent "${e}" to the trash?`)&&(await A.request(`agents.delete`,{slug:e}).catch(()=>{}),H(`/agents`))}if(!t)return(0,z.jsx)(Y,{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,z.jsxs)(ct,{width:`narrow`,children:[(0,z.jsx)(ot,{children:e?`edit ${e}`:`new agent`}),(0,z.jsx)(X,{children:(0,z.jsxs)(Ct,{className:`max-w-[680px]`,children:[(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`name`,className:`flex-1`,children:(0,z.jsx)(Z,{value:t.name,placeholder:`e.g. Max`,onChange:e=>h({name:e.target.value})})}),(0,z.jsx)(Q,{label:`emoji`,className:`w-[90px] max-[900px]:w-auto`,children:(0,z.jsx)(Z,{value:t.emoji,onChange:e=>h({emoji:e.target.value})})})]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Vx.map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":t.emoji===e,className:I(`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,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`description`,className:`flex-1`,children:(0,z.jsx)(Z,{value:t.description,placeholder:`one line: what this agent is for`,onChange:e=>h({description:e.target.value})})}),(0,z.jsx)(Q,{label:`group`,className:`w-[180px] max-[900px]:w-auto`,children:(0,z.jsx)(Z,{value:t.group,placeholder:`none`,onChange:e=>h({group:e.target.value})})})]}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(Q,{label:`harness`,className:`w-[140px] max-[900px]:w-auto`,children:(0,z.jsxs)(St,{value:t.harness,onChange:e=>h({harness:e.target.value}),children:[(0,z.jsx)(`option`,{value:`claude`,children:`claude`}),(0,z.jsx)(`option`,{value:`codex`,children:`codex`}),(0,z.jsx)(`option`,{value:`pi`,children:`pi`}),(0,z.jsx)(`option`,{value:`antigravity`,children:`antigravity`})]})}),(0,z.jsx)(Q,{label:`model`,className:`flex-1`,children:(0,z.jsx)(Z,{className:`font-mono`,value:t.model,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>h({model:e.target.value})})}),(0,z.jsx)(Q,{label:`effort`,className:`w-[140px] max-[900px]:w-auto`,children:(0,z.jsx)(St,{value:t.effort,onChange:e=>h({effort:e.target.value}),children:Je.map(e=>(0,z.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,z.jsx)(Q,{label:`system prompt — the agent's role`,children:(0,z.jsx)(xt,{className:_x,rows:10,value:t.system,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>h({system:e.target.value})})}),(0,z.jsxs)(Ux,{label:`connected workflows — autoloaded into the agent's context; it can run them`,children:[s.map(e=>(0,z.jsx)(Tt,{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,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),(0,z.jsxs)(Ux,{label:`connected knowledge — OKF bundles the agent consults and maintains`,children:[c.map(e=>(0,z.jsx)(Tt,{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,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),(l.vibeables||t.vibeables.length>0)&&(0,z.jsxs)(Ux,{label:`apps — small apps the agent builds and maintains`,linkKind:`vibeables`,children:[u.map(e=>(0,z.jsx)(Tt,{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,z.jsx)(Tt,{checked:!0,onChange:()=>g(`vibeables`,e,!1),hint:`not found in this workspace`,mono:!0,children:e},e)),!l.vibeables&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),l.vibeables&&u.length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no vibeables in this workspace yet`})]}),(0,z.jsxs)(Ux,{label:`connected skills — workspace skill packages (see the skills tab); invoked with /name in sessions`,children:[(0,z.jsx)(Tt,{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,z.jsx)(Tt,{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,z.jsx)(nt,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),r&&(0,z.jsx)(rt,{tone:`bad`,children:r}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(K,{variant:`primary`,busy:a,disabled:!t.name.trim(),onClick:p,children:a?`saving…`:e?`save`:`create`}),(0,z.jsx)(`span`,{className:`flex-1`}),e&&(0,z.jsx)(K,{variant:`danger`,icon:`delete`,onClick:m,children:`delete agent`})]})]})})]})}function Ux({label:e,linkKind:t,children:n}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-link-kind":t,children:[(0,z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e}),(0,z.jsx)(gx,{children:n})]})}var Wx=`bg-accent/7 outline-[1.5px] -outline-offset-[1.5px] outline-accent outline-dashed`,Gx=`px-2.5 pt-1.5 pb-2 text-2xs text-fg-2`;function Kx({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=F(`agents.list`,{}),[o,s]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`kw-agent-groups`)??`[]`);return Array.isArray(e)?e.map(String):[]}catch{return[]}}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)({}),C=(a?.agents??[]).map(e=>x[e.slug]===void 0?e:{...e,group:x[e.slug]||void 0});(0,v.useEffect)(()=>{S(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 w=C.filter(e=>!e.archived),T=C.filter(e=>e.archived),[E,D]=(0,v.useState)(!1),O=[...new Set([...w.map(e=>e.group??``).filter(Boolean),...o])].sort((e,t)=>e.localeCompare(t)),k=w.filter(e=>!e.group);function ee(e){s(e);try{localStorage.setItem(`kw-agent-groups`,JSON.stringify(e))}catch{}}function j(){let e=u.trim();l(!1),d(``),e&&!O.includes(e)&&ee([...o,e])}function M(e,t){p(null);let n=t.trim();if(n&&n!==e){for(let t of C.filter(t=>t.group===e))N(t.slug,n);o.includes(e)&&ee([...new Set(o.map(t=>t===e?n:t))])}}async function N(e,t){if((C.find(t=>t.slug===e)?.group??``)!==t){S(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{S(t=>{let n={...t};return delete n[e],n})}}}let P=e=>({onDragOver:t=>{g!=null&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,y!==e&&b(e))},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||g;n&&N(n,e),_(null),b(null)}}),te=e=>(0,z.jsx)(`div`,{className:g===e.slug?`opacity-40`:void 0,onDragStart:t=>{t.dataTransfer.setData(`text/plain`,e.slug),t.dataTransfer.effectAllowed=`move`,_(e.slug)},onDragEnd:()=>{_(null),b(null)},children:(0,z.jsx)(gt,{href:`/agents/${encodeURIComponent(e.slug)}`,active:e.slug===t,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness})},e.slug),R=e=>(0,z.jsx)(gt,{href:`/agents/${encodeURIComponent(e.slug)}/info`,active:e.slug===t,dim:e.slug!==t,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness},e.slug),ne;ne=n===`new`?(0,z.jsx)(Hx,{},`new`):n===`edit`&&t?(0,z.jsx)(Hx,{slug:t},t):n===`chat`&&t&&i===`new`?(0,z.jsx)(xx,{slug:t},t):n===`chat`&&t&&i?(0,z.jsx)(`div`,{className:`chat-main`,children:(0,z.jsx)(Ko,{id:i,agentName:C.find(e=>e.slug===t)?.name??t,agentDescription:C.find(e=>e.slug===t)?.description},i)}):n===`chats`?i?(0,z.jsx)(`div`,{className:`chat-main`,children:(0,z.jsx)(Ko,{id:i},i)}):(0,z.jsx)(Sx,{}):n===`info`&&t?(0,z.jsx)(Bx,{slug:t},t):t?(0,z.jsx)(xx,{slug:t},t):a?w.length?(0,z.jsx)(Mx,{agents:w}):(0,z.jsx)(Nx,{}):(0,z.jsx)(Y,{children:`loading…`});let re=(n===`agent`||n===`info`||n===`chat`)&&t?C.find(e=>e.slug===t)?.knowledge??[]:[],[ie,ae]=(0,v.useState)(()=>localStorage.getItem(`kw-kside`)!==`hidden`),[oe,se]=(0,v.useState)(()=>Number(localStorage.getItem(`kw-kside-w`))||460),ce=re.length>0&&ie;function le(e){ae(e),localStorage.setItem(`kw-kside`,e?`open`:`hidden`)}function ue(e){se(e),localStorage.setItem(`kw-kside-w`,String(e))}return(0,z.jsxs)(`div`,{className:`runs-screen agents-screen ${t?`in-agent`:``} ${ce?`has-knowledge`:``}`,style:ce?{"--kside-w":`${oe}px`}:void 0,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`agents`,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,href:`/agents/new`,children:`new`})}),(0,z.jsxs)(jt,{children:[(0,z.jsx)(`div`,{className:`mb-1.5 border-b border-line pb-1.5`,children:(0,z.jsx)(gt,{href:`/agents/chats`,active:n===`chats`,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:`🎩`}),title:`Ralv`,sub:`chief of staff of the workspace`})}),(0,z.jsxs)(`div`,{className:I(`rounded-xl`,g&&y===``&&Wx),...P(``),children:[k.map(te),g!=null&&k.length===0&&(0,z.jsx)(`div`,{className:Gx,children:`no group — drop here`})]}),O.map(e=>{let t=w.filter(t=>t.group===e);return(0,z.jsxs)(`div`,{className:I(`group/grp mt-3 rounded-xl`,g&&y===e&&Wx),...P(e),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pt-1.5 pb-0.5`,children:[f===e?(0,z.jsx)(Z,{className:`h-7 min-w-0 flex-1 text-2xs`,autoFocus:!0,"aria-label":`group name`,value:m,onChange:e=>h(e.target.value),onKeyDown:t=>{t.key===`Enter`&&M(e,m),t.key===`Escape`&&p(null)},onBlur:()=>M(e,m)}):(0,z.jsx)(it,{children:e}),(0,z.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-2`,children:t.length}),(0,z.jsx)(`span`,{className:`flex-1`}),f!==e&&(0,z.jsx)(q,{icon:`edit`,label:`Rename group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>{p(e),h(e)}}),t.length===0&&o.includes(e)&&(0,z.jsx)(q,{icon:`close`,label:`Remove empty group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>ee(o.filter(t=>t!==e))})]}),t.map(te),t.length===0&&(0,z.jsx)(`div`,{className:Gx,children:`drag agents here`})]},e)}),T.length>0&&(0,z.jsxs)(`div`,{className:`mt-2.5 border-t border-line pt-1`,children:[(0,z.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":E,onClick:()=>D(e=>!e),children:[(0,z.jsx)(it,{className:`group-hover/arch:text-fg`,children:`archived`}),(0,z.jsx)(`span`,{className:`text-[10px] tabular-nums`,children:T.length}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(B,{name:E?`expand_less`:`expand_more`,className:`ms-sm`})]}),E&&T.map(R)]}),a&&C.length===0&&(0,z.jsx)(nt,{className:`py-1.5 px-2.5`,children:`no agents yet`}),c?(0,z.jsx)(`div`,{className:`px-2.5 pt-2.5 pb-1`,children:(0,z.jsx)(Z,{className:`h-8 text-sm`,autoFocus:!0,"aria-label":`new group`,value:u,placeholder:`group name, e.g. Team Content`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j(),e.key===`Escape`&&(l(!1),d(``))},onBlur:j})}):(0,z.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:()=>l(!0),children:[(0,z.jsx)(B,{name:`add`,className:`ms-sm`}),` group`]})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:ne}),ce&&(0,z.jsx)(vx,{bundles:re,onHide:()=>le(!1),onResize:ue}),re.length>0&&!ie&&(0,z.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:()=>le(!0),title:`Show knowledge sidebar`,children:[(0,z.jsx)(B,{name:`menu_book`,className:`ms-sm`}),` knowledge`]})]})}function qx(e){if(!me(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,z.jsx)(tx,{},`new-project`):r?(0,z.jsx)(Hx,{},`new-agent`):(0,z.jsx)(dn,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,z.jsx)(cx,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,z.jsx)(Bx,{slug:n},n):r&&t[2]===`edit`?(0,z.jsx)(Hx,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,z.jsx)(dn,{slug:n},n):null}function Jx({back:e,children:t}){let n=()=>H(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,z.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,z.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,z.jsx)(q,{icon:`close`,label:`close (esc)`,className:`absolute top-3 right-3 z-1 rounded-full`,onClick:n}),(0,z.jsx)(`div`,{className:`runs-main min-w-0 pt-[18px] pr-12 pb-10 pl-6`,children:t})]})})}function Yx(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function Xx(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function Zx({slug:e,tab:t}){let n=F(`workflows.list`,{}),r=F(`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:Yx(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&&H(`/workflows/${encodeURIComponent(l)}`,{replace:!0})},[e,l,u]),(0,z.jsxs)(`div`,{className:`runs-screen workflows-screen`,children:[(0,z.jsxs)(`aside`,{className:`runs-side`,children:[(0,z.jsx)(kt,{title:`workflows`,count:n?o.length:void 0,action:(0,z.jsxs)(K,{size:`sm`,variant:`quiet`,icon:`history`,href:`/runs`,title:`every run of every workflow, newest first`,children:[`runs `,(0,z.jsx)(`span`,{className:`tabular-nums`,children:s.length})]})}),o.length>0&&(0,z.jsx)(At,{icon:`search`,value:i,placeholder:`search workflows`,"aria-label":`search workflows`,onChange:e=>a(e.target.value)}),(0,z.jsxs)(jt,{children:[c.map(t=>{let n=Yx(s,t);return(0,z.jsx)(gt,{className:`wf-row`,href:`/workflows/${encodeURIComponent(t.slug)}`,active:t.slug===e,leading:(0,z.jsx)(et,{tone:jg(n.last?.status),title:n.last?.status??`no runs yet`}),title:t.name??t.slug,titleExtra:t.error&&(0,z.jsx)(J,{tone:`bad`,children:`broken`}),meta:n.last&&G(n.last.updatedAt),sub:(0,z.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,z.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:()=>H(Xx(n.last,t)),children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,z.jsx)(Mg,{status:n.last.status})]}):(0,z.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,z.jsxs)(Mt,{className:`wf-nomatch`,children:[`no workflow matches “`,i,`”`]}),n&&o.length===0&&(0,z.jsx)(Mt,{children:`no workflows yet`})]})]}),(0,z.jsx)(`div`,{className:`runs-main`,children:e?(0,z.jsx)(p_,{slug:e,tab:t},e):n&&o.length===0?(0,z.jsxs)(Y,{icon:`account_tree`,children:[`No workflows found — expected `,(0,z.jsx)(`code`,{children:`src/workflows/`}),` or `,(0,z.jsx)(`code`,{children:`workflows/`}),` next to the output folder.`]}):(0,z.jsx)(Y,{children:`loading…`})})]})}var Qx={agents:{label:`agents`,icon:`smart_toy`},"agent-skills":{label:`agent skills`,icon:`extension`},projects:{label:`projects`,icon:`folder`},boards:{label:`boards`,icon:`view_kanban`},tasks:{label:`tasks`,icon:`task`},presentations:{label:`presentations`,icon:`slideshow`},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 $x(){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:P(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(Qx).indexOf(e)-Object.keys(Qx).indexOf(t));return(0,z.jsxs)(ct,{className:`px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{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,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(K,{variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`empty`,`*`),children:[`delete all `,u.length,` for good`]}),(0,z.jsx)(K,{variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,z.jsx)(K,{variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(`*`),children:`empty trash`}))}),n&&(0,z.jsx)(rt,{tone:`bad`,children:n}),!e&&!n&&(0,z.jsx)(X,{children:(0,z.jsx)(Y,{children:`loading…`})}),e&&u.length===0&&(0,z.jsx)(X,{children:(0,z.jsx)(Y,{icon:`delete`,children:`The trash is empty. What you delete lands here first.`})}),d.map(e=>(0,z.jsx)(X,{title:Qx[e]?.label??e,actions:(0,z.jsxs)(`code`,{className:`text-xs text-fg-2`,children:[`trash/`,e,`/`]}),children:(0,z.jsx)(`div`,{className:`p-1.5`,children:u.filter(t=>t.kind===e).map(t=>(0,z.jsx)(gt,{className:`trash-row`,leading:(0,z.jsx)(B,{name:Qx[e]?.icon??`draft`,className:`ms-sm`}),title:t.name,sub:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-mono`,children:t.from}),` · `,(0,z.jsxs)(`span`,{title:t.trashedAt,children:[`deleted `,G(t.trashedAt)]})]}),meta:(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(K,{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,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`purge`,t.id),children:`delete for good`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(t.id),children:`delete`})]})},t.id))})},e)),e&&(0,z.jsxs)(`p`,{className:`m-0 text-sm text-fg-2`,children:[`The trash lives in `,(0,z.jsx)(`code`,{children:e.root}),`, kept out of the workspace git. From the terminal:`,` `,(0,z.jsx)(`code`,{children:`kraftwerk trash`}),`, `,(0,z.jsx)(`code`,{children:`kraftwerk trash restore <id>`}),`, `,(0,z.jsx)(`code`,{children:`kraftwerk trash empty`}),`.`]})]})}function eS(){let[e,t]=(0,v.useState)(`overview`),[n,r]=(0,v.useState)(!0);return(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4 p-6`,children:[(0,z.jsx)(st,{title:`Components`,sub:`src/ui — what every screen is built from`,actions:(0,z.jsx)(K,{variant:`primary`,icon:`add`,children:`primary`})}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,z.jsxs)(X,{title:`Buttons`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 p-4`,children:[(0,z.jsx)(K,{variant:`primary`,icon:`play_arrow`,children:`Run`}),(0,z.jsx)(K,{variant:`secondary`,icon:`upload`,children:`Upload`}),(0,z.jsx)(K,{variant:`quiet`,icon:`create_new_folder`,children:`Folder`}),(0,z.jsx)(K,{variant:`danger`,icon:`delete`,children:`Move to trash`}),(0,z.jsx)(K,{variant:`primary`,busy:!0,children:`Saving`}),(0,z.jsx)(K,{variant:`secondary`,disabled:!0,children:`Disabled`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 pb-4`,children:[(0,z.jsx)(K,{size:`sm`,variant:`primary`,children:`small`}),(0,z.jsx)(K,{size:`sm`,variant:`secondary`,children:`small`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,children:`small`}),(0,z.jsx)(q,{icon:`edit`,label:`Rename`}),(0,z.jsx)(q,{icon:`download`,label:`Download`}),(0,z.jsx)(q,{icon:`delete`,label:`Delete`,variant:`danger`}),(0,z.jsx)(q,{icon:`close`,label:`Close`,size:`sm`})]})]}),(0,z.jsxs)(X,{title:`Status`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,z.jsx)($e,{n:3}),` `,(0,z.jsx)($e,{n:12,tone:`neutral`}),(0,z.jsx)(et,{tone:`ok`}),` `,(0,z.jsx)(et,{tone:`bad`}),` `,(0,z.jsx)(et,{tone:`ask`}),` `,(0,z.jsx)(et,{tone:`live`}),` `,(0,z.jsx)(et,{tone:`working`}),` `,(0,z.jsx)(et,{tone:`idle`}),(0,z.jsx)(J,{children:`static`}),` `,(0,z.jsx)(J,{tone:`ok`,children:`done`}),` `,(0,z.jsx)(J,{tone:`bad`,children:`failed`}),` `,(0,z.jsx)(J,{tone:`ask`,children:`needs approval`}),` `,(0,z.jsx)(J,{tone:`accent`,children:`running`})]}),(0,z.jsx)(rt,{tone:`bad`,children:`Could not upload brief.pdf`}),(0,z.jsx)(rt,{children:`uploading 2 of 3…`})]}),(0,z.jsx)(X,{title:`Rows`,count:1,actions:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`arrow_forward`,children:`all`}),children:(0,z.jsxs)(`div`,{className:`p-1.5`,children:[(0,z.jsx)(gt,{leading:`🐻`,title:`Max`,sub:`waiting for you · Set up the build`,subTone:`bad`,titleExtra:(0,z.jsx)($e,{n:1}),href:`/ui`}),(0,z.jsx)(gt,{leading:`🦊`,title:`Lisa`,sub:`last active 2h ago`,href:`/ui`,active:!0}),(0,z.jsx)(gt,{leading:(0,z.jsx)(`span`,{className:`ms material-symbols-rounded ms-sm`,children:`folder`}),title:`briefing`,meta:`3 files`,onClick:()=>{},actions:(0,z.jsx)(q,{icon:`edit`,label:`Rename`,size:`sm`})}),(0,z.jsx)(gt,{leading:(0,z.jsx)(et,{tone:`working`}),title:`website-check`,sub:`https://netnode.ch`,meta:`running`,size:`sm`}),(0,z.jsx)(gt,{leading:`📁`,title:`Gone project`,sub:`not in this workspace`,dim:!0})]})}),(0,z.jsxs)(X,{title:`Tabs and sections`,children:[(0,z.jsx)(_t,{items:[{id:`overview`,label:`overview`},{id:`files`,label:`files`,count:4},{id:`knowledge`,label:`knowledge`,count:0}],value:e,onChange:t}),(0,z.jsxs)(`div`,{className:`p-2`,children:[(0,z.jsx)(at,{size:`lg`,title:`needs you`,count:2,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,children:`all`}),children:(0,z.jsx)(gt,{leading:`✋`,title:`Run npm install`,sub:`🐻 Max · needs approval · 4m ago`,onClick:()=>{}})}),(0,z.jsx)(at,{title:`team`,children:(0,z.jsx)(gt,{leading:`🦊`,title:`Lisa`,sub:`Research`})})]})]}),(0,z.jsx)(X,{title:`Fields`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,z.jsx)(Q,{label:`Name`,hint:`Shown in the rail.`,children:(0,z.jsx)(Z,{placeholder:`e.g. Max`})}),(0,z.jsx)(Q,{label:`Harness`,children:(0,z.jsxs)(St,{defaultValue:`claude`,children:[(0,z.jsx)(`option`,{children:`claude`}),(0,z.jsx)(`option`,{children:`codex`}),(0,z.jsx)(`option`,{children:`pi`}),(0,z.jsx)(`option`,{children:`antigravity`})]})}),(0,z.jsx)(Q,{label:`Role`,children:(0,z.jsx)(xt,{rows:3,placeholder:`What this agent does`})})]})}),(0,z.jsxs)(X,{title:`Empty and menus`,children:[(0,z.jsx)(Y,{icon:`upload_file`,action:(0,z.jsx)(K,{variant:`secondary`,size:`sm`,icon:`upload`,children:`choose files`}),children:`Drop files here.`}),(0,z.jsx)(`div`,{className:`p-4`,children:(0,z.jsx)(Nt,{trigger:({toggle:e})=>(0,z.jsx)(K,{onClick:e,icon:`expand_more`,children:`menu`}),children:e=>(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,z.jsx)(gt,{leading:`⚙️`,title:`Settings`,onClick:e,size:`sm`}),(0,z.jsx)(gt,{leading:`🗑`,title:`Trash`,onClick:e,size:`sm`})]})})})]}),(0,z.jsx)(X,{title:`Sidebar parts`,children:(0,z.jsxs)(`div`,{className:`w-[300px] border-r border-line`,children:[(0,z.jsx)(kt,{title:`workflows`,count:3,action:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`add`,children:`new`})}),(0,z.jsx)(At,{placeholder:`search workflows`,"aria-label":`search workflows`}),(0,z.jsxs)(jt,{children:[(0,z.jsx)(gt,{leading:(0,z.jsx)(et,{tone:`ok`}),title:`triage`,sub:`checks, drafts, publishes`,size:`sm`,active:!0}),(0,z.jsx)(Mt,{children:`no workflow matches “x”`})]})]})}),(0,z.jsx)(X,{title:`Choices`,children:(0,z.jsxs)(Ct,{children:[(0,z.jsx)(Tt,{checked:n,onChange:r,hint:`every discovered skill`,children:`all skills`}),(0,z.jsx)(Tt,{checked:!n,onChange:e=>r(!e),hint:`0 concepts`,mono:!0,children:`brand-guide`}),(0,z.jsxs)(wt,{children:[(0,z.jsx)(Dt,{checked:n,onChange:r,label:`routine enabled`}),(0,z.jsxs)(nt,{children:[`Hint: a small explaining line. Keys look like `,(0,z.jsx)(tt,{children:`⌘K`}),`.`]})]}),(0,z.jsx)(Ot,{label:`Docker sandbox`,hint:`Docker is not running`,checked:n,onChange:r})]})}),(0,z.jsxs)(X,{title:`Page parts`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(lt,{children:`🐻`}),(0,z.jsx)(ot,{size:`lg`,children:`Max`}),(0,z.jsx)(J,{href:`#/ui`,children:`linked tag`})]}),(0,z.jsx)(_t,{bare:!0,label:`link tabs`,value:`pages`,items:[{id:`pages`,label:`pages`,href:`/ui`},{id:`activity`,label:`activity`,href:`/ui`}]})]}),(0,z.jsxs)(ft,{children:[(0,z.jsx)(dt,{icon:`account_tree`,title:`workflows`,action:(0,z.jsx)(K,{size:`sm`,children:`edit`}),children:(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none connected`})}),(0,z.jsx)(dt,{icon:`menu_book`,title:`knowledge`})]}),(0,z.jsxs)(mt,{children:[(0,z.jsx)(ht,{label:`source`,children:`workspace`}),(0,z.jsx)(ht,{label:`path`,mono:!0,children:`skills/release-notes/SKILL.md`})]})]})]})]})}var tS={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`}},nS={running:`text-ok`,stopped:`text-fg-2`,died:`text-ask`,missing:`text-bad`,orphaned:`text-bad`},rS={running:``,stopped:`opacity-65 grayscale-50`,died:`opacity-80`,missing:`opacity-45 grayscale-80`,orphaned:`opacity-45 grayscale-80`};function iS(){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(P(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,z.jsxs)(ct,{children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`hub`,className:`text-[28px] text-fg-2`}),title:`Workspaces`,actions:(0,z.jsxs)(z.Fragment,{children:[e&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[e.length,` known · `,p,` running`]}),e&&n&&(0,z.jsx)(rt,{tone:`bad`,children:n})]})}),(0,z.jsxs)(X,{title:`workspaces on this machine`,actions:(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`registry: `,(0,z.jsx)(`code`,{className:`text-2xs`,children:`~/.kraftwerk/workspaces`})]}),children:[!e&&!n&&(0,z.jsx)(Y,{className:`py-6`,children:`loading…`}),!e&&n&&(0,z.jsx)(`div`,{className:`px-[18px] py-4`,children:(0,z.jsx)(rt,{tone:`bad`,children:n})}),e&&e.length===0&&(0,z.jsx)(Y,{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=I(`text-md font-semibold text-fg`,e.named===!1&&`italic text-fg-2`);return(0,z.jsxs)(`div`,{className:I(`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,z.jsx)(Ve,{className:I(`size-10`,rS[e.state]),icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:h(e.icon)}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[e.live&&!e.current?(0,z.jsx)(`a`,{href:he(e),className:I(a,`no-underline hover:underline`),children:e.name}):(0,z.jsx)(`span`,{className:a,children:e.name}),e.current&&(0,z.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.4px] text-fg-2 uppercase`,children:`current`}),(0,z.jsxs)(`span`,{className:I(`inline-flex items-center gap-1.5 text-2xs font-semibold tracking-[0.4px] uppercase`,nS[e.state]),children:[e.live&&(0,z.jsx)(`span`,{className:`inline-block size-2 rounded-full bg-ok`}),tS[e.state].label]}),tS[e.state].note&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:tS[e.state].note})]}),(0,z.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.root,children:e.rootLabel??(0,z.jsx)(`span`,{className:`font-sans opacity-70`,children:`no root recorded (started by an older version)`})}),(0,z.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,z.jsx)(`span`,{children:e.url.replace(/^https?:\/\//,``)}),e.counts&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`span`,{children:[e.counts.agents,` agents`]}),(0,z.jsxs)(`span`,{children:[e.counts.workflows,` workflows`]}),(0,z.jsxs)(`span`,{children:[e.counts.runs,` runs`]}),(0,z.jsxs)(`span`,{children:[e.counts.chats,` chats`]})]}),e.lastStarted&&(0,z.jsxs)(`span`,{title:e.lastStarted,children:[`started `,G(e.lastStarted)]}),!e.live&&e.lastStopped&&(0,z.jsxs)(`span`,{title:e.lastStopped,children:[`stopped `,G(e.lastStopped)]}),e.startCount!=null&&(0,z.jsxs)(`span`,{children:[e.startCount,`× launched`]}),e.firstSeen&&(0,z.jsxs)(`span`,{title:e.firstSeen,children:[`first seen `,G(e.firstSeen)]})]}),o[t]&&(0,z.jsx)(rt,{tone:`bad`,children:o[t]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[e.live&&!e.current&&(0,z.jsxs)(`a`,{className:Qe(`secondary`,`sm`),href:he(e),title:`Open this workspace`,children:[(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),` open`]}),!e.live&&e.root&&e.exists!==!1&&!e.dirGone&&(0,z.jsx)(K,{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,z.jsx)(K,{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,z.jsx)(K,{size:`sm`,icon:`delete`,disabled:!!n,title:`Drop this project from the registry (files untouched)`,onClick:()=>l(t),children:`remove`}),r&&c===t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(K,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void f(e,`forget`),children:`confirm remove`}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},t)})]}),(0,z.jsxs)(`p`,{className:`m-0 text-xs text-fg-2 [&_code]:text-2xs`,children:[`Start launches `,(0,z.jsx)(`code`,{children:`kraftwerk ui`}),` detached in the project root (log in `,(0,z.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,z.jsx)(`code`,{children:`kraftwerk.yml`}),` — the same from the terminal:`,` `,(0,z.jsx)(`code`,{children:`kraftwerk workspaces`}),`.`]})]})}var aS=40,oS=/Mac|iPhone|iPad/.test(navigator.platform),sS=null,cS=e=>(e?.workspaces??[]).flatMap(e=>[...e.agents.map(t=>({kind:`agent`,agent:t,ws:e,key:`${e.url}|agent|${t.slug}`})),...(e.projects??[]).map(t=>({kind:`project`,project:t,ws:e,key:`${e.url}|project|${t.slug}`})),...(e.channels??[]).map(t=>({kind:`channel`,channel:t,ws:e,key:`${e.url}|channel|${t.slug}`})),...(e.entities??[]).map(t=>({kind:`entity`,entity:t,ws:e,key:`${e.url}|${t.kind}|${t.slug}`})),...(e.current?e.tasks??[]:[]).map(t=>({kind:`task`,task:t,ws:e,key:`${e.url}|task|${t.project??``}|${t.board}|${t.slug}`})),...(e.current?e.decks??[]:[]).map(t=>({kind:`deck`,deck:t,ws:e,key:`${e.url}|deck|${t.project??``}|${t.name}`}))]),lS=e=>e.kind===`thing`?e.thing.name:e.kind===`agent`?e.agent.name:e.kind===`project`?e.project.title:e.kind===`entity`?e.entity.title:e.kind===`task`?e.task.title:e.kind===`deck`?e.deck.title:e.channel.name,uS=e=>e.kind===`thing`?e.thing.sub:e.kind===`agent`?e.agent.description:e.kind===`project`?e.project.goal||(e.project.status===`active`?void 0:e.project.status):e.kind===`entity`?e.entity.detail:e.kind===`task`?`${e.task.project?`${e.task.project} · `:``}${e.task.board} · ${e.task.status}`:e.kind===`deck`?`${e.deck.project?`${e.deck.project} · `:``}${e.deck.slides} ${e.deck.slides===1?`slide`:`slides`}`:e.channel.purpose,dS=e=>e.kind===`thing`?e.thing.href:e.kind===`agent`?`/agents/${encodeURIComponent(e.agent.slug)}`:e.kind===`project`?`/projects/${encodeURIComponent(e.project.slug)}`:e.kind===`entity`?`/${e.entity.kind}/${encodeURIComponent(e.entity.slug)}`:e.kind===`task`?e.task.href:e.kind===`deck`?e.deck.href:`/channels/${encodeURIComponent(e.channel.slug)}`,fS={contacts:`contact`,places:`place`,events:`event`},pS={contacts:`person`,places:`location_on`,events:`event`},mS={active:`📁`,paused:`⏸️`,done:`✅`,archived:`🗄️`},hS=e=>e.kind===`agent`?e.agent.emoji:e.kind===`thing`?(0,z.jsx)(B,{name:e.thing.icon,className:`text-[18px] text-fg-2`}):e.kind===`project`?mS[e.project.status]:e.kind===`entity`?(0,z.jsx)(B,{name:pS[e.entity.kind],className:`text-[18px] text-fg-2`}):e.kind===`task`?(0,z.jsx)(B,{name:`task`,className:`text-[18px] text-fg-2`}):e.kind===`deck`?(0,z.jsx)(B,{name:`slideshow`,className:`text-[18px] text-fg-2`}):(0,z.jsx)(B,{name:`forum`,className:`text-[18px] text-fg-2`}),gS=`flex-none rounded-full border border-line px-1.5 py-px text-[10px] font-semibold tracking-[0.4px] uppercase`;function _S(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;let r=[],i=new Map;for(let t of e){i.has(t.ws)||i.set(t.ws,i.size);let e=lS(t).toLowerCase(),a=[e,...t.kind===`thing`?[t.thing.id,t.thing.sub??``,t.thing.type,t.thing.words??``]:t.kind===`agent`?[t.agent.slug,t.agent.description??``,t.agent.group??``,`agent`]:t.kind===`project`?[t.project.slug,t.project.goal??``,t.project.status,`project`]:t.kind===`entity`?[t.entity.slug,t.entity.detail??``,fS[t.entity.kind],`${fS[t.entity.kind]}:${t.entity.slug}`]:t.kind===`task`?[t.task.slug,`task:${t.task.slug}`,t.task.board,t.task.project??``,t.task.status,`task`]:t.kind===`deck`?[t.deck.name,`presentation:${t.deck.name}`,t.deck.project??``,`presentation`,`deck`]:[t.channel.slug,t.channel.purpose??``,`channel`],t.ws.name].join(` `).toLowerCase();if(!n.every(e=>a.includes(e)))continue;let o=e.startsWith(n[0])?0:e.includes(n[0])?1:2;r.push({hit:t,score:o,ws:i.get(t.ws)})}return r.sort((e,t)=>e.ws-t.ws||e.score-t.score).map(e=>e.hit)}function vS(e){let t=[];for(let n of e){let e=t.find(e=>e.ws===n.ws);e?e.hits.push(n):t.push({ws:n.ws,hits:[n]})}return t}async function yS(e){let t=dS(e);if(e.ws.current)return H(t);let n=e.ws.live||!e.ws.root?he(e.ws):await ge(e.ws.root);window.location.assign(`${n.replace(/\/+$/,``)}/#${t}`)}var bS={type:`command`,id:`New chat`,name:`New chat`,href:`/agents/chats`,icon:`chat`,words:`start session message ask`,keys:`⌥C`,act:{kind:`chat`,label:`chat`}},xS={type:`command`,id:`New task`,name:`New task`,href:`/boards`,icon:`task_alt`,words:`add todo create`,keys:`⌥T`,act:{kind:`task`,label:`add`}};function SS(){let[e,t]=(0,v.useState)(!1),n=De();return(0,v.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`){e.preventDefault(),t(e=>!e);return}if(!e.altKey||e.metaKey||e.ctrlKey||e.shiftKey||e.code!==`KeyC`&&e.code!==`KeyT`)return;let r=e.target;r&&(r.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(r.tagName))||(e.code!==`KeyT`||n.boards)&&(e.preventDefault(),t(e.code===`KeyC`?bS:xS))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n.boards]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex flex-none cursor-pointer items-center gap-1.5 rounded-xl border-0 bg-transparent py-1 pr-2 pl-1.5 text-fg-2 transition-colors hover:bg-surface-2 hover:text-fg active:scale-96`,onClick:()=>t(!0),title:`jump to anything, or do something (⌥C new chat, ⌥T new task)`,"aria-label":`search`,children:[(0,z.jsx)(B,{name:`search`}),(0,z.jsx)(tt,{className:`max-[1100px]:hidden`,children:oS?`⌘K`:`Ctrl K`})]}),e&&(0,z.jsx)(CS,{start:e===!0?void 0:e,onClose:()=>t(!1)})]})}function CS({onClose:e,start:t}){let[n,r]=(0,v.useState)(sS),[i,a]=(0,v.useState)(sS===null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(0),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(``),g=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=!0;return A.call(`search.agents`).then(t=>{sS=t,e&&r(t)}).catch(()=>e&&s(!0)).finally(()=>e&&a(!1)),()=>{e=!1}},[]);let _=TS(),[y,b]=(0,v.useState)(t??null),x=(0,v.useMemo)(()=>{let e=cS(n),t=n?.workspaces.find(e=>e.current);if(!t)return e;let r=_.map(e=>({kind:`thing`,thing:e,ws:t,key:`${t.url}|${e.type}|${e.id}`})),i=e.findIndex(e=>e.ws===t),a=e.reduce((e,n,r)=>n.ws===t?r+1:e,0),o=r.filter(e=>e.kind===`thing`&&e.thing.type===`command`),s=r.filter(e=>!o.includes(e));return i<0?[...r,...e]:[...e.slice(0,i),...o,...e.slice(i,a),...s,...e.slice(a)]},[n,_]),S=(0,v.useMemo)(()=>_S(x,c).slice(0,aS),[x,c]),C=(0,v.useMemo)(()=>vS(S),[S]),w=Math.min(u,Math.max(S.length-1,0));(0,v.useEffect)(()=>{g.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[w,S]);let T=e=>e?.kind===`thing`?e.thing.act:void 0,E=t=>{if(!f){if(t.kind===`thing`&&t.thing.type===`command`&&t.thing.act)return b(t.thing);t.ws.current||t.ws.live?(e(),yS(t)):(p(t.key),h(``),yS(t).catch(e=>{p(null),h(`${t.ws.name}: ${e.message}`)}))}},D=t=>{if(y)t.key===`Escape`&&(t.preventDefault(),b(null));else if(t.key===`Tab`&&!t.shiftKey&&T(S[w]))t.preventDefault(),b(S[w].thing);else if(t.key===`ArrowDown`)t.preventDefault(),d(S.length?(w+1)%S.length:0);else if(t.key===`ArrowUp`)t.preventDefault(),d(S.length?(w-1+S.length)%S.length:0);else if(t.key===`Enter`){t.preventDefault();let e=S[w];e&&E(e)}else t.key===`Escape`&&(t.preventDefault(),e())},O=`px-4 py-7 text-center text-sm text-fg-2 [&_a]:underline`,k;if(S.length>0){let e=-1;k=(0,z.jsx)(`ul`,{className:`m-0 list-none overflow-y-auto overscroll-contain p-1.5`,role:`listbox`,"aria-label":`agents, projects and channels`,ref:g,children:C.map(t=>(0,z.jsxs)(v.Fragment,{children:[(0,z.jsxs)(`li`,{className:`palette-group flex items-center gap-1.5 px-2.5 pt-3 pb-1 text-2xs font-semibold tracking-[0.4px] text-fg-2 uppercase first:pt-1.5`,role:`presentation`,title:t.ws.current?`this workspace`:t.ws.url,children:[t.ws.icon&&(0,z.jsx)(`span`,{"aria-hidden":!0,children:t.ws.icon}),(0,z.jsx)(`span`,{className:`truncate`,children:t.ws.name}),t.ws.current?(0,z.jsx)(`span`,{className:`font-normal tracking-normal normal-case`,children:`this workspace`}):t.ws.live?(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}):(0,z.jsx)(`span`,{className:gS,children:`stopped`})]}),t.hits.map(t=>{let n=++e;return(0,z.jsxs)(`li`,{role:`option`,"aria-selected":n===w,className:I(`flex cursor-pointer items-center gap-2.5 rounded-xl px-2.5 py-2`,n===w&&`bg-surface-2`),onMouseMove:()=>n!==w&&d(n),onClick:()=>E(t),children:[(0,z.jsx)(`span`,{className:`w-6 flex-none text-center text-[18px] leading-none`,"aria-hidden":!0,children:hS(t)}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(`span`,{className:`truncate text-[13.5px] font-medium text-fg`,children:lS(t)}),uS(t)&&(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:uS(t)})]}),t.kind===`thing`&&t.thing.act&&t.thing.type!==`command`&&(0,z.jsx)(`button`,{type:`button`,className:`palette-act inline-flex flex-none cursor-pointer items-center gap-1 rounded-full border border-line bg-surface px-2 py-0.5 text-xs font-medium text-fg hover:bg-accent-soft hover:text-on-accent-soft`,title:`${t.thing.act.label} here (Tab)`,onClick:e=>{e.stopPropagation(),b(t.thing)},children:t.thing.act.label}),f===t.key?(0,z.jsx)(B,{name:`progress_activity`,className:`ms-sm`}):t.kind===`thing`&&t.thing.keys?(0,z.jsx)(tt,{children:t.thing.keys}):t.kind===`thing`?(0,z.jsx)(`span`,{className:I(gS,`text-fg-2`),children:t.thing.type}):t.kind!==`agent`&&(0,z.jsx)(`span`,{className:I(gS,`text-fg-2`),children:t.kind===`entity`?fS[t.entity.kind]:t.kind===`deck`?`presentation`:t.kind})]},t.key)})]},t.ws.url||t.ws.name))})}else k=o?(0,z.jsx)(`div`,{className:O,children:`could not load the agents, projects and channels`}):i?(0,z.jsx)(`div`,{className:O,children:`looking for agents, projects and channels…`}):x.length===0?(0,z.jsxs)(`div`,{className:O,children:[`no agents yet — `,(0,z.jsx)(`a`,{href:`#/agents/new`,onClick:e,children:`create one`})]}):(0,z.jsxs)(`div`,{className:O,children:[`no agent, project or channel matches “`,c,`”`]});return(0,z.jsx)(`div`,{className:`palette-backdrop fixed inset-0 z-50 flex animate-fade items-start justify-center bg-black/35 px-4 pt-[12vh] pb-4`,onMouseDown:e,children:(0,z.jsxs)(`div`,{className:`flex max-h-[min(70dvh,560px)] w-[min(620px,100%)] animate-modal flex-col overflow-hidden rounded-2xl border border-line bg-surface shadow-modal`,role:`dialog`,"aria-label":`jump to an agent, project or channel`,onMouseDown:e=>e.stopPropagation(),onKeyDown:D,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4 py-3 text-fg-2`,children:[(0,z.jsx)(B,{name:`search`}),(0,z.jsx)(`input`,{autoFocus:!0,className:`min-w-0 flex-1 border-0 bg-transparent p-0 font-sans text-[16px] text-fg outline-none`,value:c,onChange:e=>{l(e.target.value),d(0)},placeholder:`jump to anything, or do something: new chat, new task, a skill, a workflow…`,disabled:!!y,"aria-label":`search`,autoComplete:`off`,spellCheck:!1}),i&&n&&(0,z.jsx)(B,{name:`progress_activity`,className:`ms-sm`}),(0,z.jsx)(tt,{children:`esc`})]}),y?(0,z.jsx)(Jt.Provider,{value:()=>(e(),!1),children:(0,z.jsxs)(`div`,{className:`palette-action flex flex-col gap-2 overflow-y-auto p-3`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex cursor-pointer items-center gap-1 self-start border-0 bg-transparent p-0 text-xs text-fg-2 hover:text-fg`,onClick:()=>b(null),children:[(0,z.jsx)(B,{name:`arrow_back`,className:`ms-sm`}),` back to the list`]}),y.act?.kind===`skill`&&(0,z.jsx)(Ry,{name:y.id}),y.act?.kind===`workflow`&&(0,z.jsx)(Eg,{slug:y.id,usesRequest:y.act.usesRequest!==!1}),y.act?.kind===`chat`&&(0,z.jsx)(Wy,{}),y.act?.kind===`task`&&(0,z.jsx)(qy,{})]})}):k,(0,z.jsxs)(`div`,{className:`flex items-center gap-3.5 border-t border-line px-3.5 py-2 text-2xs text-fg-2 [&>span]:inline-flex [&>span]:items-center [&>span]:gap-1`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(tt,{children:`↑`}),(0,z.jsx)(tt,{children:`↓`}),` move`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(tt,{children:`↵`}),` `,y?`send`:`open`]}),!y&&T(S[w])&&S[w].kind===`thing`&&S[w].thing.type!==`command`&&(0,z.jsxs)(`span`,{children:[(0,z.jsx)(tt,{children:`⇥`}),` `,T(S[w]).label,` here`]}),y&&(0,z.jsxs)(`span`,{children:[(0,z.jsx)(tt,{children:`esc`}),` back`]}),f&&(0,z.jsxs)(`span`,{className:`ml-auto`,children:[(0,z.jsx)(B,{name:`progress_activity`,className:`ms-sm`}),` starting the workspace…`]}),m&&(0,z.jsxs)(`span`,{className:`ml-auto max-w-[60%] truncate text-bad`,title:m,children:[(0,z.jsx)(B,{name:`warning`,className:`ms-sm`}),` `,m]})]})]})})}var wS=encodeURIComponent;function TS(){let e=De(),t=F(`skills.list`,{}),n=F(`workflows.list`,{}),r=F(`routines.list`,{}),i=F(`knowledge.list`,{}),a=F(`vibeables.list`,e.vibeables?{}:null),o=F(`chats.list`,{});return(0,v.useMemo)(()=>{let s=(e,t,n,r=``)=>({type:`page`,id:t,name:e,href:t,icon:n,words:`settings overview ${r}`}),c=(e,t,n,r,i)=>({type:`command`,id:e,name:e,href:t,icon:n,words:r,act:i});return[bS,...e.boards?[xS]:[],c(`New routine`,`/?kind=routines&open=${wS(`routines:_:new`)}`,`schedule`,`create schedule cron`),c(`New agent`,`/agents/new`,`smart_toy`,`create coworker`),...e.projects?[c(`New project`,`/projects/new`,`folder`,`create`)]:[],...e.boards?[c(`New board`,`/boards/new`,`view_kanban`,`create kanban`)]:[],c(`New knowledge bundle`,`/knowledge/new`,`menu_book`,`create wiki`),...(t?.skills??[]).filter(e=>e.source===`workspace`||e.source===`project`).map(e=>({type:`skill`,id:e.name,name:`/${e.name}`,sub:e.description||void 0,icon:`extension`,href:`/skills/${wS(e.name)}`,act:{kind:`skill`,label:`use`}})),...(n?.workflows??[]).map(e=>({type:`workflow`,id:e.slug,name:e.name||e.slug,sub:e.description||void 0,icon:`account_tree`,href:`/workflows/${wS(e.slug)}`,words:e.slug,act:e.error?void 0:{kind:`workflow`,label:`run`,usesRequest:e.usesRequest}})),...(r?.routines??[]).map(e=>({type:`routine`,id:`${e.owner}:${e.id}`,name:e.name,sub:e.schedule,icon:`schedule`,href:`/?kind=routines&open=${wS(`routines:${e.owner}:${e.id}`)}`})),...(i?.bundles??[]).map(e=>({type:`knowledge`,id:e.name,name:e.name,sub:`${e.concepts} pages`,icon:`menu_book`,href:`/knowledge/${wS(e.name)}`})),...(a?.vibeables??[]).map(e=>({type:`app`,id:e.slug,name:e.slug,icon:`web`,href:`/vibeables/${wS(e.slug)}`})),...(o?.chats??[]).filter(e=>e.title).slice(0,60).map(e=>({type:`chat`,id:e.id,name:e.title,icon:`chat`,href:$y(e)})),s(`Home`,`/`,`home`,`everything stream`),s(`Today`,`/today`,`today`,`dashboard attention`),s(`Settings`,`/settings`,`settings`,`base`),s(`All agents`,`/settings/agents`,`smart_toy`,`admin`),s(`All routines`,`/settings/routines`,`schedule`,`admin`),s(`All workflows`,`/workflows`,`account_tree`),s(`All skills`,`/skills`,`extension`),s(`All knowledge`,`/knowledge`,`menu_book`),s(`Files`,`/files`,`folder_open`),...e.boards?[s(`All boards`,`/boards`,`view_kanban`)]:[],...e.presentations?[s(`All presentations`,`/presentations`,`slideshow`,`slides decks`)]:[],...e.vibeables?[s(`All apps`,`/vibeables`,`web`,`vibeables`)]:[],...e.repos?[s(`Repositories`,`/repos`,`source`,`repos`)]:[],...e.git?[s(`Git`,`/git`,`commit`,`sync changes commit`)]:[],s(`Trash`,`/trash`,`delete`,`deleted restore`),s(`Workspaces`,`/workspaces`,`workspaces`)]},[e,t,n,r,i,a,o])}var ES=1296e5;function DS(e){if(e<6e4)return`just now`;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function OS(e,t){let n=new Date(e),r=n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),i=Math.round((new Date(n).setHours(0,0,0,0)-new Date(t).setHours(0,0,0,0))/864e5);return i<=0?r:i===1?`tomorrow ${r}`:`${n.toLocaleDateString([],{weekday:`short`})} ${r}`}function kS(e,t=``,n=new Date){if(!e)return t?{text:t,tone:`plain`}:null;let r=e=>`${e[0].title||`a session`}${e.length>1?` +${e.length-1}`:``}`;if(e.waiting.length)return{text:`waiting for you · ${r(e.waiting)}`,tone:`waiting`};if(e.working.length){let t=e.working[0].since,i=t?DS(Math.max(0,n.getTime()-Date.parse(t))):``;return{text:`working · ${r(e.working)}${i&&i!==`just now`?` · ${i}`:``}`,tone:`working`}}if(e.nextRoutine&&Date.parse(e.nextRoutine.at)-n.getTime()<ES)return{text:`next: ${e.nextRoutine.name} · ${OS(e.nextRoutine.at,n)}`,tone:`plain`};if(e.lastActiveAt){let t=DS(Math.max(0,n.getTime()-Date.parse(e.lastActiveAt)));return{text:t===`just now`?`last active just now`:`last active ${t} ago`,tone:`plain`}}return{text:t||`no sessions yet`,tone:`plain`}}var AS=e=>`section`in e;function jS(e){return[...e.top.map(e=>({slug:e})),...e.sections.flatMap(e=>[{section:e.name},...e.projects.map(e=>({slug:e}))])]}function MS(e){let t={top:[],sections:[]};for(let n of e)AS(n)?t.sections.push({name:n.section,projects:[]}):(t.sections.at(-1)?.projects??t.top).push(n.slug);return t}var NS=(e,t)=>AS(e)?`section`in t&&e.section===t.section:`slug`in t&&e.slug===t.slug;function PS(e,t,n){let r=e.findIndex(e=>NS(e,t));if(r<0)return e;let i=r+1;if(`section`in t)for(;i<e.length&&!AS(e[i]);)i++;if(n>=r&&n<=i)return e;let a=e.slice(r,i),o=[...e.slice(0,r),...e.slice(i)],s=n>r?n-a.length:n;return[...o.slice(0,s),...a,...o.slice(s)]}function FS({layout:e,visible:t,render:n,onSave:r,collapsed:i,onCollapse:a,editing:o,onEdited:s}){let[c,l]=(0,v.useState)(null),u=c??jS(e);(0,v.useEffect)(()=>l(null),[JSON.stringify(e)]);let[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(o);(0,v.useEffect)(()=>g(o),[o]);let _=async e=>{l(e),await r(MS(e))||l(null)},y=()=>{f(null),m(null)},b=(e,t)=>{let n=e.currentTarget.getBoundingClientRect(),r=e.clientY>n.top+n.height/2,i=u[t];if(d&&`slug`in d&&AS(i))return t+1;if(d&&`section`in d){let e=t;for(;e>=0&&!AS(u[e]);)e--;if(e<0)return u.findIndex(AS)<0?u.length:u.findIndex(AS);if(!r&&e===t)return e;let n=e+1;for(;n<u.length&&!AS(u[n]);)n++;return n}return r?t+1:t},x=e=>({onDragOver:t=>{if(!d)return;t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`;let n=e===void 0?u.length:b(t,e);n!==p&&m(n)},onDrop:t=>{if(!d)return;t.preventDefault(),t.stopPropagation();let n=PS(u,d,e===void 0?u.length:b(t,e));y(),n!==u&&_(n)}}),S=e=>({draggable:!0,onDragStart:t=>{t.stopPropagation(),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,`slug`in e?e.slug:e.section),f(e)},onDragEnd:y}),C=e=>t=>{if(!t.altKey||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=u.findIndex(t=>!AS(t)&&t.slug===e),r=t.key===`ArrowUp`?n-1:n+2;r<0||r>u.length||_(PS(u,{slug:e},r))},w=e=>d&&p===e?(0,z.jsx)(`div`,{className:`relative h-0`,"aria-hidden":!0,children:(0,z.jsx)(`div`,{className:`absolute inset-x-2 -top-px h-0.5 rounded-full bg-accent`})}):null,T=[],E;return u.forEach((e,r)=>{if(T.push((0,z.jsx)(v.Fragment,{children:w(r)},`line:${r}`)),AS(e)){E=e.section;let t=e.section,n=i(t),o=0;for(let e=r+1;e<u.length&&!AS(u[e]);e++)o++;T.push((0,z.jsx)(`div`,{...x(r),...h===t?{}:S({section:t}),className:I(`group/sec mt-2 flex items-center gap-0.5 rounded-control pl-1 pr-1`,d&&`section`in d&&d.section===t&&`opacity-40`),"data-section":t,children:h===t?(0,z.jsx)(IS,{name:t,taken:u.filter(AS).map(e=>e.section).filter(e=>e!==t),onDone:e=>{g(void 0),s(),e&&e!==t&&_(u.map(n=>AS(n)&&n.section===t?{section:e}:n))}}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1 border-0 bg-transparent px-1 py-1 text-left font-[inherit] text-xs font-semibold text-fg-2 hover:text-fg`,"aria-expanded":!n,title:n?`show the projects in ${t}`:`fold ${t}`,onClick:()=>a(t),children:[(0,z.jsx)(B,{name:`chevron_right`,className:I(`ms-sm flex-none text-[15px] transition-transform`,!n&&`rotate-90`)}),(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,z.jsx)(`span`,{className:`font-normal tabular-nums opacity-70`,children:o})]}),(0,z.jsxs)(`span`,{className:`flex items-center opacity-0 transition-opacity group-hover/sec:opacity-100 group-focus-within/sec:opacity-100 pointer-coarse:opacity-100`,children:[(0,z.jsx)(q,{size:`sm`,icon:`edit`,label:`rename section ${t}`,onClick:()=>g(t)}),(0,z.jsx)(q,{size:`sm`,icon:`close`,label:`remove section ${t}`,title:`remove the section; its projects move up`,onClick:()=>void _(u.filter(e=>!(AS(e)&&e.section===t)))})]})]})},`section:${t}`))}else E&&i(E)&&!t(e.slug)||T.push((0,z.jsx)(`div`,{...x(r),...S({slug:e.slug}),onKeyDown:C(e.slug),className:I(`flex flex-col gap-0.5`,d&&`slug`in d&&d.slug===e.slug&&`opacity-40`),"data-sort":e.slug,children:n(e.slug)},e.slug))}),T.push((0,z.jsx)(v.Fragment,{children:w(u.length)},`line:end`)),d&&T.push((0,z.jsx)(`div`,{className:`h-4`,...x()},`drop:end`)),(0,z.jsx)(z.Fragment,{children:T})}function IS({name:e,taken:t,onDone:n}){let[r,i]=(0,v.useState)(e),a=(0,v.useRef)(null);(0,v.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]);let o=r.trim().slice(0,60),s=!!o&&!t.includes(o);return(0,z.jsx)(`input`,{ref:a,value:r,"aria-label":`section name`,maxLength:60,className:I(`min-w-0 flex-1 rounded-control border bg-surface px-2 py-1 font-[inherit] text-xs font-semibold text-fg outline-none`,s?`border-line focus:border-accent`:`border-bad`),onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n(s?o:void 0),e.key===`Escape`&&n()},onBlur:()=>n(s?o:void 0)})}function LS(e){let t=new Set(e.sections.map(e=>e.name)),n=`New section`;for(let e=2;t.has(n);e++)n=`New section ${e}`;return n}function RS({chatPath:e}){let t=De(),n=F(`agents.list`,{},{interval:15e3}),r=F(`projects.list`,t.projects?{}:null,{interval:15e3}),i=F(`agents.status`,{},{interval:5e3}),a=e.split(`/`).filter(Boolean),o=(e,t)=>a[0]===e&&(t===void 0||(a[1]?decodeURIComponent(a[1]):void 0)===t),s=a[0]===`agents`&&a[1]===`chats`,[c,l]=HS(),u=rs()??[],d=new Map((n?.agents??[]).filter(e=>!e.archived).map(e=>[e.slug,e])),f=(r?.projects??[]).filter(e=>e.status!==`archived`||o(`projects`,e.slug)),p=e=>(e.agents??[]).map(e=>d.get(e)).filter(e=>!!e),m=e=>o(`projects`,e.slug),h=new Map(f.map(e=>[e.slug,e])),g=r?.layout?[...r.layout.top,...r.layout.sections.flatMap(e=>e.projects)].map(e=>h.get(e)).filter(e=>!!e):f,_=async e=>!!(await A.request(`projects.saveLayout`,{body:e}).catch(()=>null))?.ok,[y,b]=(0,v.useState)(),x=async()=>{if(!r?.layout)return;let e=LS(r.layout);await _({...r.layout,sections:[...r.layout.sections,{name:e,projects:[]}]})&&b(e)},S=e=>{let t=p(e).map(e=>i?.[e.slug]).filter(e=>!!e).some(e=>e.working.length&&!e.waiting.length);return(0,z.jsx)(gt,{size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}`,active:o(`projects`,e.slug),innerProps:{"data-project":e.slug,title:e.goal?`${e.title}: ${e.goal}`:e.title},leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.status===`done`?`✅`:e.status===`paused`?`⏸️`:e.status===`archived`?`🗄️`:`📁`}),title:e.title,titleExtra:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($e,{n:is.project(u,e.slug,e.agents).length,title:`waiting for you`}),t&&(0,z.jsx)(et,{tone:`working`,title:`an agent is working`})]}),titleLines:2})};return(0,z.jsx)(`nav`,{className:`rail`,"aria-label":`Conversations`,children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2 pt-2 pb-4`,children:[(0,z.jsx)(gt,{href:`/`,active:e===`/`,leading:(0,z.jsx)(B,{name:`home`}),title:`Home`,innerProps:{title:`Everything here: chats, workflows, routines and what they made`}}),(0,z.jsx)(gt,{href:`/agents/chats`,active:s,leading:(0,z.jsx)(B,{name:`chat`}),title:`Chats`,titleExtra:(0,z.jsx)($e,{n:is.general(u).length,title:`waiting for you`}),innerProps:{title:`Every chat with Ralv and in the projects; start a new one with Ralv, the chief of staff`}}),(0,z.jsx)(gt,{href:`/today`,active:e===`/today`,leading:(0,z.jsx)(B,{name:`today`}),title:`Today`,innerProps:{title:`Today: what needs you, what happened`}}),t.projects&&(0,z.jsxs)(zS,{label:`projects`,href:`/projects`,add:r?.enabled?{href:`/projects/new`,label:`new project`}:void 0,badge:c.all?(0,z.jsx)($e,{n:new Set(f.filter(e=>!m(e)).flatMap(e=>is.project(u,e.slug,e.agents).map(e=>e.id))).size,title:`waiting in the projects folded away`}):void 0,fold:f.length>0?(0,z.jsxs)(z.Fragment,{children:[!c.all&&r?.layout&&(0,z.jsx)(q,{size:`sm`,icon:`create_new_folder`,label:`new section`,title:`new section: drag projects into it`,onClick:()=>void x()}),(0,z.jsx)(q,{size:`sm`,icon:c.all?`chevron_right`:`expand_more`,label:c.all?`show all projects`:`collapse projects`,"aria-expanded":!c.all,onClick:()=>l(e=>({...e,all:!e.all}))})]}):void 0,children:[c.all||!r?.layout?g.filter(e=>!c.all||m(e)).map(e=>(0,z.jsx)(v.Fragment,{children:S(e)},e.slug)):(0,z.jsx)(FS,{layout:r.layout,visible:e=>!!h.get(e)&&m(h.get(e)),render:e=>h.get(e)?S(h.get(e)):null,onSave:_,collapsed:e=>!!c.sections[e],onCollapse:e=>l(t=>({...t,sections:{...t.sections,[e]:!t.sections[e]}})),editing:y,onEdited:()=>b(void 0)}),c.all&&f.length>0&&(0,z.jsxs)(K,{variant:`quiet`,size:`sm`,icon:`expand_more`,className:`justify-start`,onClick:()=>l(e=>({...e,all:!1})),children:[f.filter(e=>!m(e)).length,` more`]})]}),(0,z.jsx)(zS,{label:`agents`,href:`/agents`,add:{href:`/agents/new`,label:`new agent`},children:(n?.agents??[]).filter(e=>!e.archived).map(e=>{let t=kS(i?.[e.slug],e.description);return(0,z.jsx)(gt,{href:`/agents/${encodeURIComponent(e.slug)}`,active:o(`agents`,e.slug)||o(`team`,e.slug),innerProps:{title:e.description||void 0},leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji||`🤖`}),title:e.name,titleExtra:(0,z.jsx)(BS,{n:is.agent(u,e.slug).length,st:i?.[e.slug]}),sub:t?(0,z.jsx)(`span`,{className:`rail-status${t.tone===`plain`?``:` ${t.tone}`}`,children:t.text}):void 0,subTone:t?.tone===`waiting`?`bad`:t?.tone===`working`?`accent`:`plain`},e.slug)})})]})})}function zS({label:e,href:t,add:n,badge:r,fold:i,children:a}){return(0,z.jsxs)(`div`,{className:`mt-3 flex flex-col gap-0.5`,role:`group`,"aria-label":e[0].toUpperCase()+e.slice(1),children:[(0,z.jsxs)(`div`,{className:`group/head flex items-center gap-1 pl-2.5 pr-1`,children:[(0,z.jsx)(U,{href:t,className:`flex-1 px-0 py-1 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-2 no-underline hover:text-fg`,children:e}),r,(0,z.jsxs)(`span`,{className:`flex items-center gap-1 opacity-0 transition-opacity group-hover/head:opacity-100 group-focus-within/head:opacity-100 pointer-coarse:opacity-100`,children:[n&&(0,z.jsx)(q,{size:`sm`,icon:`add`,label:n.label,href:n.href}),i]})]}),a]})}function BS({n:e,st:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($e,{n:e,title:`waiting for you`}),!e&&t?.working.length&&!t.waiting.length?(0,z.jsx)(et,{tone:`working`,title:`working`}):null]})}var VS=`kw-rail-fold`;function HS(){let[e,t]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(VS)??`null`),t=e=>e&&typeof e==`object`?e:{};return{all:!!e?.all,open:t(e?.open),sections:t(e?.sections)}}catch{return{all:!1,open:{},sections:{}}}});return[e,e=>t(t=>{let n=e(t);try{localStorage.setItem(VS,JSON.stringify(n))}catch{}return n})]}function US(){let e=F(`agents.list`,{},{interval:3e4}),t=F(`agents.status`,{},{interval:15e3}),[n,r]=(0,v.useState)(``),i=e?.agents??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||[e.name,e.slug,e.description,e.group,e.harness,e.model].some(e=>e?.toLowerCase().includes(a))).sort((e,t)=>Number(!!e.archived)-Number(!!t.archived)||(e.group??``).localeCompare(t.group??``)||e.name.localeCompare(t.name)),s=i.filter(e=>!e.archived).length;return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`smart_toy`,className:`text-[28px] text-fg-2`}),title:`Agents`,sub:e?`${s} active${i.length>s?` · ${i.length-s} archived`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter agents`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/agents/new`,children:`new agent`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`smart_toy`,children:`No agents yet. Create the first one with "new agent".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No agent matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`agents-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`agent`}),(0,z.jsx)(`th`,{children:`group`}),(0,z.jsx)(`th`,{children:`runs on`}),(0,z.jsx)(`th`,{children:`linked`}),(0,z.jsx)(`th`,{children:`now`}),(0,z.jsx)(`th`,{})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(WS,{a:e,st:t?.[e.slug]},e.slug))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function WS({a:e,st:t}){let n=`/agents/${encodeURIComponent(e.slug)}`,r=[[e.workflows.length,`workflow`],[e.knowledge.length,`knowledge`],[e.vibeables.length,`app`],[e.files?.length??0,`folder`]].filter(([e])=>e);return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3 ${e.archived?`opacity-60`:``}`,"data-agent":e.slug,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:n,className:`flex items-start gap-2.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsx)(`span`,{className:`text-[18px] leading-5`,children:e.emoji||`🤖`}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.name,` `,e.archived&&(0,z.jsx)(J,{children:`archived`})]}),e.description&&(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.description})]})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2`,children:e.group??`—`}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap`,children:[e.harness,(e.model||e.effort)&&(0,z.jsx)(`div`,{className:`text-xs text-fg-2`,children:[e.model,e.effort].filter(Boolean).join(` · `)})]}),(0,z.jsxs)(`td`,{className:`text-xs text-fg-2`,children:[r.length===0&&e.skills===void 0?`—`:r.map(([e,t])=>(0,z.jsxs)(`div`,{children:[e,` `,t,e===1||t===`knowledge`?``:`s`]},t)),e.skills!==void 0&&(0,z.jsx)(`div`,{title:`its skill allowlist; agents without one may use every skill`,children:e.skills.length===0?`no skills`:`${e.skills.length} skill${e.skills.length===1?``:`s`} allowed`})]}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,children:[t?.waiting.length?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-fg`,children:[(0,z.jsx)(et,{tone:`ask`}),` waiting for you`]}):t?.working.length?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-fg`,children:[(0,z.jsx)(et,{tone:`working`}),` working`]}):t?.lastActiveAt?(0,z.jsxs)(z.Fragment,{children:[`active `,G(t.lastActiveAt)]}):`never used`,t?.nextRoutine&&(0,z.jsxs)(`div`,{title:t.nextRoutine.at,children:[`⏰ `,t.nextRoutine.name]})]}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-right`,children:(0,z.jsx)(q,{icon:`edit`,label:`edit ${e.name}`,size:`sm`,href:`${n}/edit`})})]})}var GS=`/settings/routines`,KS=(e,t)=>`${GS}?open=${encodeURIComponent(`${e}:${t}`)}`;function qS(){let e=F(`routines.list`,{},{interval:3e4}),t=F(`projects.list`,{},{interval:6e4}),[n,r]=(0,v.useState)(``),[i,a]=(new URLSearchParams(ne().split(`?`)[1]??``).get(`open`)??``).split(`:`),o=e?.routines??[],s=e=>t?.projects.find(t=>t.slug===e)?.title??e,c=n.trim().toLowerCase(),l=o.filter(e=>!c||[e.name,e.prompt,e.schedule,e.agent?.name,e.project,e.runsOn].some(e=>e?.toLowerCase().includes(c))).sort((e,t)=>(e.nextRunAt??`9`).localeCompare(t.nextRunAt??`9`)||e.name.localeCompare(t.name)),u=o.filter(e=>e.enabled&&e.nextRunAt).length;return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`schedule`,className:`text-[28px] text-fg-2`}),title:`Routines`,sub:e?`${o.length} routine${o.length===1?``:`s`} · ${u} scheduled on this machine`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[o.length>0&&(0,z.jsx)(Z,{"aria-label":`filter routines`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:KS(`_`,`new`),children:`new routine`})]})}),(0,z.jsx)(X,{children:e?o.length===0?(0,z.jsx)(Y,{icon:`schedule`,children:`No routines yet. Create the first one with "new routine".`}):l.length===0?(0,z.jsxs)(Y,{children:[`No routine matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`routines-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`routine`}),(0,z.jsx)(`th`,{children:`who`}),(0,z.jsx)(`th`,{children:`project`}),(0,z.jsx)(`th`,{children:`schedule`}),(0,z.jsx)(`th`,{children:`runs on`}),(0,z.jsx)(`th`,{children:`last run`})]})}),(0,z.jsx)(`tbody`,{children:l.map(e=>(0,z.jsx)(JS,{r:e,projectTitle:e.project?s(e.project):void 0},`${e.owner}:${e.id}`))})]})}):(0,z.jsx)(Y,{children:`loading…`})}),i&&a&&(0,z.jsx)(Hy,{label:`routine`,title:a===`new`&&i===`_`?`New routine`:o.find(e=>e.owner===i&&e.id===a)?.name??`Routine`,onClose:()=>H(GS),children:(0,z.jsx)(`div`,{className:`-m-3`,children:(0,z.jsx)(vb,{owner:i,id:a,onOpen:e=>{let[,t,n]=(e??``).split(`:`);H(t&&n?KS(t,n):GS,{replace:!0})}})})})]})}function JS({r:e,projectTitle:t}){return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3 ${e.enabled?``:`opacity-60`}`,"data-routine":`${e.owner}:${e.id}`,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:KS(e.owner,e.id),className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.name,` `,!e.enabled&&(0,z.jsx)(J,{children:`paused`}),` `,e.private&&(0,z.jsx)(J,{children:`private`})]}),(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.prompt})]})}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap`,children:[fb(e),e.owner!==`_`&&(0,z.jsx)(`div`,{className:`text-xs text-fg-2`,children:`the agent's own`})]}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2`,children:e.project?(0,z.jsx)(U,{href:`/projects/${encodeURIComponent(e.project)}`,children:t}):`—`}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap`,children:[(0,z.jsx)(`code`,{className:`text-xs`,children:e.schedule}),(0,z.jsx)(`div`,{className:`text-xs text-fg-2`,children:pb(e)})]}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs`,children:e.runner===`here`?(0,z.jsx)(J,{title:`runs_on: ${e.runsOn} — this machine fires it`,children:`here`}):e.runner===`unassigned`?(0,z.jsx)(J,{tone:e.enabled?`ask`:`neutral`,title:`no runs_on — it fires on no machine until one adopts it`,children:`no runner`}):(0,z.jsx)(J,{tone:e.retired?`ask`:`neutral`,title:e.retired?`a retired identity of this machine — it fires nowhere until reassigned`:`another machine fires it, not this one`,children:e.runsOn})}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,children:[e.lastChatId?(0,z.jsx)(U,{href:mb(e,e.lastChatId),children:Ke(e.lastRunAt)}):`never ran`,e.awaitingApproval&&e.lastChatId&&(0,z.jsx)(`div`,{children:(0,z.jsx)(J,{href:mb(e,e.lastChatId),tone:`bad`,children:`needs approval`})}),e.lastError&&(0,z.jsx)(`div`,{title:e.lastError,children:(0,z.jsx)(J,{tone:`bad`,children:`error`})})]})]})}function YS(){let e=F(`workflows.list`,{},{interval:3e4}),t=F(`runs.list`,{},{interval:3e4}),[n,r]=(0,v.useState)(``),i=e?.workflows??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||[e.name,e.slug,e.description].some(e=>e?.toLowerCase().includes(a))).sort((e,t)=>(e.name||e.slug).localeCompare(t.name||t.slug)),s=i.filter(e=>e.error).length,c=e=>(t?.runs??[]).filter(t=>t.workflow===e.slug||!!e.name&&t.workflow===e.name).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt));return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`account_tree`,className:`text-[28px] text-fg-2`}),title:`Workflows`,sub:e?`${i.length} workflow${i.length===1?``:`s`}${s?` · ${s} unreadable`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter workflows`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/agents/chats`,title:`ask Ralv to make a workflow`,children:`new workflow`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`account_tree`,children:`No workflows yet. Ask Ralv to make the first one with "new workflow".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No workflow matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`workflows-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`workflow`}),(0,z.jsx)(`th`,{children:`steps`}),(0,z.jsx)(`th`,{children:`request`}),(0,z.jsx)(`th`,{children:`runs`}),(0,z.jsx)(`th`,{children:`last run`})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(XS,{w:e,runs:t?c(e):void 0},e.slug))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function XS({w:e,runs:t}){let n=t?.[0],r=!!n?.awaitingDecision&&n.status===`running`;return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-workflow":e.slug,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:`/workflows/${encodeURIComponent(e.slug)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.name||e.slug,` `,e.error&&(0,z.jsx)(J,{tone:`bad`,title:e.error,children:`error`})]}),(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.description||e.slug})]})}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap`,children:[e.steps,` step`,e.steps===1?``:`s`,(0,z.jsxs)(`div`,{className:`text-xs text-fg-2`,children:[e.agents,` agent`,e.agents===1?``:`s`]})]}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2`,title:e.usesRequest?`a step reads the request: it asks for one before it runs`:`no step reads a request: it runs straight away`,children:e.usesRequest?`yes`:`no`}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2 tabular-nums`,children:t?t.length||`—`:``}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,children:t?n?(0,z.jsxs)(U,{href:`/runs/${encodeURIComponent(n.id)}`,className:`inline-flex items-center gap-1.5`,children:[(0,z.jsx)(et,{tone:r?`ask`:n.status===`running`?`working`:n.status===`ok`?`ok`:n.status===`failed`?`bad`:`idle`}),r?`decision needed`:n.status===`aborted`?`stopped`:n.status,` · `,Ke(n.updatedAt)]}):`never ran`:``})]})}function ZS(){let e=F(`knowledge.list`,{},{interval:3e4}),t=F(`agents.list`,{},{interval:3e4}),[n,r]=(0,v.useState)(``),i=e?.bundles??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||e.name.toLowerCase().includes(a)).sort((e,t)=>e.name.localeCompare(t.name)),s=i.reduce((e,t)=>e+t.concepts,0),c=e=>(t?.agents??[]).filter(t=>!t.archived&&t.knowledge.includes(e.name));return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`menu_book`,className:`text-[28px] text-fg-2`}),title:`Knowledge`,sub:e?`${i.length} bundle${i.length===1?``:`s`} · ${s} page${s===1?``:`s`}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter knowledge`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/knowledge/new`,children:`new bundle`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`menu_book`,children:`No knowledge yet. Create the first bundle with "new bundle".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No bundle matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`knowledge-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`bundle`}),(0,z.jsx)(`th`,{children:`pages`}),(0,z.jsx)(`th`,{children:`changed`}),(0,z.jsx)(`th`,{children:`used by`})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(QS,{b:e,usedBy:t?c(e):void 0},e.name))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function QS({b:e,usedBy:t}){return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-bundle":e.name,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:`/knowledge/${encodeURIComponent(e.name)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.name}),e.okfVersion&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`OKF `,e.okfVersion]})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2 tabular-nums`,children:e.concepts}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:G(e.updatedAt)}),(0,z.jsx)(`td`,{className:`text-xs text-fg-2`,children:t?t.length===0?`—`:t.map(e=>(0,z.jsx)(`div`,{children:(0,z.jsxs)(U,{href:`/agents/${encodeURIComponent(e.slug)}`,children:[e.emoji||`🤖`,` `,e.name]})},e.slug)):``})]})}var $S=encodeURIComponent,eC=e=>`${e.project??``}:${e.board}`;function tC(){let e=F(`boards.list`,{query:{all:`1`}},{interval:3e4}),t=F(`tasks.list`,{},{interval:3e4}),n=F(`projects.list`,{},{interval:6e4}),[r,i]=(0,v.useState)(``),a=e?.boards??[],o=e=>n?.projects.find(t=>t.slug===e)?.title??e,s=r.trim().toLowerCase(),c=a.filter(e=>!s||[e.title,e.board,e.project,e.project&&o(e.project)].some(e=>e?.toLowerCase().includes(s))).sort((e,t)=>(e.project??``).localeCompare(t.project??``)||e.title.localeCompare(t.title)),l=a.reduce((e,t)=>e+t.tasks,0),u=new Map;for(let e of t?.tasks??[])u.set(eC(e),[...u.get(eC(e))??[],e]);return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`view_kanban`,className:`text-[28px] text-fg-2`}),title:`Boards`,sub:e?`${a.length} board${a.length===1?``:`s`} · ${l} task${l===1?``:`s`}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[a.length>0&&(0,z.jsx)(Z,{"aria-label":`filter boards`,placeholder:`filter`,value:r,onChange:e=>i(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/boards/new`,children:`new board`})]})}),(0,z.jsx)(X,{children:e?a.length===0?(0,z.jsx)(Y,{icon:`view_kanban`,children:`No boards yet. Create the first one with "new board".`}):c.length===0?(0,z.jsxs)(Y,{children:[`No board matches "`,r,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`boards-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`board`}),(0,z.jsx)(`th`,{children:`project`}),(0,z.jsx)(`th`,{children:`tasks`}),(0,z.jsx)(`th`,{children:`open`}),(0,z.jsx)(`th`,{children:`changed`})]})}),(0,z.jsx)(`tbody`,{children:c.map(e=>(0,z.jsx)(nC,{b:e,tasks:t?u.get(eC(e))??[]:void 0,projectTitle:e.project?o(e.project):void 0},eC(e)))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function nC({b:e,tasks:t,projectTitle:n}){let r=e.project?`/projects/${$S(e.project)}/boards/${$S(e.board)}`:`/boards/${$S(e.board)}`,i=new Set(e.columns.filter(e=>e.done).map(e=>e.slug)),a=new Set(e.columns.filter(e=>e.review).map(e=>e.slug)),o=t?.filter(e=>!i.has(e.status)),s=t?.filter(e=>a.has(e.status)).length??0,c=t?.filter(e=>e.stale).length??0;return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-board":eC(e),children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:r,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.title,` `,e.configError&&(0,z.jsx)(J,{tone:`bad`,title:e.configError,children:`error`})]}),(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.columns.map(e=>e.label).join(` · `)||e.board})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2`,children:e.project?(0,z.jsx)(U,{href:`/projects/${$S(e.project)}`,children:n}):`—`}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-fg-2 tabular-nums`,children:t?t.length:e.tasks}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,children:o?o.length===0?`—`:(0,z.jsxs)(z.Fragment,{children:[o.length,` open`,s>0&&(0,z.jsx)(`div`,{children:(0,z.jsxs)(J,{tone:`ask`,title:`tasks in a review column: they wait for a human`,children:[s,` in review`]})}),c>0&&(0,z.jsxs)(`div`,{title:`assigned, in a work column, and nothing logged for a while`,children:[c,` stale`]})]}):``}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:G(e.updatedAt)})]})}function rC(){let e=F(`vibeables.list`,{},{interval:3e4}),t=F(`agents.list`,{},{interval:3e4}),[n,r]=(0,v.useState)(``),i=e?.vibeables??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||[e.slug,e.dev].some(e=>e?.toLowerCase().includes(a))).sort((e,t)=>e.slug.localeCompare(t.slug)),s=i.filter(e=>e.configError).length,c=e=>(t?.agents??[]).filter(t=>!t.archived&&t.vibeables.includes(e.slug));return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`web`,className:`text-[28px] text-fg-2`}),title:`Apps`,sub:e?`${i.length} app${i.length===1?``:`s`}${s?` · ${s} unreadable`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter apps`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/vibeables/new`,children:`new app`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`web`,children:e.error??`No apps yet. Create the first one with "new app".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No app matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`apps-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`app`}),(0,z.jsx)(`th`,{children:`preview`}),(0,z.jsx)(`th`,{children:`used by`}),(0,z.jsx)(`th`,{children:`changed`})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(iC,{v:e,usedBy:t?c(e):void 0},e.slug))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function iC({v:e,usedBy:t}){return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-app":e.slug,children:[(0,z.jsx)(`td`,{className:`max-w-[340px]`,children:(0,z.jsxs)(U,{href:`/vibeables/${encodeURIComponent(e.slug)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.slug,` `,e.configError&&(0,z.jsx)(J,{tone:`bad`,title:e.configError,children:`error`})]}),(0,z.jsx)(`span`,{className:`truncate text-xs text-fg-2`,title:e.path,children:e.path})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap`,children:e.dev?(0,z.jsxs)(z.Fragment,{children:[`dev server`,(0,z.jsx)(`div`,{className:`text-xs text-fg-2`,children:(0,z.jsx)(`code`,{children:e.dev})})]}):e.hasIndex?`static page`:(0,z.jsx)(`span`,{className:`text-fg-2`,title:`no index.html in the served folder and no dev command`,children:`nothing to show yet`})}),(0,z.jsx)(`td`,{className:`text-xs text-fg-2`,children:t?t.length===0?`—`:t.map(e=>(0,z.jsx)(`div`,{children:(0,z.jsxs)(U,{href:`/agents/${encodeURIComponent(e.slug)}`,children:[e.emoji||`🤖`,` `,e.name]})},e.slug)):``}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:G(e.updatedAt)})]})}var aC={workspace:`this workspace`,machine:`every workspace on this machine`},oC={api_key:`API key`,subscription_token:`subscription token`};function sC(e){return e.credential?{tone:`ok`,text:`${oC[e.credential.kind]} ending in ${e.credential.ending}, for ${aC[e.credential.scope]}`}:e.env.length?{tone:`ok`,text:`${e.env.join(`, `)} from the shell or the workspace's .env`}:e.login===`present`?{tone:`ok`,text:`its own login on this machine`}:e.login===`absent`?{tone:`bad`,text:`nothing: no key, no token, and its CLI is not logged in here`}:{tone:`neutral`,text:`its own login on this machine, if there is one — a chat on it says who`}}function cC(){let[e,t]=(0,v.useState)(0),n=F(`harnesses.list`,{},{interval:15e3,refresh:e}),r=n?.harnesses??[],i=r.filter(e=>e.available).length;return(0,z.jsxs)(ct,{className:`max-w-[860px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`key`,className:`text-[28px] text-fg-2`}),title:`Harnesses`,sub:n?`${i} of ${r.length} usable here · keys stay on this machine`:void 0}),n?(0,z.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map(e=>(0,z.jsx)(lC,{h:e,onChanged:()=>t(e=>e+1)},e.id))}):(0,z.jsx)(X,{children:(0,z.jsx)(Y,{children:`loading…`})})]})}function lC({h:e,onChanged:t}){let n=sC(e);return(0,z.jsx)(X,{title:e.label,actions:(0,z.jsxs)(z.Fragment,{children:[e.adapter&&(0,z.jsxs)(J,{title:`its adapter comes with kraftwerk: chats and agents with protocol: acp`,children:[`bundled `,e.adapter.version]}),e.cli&&(0,z.jsxs)(J,{title:e.cli.path,children:[e.cli.command,` on the PATH`]}),!e.available&&(0,z.jsx)(J,{tone:`bad`,children:`not installed`})]}),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 px-[18px] py-3.5`,"data-harness":e.id,children:[!e.available&&(0,z.jsxs)(rt,{tone:`bad`,children:[`Not usable on this machine: install its CLI (`,(0,z.jsx)(`code`,{children:e.needs}),`) and log in with it.`]}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(`span`,{className:`text-2xs tracking-[0.5px] text-fg-2 uppercase`,children:`signs in with`}),(0,z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,z.jsx)(J,{tone:n.tone,children:e.credential?oC[e.credential.kind]:e.env.length?`environment`:e.login===`absent`?`not signed in`:`CLI login`}),(0,z.jsx)(`span`,{children:n.text}),e.credential&&(0,z.jsxs)(`span`,{className:`text-fg-2`,children:[`· set `,G(new Date(e.credential.setAt).toISOString())]})]}),e.seen&&(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`Last chat (`,G(new Date(e.seen.at).toISOString()),`): `,e.seen.kind===`none`?`not signed in`:[e.seen.email??e.seen.label,e.seen.organization,e.seen.plan].filter(Boolean).join(` · `),e.seen.detail?` — ${e.seen.detail}`:``]})]}),e.accepts.length>0?(0,z.jsx)(uC,{h:e,onChanged:t}):(0,z.jsx)(nt,{children:`It signs in with its own CLI only; there is nothing to store for it here.`})]})})}function uC({h:e,onChanged:t}){let[n,r]=(0,v.useState)(e.credential?.kind??e.accepts[0].kind),[i,a]=(0,v.useState)(e.credential?.scope??`workspace`),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),f=e.accepts.find(e=>e.kind===n)??e.accepts[0];async function p(e){l(!0),d(``);try{await e(),s(``),t()}catch(e){d(e instanceof w?e.message:`could not save`)}finally{l(!1)}}return(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 border-t border-line pt-3`,onSubmit:t=>{t.preventDefault(),o.trim()&&p(()=>A.call(`harnesses.setCredential`,{id:e.id,body:{kind:n,value:o,scope:i}}))},children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.accepts.length>1&&(0,z.jsx)(St,{"aria-label":`what to store`,value:n,onChange:e=>r(e.target.value),className:`w-auto`,children:e.accepts.map(e=>(0,z.jsx)(`option`,{value:e.kind,children:e.label},e.kind))}),(0,z.jsx)(Z,{type:`password`,autoComplete:`off`,spellCheck:!1,"aria-label":`${f.label} for ${e.label}`,placeholder:e.credential?`paste a new one`:`paste the ${f.label}`,value:o,onChange:e=>s(e.target.value),className:`min-w-[220px] flex-1 font-mono`}),(0,z.jsxs)(St,{"aria-label":`where it applies`,value:i,onChange:e=>a(e.target.value),className:`w-auto`,children:[(0,z.jsx)(`option`,{value:`workspace`,children:`this workspace`}),(0,z.jsx)(`option`,{value:`machine`,children:`every workspace here`})]}),(0,z.jsx)(K,{variant:`primary`,type:`submit`,disabled:c||!o.trim(),children:e.credential?`replace`:`save`}),e.credential&&(0,z.jsx)(K,{type:`button`,disabled:c,onClick:()=>void p(()=>A.call(`harnesses.removeCredential`,{id:e.id,query:{scope:e.credential.scope}})),title:`forget the ${oC[e.credential.kind]} stored for ${aC[e.credential.scope]}`,children:`remove`})]}),(0,z.jsxs)(nt,{children:[f.hint,` It is kept on this machine, outside the workspace's files, and used by the next chat or run.`]}),u&&(0,z.jsx)(rt,{tone:`bad`,children:u})]})}var dC=[`active`,`paused`,`done`,`archived`],fC={active:`📁`,paused:`⏸️`,done:`✅`,archived:`🗄️`};function pC(){let[e,t]=(0,v.useState)(0),n=F(`projects.list`,{},{interval:3e4,refresh:e}),r=F(`agents.list`,{},{interval:6e4}),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),f=n?.projects??[],p=i.trim().toLowerCase(),m=f.filter(e=>e.status===`archived`).length,h=f.filter(e=>o||e.status!==`archived`).filter(e=>!p||[e.title,e.slug,e.goal].some(e=>e?.toLowerCase().includes(p))).sort((e,t)=>dC.indexOf(e.status)-dC.indexOf(t.status)||e.title.localeCompare(t.title)),g=e=>{let t=r?.agents.find(t=>t.slug===e);return t?`${t.emoji||`🤖`} ${t.name}`:e},_=async(e,n)=>{l(e.slug),d(``);try{let r=await A.request(`projects.save`,{slug:e.slug,body:{status:n}});if(!r.ok)throw Error(P(r));t(e=>e+1)}catch(t){d(`${e.title}: ${t.message}`)}finally{l(``)}};return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`folder_special`,className:`text-[28px] text-fg-2`}),title:`Projects`,sub:n?`${f.length} project${f.length===1?``:`s`}${m?` · ${m} archived`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[m>0&&(0,z.jsx)(Tt,{checked:o,onChange:s,children:`show archived`}),f.length>0&&(0,z.jsx)(Z,{"aria-label":`filter projects`,placeholder:`filter`,value:i,onChange:e=>a(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/projects/new`,children:`new project`})]})}),u&&(0,z.jsx)(rt,{tone:`bad`,children:u}),(0,z.jsx)(X,{children:n?f.length===0?(0,z.jsx)(Y,{icon:`folder_special`,children:`No projects yet. Create the first one with "new project".`}):h.length===0?(0,z.jsx)(Y,{children:p?`No project matches "${i}".`:`Every project is archived.`}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`projects-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`project`}),(0,z.jsx)(`th`,{children:`status`}),(0,z.jsx)(`th`,{children:`agents`}),(0,z.jsx)(`th`,{children:`changed`}),(0,z.jsx)(`th`,{"aria-label":`actions`})]})}),(0,z.jsx)(`tbody`,{children:h.map(e=>(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3 ${e.status===`archived`?`opacity-60`:``}`,"data-project":e.slug,children:[(0,z.jsx)(`td`,{className:`max-w-[380px]`,children:(0,z.jsxs)(U,{href:`/projects/${encodeURIComponent(e.slug)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:fC[e.status]}),` `,e.title,` `,e.configError&&(0,z.jsx)(J,{tone:`bad`,title:e.configError,children:`error`})]}),(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.goal||`no goal written yet`})]})}),(0,z.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,z.jsx)(St,{"aria-label":`status of ${e.title}`,value:e.status,disabled:c===e.slug,onChange:t=>void _(e,t.target.value),className:`h-8 w-[120px] text-sm`,children:dC.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})}),(0,z.jsx)(`td`,{className:`text-xs text-fg-2`,children:(e.agents??[]).length===0?`—`:(e.agents??[]).map(e=>(0,z.jsx)(`div`,{children:g(e)},e))}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:e.updatedAt?G(e.updatedAt):`—`}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-right`,children:(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:e.status===`archived`?`unarchive`:`archive`,busy:c===e.slug,disabled:!!c,onClick:()=>void _(e,e.status===`archived`?`active`:`archived`),title:e.status===`archived`?`back to active: it shows in the rail again`:`archive: it leaves the rail, its folder stays`,children:e.status===`archived`?`unarchive`:`archive`})})]},e.slug))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}var mC={workspace:{label:`workspace`,title:`the workspace's skills root`},project:{label:`project`,title:`.claude/skills of the workspace`},user:{label:`personal`,title:`~/.claude/skills on this machine`},agent:{label:`agent`,title:`an agent's own skills folder`}},hC=[`workspace`,`project`,`agent`,`user`];function gC(){let e=F(`skills.list`,{},{interval:3e4}),t=F(`agents.list`,{},{interval:3e4}),[n,r]=(0,v.useState)(``),i=e?.skills??[],a=n.trim().toLowerCase(),o=i.filter(e=>!a||[e.name,e.description,mC[e.source].label,e.agent].some(e=>e?.toLowerCase().includes(a))).sort((e,t)=>hC.indexOf(e.source)-hC.indexOf(t.source)||e.name.localeCompare(t.name)),s=i.filter(e=>e.source!==`user`).length,c=e=>t?.agents.find(t=>t.slug===e)?.name??e,l=e=>(t?.agents??[]).filter(t=>!t.archived&&t.skills?.includes(e.name));return(0,z.jsxs)(ct,{className:`max-w-[1160px] px-6 py-6`,children:[(0,z.jsx)(st,{icon:(0,z.jsx)(B,{name:`extension`,className:`text-[28px] text-fg-2`}),title:`Skills`,sub:e?`${s} in the workspace${i.length>s?` · ${i.length-s} personal`:``}`:void 0,actions:(0,z.jsxs)(z.Fragment,{children:[i.length>0&&(0,z.jsx)(Z,{"aria-label":`filter skills`,placeholder:`filter`,value:n,onChange:e=>r(e.target.value),className:`w-[200px]`}),(0,z.jsx)(K,{variant:`primary`,icon:`add`,href:`/agents/chats`,title:`ask Ralv to make a skill`,children:`new skill`})]})}),(0,z.jsx)(X,{children:e?i.length===0?(0,z.jsx)(Y,{icon:`extension`,children:`No skills yet. Ask Ralv to make the first one with "new skill".`}):o.length===0?(0,z.jsxs)(Y,{children:[`No skill matches "`,n,`".`]}):(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`skills-admin w-full border-collapse text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-left text-2xs tracking-[0.5px] text-fg-2 uppercase [&>th]:px-[18px] [&>th]:py-2.5 [&>th]:font-medium`,children:[(0,z.jsx)(`th`,{children:`skill`}),(0,z.jsx)(`th`,{children:`source`}),(0,z.jsx)(`th`,{children:`limited to`}),(0,z.jsx)(`th`,{children:`changed`})]})}),(0,z.jsx)(`tbody`,{children:o.map(e=>(0,z.jsx)(_C,{s:e,owner:c(e.agent),limitedTo:t?l(e):void 0},`${e.source}:${e.agent??``}:${e.name}`))})]})}):(0,z.jsx)(Y,{children:`loading…`})})]})}function _C({s:e,owner:t,limitedTo:n}){let r=mC[e.source];return(0,z.jsxs)(`tr`,{className:`border-t border-line align-top [&>td]:px-[18px] [&>td]:py-3`,"data-skill":e.name,children:[(0,z.jsx)(`td`,{className:`max-w-[420px]`,children:(0,z.jsxs)(U,{href:`/skills/${encodeURIComponent(e.name)}`,className:`flex min-w-0 flex-col gap-0.5 text-fg no-underline hover:text-accent`,children:[(0,z.jsxs)(`span`,{className:`font-medium`,children:[`/`,e.name]}),e.description&&(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-2`,children:e.description})]})}),(0,z.jsxs)(`td`,{className:`whitespace-nowrap text-xs`,children:[(0,z.jsx)(J,{title:`${r.title} — ${e.dir}`,children:r.label}),e.source===`agent`&&t&&(0,z.jsx)(`div`,{className:`mt-0.5 text-fg-2`,children:t})]}),(0,z.jsx)(`td`,{className:`text-xs text-fg-2`,title:`agents whose skill allowlist names it; agents without an allowlist may use every skill`,children:n?n.length===0?`—`:n.map(e=>(0,z.jsx)(`div`,{children:(0,z.jsxs)(U,{href:`/agents/${encodeURIComponent(e.slug)}`,children:[e.emoji||`🤖`,` `,e.name]})},e.slug)):``}),(0,z.jsx)(`td`,{className:`whitespace-nowrap text-xs text-fg-2`,title:e.updatedAt,children:G(e.updatedAt)})]})}function vC(){let e=De();return[{id:`settings`,main:!0,href:`/settings`,label:`base settings`,icon:`settings`},{id:`agents`,main:!0,href:`/settings/agents`,label:`agents`,icon:`smart_toy`},...e.projects?[{id:`projects`,main:!0,href:`/settings/projects`,label:`projects`,icon:`folder_special`}]:[],{id:`routines`,main:!0,href:`/settings/routines`,label:`routines`,icon:`schedule`},{id:`workflows`,main:!0,href:`/settings/workflows`,label:`workflows`,icon:`account_tree`},{id:`knowledge`,main:!0,href:`/settings/knowledge`,label:`knowledge`,icon:`menu_book`},{id:`files`,main:!0,href:`/files`,label:`files`,icon:`folder_open`},...e.boards?[{id:`boards`,main:!0,href:`/settings/boards`,label:`boards`,icon:`view_kanban`}]:[],...e.presentations?[{id:`presentations`,href:`/presentations`,label:`presentations`,icon:`slideshow`}]:[],...e.vibeables?[{id:`vibeables`,href:`/settings/apps`,label:`apps`,icon:`web`}]:[],{id:`skills`,main:!0,href:`/settings/skills`,label:`skills`,icon:`extension`},{id:`harnesses`,href:`/settings/harnesses`,label:`harnesses`,icon:`key`},...e.repos?[{id:`repos`,href:`/repos`,label:`repositories`,icon:`source`}]:[],...e.contacts?[{id:`contacts`,href:`/contacts`,label:`contacts`,icon:`person`}]:[],...e.places?[{id:`places`,href:`/places`,label:`places`,icon:`location_on`}]:[],...e.events?[{id:`events`,href:`/events`,label:`events`,icon:`event`}]:[],{id:`workspaces`,href:`/workspaces`,label:`workspaces`,icon:`grid_view`}]}var yC=new Set([`settings`,`workflows`,`runs`,`knowledge`,`files`,`boards`,`presentations`,`vibeables`,`skills`,`repos`,`contacts`,`places`,`events`,`workspaces`]),bC=new Set([`agents`,`routines`,`workflows`,`knowledge`,`boards`,`skills`,`harnesses`]);function xC(e){return yC.has(e.split(`?`)[0].split(`/`).filter(Boolean)[0]??``)}function SC({path:e}){let t=vC(),[n=``,r=``]=e.split(`?`)[0].split(`/`).filter(Boolean),i=n===`settings`?bC.has(r)?r:r===`apps`?`vibeables`:`settings`:n===`runs`?`workflows`:n,a=e=>i===e;return(0,z.jsx)(`nav`,{className:`settings-nav sticky top-[var(--topbar-h)] z-[9] flex h-11 items-center gap-0.5 overflow-x-auto bg-bg px-5 shadow-[inset_0_-1px_0_var(--line)] [scrollbar-width:none] max-[800px]:px-3`,"aria-label":`Settings`,children:t.map((e,t)=>{let n=a(e.id);return(0,z.jsxs)(U,{href:e.href,className:I(`inline-flex flex-none items-center gap-1.5 rounded-full px-3 py-1 text-[13.5px] font-semibold no-underline transition-colors [&_.ms]:text-[18px]`,n?`bg-surface text-accent shadow-[inset_0_0_0_1px_var(--line)]`:`text-fg-2 hover:bg-surface-2 hover:text-fg`,t===0&&`mr-2`),"aria-current":n?`page`:void 0,"aria-label":e.label,title:e.label,children:[(0,z.jsx)(B,{name:e.icon,fill:n}),` `,(0,z.jsx)(`span`,{className:I(!n&&(e.main?`max-[1100px]:hidden`:`max-[1720px]:hidden`)),children:e.label})]},e.id)})})}function CC({path:e}){let t=De(),n=e.split(`?`)[0].split(`/`).filter(Boolean)[0]??``;return(0,z.jsxs)(z.Fragment,{children:[t.git&&(0,z.jsxs)(`span`,{className:`relative inline-flex flex-none`,children:[(0,z.jsx)(q,{icon:`cloud_sync`,label:`git`,href:`/git`,className:n===`git`?`text-accent`:void 0}),(0,z.jsx)(wC,{})]}),(0,z.jsx)(q,{icon:`delete`,label:`trash`,href:`/trash`,className:n===`trash`?`text-accent`:void 0})]})}function wC(){let e=F(`git.status`,{},{interval:15e3}),t=e?.files?.filter(e=>e.syncable).length??0,n=e?.behind?`${e.behind}↓`:e?.ahead?`${e.ahead}↑`:t?String(t):``;return n?(0,z.jsx)(`span`,{className:I(`git-badge pointer-events-none absolute -top-1 -right-1.5 rounded-full bg-surface-2 px-1 text-[10px] leading-[14px] font-semibold tabular-nums`,e?.behind?`text-accent`:e?.ahead?`text-ok`:`text-fg-2`),children:n}):null}var TC=``,EC=e=>{let t=e.replace(/^# .*\n+/,``).replace(/\(human:user\)/g,`(you)`);return TC?t.split(`(${TC})`).join(`(you)`):t},DC=`flex flex-col gap-1.5 px-1.5 pb-6 pt-3`,OC=`m-0 px-2.5 pb-0.5 text-md leading-[1.45] text-fg`,kC=`m-0 px-2.5 py-0.5 text-sm text-fg-2`,AC=`md-body px-2.5 text-sm leading-normal`,jC=e=>fo.sanitize(Mi.parse(EC(e),{async:!1}));function MC(e,t){let n=[],r=``;for(let i of e.split(`
487
+ `)){let e=/^## (.+)$/.exec(i.trim());if(e?r=e[1]:/^[-*] /.test(i)&&n.push({day:r,text:i.replace(/^[-*] /,``)}),n.length>=t)break}return n}function NC({items:e}){return e.length===0?null:(0,z.jsx)(at,{size:`lg`,title:`needs you`,count:e.length,children:e.map(e=>(0,z.jsx)(gt,{onClick:()=>ds(e),leading:(0,z.jsx)(B,{name:as(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${e.owner.agent?`${e.owner.agent.emoji??``} ${e.owner.agent.name} · `:``}${os(e.kind)} · ${G(e.since)}`},e.id))})}function PC({slugs:e,agents:t,status:n,title:r=`team`}){let i=e.map(e=>t.find(t=>t.slug===e)).filter(e=>!!e);return i.length===0?null:(0,z.jsx)(at,{size:`lg`,title:r,children:i.map(e=>{let t=kS(n?.[e.slug],e.description);return(0,z.jsx)(gt,{href:`/agents/${encodeURIComponent(e.slug)}`,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:e.emoji||`🤖`}),title:e.name,sub:t?.text,subTone:t?.tone===`waiting`?`bad`:t?.tone===`working`?`accent`:`plain`},e.slug)})})}function FC({scope:e}){let t=F(`files.recent`,{query:{scope:e}},{interval:2e4});return!t||t.count===0?null:(0,z.jsx)(at,{size:`lg`,title:`files`,count:t.count,action:(0,z.jsxs)(K,{variant:`quiet`,size:`sm`,href:Cs(e),children:[`all `,(0,z.jsx)(B,{name:`arrow_forward`,className:`ms-sm`})]}),children:t.recent.map(t=>{let n=t.path.includes(`/`)?t.path.slice(0,t.path.lastIndexOf(`/`)):``;return(0,z.jsx)(gt,{href:Cs(e,n,t.path),leading:(0,z.jsx)(B,{name:`draft`,className:`ms-sm`}),title:t.path.split(`/`).pop(),sub:`${n?`${n}/ · `:``}${G(t.at)}`},t.path)})})}function IC({of:e}){TC=F(`me.get`,{},{interval:3e5})?.actor??``;let t=rs()??[],n=F(`agents.list`,{},{interval:15e3})?.agents??[],r=F(`agents.status`,{},{interval:5e3})??void 0;if(e.kind===`project`){let i=e.project,a=i.links.agents.map(e=>e.slug),o=MC(i.log,5);return(0,z.jsxs)(`div`,{className:DC,children:[(0,z.jsx)(at,{size:`lg`,title:`goal`,children:(0,z.jsxs)(`p`,{className:OC,children:[i.goal||(0,z.jsx)(`span`,{className:`text-fg-2`,children:`No goal written yet.`}),i.status!==`active`&&(0,z.jsxs)(`span`,{className:`text-fg-2`,children:[` · `,i.status]})]})}),o.length>0&&(0,z.jsx)(at,{size:`lg`,title:`lately`,children:o.map((e,t)=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[74px_minmax(0,1fr)] gap-2 px-2.5 py-1 text-sm`,children:[(0,z.jsx)(`span`,{className:`pt-px text-xs tabular-nums text-fg-2`,children:e.day}),(0,z.jsx)(`span`,{dangerouslySetInnerHTML:{__html:fo.sanitize(Mi.parseInline(EC(e.text),{async:!1}))}})]},t))}),(0,z.jsx)(NC,{items:is.project(t,i.slug,a)}),(0,z.jsx)(PC,{slugs:a,agents:n,status:r}),(0,z.jsx)(at,{size:`lg`,title:`where it stands`,children:i.state.trim()?(0,z.jsx)(`div`,{className:AC,dangerouslySetInnerHTML:{__html:jC(i.state)}}):(0,z.jsx)(`p`,{className:kC,children:`Nothing recorded yet: the project's chat writes this down at the end of a session that changed something.`})}),(0,z.jsx)(FC,{scope:`project:${i.slug}`}),i.records.length>0&&(0,z.jsx)(at,{size:`lg`,title:`systems of record`,children:i.records.map((e,t)=>(0,z.jsx)(gt,{onClick:()=>e.url&&window.open(e.url,`_blank`,`noopener`),leading:(0,z.jsx)(B,{name:`open_in_new`,className:`ms-sm`}),title:e.title||e.kind,sub:e.note},t))})]})}if(e.kind===`agent`)return(0,z.jsx)(LC,{agent:e.agent,journal:e.journal,waiting:t,status:r});if(e.kind===`channel`){let i=e.channel;return(0,z.jsxs)(`div`,{className:DC,children:[(0,z.jsx)(`p`,{className:OC,children:i.purpose||(0,z.jsxs)(`span`,{className:`text-fg-2`,children:[`A group chat with `,i.members.length,` agent`,i.members.length===1?``:`s`,`.`]})}),(0,z.jsx)(NC,{items:is.channel(t,i.slug)}),(0,z.jsx)(PC,{slugs:i.members,agents:n,status:r,title:`in this channel`})]})}return(0,z.jsx)(RC,{waiting:t,agents:n,status:r})}function LC({agent:e,journal:t,waiting:n,status:r}){let i=F(`projects.list`,{},{interval:3e4})?.projects??[],a=F(`agents.routines`,{slug:e.slug},{interval:3e4})?.routines??[],[o,s]=(0,v.useState)(t);(0,v.useEffect)(()=>s(t),[t]);let c=kS(r?.[e.slug],e.description),l=i.filter(t=>t.agents.includes(e.slug));return(0,z.jsxs)(`div`,{className:DC,children:[(0,z.jsx)(`p`,{className:OC,children:e.description||(0,z.jsx)(`span`,{className:`text-fg-2`,children:`No description yet.`})}),c&&c.text!==e.description&&(0,z.jsx)(`p`,{className:`m-0 px-2.5 text-sm ${c.tone===`waiting`?`text-bad`:c.tone===`working`?`text-accent`:`text-fg-2`}`,children:c.text}),(0,z.jsx)(NC,{items:is.agent(n,e.slug)}),l.length>0&&(0,z.jsx)(at,{size:`lg`,title:`works on`,children:l.map(e=>(0,z.jsx)(gt,{href:`/projects/${encodeURIComponent(e.slug)}`,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),title:e.title,sub:e.goal||void 0},e.slug))}),a.length>0&&(0,z.jsx)(at,{size:`lg`,title:`schedule`,children:a.map(e=>(0,z.jsx)(gt,{leading:(0,z.jsx)(B,{name:`schedule`,className:`ms-sm`}),title:e.name,sub:`${e.enabled?e.nextRunAt?`next ${new Date(e.nextRunAt).toLocaleString([],{weekday:`short`,hour:`2-digit`,minute:`2-digit`})}`:e.schedule:`paused`}${e.lastRunAt?` · last ${G(e.lastRunAt)}`:``}`},e.id))}),(0,z.jsxs)(at,{size:`lg`,title:`journal`,children:[(0,z.jsx)(zC,{slug:e.slug,onAdded:s}),(0,z.jsx)(`div`,{className:AC,dangerouslySetInnerHTML:{__html:jC(EC(o)||`_Nothing yet: the agent notes what it learns, decides and promises here, and reads it back at the start of every session._`)}})]})]})}function RC({waiting:e,agents:t,status:n}){let r=F(`projects.list`,{},{interval:3e4}),i=(r?.projects??[]).filter(e=>e.status===`active`);return(0,z.jsxs)(`div`,{className:DC,children:[(0,z.jsx)(NC,{items:e}),r?.enabled&&(0,z.jsxs)(at,{size:`lg`,title:`projects`,count:i.length,children:[i.length===0&&(0,z.jsx)(`p`,{className:kC,children:`No active projects.`}),i.map(t=>{let n=is.project(e,t.slug,t.agents).length;return(0,z.jsx)(gt,{href:`/projects/${encodeURIComponent(t.slug)}`,leading:(0,z.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),title:t.title,sub:n?`${n} waiting for you`:t.goal||`no goal yet`,subTone:n?`bad`:`plain`},t.slug)})]}),(0,z.jsx)(PC,{slugs:t.filter(e=>!e.archived).map(e=>e.slug),agents:t,status:n,title:`agents`}),(0,z.jsx)(FC,{scope:`workspace`})]})}function zC({slug:e,onAdded:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=async()=>{if(!n.trim())return;a(!0),s(``);let i=await A.request(`agents.addJournal`,{slug:e,body:{entry:n,kind:`note`}}).then(e=>e.ok?{error:void 0,journal:e.data?.journal}:{error:P(e),journal:void 0}).catch(e=>({error:e.message,journal:void 0}));if(a(!1),i.error||i.journal===void 0)return s(i.error??`could not save`);r(``),t(i.journal)};return(0,z.jsxs)(`div`,{className:`px-2.5 pb-1.5 pt-0.5`,children:[(0,z.jsx)(Z,{className:`h-8 text-sm`,value:n,placeholder:`add a note for the agent to remember`,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&void c(),disabled:i}),o&&(0,z.jsx)(rt,{tone:`bad`,children:o})]})}var BC=[{id:`contacts`,icon:`person`},{id:`places`,icon:`location_on`},{id:`events`,icon:`event`}];function VC(e){let t=e.split(`/`).filter(Boolean),n=t[1]?decodeURIComponent(t[1]):``;return t[0]===`projects`&&n&&n!==`new`?{kind:`project`,slug:n}:t[0]===`channels`&&n&&n!==`new`?{kind:`channel`,slug:n}:(t[0]===`agents`||t[0]===`team`)&&n&&n!==`new`&&n!==`chats`?{kind:`agent`,slug:n}:{kind:`general`}}function HC(e){let t=new Date(e),n=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),r=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),i=Math.round((r(t)-r(new Date))/864e5);return i===0?`today ${n}`:i===1?`tomorrow ${n}`:i>1&&i<7?`${t.toLocaleDateString([],{weekday:`short`})} ${n}`:`${t.toLocaleDateString([],{day:`numeric`,month:`short`})} ${n}`}var UC=(e,t)=>e.map(e=>({slug:e,found:t.has(e)}));function WC({chatPath:e,workspace:t}){let n=VC(e),r=e.split(`/`).filter(Boolean),i=r[0]===`agents`&&r[1]===`chats`,a=r[0]===`agents`&&n.kind===`agent`,o=(r[0]===`projects`||a)&&r[2]===`chat`&&r[3]&&r[3]!==`new`?r[3]:i&&r[2]&&r[2]!==`new`?r[2]:void 0,s=n.kind===`project`?`/projects/${encodeURIComponent(n.slug)}`:a?`/agents/${encodeURIComponent(n.slug)}`:i?`/agents/chats`:void 0,c=`${n.kind}:${`slug`in n?n.slug:``}`,l=F(`chats.list`,o?{}:null,{interval:3e4}),u=o?l?.chats.find(e=>e.id===o):void 0,d=u?.task??(u?.scope.kind===`agent`?u.scope.task:void 0),f=d?rc(d):null,p=De(),[m,h]=n.kind===`project`?[`/projects/${encodeURIComponent(n.slug)}/info`,`edit the project: brief, state, records, links`]:n.kind===`agent`?[`/agents/${encodeURIComponent(n.slug)}/info`,`edit the agent: profile and settings`]:n.kind===`channel`?[`/channels/${encodeURIComponent(n.slug)}/edit`,`edit the channel`]:[`/settings`,`workspace settings`],g=F(`workflows.list`,{},{interval:15e3}),_=F(`runs.list`,{},{interval:6e3}),y=F(`routines.list`,{},{interval:3e4}),[b,x]=(0,v.useState)(null),S=F(`knowledge.list`,{},{interval:15e3}),C=F(`vibeables.list`,p.vibeables?{}:null,{interval:15e3}),w=F(`boards.list`,p.boards&&n.kind===`project`?{query:{project:n.slug}}:null,{interval:15e3}),T=n.kind===`project`?w?.boards??[]:[],E=F(`presentations.list`,p.presentations&&n.kind===`project`?{query:{project:n.slug}}:null,{interval:15e3}),D=n.kind===`project`?E?.presentations??[]:[],[O,k]=(0,v.useState)(null),[ee,j]=(0,v.useState)(0),M=()=>{try{return localStorage.getItem(`kw-ctx-tab`)||`overview`}catch{return`overview`}},[N,P]=(0,v.useState)(M),[I,te]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>R(`browser`);return window.addEventListener(po,e),()=>window.removeEventListener(po,e)},[]);let R=e=>{P(e);try{localStorage.setItem(`kw-ctx-tab`,e)}catch{}};(0,v.useEffect)(()=>{P(d?`task`:e=>e===`task`?M():e)},[o,d]);let[re,ie]=(0,v.useState)({});(0,v.useEffect)(()=>ie(ge.current?{vibeables:`/vibeables/${encodeURIComponent(ge.current.slug)}`}:{}),[c]);let[ae,oe]=(0,v.useState)(!1);(0,v.useEffect)(()=>oe(!1),[c]);let se=ne(),ce=n.kind===`project`?new URLSearchParams(se.split(`?`)[1]??``).get(`app`):null;(0,v.useEffect)(()=>{ce&&(R(`vibeables`),ie(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(ce)}`})),oe(!0))},[ce,c]);let le=e=>ie(t=>({...t,[xe]:e})),[ue,de]=(0,v.useState)({dir:``});(0,v.useEffect)(()=>de({dir:``}),[c]);let V=async(e,t,n)=>{(await A.request(`projects.link`,{slug:e,body:{kind:`vibeables`,target:t,remove:n}}).catch(()=>null))?.ok&&j(e=>e+1)},fe=()=>{oe(!1),ie(e=>({...e,[xe]:null}))},pe=e=>t=>t.startsWith(e)?(ie(e=>({...e,[xe]:t})),!0):!1,[H,he]=(0,v.useState)(null),ge=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;ge.current=t,he(t),t?(R(`vibeables`),ie(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(t.slug)}`}))):ie(e=>e.vibeables?.startsWith(`/vibeables/`)?{...e,vibeables:null}:e)};return window.addEventListener(Xt,e),()=>window.removeEventListener(Xt,e)},[]);let ve=p.repos&&!!O?.repos,ye=n.kind===`project`?`project:${n.slug}`:O?.channel?.project?`project:${O.channel.project}`:`workspace`,be=[...f?[{id:`task`,label:`task`,allHref:Ws(f,f.task)}]:[],{id:`overview`,label:`overview`},{id:`files`,label:`files`,allHref:`/files/${encodeURIComponent(ye)}`},{id:`knowledge`,label:`knowledge`,count:O?.knowledge.length,allHref:`/knowledge`},...p.vibeables?[{id:`vibeables`,label:`apps`,count:O?.all?C?.vibeables.length:O?.vibeables?.length??0,allHref:`/vibeables`}]:[],{id:`workflows`,label:`workflows`,count:O?.workflows.length,allHref:`/workflows`},...p.boards&&n.kind===`project`?[{id:`board`,label:`boards`,count:T.reduce((e,t)=>e+t.review,0)||void 0,allHref:`/projects/${encodeURIComponent(n.slug)}/boards`}]:[],...p.presentations&&n.kind===`project`?[{id:`presentations`,label:`presentations`,count:D.length,allHref:`/projects/${encodeURIComponent(n.slug)}/presentations`}]:[],...ve?[{id:`repos`,label:`repositories`,count:O?.repos?.length,allHref:`/repos`}]:[],...BC.filter(e=>p[e.id]&&O?.[e.id]).map(e=>({id:e.id,label:e.id,count:O?.[e.id]?.length,allHref:`/${e.id}`})),...I>0||N===`browser`?[{id:`browser`,label:`browser`,count:I}]:[]],xe=be.some(e=>e.id===N)?N:`overview`,Se=be.find(e=>e.id===xe),Ce=re[xe]??null,we=!!H&&xe===`vibeables`&&Ce===`/vibeables/${encodeURIComponent(H.slug)}`,Te=xe===`vibeables`&&!!Ce,Ee=ae&&Te,Oe=e=>t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),le(e))};(0,v.useEffect)(()=>{let e=setInterval(()=>j(e=>e+1),15e3);return()=>clearInterval(e)},[]);let ke=me(se),Ae=(0,v.useRef)(ke);(0,v.useEffect)(()=>{Ae.current&&!ke&&j(e=>e+1),Ae.current=ke},[ke]),(0,v.useEffect)(()=>{let e=!0,r=new Set((g?.workflows??[]).map(e=>e.slug)),i=new Set((S?.bundles??[]).map(e=>e.name)),a=new Set((C?.vibeables??[]).map(e=>e.slug));return(async()=>{let o=null;if(n.kind===`agent`){let e=await A.call(`agents.get`,{slug:n.slug}).catch(()=>null);e&&(o={title:`${e.emoji?`${e.emoji} `:``}${e.name}`,agent:e,workflows:UC(e.workflows,r),knowledge:UC(e.knowledge,i),editHref:`/agents/${encodeURIComponent(n.slug)}/edit`},(e.vibeables??[]).length>0&&(o.vibeables=UC(e.vibeables,a)),o.journal=(await A.call(`agents.journal`,{slug:n.slug}).catch(()=>null))?.journal??``)}else if(n.kind===`project`){let e=await A.call(`projects.get`,{slug:n.slug}).catch(()=>null);e&&(o={title:`📁 ${e.title}`,project:e,workflows:e.links.workflows,knowledge:e.links.knowledge,vibeables:e.links.vibeables,repos:e.links.repos,agents:e.links.agents,contacts:e.links.contacts,places:e.links.places,events:e.links.events,records:e.records,state:e.state,log:e.log,editHref:`/projects/${encodeURIComponent(n.slug)}/info`})}else if(n.kind===`channel`){let e=(await A.call(`channels.list`).catch(()=>null))?.channels.find(e=>e.slug===n.slug);if(e){let t=(await Promise.all(e.members.map(e=>A.call(`agents.get`,{slug:e}).catch(()=>null)))).filter(e=>!!e),s=e=>[...new Set(t.flatMap(e))],c=s(e=>e.vibeables??[]);o={title:`#${e.slug}`,channel:e,workflows:UC(s(e=>e.workflows),r),knowledge:UC(s(e=>e.knowledge),i),...c.length>0?{vibeables:UC(c,a)}:{},agents:e.members.map(e=>({slug:e,found:t.some(t=>t.slug===e),label:t.find(t=>t.slug===e)?.name})),editHref:`/channels/${encodeURIComponent(n.slug)}/edit`}}}else o={title:`${t.icon?`${t.icon} `:``}${t.name||`workspace`}`,workflows:UC([...r],r),knowledge:UC([...i],i),all:!0};e&&k(o)})(),()=>{e=!1}},[c,ee,g,S,C,t.name,t.icon]);let je=e=>g?.workflows.find(t=>t.slug===e),Me=e=>e?_?.runs.find(t=>t.workflow===(e.name??e.slug)||t.workflow===e.slug):void 0,Ne=e=>S?.bundles.find(t=>t.name===e),Pe=e=>C?.vibeables.find(t=>t.slug===e),Fe=e=>(0,z.jsxs)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:[O?.all?`No ${e} in this workspace yet.`:`No ${e} linked.`,O?.editHref&&!O.all&&(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(U,{href:O.editHref,className:`text-accent`,children:`Edit the links`}),`.`]})]});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`space-title flex min-w-0 items-center gap-2 px-1`,children:[s?(0,z.jsx)(U,{href:s,className:`project-home-link min-w-0 truncate rounded-control text-[22px] leading-[1.15] font-[750] tracking-[-0.015em] text-fg no-underline animate-fade hover:text-accent max-[800px]:text-lg`,title:`${O?.title??``} · all sessions`,children:O?O.title:`…`},O?.title??``):(0,z.jsx)(`span`,{className:`min-w-0 truncate text-[22px] leading-[1.15] font-[750] tracking-[-0.015em] text-fg animate-fade max-[800px]:text-lg`,title:O?.title,children:O?O.title:`…`},O?.title??``),m&&(0,z.jsx)(U,{href:m,className:`ctx-edit inline-grid size-7 flex-none place-items-center rounded-full text-fg-2 no-underline transition-colors hover:bg-surface-2 hover:text-accent active:scale-96 [&_.ms]:text-[18px]`,title:h,"aria-label":h,children:(0,z.jsx)(B,{name:`edit`,className:`ms-sm`})}),o&&s&&(0,z.jsx)(Sn,{id:o,fallbackTitle:i||a?`new chat`:`new session`,backHref:s},o)]}),(0,z.jsxs)(`aside`,{className:`ctx`,"aria-label":`Context`,"data-full":Ee||void 0,children:[(0,z.jsx)(_t,{className:`flex-none gap-y-0.5 pt-2`,label:`Categories`,items:be,value:xe,onChange:R}),Ce&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2`,children:[(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`arrow_back`,onClick:fe,"aria-label":`Back to the list`,children:Se?.label}),(0,z.jsx)(`span`,{className:`flex-1`}),Te&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:Ee?`close_fullscreen`:`open_in_full`,onClick:()=>oe(!Ee),title:Ee?`back beside the chat`:`full size, in place of the chat`,children:Ee?`beside the chat`:`full size`}),(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`open_in_new`,href:Ce,title:`Open as a page`,children:`page`})]}),Ce&&xe===`knowledge`&&(0,z.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,z.jsx)(_e.Provider,{value:pe(`/knowledge/`),children:(()=>{let e=Ce.split(`/`).filter(Boolean),t=decodeURIComponent(e[1]??``),n=e.length>2?e.slice(2).map(decodeURIComponent).join(`/`):void 0;return(0,z.jsx)(F_,{name:t,conceptId:n},t)})()})}),Ce&&xe===`workflows`&&(0,z.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,z.jsx)(_e.Provider,{value:pe(`/workflows/`),children:(()=>{let e=Ce.split(`/`).filter(Boolean),t=e[2]===`details`||e[2]===`runs`?e[2]:`overview`;return(0,z.jsx)(p_,{slug:decodeURIComponent(e[1]??``),tab:t},e[1])})()})}),Ce&&xe===`vibeables`&&!we&&(0,z.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,z.jsx)(en,{slug:decodeURIComponent(Ce.split(`/`).filter(Boolean)[1]??``)},Ce)}),(0,z.jsx)(`div`,{id:Zt,className:`ctx-body ctx-embed ctx-embed-vibe`,hidden:!we}),(0,z.jsx)(`div`,{className:`ctx-body ctx-embed ctx-browser`,hidden:xe!==`browser`,children:(0,z.jsx)(bo,{storeKey:c,onTabs:te},c)}),(0,z.jsxs)(`div`,{className:`ctx-body`,role:`tabpanel`,hidden:xe===`browser`||!!Ce&&[`knowledge`,`workflows`,`vibeables`].includes(xe),children:[Se?.allHref&&(0,z.jsx)(`div`,{className:`flex justify-end px-1 pb-1`,children:(0,z.jsxs)(K,{variant:`quiet`,size:`sm`,href:Se.allHref,children:[`all `,Se.label,` `,(0,z.jsx)(B,{name:`arrow_forward`,className:`ms-sm`})]})}),xe===`workflows`&&(0,z.jsxs)(z.Fragment,{children:[O&&O.workflows.length===0&&Fe(`workflows`),O?.workflows.map(({slug:e,found:t})=>{let n=je(e),r=Me(n),i=t&&!!n&&!n.error,a=(y?.routines??[]).filter(t=>t.workflows.includes(e));return(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,z.jsx)(gt,{href:`/workflows/${encodeURIComponent(e)}`,onClick:t?Oe(`/workflows/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,z.jsx)(et,{tone:!t||n?.error?`bad`:KC(r?.status)}),title:n?.name??e,sub:t?n?.error?`broken`:r?`${r.status} · ${G(r.updatedAt)}`:n?.description??`no runs yet`:`not in this workspace`,actionsAlways:!0,actions:i?(0,z.jsx)(q,{size:`sm`,icon:b===e?`close`:`play_arrow`,label:b===e?`close the launcher of ${n.name??e}`:`run ${n.name??e}`,"aria-expanded":b===e,onClick:()=>x(b===e?null:e)}):void 0}),a.map(e=>(0,z.jsxs)(U,{href:e.owner===`_`?`/?kind=routines&open=${encodeURIComponent(`routines:_:${e.id}`)}`:`/agents/${encodeURIComponent(e.owner)}/info`,className:`routine-line flex min-w-0 items-center gap-1.5 pt-0.5 pb-2 pl-[46px] pr-3 text-xs text-fg-2 no-underline hover:text-fg`,title:`${e.agent?`${e.agent.name}'s routine`:`The routine`} "${e.name}" (${e.schedule}) runs this workflow: ${e.prompt}`,children:[(0,z.jsx)(B,{name:`schedule`,className:`ms-sm flex-none text-[14px]`}),(0,z.jsxs)(`span`,{className:`min-w-0 truncate`,children:[fb(e),` · `,e.name,` · `,e.enabled?e.nextRunAt?`next ${HC(e.nextRunAt)}`:e.schedule:`paused`]})]},`${e.owner}/${e.id}`)),b===e&&n&&(0,z.jsx)(`div`,{className:`mx-1 mb-2`,children:(0,z.jsx)(Eg,{slug:e,usesRequest:n.usesRequest,onLaunched:()=>{x(null),le(`/workflows/${encodeURIComponent(e)}`)}})})]},e)})]}),xe===`knowledge`&&(0,z.jsxs)(z.Fragment,{children:[O&&O.knowledge.length===0&&Fe(`knowledge`),O?.knowledge.map(({slug:e,found:t})=>{let n=Ne(e);return(0,z.jsx)(gt,{href:`/knowledge/${encodeURIComponent(e)}`,onClick:t?Oe(`/knowledge/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,z.jsx)(B,{name:`menu_book`,className:`ms-sm`}),title:e,sub:t?n?`${n.concepts} ${n.concepts===1?`page`:`pages`}${n.updatedAt?` · ${G(n.updatedAt)}`:``}`:void 0:`not in this workspace`},e)})]}),xe===`vibeables`&&O&&(0,z.jsxs)(z.Fragment,{children:[(O.all?(C?.vibeables??[]).map(e=>({slug:e.slug,found:!0})):O.vibeables??[]).map(({slug:e,found:t})=>{let r=Pe(e);return(0,z.jsx)(gt,{href:`/vibeables/${encodeURIComponent(e)}`,onClick:t?Oe(`/vibeables/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,z.jsx)(B,{name:`web`,className:`ms-sm`}),title:e,sub:t?r?.updatedAt?`changed ${G(r.updatedAt)}`:void 0:`not in this workspace`,actions:n.kind===`project`?(0,z.jsx)(q,{icon:`keep_off`,size:`sm`,label:`unpin ${e}`,onClick:()=>void V(n.slug,e,!0)}):void 0},e)}),n.kind===`project`&&C&&(0,z.jsx)(GC,{options:C.vibeables.map(e=>e.slug).filter(e=>!O.vibeables?.some(t=>t.slug===e)),onPin:e=>void V(n.slug,e,!1)}),O.all&&C&&C.vibeables.length===0&&Fe(`vibeables`),!O.all&&O.vibeables?.length===0&&Fe(`vibeables`)]}),BC.map(e=>xe===e.id&&O?.[e.id]&&(0,z.jsxs)(v.Fragment,{children:[O[e.id].length===0&&Fe(e.id),O[e.id].map(({slug:t,found:n,label:r})=>(0,z.jsx)(gt,{href:`/${e.id}/${encodeURIComponent(t)}`,dim:!n,leading:(0,z.jsx)(B,{name:e.icon,className:`ms-sm`}),title:n&&r?r:t,sub:n?r?t:void 0:`not in this workspace`},t))]},e.id)),xe===`board`&&n.kind===`project`&&(0,z.jsxs)(z.Fragment,{children:[w&&w.enabled&&T.length===0&&(0,z.jsxs)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:[`No board yet. `,(0,z.jsx)(U,{href:`/projects/${encodeURIComponent(n.slug)}/boards`,className:`text-accent`,children:`Open the tasks board`}),` — it is created on first use.`]}),w&&!w.enabled&&(0,z.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:w.error}),T.map(e=>(0,z.jsx)(fc,{project:e.project,board:e.board},`${e.project??``}/${e.board}`))]}),xe===`presentations`&&n.kind===`project`&&(0,z.jsxs)(z.Fragment,{children:[E&&!E.enabled&&(0,z.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:E.error}),E?.enabled&&D.length===0&&Fe(`presentations`),D.map(e=>(0,z.jsx)(gt,{href:`/projects/${encodeURIComponent(n.slug)}/presentations/${encodeURIComponent(e.name)}`,innerProps:{"data-deck":e.name},leading:(0,z.jsx)(B,{name:`slideshow`,className:`ms-sm`}),title:e.title,sub:e.error?`unreadable deck.md`:`${e.slides} ${e.slides===1?`slide`:`slides`}${e.updatedAt?` · ${G(e.updatedAt)}`:``}`,subTone:e.error?`bad`:`plain`},e.name)),E?.enabled&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`add`,className:`justify-start`,href:`/projects/${encodeURIComponent(n.slug)}/presentations/new`,children:`new presentation`})]}),xe===`repos`&&O?.repos&&(0,z.jsxs)(z.Fragment,{children:[O.repos.length===0&&Fe(`repositories`),O.repos.map(({slug:e,found:t})=>(0,z.jsx)(gt,{href:`/repos/${encodeURIComponent(e)}`,dim:!t,leading:(0,z.jsx)(B,{name:`source`,className:`ms-sm`}),title:e,sub:t?void 0:`not in this workspace`},e))]}),xe===`task`&&f&&(0,z.jsx)(ic,{project:f.project,board:f.board,task:f.task,embedded:!0},d),xe===`overview`&&O&&(0,z.jsx)(IC,{of:O.project?{kind:`project`,project:O.project}:O.agent?{kind:`agent`,agent:O.agent,journal:O.journal??``}:O.channel?{kind:`channel`,channel:O.channel}:{kind:`workspace`}},c),xe===`files`&&(0,z.jsx)(As,{compact:!0,scope:ye,dir:ue.dir,file:ue.file,onOpen:(e,t)=>de({dir:e,file:t})},ye)]},xe)]})]})}function GC({options:e,onPin:t}){return e.length===0?null:(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-2 text-fg-2`,children:[(0,z.jsx)(B,{name:`keep`,className:`ms-sm`}),(0,z.jsxs)(St,{className:`h-8 text-sm`,value:``,onChange:e=>e.target.value&&t(e.target.value),"aria-label":`pin an app to this project`,children:[(0,z.jsx)(`option`,{value:``,children:`pin an app to this project…`}),e.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]})}function KC(e){return e===`ok`?`ok`:e===`failed`?`bad`:e===`running`?`working`:`idle`}var qC=`kw-chat-path`,JC=`kw-ctx-w`,YC=()=>{try{let e=Number(localStorage.getItem(JC));return e>0?e:null}catch{return null}};function XC({onResize:e}){let[t,n]=(0,v.useState)(!1);return(0,z.jsx)(`div`,{className:`split-handle${t?` dragging`:``}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`resize chat and context`,title:`drag to resize · double-click for one third · two thirds`,onPointerDown:t=>{if(t.button!==0)return;let r=t.currentTarget.closest(`.shell`);if(!r)return;t.preventDefault();let i=r.getBoundingClientRect().right-parseFloat(getComputedStyle(r).paddingRight),a=t=>e(Math.round(i-t.clientX)),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),document.body.classList.remove(`kw-resizing`),n(!1)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),document.body.classList.add(`kw-resizing`),n(!0)},onDoubleClick:()=>e(null)})}var ZC=(e,t)=>{try{return sessionStorage.getItem(e)||t}catch{return t}},QC=(e,t)=>{try{sessionStorage.setItem(e,t)}catch{}};function $C(){let e=ne();ms();let[t]=e.split(`?`),n=t.split(`/`).filter(Boolean),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)([]),_=de(t),y=V(t),b=ue.has(n[0]??``)&&!_&&!y,x=n.length===0||n[0]===`artifacts`,S=n[0]===`today`,C=x||S,w=b&&n[0]===`projects`&&n.length===2&&n[1]!==`new`&&new URLSearchParams(e.split(`?`)[1]??``).has(`open`),[T,E]=(0,v.useState)(()=>ZC(qC,`/agents/chats`)),D=b?qx(t):null,O=b&&!D?t:T,[k,ee]=(0,v.useState)(`chat`),[A,j]=(0,v.useState)(YC),M=e=>{j(e);try{e===null?localStorage.removeItem(JC):localStorage.setItem(JC,String(e))}catch{}};(0,v.useEffect)(()=>{ee(e=>e===`side`?`chat`:e)},[e]),(0,v.useEffect)(()=>{b&&!qx(t)&&(E(t),QC(qC,t))},[e]),(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;fe(t)===`chat`?(E(t),QC(qC,t)):window.location.replace(`#${t}`)};return window.addEventListener(pe,e),()=>window.removeEventListener(pe,e)},[]);let N=F(`meta.get`,{},{interval:3e4});(0,v.useEffect)(()=>{let e=N;e&&(i(e.workspaceName??``),o(e.workspaceIcon??``),c(e.workspaceColor??``),u(e.workspaceNamed!==!1),f(e.workspaceRootLabel??``),m(e.workspaceRoot??``),Ee({git:!!e.git,repos:!!e.repos,vibeables:!!e.vibeables,projects:!!e.projects,contacts:!!e.contacts,places:!!e.places,events:!!e.events,boards:!!e.boards,presentations:!!e.presentations}),g(Array.isArray(e.switcher)?e.switcher:[]))},[N]),(0,v.useEffect)(()=>{if(ce(r?`${r} — kraftwerk`:`kraftwerk inspector`),!a)return;let e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="0.9em" font-size="85">${a}</text></svg>`,t=document.querySelector(`link[rel="icon"]`);t||(t=document.createElement(`link`),t.rel=`icon`,document.head.appendChild(t)),t.href=`data:image/svg+xml,${encodeURIComponent(e)}`},[r,a]);let P=O.split(`/`).filter(Boolean),I=new URLSearchParams(e.split(`?`)[1]??``).get(`workflow`)??void 0,te;te=P[0]===`chats`?(0,z.jsx)(Kx,{seg:P}):P[0]===`projects`?(0,z.jsx)(ex,{seg:P.slice(1)}):P[0]===`channels`?(0,z.jsx)(fn,{seg:P.slice(1)}):(0,z.jsx)(Kx,{seg:P.slice(1)});let R=null;_?R=(0,z.jsx)(sc,{seg:n.slice(3),project:decodeURIComponent(n[1])}):y?R=(0,z.jsx)(Lh,{seg:n.slice(3),project:decodeURIComponent(n[1])}):n[0]===`runs`&&n[1]?R=(0,z.jsx)(Ig,{id:n[1],workflow:I}):n[0]===`runs`?R=(0,z.jsx)(lw,{}):n[0]===`workflows`?R=(0,z.jsx)(Zx,{slug:n[1]?decodeURIComponent(n[1]):void 0,tab:n[2]===`details`||n[2]===`runs`?n[2]:`overview`}):n[0]===`vibeables`?R=(0,z.jsx)(un,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`knowledge`?R=(0,z.jsx)(D_,{bundle:n[1]?decodeURIComponent(n[1]):void 0,conceptId:n.length>2?n.slice(2).map(decodeURIComponent).join(`/`):void 0}):n[0]===`skills`?R=(0,z.jsx)(Fy,{name:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`settings`?R=n[1]===`agents`?(0,z.jsx)(US,{}):n[1]===`routines`?(0,z.jsx)(qS,{}):n[1]===`workflows`?(0,z.jsx)(YS,{}):n[1]===`knowledge`?(0,z.jsx)(ZS,{}):n[1]===`boards`?(0,z.jsx)(tC,{}):n[1]===`apps`?(0,z.jsx)(rC,{}):n[1]===`harnesses`?(0,z.jsx)(cC,{}):n[1]===`projects`?(0,z.jsx)(pC,{}):n[1]===`skills`?(0,z.jsx)(gC,{}):n[1]===`cloud`?(0,z.jsx)(Qv,{}):(0,z.jsx)(Ev,{}):n[0]===`trash`?R=(0,z.jsx)($x,{}):n[0]===`ui`?R=(0,z.jsx)(eS,{}):n[0]===`files`?R=(0,z.jsx)(Os,{scope:n[1]?decodeURIComponent(n[1]):`workspace`,dir:n.slice(2).map(decodeURIComponent).join(`/`),file:new URLSearchParams(e.split(`?`)[1]??``).get(`file`)??void 0}):n[0]===`workspaces`?R=(0,z.jsx)(iS,{}):n[0]===`git`?R=(0,z.jsx)(fy,{}):n[0]===`repos`?R=(0,z.jsx)(Ay,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`contacts`||n[0]===`places`||n[0]===`events`?R=(0,z.jsx)(hg,{kind:n[0],slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`boards`?R=(0,z.jsx)(sc,{seg:n.slice(1)}):n[0]===`presentations`&&(R=(0,z.jsx)(Lh,{seg:n.slice(1)}));let re=!!R&&!_&&!y&&xC(t);return(0,v.useEffect)(()=>{let e=document.documentElement,t=p||r,n=t?ze(ke(s,t)):null;if(!n)delete e.dataset.wsAccent;else{for(let[t,r]of Object.entries(n))e.style.setProperty(t,r);e.dataset.wsAccent=``}},[s,p,r]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`header`,{className:`topbar sticky top-0 z-10 flex h-[var(--topbar-h)] items-center gap-3.5 bg-bg px-5 shadow-[inset_0_-1px_0_var(--line)] max-[1520px]:gap-2.5 max-[800px]:gap-1.5 max-[800px]:px-3`,style:{"--ws-c":ke(s,p||r)},children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-none items-center gap-2.5 max-[800px]:flex-[0_1_auto] max-[800px]:gap-1`,children:[(0,z.jsx)(`a`,{href:`#/`,className:`grid size-8 place-items-center rounded-full text-[15px] leading-none transition-shadow hover:shadow-[0_0_0_4px_color-mix(in_srgb,var(--ws-c,var(--text))_16%,transparent)]`,title:`Home`,children:r?(0,z.jsx)(Ve,{size:`sm`,icon:a,name:r,color:s,seed:p||r}):(0,z.jsx)(B,{name:`home`})}),r&&(0,z.jsx)(cw,{name:r,icon:a,color:s,named:l,root:d,seed:p||r,entries:h})]}),(0,z.jsx)(`span`,{className:`flex-[1_1_8px]`}),(0,z.jsx)(SS,{}),(0,z.jsx)(CC,{path:t}),(0,z.jsx)(Xv,{}),(0,z.jsx)(q,{icon:`settings`,label:`settings`,href:`/settings`,"aria-current":n[0]===`settings`?`page`:void 0}),(0,z.jsx)(pw,{}),(0,z.jsx)(ps,{}),(0,z.jsx)(gw,{}),(0,z.jsx)(fw,{}),(0,z.jsx)(dw,{})]}),re&&(0,z.jsx)(SC,{path:t}),R&&(0,z.jsx)(`main`,{className:`shell shell-global`,style:re?{"--topbar-h":`108px`}:void 0,children:(0,z.jsx)(Xo,{children:R})}),(0,z.jsxs)(`main`,{className:`shell three${C?` home`:``}`,"data-focus":k,hidden:!!R,style:A?{"--ctx-w":`${A}px`}:void 0,children:[(0,z.jsx)(RS,{chatPath:x?`/`:S?`/today`:O}),(0,z.jsxs)(`section`,{className:`col-chat`,"aria-label":x?`Home`:S?`Today`:`Conversation`,children:[x?(0,z.jsx)(Fb,{}):S?(0,z.jsx)(nb,{}):te,(0,z.jsx)(XC,{onResize:M})]}),x||w?(0,z.jsx)(Ib,{}):(0,z.jsx)(WC,{chatPath:C?`/`:O,workspace:{name:r,icon:a}}),D&&(0,z.jsx)(Jx,{back:O,children:D})]}),!R&&(0,z.jsxs)(`nav`,{className:`places`,"aria-label":`Sections`,children:[(0,z.jsxs)(`button`,{className:k===`side`?`active`:``,onClick:()=>ee(`side`),children:[(0,z.jsx)(B,{name:`menu`}),` list`]}),(0,z.jsxs)(`button`,{className:k===`chat`?`active`:``,onClick:()=>ee(`chat`),children:[(0,z.jsx)(B,{name:`forum`}),` chat`]}),(0,z.jsxs)(`button`,{className:k===`context`?`active`:``,onClick:()=>ee(`context`),children:[(0,z.jsx)(B,{name:`account_tree`}),` context`]})]})]})}function ew(e){try{let t=new URL(e);return t.hostname===`localhost`||t.hostname===`127.0.0.1`?`:${t.port||(t.protocol===`https:`?443:80)}`:t.host}catch{return e.replace(/^https?:\/\//,``)}}var tw=`truncate text-sm text-fg-2 group-aria-[current=true]/ws:text-on-accent-soft group-aria-[current=true]/ws:opacity-80`,nw=`group/ws relative flex min-h-[60px] items-center gap-3.5 px-4 py-2.5 text-fg no-underline transition-colors`;function rw({label:e}){return e?(0,z.jsx)(`span`,{className:I(tw,`[direction:rtl] text-left`),title:e,children:(0,z.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})}):null}function iw({name:e,named:t}){let n=t===!1;return(0,z.jsx)(`span`,{className:I(`truncate text-md tracking-[0.2px]`,n&&`italic text-fg-2`,`group-data-[missing]/ws:line-through group-data-[stopped]/ws:text-fg-2`),title:n?`${e} — folder name; set name: in kraftwerk.yml`:e,children:e})}function aw({entry:e,ambiguous:t}){let[n,r]=(0,v.useState)(`idle`),[i,a]=(0,v.useState)(``),o=e.exists===!1,s=async()=>{r(`starting`),a(``);try{window.location.assign(await ge(e.root))}catch(e){r(`error`),a(e.message)}};return(0,z.jsxs)(`span`,{className:I(nw,`cursor-default`),role:`menuitem`,"data-stopped":``,"data-missing":o?``:void 0,style:{"--ws-c":ke(e.color,e.root??e.url)},children:[(0,z.jsx)(Ve,{className:`opacity-60 grayscale-50`,icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:t}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(iw,{name:e.name,named:e.named}),n===`error`?(0,z.jsx)(`span`,{className:I(tw,`text-bad`),title:i,children:i}):o?(0,z.jsx)(`span`,{className:tw,children:`folder missing`}):(0,z.jsx)(rw,{label:e.rootLabel})]}),(0,z.jsxs)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:[(0,z.jsx)(ow,{entry:e}),(0,z.jsx)(K,{variant:`quiet`,size:`sm`,icon:`play_arrow`,busy:n===`starting`,className:`text-accent hover:text-accent`,disabled:o,title:o?`The project folder no longer exists`:`Start the UI for this project`,onClick:e=>{e.stopPropagation(),s()},children:n===`starting`?`starting`:`start`})]})]})}function ow({entry:e}){return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap text-2xs font-medium tracking-[0.5px] text-fg-2`,children:[e.live&&(0,z.jsx)(et,{tone:`ok`,title:`running`}),!e.here&&(0,z.jsx)(`span`,{className:`max-[800px]:hidden`,children:ew(e.url)})]})}function sw({entry:e,ambiguous:t}){let n=e.root??e.url;return(0,z.jsxs)(`a`,{className:I(nw,`hover:bg-surface-2 active:bg-surface-2`),role:`menuitem`,href:he(e),style:{"--ws-c":ke(e.color,n)},children:[(0,z.jsx)(Ve,{icon:e.icon,name:e.name,color:e.color,seed:n,ambiguous:t}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(iw,{name:e.name,named:e.named}),(0,z.jsx)(rw,{label:e.rootLabel??(e.root?void 0:e.url.replace(/^https?:\/\//,``))})]}),(0,z.jsx)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:(0,z.jsx)(ow,{entry:e})})]})}function cw({name:e,icon:t,color:n,named:r,root:i,seed:a,entries:o}){let[s,c]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!s)return;let e=e=>{e.target.closest(`[data-switcher]`)||c(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]);let l=new Map;for(let e of[t,...o.map(e=>e.icon)])e&&l.set(e,(l.get(e)??0)+1);let u=e=>!!e&&(l.get(e)??0)>1,d=[{key:`running`,label:`running`,items:o.filter(e=>e.live===!0)},{key:`stopped`,label:`stopped`,items:o.filter(e=>e.live===!1)},{key:`linked`,label:`linked`,items:o.filter(e=>e.live===void 0)}].filter(e=>e.items.length>0),f=a||e;return(0,z.jsxs)(`span`,{className:`relative inline-flex min-w-0`,"data-switcher":``,children:[(0,z.jsxs)(`button`,{type:`button`,className:`env-switch inline-flex max-w-[220px] min-w-0 cursor-pointer items-center gap-[5px] rounded-xl border-0 bg-transparent px-2 py-1 font-[inherit] text-[15px] font-bold tracking-[0.02em] whitespace-nowrap text-fg transition-colors hover:bg-surface-2 max-[1520px]:max-w-[250px]`,title:i?`${i} — workspace menu`:`Workspace menu`,"aria-haspopup":`menu`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),(0,z.jsx)(B,{name:`expand_more`,className:`flex-none opacity-55`})]}),s&&(0,z.jsxs)(`div`,{className:`absolute top-[calc(100%+8px)] left-0 z-20 max-h-[calc(100dvh-120px)] max-w-[min(480px,92vw)] min-w-[360px] max-[800px]:fixed max-[800px]:inset-x-2 max-[800px]:top-[calc(var(--topbar-h)-4px)] max-[800px]:max-w-none max-[800px]:min-w-0 overflow-y-auto overscroll-contain rounded-card border border-line bg-surface py-2 shadow-pop`,role:`menu`,children:[o.length>0&&(0,z.jsx)(it,{className:`block px-4 pt-1 pb-2`,children:`workspaces`}),(0,z.jsxs)(`span`,{className:I(nw,`cursor-default bg-accent-soft text-on-accent-soft`),"aria-current":`true`,style:{"--ws-c":ke(n,f)},children:[(0,z.jsx)(Ve,{icon:t,name:e,color:n,seed:f,ambiguous:u(t)}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(iw,{name:e,named:r}),i?(0,z.jsx)(rw,{label:i}):(0,z.jsx)(`span`,{className:tw,children:`this workspace`})]}),(0,z.jsx)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:(0,z.jsx)(B,{name:`check`,className:`text-[24px] text-on-accent-soft`})})]}),d.map(e=>(0,z.jsxs)(`div`,{className:`mt-2 border-t border-line pt-1`,role:`group`,"aria-label":e.label,children:[(0,z.jsx)(it,{className:`block px-4 pt-2 pb-1`,children:e.label}),e.items.map(e=>e.live===!1&&e.root?(0,z.jsx)(aw,{entry:e,ambiguous:u(e.icon)},e.root):(0,z.jsx)(sw,{entry:e,ambiguous:u(e.icon)},e.root??e.url))]},e.key)),o.length>0&&(0,z.jsxs)(`a`,{className:`mt-2 flex min-h-12 items-center gap-4 border-t border-line px-4 text-md text-fg no-underline transition-colors hover:bg-surface-2`,href:`#/workspaces`,role:`menuitem`,onClick:()=>c(!1),children:[(0,z.jsx)(B,{name:`hub`,className:`text-[22px] text-fg-2`}),` manage workspaces`]}),(0,z.jsx)(yw,{onClose:()=>c(!1)})]})]})}function lw(){let[e,t]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let e=!0;return A.call(`runs.list`).then(n=>{e&&(n.runs.length>0?H(`/runs/${n.runs[0].id}`,{replace:!0}):t({outputDir:n.outputDir}))}).catch(()=>{}),()=>{e=!1}},[]),e?(0,z.jsxs)(Y,{icon:`play_circle`,children:[`No runs found in `,(0,z.jsx)(`code`,{children:e.outputDir}),`. Start one from the`,` `,(0,z.jsx)(`a`,{href:`#/workflows`,className:`text-accent`,children:`workflows`}),` list or with `,(0,z.jsx)(`code`,{children:`kraftwerk run <workflow> [request]`}),`.`]}):(0,z.jsx)(Y,{children:`loading…`})}async function uw(e){await A.request(`server.restart`).catch(()=>{});for(let t=0;t<60;t++){await new Promise(e=>setTimeout(e,500));try{if((await A.call(`meta.get`)).version===e)break}catch{}}location.reload()}function dw(){let e=F(`meta.get`,{},{interval:3e4}),[t,n]=(0,v.useState)(!1),r=e?.restartable&&e.diskVersion&&e.diskVersion!==e.version?e.diskVersion:null;async function i(){r&&(n(!0),await uw(r))}return!r&&!t?null:(0,z.jsx)(`button`,{type:`button`,className:`mr-2.5 inline-flex flex-none cursor-pointer items-center gap-1 rounded-full border border-accent bg-accent/10 px-3 py-1 font-[inherit] text-xs text-accent hover:bg-accent/18 disabled:cursor-default disabled:opacity-70`,disabled:t,title:`v${r} is installed on disk, the server still runs v${e?.version}. Click to relaunch with the new version.`,onClick:()=>void i(),children:t?`relaunching…`:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{name:`restart_alt`,className:`ms-sm`}),` v`,r,` ready — relaunch`]})})}function fw(){let e=F(`me.get`,{},{interval:6e4}),[t,n]=(0,v.useState)(!1);if(!e||e.mode!==`cloud`||!e.signedIn)return null;let r=async()=>{n(!0);let e=await fetch(`${A.baseUrl}/auth/signout`,{method:`POST`}).catch(()=>null),t=e?.ok?(await e.json()).signin:void 0;location.assign(t??`${A.baseUrl}/`)};return(0,z.jsx)(Nt,{align:`end`,trigger:({toggle:t})=>(0,z.jsx)(`button`,{type:`button`,"aria-label":`signed in as ${e.handle}`,title:`${e.handle} · ${e.email??``}`,onClick:t,className:`grid size-7 cursor-pointer place-items-center rounded-full border-0 bg-accent/15 text-xs font-semibold text-accent uppercase hover:bg-accent/25`,children:e.handle.slice(0,1)}),children:()=>(0,z.jsxs)(`div`,{className:`flex min-w-[220px] flex-col gap-1 p-3 text-sm`,children:[(0,z.jsxs)(`span`,{className:`font-medium`,children:[`@`,e.handle]}),e.email&&(0,z.jsx)(`span`,{className:`text-xs text-fg-2`,children:e.email}),(0,z.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[e.role,` · signed in with kraftwerk cloud`]}),(0,z.jsx)(K,{size:`sm`,variant:`quiet`,icon:`logout`,busy:t,onClick:()=>void r(),className:`mt-2 self-start`,children:`sign out`})]})})}function pw(){let e=Se();return(0,z.jsxs)(`button`,{type:`button`,className:I(`expert-toggle inline-flex cursor-pointer items-center gap-[7px] rounded-full border-0 bg-transparent px-2 py-1 font-mono text-2xs tracking-[0.5px] transition-colors hover:text-fg`,e?`text-fg`:`text-fg-2`),title:e?`Expert mode on — full detail`:`Expert mode off — simplified view`,"aria-pressed":e,onClick:()=>xe(!e),children:[(0,z.jsx)(`span`,{className:I(`relative h-[15px] w-[26px] rounded-full transition-colors`,e?`bg-accent`:`bg-fg/14`),children:(0,z.jsx)(`span`,{className:I(`absolute top-0.5 size-[11px] rounded-full transition-[left,background-color]`,e?`left-[13px] bg-on-accent`:`left-0.5 bg-surface`)})}),(0,z.jsx)(`span`,{className:`max-[640px]:hidden`,children:`expert`})]})}var mw={approval:`gavel`,routine_done:`schedule`,routine_failed:`schedule`,run_done:`account_tree`,run_failed:`account_tree`,task_woken:`view_kanban`,task_wake_failed:`view_kanban`,task_assigned:`assignment_ind`},hw=`kw.notif.toast.dismissed`;function gw(){let[e,t]=(0,v.useState)(!1),n=F(`notifications.list`,{},{interval:5e3}),[r,i]=(0,v.useState)(()=>typeof Notification>`u`?`unsupported`:Notification.permission),[a,o]=(0,v.useState)(()=>{try{return localStorage.getItem(hw)===`1`}catch{return!1}}),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>l(null),[n]);let f=(c??n)?.items??[],p=rs()??[],m=new Set(p.map(e=>e.notificationId).filter(Boolean)),h=f.filter(e=>e.kind!==`approval`&&!m.has(e.id)),g=h.filter(e=>!e.readAt).length,_=p.length;(0,v.useEffect)(()=>se(p.length),[p.length]),(0,v.useEffect)(()=>{if(n){if(!s.current)s.current=new Set(f.map(e=>e.id));else for(let e of f)if(!s.current.has(e.id)&&(s.current.add(e.id),!(e.readAt||r!==`granted`)&&(document.hidden||location.hash!==`#${e.href}`)))try{let t=new Notification(e.title,{body:e.body,tag:e.id});t.onclick=()=>{window.focus(),S(e),t.close()}}catch{}}},[n]),(0,v.useEffect)(()=>{if(!e)return;let n=e=>{e.target.closest(`[data-bell]`)||t(!1)};return window.addEventListener(`mousedown`,n),()=>window.removeEventListener(`mousedown`,n)},[e]);async function y(e){try{let t=await e;if(!t.ok)return;let n=t.data;l(`items`in n?n:{items:[],unread:0})}catch{}}let b=e=>y(A.request(`notifications.read`,{body:{ids:e}})),x=()=>y(A.request(`notifications.clear`));function S(e){t(!1),e.readAt||b([e.id]),H(e.href)}async function C(e){d(e.id);try{let n=await A.request(`notifications.diagnose`,{id:e.id});n.ok?(t(!1),H(n.data.href)):n.error&&alert(n.error)}catch{}d(null)}async function w(){typeof Notification<`u`&&i(await Notification.requestPermission())}function T(){o(!0);try{localStorage.setItem(hw,`1`)}catch{}}let E=r==="default"&&!a;return(0,z.jsxs)(`span`,{className:`relative inline-flex`,"data-bell":``,children:[(0,z.jsxs)(`button`,{type:`button`,className:I(`relative grid size-8 cursor-pointer place-items-center rounded-full border-0 bg-transparent transition-colors hover:bg-surface-2 hover:text-fg`,_?`text-fg`:`text-fg-2`),title:_?`${_} thing${_===1?``:`s`} waiting for you`:g?`${g} update${g===1?``:`s`}`:`Notifications`,"aria-label":`Notifications`,onClick:()=>t(e=>!e),children:[(0,z.jsx)(B,{name:_?`notifications_active`:`notifications`}),g>0&&(0,z.jsx)(`span`,{className:`absolute top-1.5 right-1.5 size-[7px] rounded-full bg-accent`})]}),e&&(0,z.jsxs)(`div`,{className:`notif-pop absolute right-0 top-[calc(100%+8px)] z-50 flex max-h-[min(80dvh,640px)] w-[min(460px,92vw)] flex-col overflow-hidden rounded-card border border-line bg-surface shadow-pop`,role:`menu`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-line px-4 py-2`,children:[(0,z.jsx)(it,{className:`text-fg`,children:`notifications`}),(0,z.jsx)(`span`,{className:`flex-1`}),g>0&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,onClick:()=>void b(h.filter(e=>!e.readAt).map(e=>e.id)),children:`mark updates read`}),f.length>0&&(0,z.jsx)(K,{variant:`quiet`,size:`sm`,onClick:()=>void x(),children:`clear`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain pb-1.5`,children:[E&&(0,z.jsxs)(`div`,{className:`m-2 flex flex-col gap-2 rounded-control bg-surface-2 p-3 text-sm`,children:[(0,z.jsx)(`span`,{children:`Get a system notification when something needs you, even with this tab in the background.`}),(0,z.jsxs)(`span`,{className:`flex gap-2`,children:[(0,z.jsx)(K,{variant:`primary`,size:`sm`,onClick:()=>void w(),children:`enable`}),(0,z.jsx)(K,{variant:`quiet`,size:`sm`,onClick:T,children:`not now`})]})]}),r===`denied`&&(0,z.jsx)(`p`,{className:`m-0 px-4 pt-2 text-xs text-fg-2`,children:`Browser notifications are blocked for this site — allow them in the address bar to get system alerts.`}),(0,z.jsx)(at,{title:`needs you`,count:p.length||void 0,className:`px-1.5 pt-1.5`,children:p.length===0?(0,z.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-fg-2`,children:`nothing is waiting for you`}):vw(p).map(([e,n])=>(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`notif-owner px-2.5 pb-0.5 pt-2 text-xs font-semibold text-fg`,children:e}),n.map(e=>{let n=e.notificationId?f.find(t=>t.id===e.notificationId):void 0;return(0,z.jsx)(gt,{className:`notif-row need`,onClick:()=>{t(!1),ds(e)},leading:(0,z.jsx)(B,{name:as(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${os(e.kind)}${e.chatTitle?` · in ${e.chatTitle}`:``}`,meta:G(e.since),actionsAlways:!0,actions:n?.diagnose?(0,z.jsx)(_w,{busy:u===n.id,onClick:()=>void C(n)}):void 0},e.id)})]},e))}),(0,z.jsx)(at,{title:`updates`,className:`px-1.5 pt-1.5`,children:h.length===0?(0,z.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-fg-2`,children:`no updates`}):h.slice(0,50).map(e=>(0,z.jsx)(gt,{className:I(`notif-row`,!e.readAt&&`bg-accent/5`),onClick:()=>S(e),leading:(0,z.jsx)(B,{name:mw[e.kind],className:I(`ms-sm`,e.kind.endsWith(`failed`)?`text-bad`:e.kind.endsWith(`done`)?`text-ok`:``)}),title:e.title,sub:e.body,meta:G(e.at),actionsAlways:!0,actions:e.diagnose?(0,z.jsx)(_w,{busy:u===e.id,onClick:()=>void C(e)}):void 0},e.id))})]})]})]})}function _w({busy:e,onClick:t}){return(0,z.jsx)(K,{variant:`secondary`,size:`sm`,icon:`troubleshoot`,busy:e,title:`Open a chat that finds the cause and proposes the fix`,onClick:e=>{e.stopPropagation(),t()},children:e?`starting…`:`diagnose`})}function vw(e){let t=new Map;for(let n of e){let e=ss(n.owner);t.set(e,[...t.get(e)??[],n])}return[...t.entries()]}function yw({onClose:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``);return(0,v.useEffect)(()=>{A.call(`meta.get`).then(e=>o(e.version)).catch(()=>{}),A.call(`runs.list`).then(n).catch(()=>{}),A.call(`workflows.list`).then(i).catch(()=>{})},[]),(0,z.jsxs)(`div`,{className:`ws-menu mt-1.5 flex flex-col gap-0.5 border-t border-line px-1.5 pb-1 pt-2`,children:[(0,z.jsx)(bw,{label:`Theme`,children:(0,z.jsx)(Tw,{})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 py-1.5 text-xs`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(it,{children:`Workflows`}),` `,r?`${r.workflows.length} discovered`:`…`,` `,(0,z.jsx)(`code`,{className:`block break-all text-2xs text-fg-2`,title:r?.root,children:r?.root??``})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(it,{children:`Runs`}),` `,t?`${t.runs.length} total`:`…`,` `,(0,z.jsx)(`code`,{className:`block break-all text-2xs text-fg-2`,title:t?.outputDir,children:t?.outputDir??``})]})]}),(0,z.jsx)(bw,{label:(0,z.jsx)(`span`,{className:`font-mono`,children:a?`kraftwerk ${a}`:`…`}),children:(0,z.jsx)(Sw,{})})]})}function bw({label:e,children:t}){return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2.5 py-1.5`,children:[(0,z.jsx)(`span`,{className:`text-sm text-fg-2`,children:e}),t]})}function xw(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++)if((n[e]??0)!==(r[e]??0))return(n[e]??0)<(r[e]??0);return!1}function Sw(){let[e,t]=(0,v.useState)(`idle`),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1);async function u(){t(`busy`);try{let e=await A.call(`update.check`);if(!e.latest)throw Error();r(e),t(`done`)}catch{t(`err`)}}let d=i?.state===`running`;(0,v.useEffect)(()=>{if(!d)return;let e=!0,t=setInterval(async()=>{try{let t=await A.call(`update.status`);if(!e)return;a(t)}catch{}},1e3);return()=>{e=!1,clearInterval(t)}},[d]);async function f(){if(!n)return;s(``);let e=await A.request(`update.start`,{body:{version:n.latest}});e.ok?a(e.data):s(e.error??`update refused`)}if(i&&i.state!==`idle`&&n){let e=i.log[i.log.length-1]??``;return i.state===`running`?(0,z.jsxs)(`span`,{className:I(Cw,`basis-full flex-wrap`),children:[(0,z.jsx)(B,{name:`progress_activity`,className:`ms-sm`}),` installing v`,n.latest,`…`,e&&(0,z.jsx)(`code`,{className:`max-w-full truncate text-2xs text-fg-2`,title:i.log.join(`
488
+ `),children:e})]}):i.state===`done`?(0,z.jsxs)(`span`,{className:I(Cw,ww),children:[`v`,n.latest,` installed —`,` `,i.restartable?(0,z.jsx)(K,{size:`sm`,icon:`restart_alt`,busy:c,onClick:()=>{l(!0),uw(n.latest)},children:c?`relaunching…`:`relaunch`}):(0,z.jsxs)(z.Fragment,{children:[`restart `,(0,z.jsx)(`code`,{children:`kraftwerk ui`}),` to use it`]})]}):(0,z.jsxs)(`span`,{className:I(Cw,`basis-full flex-wrap text-bad`),title:i.log.join(`
489
+ `),children:[(0,z.jsx)(B,{name:`error`,className:`ms-sm`}),` install failed`,e?` — ${e}`:``,` · `,(0,z.jsxs)(`code`,{children:[`npm i -g `,n.name,`@latest`]})]})}return e===`done`&&n?xw(n.current,n.latest)?(0,z.jsxs)(`span`,{className:I(Cw,ww),children:[`v`,n.latest,` available —`,` `,o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-normal text-fg-2`,title:o,children:o}),` · `,(0,z.jsxs)(`code`,{className:`text-2xs`,children:[`npm i -g `,n.name,`@latest`]})]}):(0,z.jsx)(K,{size:`sm`,icon:`download`,onClick:()=>void f(),children:`update now`})]}):(0,z.jsxs)(`span`,{className:Cw,children:[(0,z.jsx)(B,{name:`check`,className:`ms-sm text-ok`}),` up to date`]}):(0,z.jsx)(K,{size:`sm`,icon:e===`busy`||e===`err`?void 0:`sync`,disabled:e===`busy`,onClick:()=>void u(),children:e===`busy`?`checking…`:e===`err`?`npm unreachable — retry`:`check for updates`})}var Cw=`inline-flex items-center gap-[5px] text-xs text-fg-2`,ww=`basis-full flex-wrap font-medium text-accent`;function Tw(){return(0,z.jsx)(K,{size:`sm`,icon:`contrast`,onClick:()=>{let e=document.documentElement,t=e.dataset.theme===`light`?`dark`:`light`;e.dataset.theme=t;try{localStorage.setItem(`kw-theme`,t)}catch{}},children:`day / night`})}(0,y.createRoot)(document.getElementById(`root`)).render((0,z.jsx)(v.StrictMode,{children:(0,z.jsx)(lv,{children:(0,z.jsx)($C,{})})}));export{o as a,d as i,R as n,s as o,h as r,l as s,Rs as t};